mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
only attach image to post if post was successfully created
This commit is contained in:
parent
15c628903d
commit
2729539d8c
1 changed files with 4 additions and 4 deletions
|
@ -706,12 +706,12 @@ def post_json_to_model(activity_log, post_json, user, community) -> Post:
|
|||
if not domain.banned:
|
||||
domain.post_count += 1
|
||||
post.domain = domain
|
||||
if 'image' in post_json and post.image is None:
|
||||
image = File(source_url=post_json['image']['url'])
|
||||
db.session.add(image)
|
||||
post.image = image
|
||||
|
||||
if post is not None:
|
||||
if 'image' in post_json and post.image is None:
|
||||
image = File(source_url=post_json['image']['url'])
|
||||
db.session.add(image)
|
||||
post.image = image
|
||||
db.session.add(post)
|
||||
community.post_count += 1
|
||||
activity_log.result = 'success'
|
||||
|
|
Loading…
Add table
Reference in a new issue