mirror of https://gitlab.com/bashrc2/epicyon
Allow attributedTo to contain actor json
parent
377bd7606b
commit
5d0ec67b7b
|
|
@ -3327,6 +3327,13 @@ def daemon_http_get(self) -> None:
|
||||||
redirect_headers(self, hashtag_url, None, calling_domain, 303)
|
redirect_headers(self, hashtag_url, None, calling_domain, 303)
|
||||||
return
|
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
|
# hashtag search
|
||||||
if self.path.startswith('/tags/') or \
|
if self.path.startswith('/tags/') or \
|
||||||
(authorized and '/tags/' in self.path):
|
(authorized and '/tags/' in self.path):
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ def update_inbox_queue(self, nickname: str, message_json: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('INBOX: checking object fields')
|
print('INBOX: checking object fields')
|
||||||
# check that some fields are a string or list
|
# 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:
|
for check_field in string_or_list_fields:
|
||||||
if not message_json['object'].get(check_field):
|
if not message_json['object'].get(check_field):
|
||||||
continue
|
continue
|
||||||
|
|
@ -346,6 +346,19 @@ def update_inbox_queue(self, nickname: str, message_json: {},
|
||||||
http_400(self)
|
http_400(self)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return 3
|
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
|
# check that some fields are strings
|
||||||
string_fields = (
|
string_fields = (
|
||||||
'id', 'actor', 'type', 'content', 'published',
|
'id', 'actor', 'type', 'content', 'published',
|
||||||
|
|
|
||||||
12
src/utils.py
12
src/utils.py
|
|
@ -132,7 +132,7 @@ def get_person_icon(person_json: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def get_attributed_to(field: str | list) -> str:
|
def get_attributed_to(field: str | list | dict) -> str:
|
||||||
"""Returns the actor
|
"""Returns the actor
|
||||||
"""
|
"""
|
||||||
if isinstance(field, str):
|
if isinstance(field, str):
|
||||||
|
|
@ -151,6 +151,16 @@ def get_attributed_to(field: str | list) -> str:
|
||||||
return attrib['id']
|
return attrib['id']
|
||||||
if isinstance(field[0], str):
|
if isinstance(field[0], str):
|
||||||
return field[0]
|
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
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue