relay: add additional assertion proving that a message is never relayed back to it's origin

This commit is contained in:
kaniini 2018-12-03 20:26:46 +00:00
parent c9cd9a8337
commit e44544d22e
1 changed files with 2 additions and 4 deletions

View File

@ -161,8 +161,10 @@ def distill_inboxes(actor, object_id):
inbox = get_actor_inbox(actor) inbox = get_actor_inbox(actor)
targets = [target for target in DATABASE.get('relay-list', []) if target != inbox] targets = [target for target in DATABASE.get('relay-list', []) if target != inbox]
targets = [target for target in targets if urlsplit(target).hostname != origin_hostname] targets = [target for target in targets if urlsplit(target).hostname != origin_hostname]
hostnames = [urlsplit(target).hostname for target in targets]
assert inbox not in targets assert inbox not in targets
assert origin_hostname not in hostnames
return targets return targets
@ -186,10 +188,6 @@ async def handle_relay(actor, data, request):
logging.debug('>> already relayed %r as %r', object_id, CACHE[object_id]) logging.debug('>> already relayed %r as %r', object_id, CACHE[object_id])
return return
# don't relay mastodon announces -- causes LRP fake direction issues
if data['type'] == 'Announce' and len(data.get('cc', [])) > 0:
return
activity_id = "https://{}/activities/{}".format(request.host, uuid.uuid4()) activity_id = "https://{}/activities/{}".format(request.host, uuid.uuid4())
message = { message = {