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
|
language_id = 2
|
||||||
|
|
||||||
# change when Polls are supported
|
# 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}
|
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()
|
community = Community.query.filter_by(id=community_id).one()
|
||||||
|
@ -193,11 +195,13 @@ def put_post(auth, data):
|
||||||
language_id = 2
|
language_id = 2
|
||||||
|
|
||||||
# change when Polls are supported
|
# 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}
|
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()
|
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)
|
post_json = post_view(post=post, variant=4, user_id=user_id)
|
||||||
return post_json
|
return post_json
|
||||||
|
|
|
@ -275,6 +275,7 @@ def edit_post(input, post, type, src, user=None, auth=None, uploaded_file=None,
|
||||||
if remove_file:
|
if remove_file:
|
||||||
remove_file.delete_from_disk()
|
remove_file.delete_from_disk()
|
||||||
post.image_id = None
|
post.image_id = None
|
||||||
|
if post.url:
|
||||||
domain = domain_from_url(post.url)
|
domain = domain_from_url(post.url)
|
||||||
if domain:
|
if domain:
|
||||||
domain.post_count -= 1
|
domain.post_count -= 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue