reply control for pixelfed capabilities

main
Bob Mottram 2023-12-10 22:58:05 +00:00
parent 29ddb00090
commit ad4d30a1bb
2 changed files with 22 additions and 8 deletions

View File

@ -3355,7 +3355,11 @@ def json_post_allows_comments(post_json_object: {}) -> bool:
if 'capabilities' in post_json_object: if 'capabilities' in post_json_object:
if isinstance(post_json_object['capabilities'], dict): if isinstance(post_json_object['capabilities'], dict):
if 'reply' in post_json_object['capabilities']: if 'reply' in post_json_object['capabilities']:
reply_control = post_json_object['capabilities']['reply'] if isinstance(post_json_object['capabilities']['reply'], str):
reply_control = post_json_object['capabilities']['reply']
else:
# capabilities exist but there is no reply field
reply_control = 'noreply'
obj_dict_exists = False obj_dict_exists = False
if has_object_dict(post_json_object): if has_object_dict(post_json_object):
obj_dict_exists = True obj_dict_exists = True
@ -3365,9 +3369,15 @@ def json_post_allows_comments(post_json_object: {}) -> bool:
if 'capabilities' in post_obj: if 'capabilities' in post_obj:
if isinstance(post_obj['capabilities'], dict): if isinstance(post_obj['capabilities'], dict):
if 'reply' in post_obj['capabilities']: if 'reply' in post_obj['capabilities']:
reply_control = post_obj['capabilities']['reply'] if isinstance(post_obj['capabilities']['reply'], str):
reply_control = post_obj['capabilities']['reply']
else:
# capabilities exist but there is no reply field
reply_control = 'noreply'
if reply_control: if reply_control:
if isinstance(reply_control, str): if isinstance(reply_control, str):
if reply_control == 'noreply':
return False
if not reply_control.endswith('#Public'): if not reply_control.endswith('#Public'):
# TODO handle non-public reply permissions # TODO handle non-public reply permissions
print('CAPABILITIES: replies ' + str(reply_control)) print('CAPABILITIES: replies ' + str(reply_control))

View File

@ -4237,12 +4237,16 @@ def disallow_announce(content: str, attachment: [], capabilities: {}) -> bool:
"""Are announces/boosts not allowed for the given post? """Are announces/boosts not allowed for the given post?
""" """
# pixelfed style capabilities # pixelfed style capabilities
if capabilities.get('announce'): if capabilities:
if isinstance(capabilities['announce'], str): if 'announce' in capabilities:
if not capabilities['announce'].endswith('#Public'): if isinstance(capabilities['announce'], str):
# TODO handle non-public announce permissions if not capabilities['announce'].endswith('#Public'):
print('CAPABILITIES: announce ' + capabilities['announce']) # TODO handle non-public announce permissions
return True print('CAPABILITIES: announce ' + capabilities['announce'])
return True
else:
# capabilities exist but with no announce defined
return True
# emojis # emojis
disallow_strings = ( disallow_strings = (