Check all possible statuses

merge-requests/30/head
Bob Mottram 2024-05-26 12:02:52 +01:00
parent e3c04b01ce
commit 3d34b5895a
2 changed files with 13 additions and 4 deletions

View File

@ -18,6 +18,7 @@ from languages import understood_post_language
from like import update_likes_collection
from reaction import update_reaction_collection
from reaction import valid_emoji_content
from utils import get_statuses_list
from utils import quote_toots_allowed
from utils import get_post_attachments
from utils import lines_in_file
@ -3228,7 +3229,15 @@ def _receive_announce(recent_posts_cache: {},
print('DEBUG: self-boost rejected')
return False
if not has_users_path(message_json['object']):
if '/objects/' not in str(message_json['object']):
# does the object contain a statuses path?
statuses = get_statuses_list()
status_path_found = False
for status_str in statuses:
if status_str in str(message_json['object']):
status_path_found = True
break
# log any unrecognised statuses
if not status_path_found:
print('WARN: unknown users path ' + str(message_json['object']))
if debug:
print('DEBUG: ' +

View File

@ -1651,7 +1651,7 @@ def dangerous_svg(content: str, allow_local_network_access: bool) -> bool:
separators, invalid_strings)
def _get_statuses_list() -> []:
def get_statuses_list() -> []:
"""Returns a list of statuses path strings
"""
return ('/statuses/', '/objects/', '/honk/', '/p/', '/h/', '/api/posts/',
@ -1661,7 +1661,7 @@ def _get_statuses_list() -> []:
def contains_statuses(url: str) -> bool:
"""Whether the given url contains /statuses/
"""
statuses_list = _get_statuses_list()
statuses_list = get_statuses_list()
for status_str in statuses_list:
if status_str in url:
return True
@ -1674,7 +1674,7 @@ def get_actor_from_post_id(post_id: str) -> str:
https://somedomain/users/nick
"""
actor = post_id
statuses_list = _get_statuses_list()
statuses_list = get_statuses_list()
pixelfed_style_statuses = ['/p/']
for status_str in statuses_list:
if status_str not in actor: