mirror of https://gitlab.com/bashrc2/epicyon
Allow string to field for Follow
parent
bad7e4f67b
commit
1b82841125
10
daemon.py
10
daemon.py
|
@ -2199,11 +2199,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not message_json.get(check_field):
|
||||
continue
|
||||
if not isinstance(message_json[check_field], list):
|
||||
print('INBOX: To and Cc fields should be lists ' +
|
||||
check_field + ' ' + str(message_json[check_field]))
|
||||
self._400()
|
||||
self.server.postreq_busy = False
|
||||
return 3
|
||||
print('INBOX: WARN: To and Cc fields should be lists, ' +
|
||||
check_field + '=' + str(message_json[check_field]))
|
||||
# self._400()
|
||||
# self.server.postreq_busy = False
|
||||
# return 3
|
||||
|
||||
if has_object_dict(message_json):
|
||||
if debug:
|
||||
|
|
|
@ -213,18 +213,34 @@ def _post_is_to_you(actor: str, post_json_object: {}) -> bool:
|
|||
"""
|
||||
to_your_actor = False
|
||||
if post_json_object.get('to'):
|
||||
if actor in post_json_object['to']:
|
||||
to_your_actor = True
|
||||
if isinstance(post_json_object['to'], list):
|
||||
if actor in post_json_object['to']:
|
||||
to_your_actor = True
|
||||
elif isinstance(post_json_object['to'], str):
|
||||
if actor == post_json_object['to']:
|
||||
to_your_actor = True
|
||||
if not to_your_actor and post_json_object.get('cc'):
|
||||
if actor in post_json_object['cc']:
|
||||
to_your_actor = True
|
||||
if isinstance(post_json_object['cc'], list):
|
||||
if actor in post_json_object['cc']:
|
||||
to_your_actor = True
|
||||
elif isinstance(post_json_object['cc'], str):
|
||||
if actor == post_json_object['cc']:
|
||||
to_your_actor = True
|
||||
if not to_your_actor and has_object_dict(post_json_object):
|
||||
if post_json_object['object'].get('to'):
|
||||
if actor in post_json_object['object']['to']:
|
||||
to_your_actor = True
|
||||
if isinstance(post_json_object['to'], list):
|
||||
if actor in post_json_object['object']['to']:
|
||||
to_your_actor = True
|
||||
elif isinstance(post_json_object['to'], str):
|
||||
if actor == post_json_object['object']['to']:
|
||||
to_your_actor = True
|
||||
if not to_your_actor and post_json_object['object'].get('cc'):
|
||||
if actor in post_json_object['object']['cc']:
|
||||
to_your_actor = True
|
||||
if isinstance(post_json_object['cc'], list):
|
||||
if actor in post_json_object['object']['cc']:
|
||||
to_your_actor = True
|
||||
elif isinstance(post_json_object['cc'], str):
|
||||
if actor == post_json_object['object']['cc']:
|
||||
to_your_actor = True
|
||||
return to_your_actor
|
||||
|
||||
|
||||
|
|
8
inbox.py
8
inbox.py
|
@ -3846,8 +3846,12 @@ def _send_to_group_members(server, session, session_onion, session_i2p,
|
|||
domain = handle.split('@')[1]
|
||||
domain_full = get_full_domain(domain, port)
|
||||
group_actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
if group_actor not in post_json_object['to']:
|
||||
return
|
||||
if isinstance(post_json_object['to'], list):
|
||||
if group_actor not in post_json_object['to']:
|
||||
return
|
||||
else:
|
||||
if group_actor != post_json_object['to']:
|
||||
return
|
||||
cc_str = ''
|
||||
nickname = handle.split('@')[0].replace('!', '')
|
||||
|
||||
|
|
|
@ -107,6 +107,11 @@ def _person_receive_update_outbox(base_dir: str, http_prefix: str,
|
|||
return
|
||||
domain_full = get_full_domain(domain, port)
|
||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
if not isinstance(message_json['to'], list):
|
||||
if debug:
|
||||
print('DEBUG: c2s actor update - to field is not a list ' +
|
||||
str(message_json['to']))
|
||||
return
|
||||
if len(message_json['to']) != 1:
|
||||
if debug:
|
||||
print('DEBUG: c2s actor update - to does not contain one actor ' +
|
||||
|
|
42
posts.py
42
posts.py
|
@ -477,23 +477,37 @@ def _is_public_feed_post(item: {}, person_posts: {}, debug: bool) -> bool:
|
|||
if isinstance(this_item, dict):
|
||||
if this_item.get('to'):
|
||||
is_public = False
|
||||
for recipient in this_item['to']:
|
||||
if isinstance(this_item['to'], list):
|
||||
for recipient in this_item['to']:
|
||||
if recipient.endswith('#Public') or \
|
||||
recipient == 'as:Public' or \
|
||||
recipient == 'Public':
|
||||
is_public = True
|
||||
break
|
||||
elif isinstance(this_item['to'], str):
|
||||
recipient = this_item['to']
|
||||
if recipient.endswith('#Public') or \
|
||||
recipient == 'as:Public' or \
|
||||
recipient == 'Public':
|
||||
is_public = True
|
||||
break
|
||||
if not is_public:
|
||||
return False
|
||||
elif isinstance(this_item, str) or item_is_note:
|
||||
if item.get('to'):
|
||||
is_public = False
|
||||
for recipient in item['to']:
|
||||
if isinstance(item['to'], list):
|
||||
for recipient in item['to']:
|
||||
if recipient.endswith('#Public') or \
|
||||
recipient == 'as:Public' or \
|
||||
recipient == 'Public':
|
||||
is_public = True
|
||||
break
|
||||
elif isinstance(item['to'], str):
|
||||
recipient = item['to']
|
||||
if recipient.endswith('#Public') or \
|
||||
recipient == 'as:Public' or \
|
||||
recipient == 'Public':
|
||||
is_public = True
|
||||
break
|
||||
if not is_public:
|
||||
return False
|
||||
return True
|
||||
|
@ -1906,14 +1920,26 @@ def _post_is_addressed_to_followers(nickname: str, domain: str, port: int,
|
|||
if post_json_object['type'] != 'Update' and \
|
||||
has_object_dict(post_json_object):
|
||||
if post_json_object['object'].get('to'):
|
||||
to_list = post_json_object['object']['to']
|
||||
if isinstance(post_json_object['object']['to'], list):
|
||||
to_list = post_json_object['object']['to']
|
||||
elif isinstance(post_json_object['object']['to'], str):
|
||||
to_list = [post_json_object['object']['to']]
|
||||
if post_json_object['object'].get('cc'):
|
||||
cc_list = post_json_object['object']['cc']
|
||||
if isinstance(post_json_object['object']['cc'], list):
|
||||
cc_list = post_json_object['object']['cc']
|
||||
elif isinstance(post_json_object['object']['cc'], str):
|
||||
cc_list = [post_json_object['object']['cc']]
|
||||
else:
|
||||
if post_json_object.get('to'):
|
||||
to_list = post_json_object['to']
|
||||
if isinstance(post_json_object['to'], list):
|
||||
to_list = post_json_object['to']
|
||||
elif isinstance(post_json_object['to'], str):
|
||||
to_list = [post_json_object['to']]
|
||||
if post_json_object.get('cc'):
|
||||
cc_list = post_json_object['cc']
|
||||
if isinstance(post_json_object['cc'], list):
|
||||
cc_list = post_json_object['cc']
|
||||
elif isinstance(post_json_object['cc'], str):
|
||||
cc_list = [post_json_object['cc']]
|
||||
|
||||
followers_url = \
|
||||
local_actor_url(http_prefix, nickname, domain_full) + '/followers'
|
||||
|
|
2
utils.py
2
utils.py
|
@ -2317,6 +2317,8 @@ def is_reminder(post_json_object: {}) -> bool:
|
|||
return False
|
||||
if not post_json_object['object'].get('tag'):
|
||||
return False
|
||||
if not isinstance(post_json_object['object']['to'], list):
|
||||
return False
|
||||
if len(post_json_object['object']['to']) != 1:
|
||||
return False
|
||||
if post_json_object['object']['to'][0] != \
|
||||
|
|
Loading…
Reference in New Issue