mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-09 18:08:00 +00:00
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
This commit is contained in:
parent
938d3f419e
commit
e700f9baa2
|
@ -42,15 +42,15 @@ class Connection(SqlConnection):
|
||||||
return get_app()
|
return get_app()
|
||||||
|
|
||||||
|
|
||||||
def distill_inboxes(self, message: Message) -> Iterator[str]:
|
def distill_inboxes(self, message: Message) -> Iterator[Row]:
|
||||||
src_domains = {
|
src_domains = {
|
||||||
message.domain,
|
message.domain,
|
||||||
urlparse(message.object_id).netloc
|
urlparse(message.object_id).netloc
|
||||||
}
|
}
|
||||||
|
|
||||||
for inbox in self.get_inboxes():
|
for instance in self.get_inboxes():
|
||||||
if inbox['domain'] not in src_domains:
|
if instance['domain'] not in src_domains:
|
||||||
yield inbox['inbox']
|
yield instance
|
||||||
|
|
||||||
|
|
||||||
def get_config(self, key: str) -> Any:
|
def get_config(self, key: str) -> Any:
|
||||||
|
|
|
@ -35,8 +35,8 @@ async def handle_relay(view: ActorView, conn: Connection) -> None:
|
||||||
message = Message.new_announce(view.config.domain, view.message.object_id)
|
message = Message.new_announce(view.config.domain, view.message.object_id)
|
||||||
logging.debug('>> relay: %s', message)
|
logging.debug('>> relay: %s', message)
|
||||||
|
|
||||||
for inbox in conn.distill_inboxes(view.message):
|
for instance in conn.distill_inboxes(view.message):
|
||||||
view.app.push_message(inbox, message, view.instance)
|
view.app.push_message(instance["inbox"], message, instance)
|
||||||
|
|
||||||
view.cache.set('handle-relay', view.message.object_id, message.id, 'str')
|
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)
|
message = Message.new_announce(view.config.domain, view.message)
|
||||||
logging.debug('>> forward: %s', message)
|
logging.debug('>> forward: %s', message)
|
||||||
|
|
||||||
for inbox in conn.distill_inboxes(view.message):
|
for instance in conn.distill_inboxes(view.message):
|
||||||
view.app.push_message(inbox, message, view.instance)
|
view.app.push_message(instance["inbox"], await view.request.read(), instance)
|
||||||
|
|
||||||
view.cache.set('handle-relay', view.message.id, message.id, 'str')
|
view.cache.set('handle-relay', view.message.id, message.id, 'str')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue