Apply pixelfed style capabilities for announce permission

main
Bob Mottram 2023-08-04 10:38:48 +01:00
parent 3d5d508533
commit 025ec98673
4 changed files with 22 additions and 5 deletions

View File

@ -2259,8 +2259,13 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
attachment = []
if post_json_object['object'].get('attachment'):
attachment = post_json_object['object']['attachment']
capabilities = {}
if post_json_object['object'].get('capabilities'):
capabilities = \
post_json_object['object']['capabilities']
if not disallow_announce(post_summary + ' ' +
post_content, attachment):
post_content, attachment,
capabilities):
if post_json_object.get('id'):
post_id = post_json_object['id']
announce_actor = \

View File

@ -3241,9 +3241,9 @@ def json_post_allows_comments(post_json_object: {}) -> bool:
if reply_control:
if isinstance(reply_control, str):
if not reply_control.endswith('#Public'):
# TODO handle non-public reply permissions
print('CAPABILITIES: replies ' + str(reply_control))
return False
# TODO handle non-public reply permissions
print('DEBUG: non-public replies ' + str(reply_control))
if 'commentsEnabled' in post_json_object:
return post_json_object['commentsEnabled']

View File

@ -4013,9 +4013,18 @@ def is_i2p_request(calling_domain: str, referer_domain: str,
return False
def disallow_announce(content: str, attachment: []) -> bool:
def disallow_announce(content: str, attachment: [], capabilities: {}) -> bool:
"""Are announces/boosts not allowed for the given post?
"""
# pixelfed style capabilities
if capabilities.get('announce'):
if isinstance(capabilities['announce'], str):
if not capabilities['announce'].endswith('#Public'):
# TODO handle non-public announce permissions
print('CAPABILITIES: announce ' + capabilities['announce'])
return True
# emojis
disallow_strings = (
':boost_no:',
':noboost:',

View File

@ -2637,7 +2637,10 @@ def individual_post_as_html(signing_priv_key_pem: str,
attachment = []
if post_json_object['object'].get('attachment'):
attachment = post_json_object['object']['attachment']
if disallow_announce(content_all_str, attachment):
capabilities = {}
if post_json_object['object'].get('capabilities'):
capabilities = post_json_object['object']['capabilities']
if disallow_announce(content_all_str, attachment, capabilities):
announce_str = ''
# does an emoji indicate a no replies preference?
# if so then don't show the reply icon