mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-21 22:17:59 +00:00
relay: never relay an object back to the instance which hosts it
This commit is contained in:
parent
b607e382cb
commit
3af63d4d9f
|
@ -147,11 +147,14 @@ def strip_html(data):
|
|||
return cgi.escape(no_tags)
|
||||
|
||||
|
||||
def distill_inboxes(actor):
|
||||
def distill_inboxes(actor, object_id):
|
||||
global DATABASE
|
||||
|
||||
origin_hostname = urlsplit(object_id).hostname
|
||||
|
||||
inbox = get_actor_inbox(actor)
|
||||
targets = [target for target in DATABASE.get('relay-list', []) if target != inbox]
|
||||
targets = [target for target in targets if urlsplit(target).hostname != origin_hostname]
|
||||
|
||||
assert inbox not in targets
|
||||
|
||||
|
@ -194,7 +197,7 @@ async def handle_relay(actor, data, request):
|
|||
|
||||
logging.debug('>> relay: %r', message)
|
||||
|
||||
inboxes = distill_inboxes(actor)
|
||||
inboxes = distill_inboxes(actor, object_id)
|
||||
|
||||
futures = [push_message_to_actor({'inbox': inbox}, message, 'https://{}/actor#main-key'.format(request.host)) for inbox in inboxes]
|
||||
asyncio.ensure_future(asyncio.gather(*futures))
|
||||
|
|
Loading…
Reference in a new issue