mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
API: fixes for post create / edit with the app
This commit is contained in:
parent
b4aa566dba
commit
1df4cde0d8
2 changed files with 11 additions and 6 deletions
|
@ -167,7 +167,9 @@ def post_post(auth, data):
|
|||
language_id = 2
|
||||
|
||||
# change when Polls are supported
|
||||
type = None
|
||||
type = POST_TYPE_ARTICLE
|
||||
if url:
|
||||
type = POST_TYPE_LINK
|
||||
|
||||
input = {'title': title, 'body': body, 'url': url, 'nsfw': nsfw, 'language_id': language_id, 'notify_author': True}
|
||||
community = Community.query.filter_by(id=community_id).one()
|
||||
|
@ -193,11 +195,13 @@ def put_post(auth, data):
|
|||
language_id = 2
|
||||
|
||||
# change when Polls are supported
|
||||
type = None
|
||||
type = POST_TYPE_ARTICLE
|
||||
if url:
|
||||
type = POST_TYPE_LINK
|
||||
|
||||
input = {'title': title, 'body': body, 'url': url, 'nsfw': nsfw, 'language_id': language_id, 'notify_author': True}
|
||||
post = Post.query.filter_by(id=post_id).one()
|
||||
user_id, post = edit_post(input, post, type, SRC_API, auth)
|
||||
user_id, post = edit_post(input, post, type, SRC_API, auth=auth)
|
||||
|
||||
post_json = post_view(post=post, variant=4, user_id=user_id)
|
||||
return post_json
|
||||
|
|
|
@ -275,9 +275,10 @@ def edit_post(input, post, type, src, user=None, auth=None, uploaded_file=None,
|
|||
if remove_file:
|
||||
remove_file.delete_from_disk()
|
||||
post.image_id = None
|
||||
domain = domain_from_url(post.url)
|
||||
if domain:
|
||||
domain.post_count -= 1
|
||||
if post.url:
|
||||
domain = domain_from_url(post.url)
|
||||
if domain:
|
||||
domain.post_count -= 1
|
||||
|
||||
# remove any old tags
|
||||
db.session.execute(text('DELETE FROM "post_tag" WHERE post_id = :post_id'), {'post_id': post.id})
|
||||
|
|
Loading…
Reference in a new issue