From e700f9baa2c883205e558db59754829f75cc8b48 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Wed, 27 Mar 2024 12:48:22 -0400 Subject: [PATCH] use right algorithm for inbox pushes * return instance rows from distill_inboxes * pass the row of the instance being POSTed to the instance parameter of HttpClient.post --- relay/database/connection.py | 8 ++++---- relay/processors.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/relay/database/connection.py b/relay/database/connection.py index 8c64641..67ef5c0 100644 --- a/relay/database/connection.py +++ b/relay/database/connection.py @@ -42,15 +42,15 @@ class Connection(SqlConnection): return get_app() - def distill_inboxes(self, message: Message) -> Iterator[str]: + def distill_inboxes(self, message: Message) -> Iterator[Row]: src_domains = { message.domain, urlparse(message.object_id).netloc } - for inbox in self.get_inboxes(): - if inbox['domain'] not in src_domains: - yield inbox['inbox'] + for instance in self.get_inboxes(): + if instance['domain'] not in src_domains: + yield instance def get_config(self, key: str) -> Any: diff --git a/relay/processors.py b/relay/processors.py index 5d2634b..910ecf3 100644 --- a/relay/processors.py +++ b/relay/processors.py @@ -35,8 +35,8 @@ async def handle_relay(view: ActorView, conn: Connection) -> None: message = Message.new_announce(view.config.domain, view.message.object_id) logging.debug('>> relay: %s', message) - for inbox in conn.distill_inboxes(view.message): - view.app.push_message(inbox, message, view.instance) + for instance in conn.distill_inboxes(view.message): + view.app.push_message(instance["inbox"], message, instance) view.cache.set('handle-relay', view.message.object_id, message.id, 'str') @@ -53,8 +53,8 @@ async def handle_forward(view: ActorView, conn: Connection) -> None: message = Message.new_announce(view.config.domain, view.message) logging.debug('>> forward: %s', message) - for inbox in conn.distill_inboxes(view.message): - view.app.push_message(inbox, message, view.instance) + for instance in conn.distill_inboxes(view.message): + view.app.push_message(instance["inbox"], await view.request.read(), instance) view.cache.set('handle-relay', view.message.id, message.id, 'str')