Allow attributedTo to contain actor json

main
bashrc 2026-09-04 22:33:07 +01:00
parent 377bd7606b
commit 5d0ec67b7b
3 changed files with 32 additions and 2 deletions

View File

@ -3327,6 +3327,13 @@ def daemon_http_get(self) -> None:
redirect_headers(self, hashtag_url, None, calling_domain, 303)
return
if self.path.startswith('/labels/'):
# TODO
# label_str = self.path.split('/labels/')[1]
self.server.getreq_busy = False
http_404(self, 720)
return
# hashtag search
if self.path.startswith('/tags/') or \
(authorized and '/tags/' in self.path):

View File

@ -333,7 +333,7 @@ def update_inbox_queue(self, nickname: str, message_json: {},
if debug:
print('INBOX: checking object fields')
# check that some fields are a string or list
string_or_list_fields = ('url', 'attributedTo')
string_or_list_fields: dict = ['url']
for check_field in string_or_list_fields:
if not message_json['object'].get(check_field):
continue
@ -346,6 +346,19 @@ def update_inbox_queue(self, nickname: str, message_json: {},
http_400(self)
self.server.postreq_busy = False
return 3
# check that some fields are a string or list or dict
check_field: str = 'attributedTo'
if message_json['object'].get(check_field):
field_value = message_json['object'][check_field]
if not isinstance(field_value, str) and \
not isinstance(field_value, list) and \
not isinstance(field_value, dict):
print('INBOX: ' +
check_field + ' should be a string or list or dict ' +
str(message_json['object'][check_field]))
http_400(self)
self.server.postreq_busy = False
return 3
# check that some fields are strings
string_fields = (
'id', 'actor', 'type', 'content', 'published',

View File

@ -132,7 +132,7 @@ def get_person_icon(person_json: {}) -> str:
return ''
def get_attributed_to(field: str | list) -> str:
def get_attributed_to(field: str | list | dict) -> str:
"""Returns the actor
"""
if isinstance(field, str):
@ -151,6 +151,16 @@ def get_attributed_to(field: str | list) -> str:
return attrib['id']
if isinstance(field[0], str):
return field[0]
if isinstance(field, dict):
if not (field.get('type') and field.get('id')):
return None
if not (isinstance(field['type'], str) and
isinstance(field['id'], str)):
return None
potential_id: str = remove_id_ending(field['id'])
if field['type'] == 'Person' and \
resembles_url(potential_id):
return potential_id
return None