fix distill_inboxes

This commit is contained in:
Izalia Mae 2022-11-29 17:41:04 -05:00
parent 5397bb4653
commit 1a7abb4ecb
3 changed files with 14 additions and 9 deletions

View file

@ -184,3 +184,14 @@ class RelayDatabase(dict):
domain = urlparse(inbox).hostname domain = urlparse(inbox).hostname
del self['follow-requests'][domain] del self['follow-requests'][domain]
def distill_inboxes(self, message):
src_domains = {
message.domain,
urlparse(message.objectid).netloc
}
for domain, instance in self['relay-list'].items():
if domain not in src_domains:
yield instance['inbox']

View file

@ -84,12 +84,6 @@ def check_open_port(host, port):
return False return False
def distill_inboxes(actor, object_id):
for inbox in app.database.inboxes:
if inbox != actor.shared_inbox and urlparse(inbox).hostname != urlparse(object_id).hostname:
yield inbox
class DotDict(dict): class DotDict(dict):
def __init__(self, _data, **kwargs): def __init__(self, _data, **kwargs):
dict.__init__(self) dict.__init__(self)

View file

@ -4,7 +4,7 @@ import logging
from cachetools import LRUCache from cachetools import LRUCache
from uuid import uuid4 from uuid import uuid4
from .misc import Message, distill_inboxes from .misc import Message
cache = LRUCache(1024) cache = LRUCache(1024)
@ -23,7 +23,7 @@ async def handle_relay(request):
cache[request.message.objectid] = message.id cache[request.message.objectid] = message.id
logging.debug(f'>> relay: {message}') logging.debug(f'>> relay: {message}')
inboxes = distill_inboxes(request.actor, request.message.objectid) niboxes = request.database.distill_inboxes(request.message)
for inbox in inboxes: for inbox in inboxes:
request.app.push_message(inbox, message) request.app.push_message(inbox, message)
@ -42,7 +42,7 @@ async def handle_forward(request):
cache[request.message.id] = message.id cache[request.message.id] = message.id
logging.debug(f'>> forward: {message}') logging.debug(f'>> forward: {message}')
inboxes = distill_inboxes(request.actor, request.message.objectid) inboxes = request.database.distill_inboxes(request.message)
for inbox in inboxes: for inbox in inboxes:
request.app.push_message(inbox, message) request.app.push_message(inbox, message)