mirror of https://gitlab.com/bashrc2/epicyon
Reply controls
parent
7fb11a9fea
commit
865bae0963
28
inbox.py
28
inbox.py
|
@ -3222,17 +3222,43 @@ def _receive_undo_announce(recent_posts_cache: {},
|
|||
def json_post_allows_comments(post_json_object: {}) -> bool:
|
||||
"""Returns true if the given post allows comments/replies
|
||||
"""
|
||||
# reply control with
|
||||
# https://codeberg.org/fediverse/fep/src/branch/main/fep/5624/fep-5624.md
|
||||
reply_control = None
|
||||
if 'canReply' in post_json_object:
|
||||
reply_control = post_json_object['canReply']
|
||||
if 'capabilities' in post_json_object:
|
||||
if isinstance(post_json_object['capabilities'], dict):
|
||||
if 'reply' in post_json_object['capabilities']:
|
||||
reply_control = post_json_object['capabilities']['reply']
|
||||
obj_dict_exists = False
|
||||
if has_object_dict(post_json_object):
|
||||
obj_dict_exists = True
|
||||
post_obj = post_json_object['object']
|
||||
if 'canReply' in post_obj:
|
||||
reply_control = post_obj['canReply']
|
||||
if 'capabilities' in post_obj:
|
||||
if isinstance(post_obj['capabilities'], dict):
|
||||
if 'reply' in post_obj['capabilities']:
|
||||
reply_control = post_obj['capabilities']['reply']
|
||||
if reply_control:
|
||||
if isinstance(reply_control, str):
|
||||
if not reply_control.endswith('#Public'):
|
||||
return False
|
||||
|
||||
if 'commentsEnabled' in post_json_object:
|
||||
return post_json_object['commentsEnabled']
|
||||
if 'rejectReplies' in post_json_object:
|
||||
return not post_json_object['rejectReplies']
|
||||
|
||||
if post_json_object.get('object'):
|
||||
if not has_object_dict(post_json_object):
|
||||
if not obj_dict_exists:
|
||||
return False
|
||||
if 'commentsEnabled' in post_json_object['object']:
|
||||
return post_json_object['object']['commentsEnabled']
|
||||
if 'rejectReplies' in post_json_object['object']:
|
||||
return not post_json_object['object']['rejectReplies']
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue