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):
|
if not message_json.get(check_field):
|
||||||
continue
|
continue
|
||||||
if not isinstance(message_json[check_field], list):
|
if not isinstance(message_json[check_field], list):
|
||||||
print('INBOX: To and Cc fields should be lists ' +
|
print('INBOX: WARN: To and Cc fields should be lists, ' +
|
||||||
check_field + ' ' + str(message_json[check_field]))
|
check_field + '=' + str(message_json[check_field]))
|
||||||
self._400()
|
# self._400()
|
||||||
self.server.postreq_busy = False
|
# self.server.postreq_busy = False
|
||||||
return 3
|
# return 3
|
||||||
|
|
||||||
if has_object_dict(message_json):
|
if has_object_dict(message_json):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
||||||
|
|
@ -213,18 +213,34 @@ def _post_is_to_you(actor: str, post_json_object: {}) -> bool:
|
||||||
"""
|
"""
|
||||||
to_your_actor = False
|
to_your_actor = False
|
||||||
if post_json_object.get('to'):
|
if post_json_object.get('to'):
|
||||||
|
if isinstance(post_json_object['to'], list):
|
||||||
if actor in post_json_object['to']:
|
if actor in post_json_object['to']:
|
||||||
to_your_actor = True
|
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 not to_your_actor and post_json_object.get('cc'):
|
||||||
|
if isinstance(post_json_object['cc'], list):
|
||||||
if actor in post_json_object['cc']:
|
if actor in post_json_object['cc']:
|
||||||
to_your_actor = True
|
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 not to_your_actor and has_object_dict(post_json_object):
|
||||||
if post_json_object['object'].get('to'):
|
if post_json_object['object'].get('to'):
|
||||||
|
if isinstance(post_json_object['to'], list):
|
||||||
if actor in post_json_object['object']['to']:
|
if actor in post_json_object['object']['to']:
|
||||||
to_your_actor = True
|
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 not to_your_actor and post_json_object['object'].get('cc'):
|
||||||
|
if isinstance(post_json_object['cc'], list):
|
||||||
if actor in post_json_object['object']['cc']:
|
if actor in post_json_object['object']['cc']:
|
||||||
to_your_actor = True
|
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
|
return to_your_actor
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
4
inbox.py
4
inbox.py
|
|
@ -3846,8 +3846,12 @@ def _send_to_group_members(server, session, session_onion, session_i2p,
|
||||||
domain = handle.split('@')[1]
|
domain = handle.split('@')[1]
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
group_actor = local_actor_url(http_prefix, nickname, domain_full)
|
group_actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
|
if isinstance(post_json_object['to'], list):
|
||||||
if group_actor not in post_json_object['to']:
|
if group_actor not in post_json_object['to']:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
if group_actor != post_json_object['to']:
|
||||||
|
return
|
||||||
cc_str = ''
|
cc_str = ''
|
||||||
nickname = handle.split('@')[0].replace('!', '')
|
nickname = handle.split('@')[0].replace('!', '')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,11 @@ def _person_receive_update_outbox(base_dir: str, http_prefix: str,
|
||||||
return
|
return
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
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 len(message_json['to']) != 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s actor update - to does not contain one actor ' +
|
print('DEBUG: c2s actor update - to does not contain one actor ' +
|
||||||
|
|
|
||||||
26
posts.py
26
posts.py
|
|
@ -477,23 +477,37 @@ def _is_public_feed_post(item: {}, person_posts: {}, debug: bool) -> bool:
|
||||||
if isinstance(this_item, dict):
|
if isinstance(this_item, dict):
|
||||||
if this_item.get('to'):
|
if this_item.get('to'):
|
||||||
is_public = False
|
is_public = False
|
||||||
|
if isinstance(this_item['to'], list):
|
||||||
for recipient in this_item['to']:
|
for recipient in this_item['to']:
|
||||||
if recipient.endswith('#Public') or \
|
if recipient.endswith('#Public') or \
|
||||||
recipient == 'as:Public' or \
|
recipient == 'as:Public' or \
|
||||||
recipient == 'Public':
|
recipient == 'Public':
|
||||||
is_public = True
|
is_public = True
|
||||||
break
|
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
|
||||||
if not is_public:
|
if not is_public:
|
||||||
return False
|
return False
|
||||||
elif isinstance(this_item, str) or item_is_note:
|
elif isinstance(this_item, str) or item_is_note:
|
||||||
if item.get('to'):
|
if item.get('to'):
|
||||||
is_public = False
|
is_public = False
|
||||||
|
if isinstance(item['to'], list):
|
||||||
for recipient in item['to']:
|
for recipient in item['to']:
|
||||||
if recipient.endswith('#Public') or \
|
if recipient.endswith('#Public') or \
|
||||||
recipient == 'as:Public' or \
|
recipient == 'as:Public' or \
|
||||||
recipient == 'Public':
|
recipient == 'Public':
|
||||||
is_public = True
|
is_public = True
|
||||||
break
|
break
|
||||||
|
elif isinstance(item['to'], str):
|
||||||
|
recipient = item['to']
|
||||||
|
if recipient.endswith('#Public') or \
|
||||||
|
recipient == 'as:Public' or \
|
||||||
|
recipient == 'Public':
|
||||||
|
is_public = True
|
||||||
if not is_public:
|
if not is_public:
|
||||||
return False
|
return False
|
||||||
return True
|
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 \
|
if post_json_object['type'] != 'Update' and \
|
||||||
has_object_dict(post_json_object):
|
has_object_dict(post_json_object):
|
||||||
if post_json_object['object'].get('to'):
|
if post_json_object['object'].get('to'):
|
||||||
|
if isinstance(post_json_object['object']['to'], list):
|
||||||
to_list = post_json_object['object']['to']
|
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'):
|
if post_json_object['object'].get('cc'):
|
||||||
|
if isinstance(post_json_object['object']['cc'], list):
|
||||||
cc_list = post_json_object['object']['cc']
|
cc_list = post_json_object['object']['cc']
|
||||||
|
elif isinstance(post_json_object['object']['cc'], str):
|
||||||
|
cc_list = [post_json_object['object']['cc']]
|
||||||
else:
|
else:
|
||||||
if post_json_object.get('to'):
|
if post_json_object.get('to'):
|
||||||
|
if isinstance(post_json_object['to'], list):
|
||||||
to_list = post_json_object['to']
|
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'):
|
if post_json_object.get('cc'):
|
||||||
|
if isinstance(post_json_object['cc'], list):
|
||||||
cc_list = post_json_object['cc']
|
cc_list = post_json_object['cc']
|
||||||
|
elif isinstance(post_json_object['cc'], str):
|
||||||
|
cc_list = [post_json_object['cc']]
|
||||||
|
|
||||||
followers_url = \
|
followers_url = \
|
||||||
local_actor_url(http_prefix, nickname, domain_full) + '/followers'
|
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
|
return False
|
||||||
if not post_json_object['object'].get('tag'):
|
if not post_json_object['object'].get('tag'):
|
||||||
return False
|
return False
|
||||||
|
if not isinstance(post_json_object['object']['to'], list):
|
||||||
|
return False
|
||||||
if len(post_json_object['object']['to']) != 1:
|
if len(post_json_object['object']['to']) != 1:
|
||||||
return False
|
return False
|
||||||
if post_json_object['object']['to'][0] != \
|
if post_json_object['object']['to'][0] != \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue