Allow pixelfed style post ids

merge-requests/30/head
Bob Mottram 2023-08-03 15:12:39 +01:00
parent 45d72880b7
commit f2bb43c89e
3 changed files with 15 additions and 4 deletions

View File

@ -978,7 +978,8 @@ def _inbox_post_recipients(base_dir: str, post_json_object: {},
if debug and post_json_object.get('object'):
if isinstance(post_json_object['object'], str):
if '/statuses/' in post_json_object['object'] or \
'/objects/' in post_json_object['object']:
'/objects/' in post_json_object['object'] or \
'/p/' in post_json_object['object']:
print('DEBUG: inbox item is a link to a post')
else:
if '/users/' in post_json_object['object']:
@ -3114,7 +3115,15 @@ def _receive_announce(recent_posts_cache: {},
lookup_actor = lookup_actor.split('/statuses/')[0]
elif '/objects/' in lookup_actor:
lookup_actor = lookup_actor.split('/objects/')[0]
elif '/p/' in lookup_actor:
# pixelfed style post id
lookup_nick = lookup_actor.split('/p/')[1]
if '/' in lookup_nick:
lookup_nick = lookup_nick.split('/')[0]
lookup_actor = \
lookup_actor.split('/p/')[0] + '/users/' + lookup_nick
if lookup_actor:
if is_recent_post(post_json_object, 3):
if not os.path.isfile(post_filename + '.tts'):
domain_full = get_full_domain(domain, port)

View File

@ -1236,7 +1236,8 @@ def can_remove_post(base_dir: str,
"""Returns true if the given post can be removed
"""
if '/statuses/' not in post_id and \
'/objects/' not in post_id:
'/objects/' not in post_id and \
'/p/' not in post_id:
return False
domain_full = get_full_domain(domain, port)

View File

@ -5551,9 +5551,10 @@ def download_announce(session, base_dir: str, http_prefix: str,
if converted_json:
announced_json = converted_json
if '/statuses/' not in announced_json['id'] and \
'/objects/' not in announced_json['id']:
'/objects/' not in announced_json['id'] and \
'/p/' not in announced_json['id']:
print('WARN: announced post id does not contain /statuses/ ' +
'or /objects/ ' + str(announced_json))
'or /objects/ or /p/ ' + str(announced_json))
_reject_announce(announce_filename,
base_dir, nickname, domain, post_id,
recent_posts_cache)