Check that to addresses are local

main
Bob Mottram 2023-01-08 14:42:47 +00:00
parent 373eb35a29
commit 36fc32a064
1 changed files with 11 additions and 0 deletions

View File

@ -267,8 +267,19 @@ def post_message_to_outbox(session, translate: {},
if has_object_dict(message_json): if has_object_dict(message_json):
# if this is a local only post, is it really local? # if this is a local only post, is it really local?
if 'localOnly' in message_json['object'] and \ if 'localOnly' in message_json['object'] and \
message_json['object'].get('to') and \
message_json['object'].get('attributedTo'): message_json['object'].get('attributedTo'):
if message_json['object']['localOnly'] is True: if message_json['object']['localOnly'] is True:
# check that the to addresses are local
if isinstance(message_json['object']['to'], list):
for to_actor in message_json['object']['to']:
to_domain, to_port = get_domain_from_actor(to_actor)
to_domain_full = get_full_domain(to_domain, to_port)
if domain_full != to_domain_full:
print("REJECT: local only post isn't local " +
str(message_json))
return False
# check that the sender is local
local_actor = message_json['object']['attributedTo'] local_actor = message_json['object']['attributedTo']
local_domain, local_port = get_domain_from_actor(local_actor) local_domain, local_port = get_domain_from_actor(local_actor)
local_domain_full = get_full_domain(local_domain, local_port) local_domain_full = get_full_domain(local_domain, local_port)