Mercurial > libervia-backend
comparison sat/plugins/plugin_comp_ap_gateway/pubsub_service.py @ 3868:37d2c0282304
component AP gateway (pubsub): only emit a `Follow` activity for microblog subscription:
this avoid to emit Follow subscription when an entity wants to subscribe to attachments
or other special nodes.
rel 370
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 21 Jul 2022 18:05:20 +0200 |
parents | 59fbb66b2923 |
children | aa7197b67c26 |
comparison
equal
deleted
inserted
replaced
3867:c3e6c54660da | 3868:37d2c0282304 |
---|---|
476 else: | 476 else: |
477 raise exceptions.InternalError( | 477 raise exceptions.InternalError( |
478 f"unmanaged subscription state: {subscription.state}" | 478 f"unmanaged subscription state: {subscription.state}" |
479 ) | 479 ) |
480 | 480 |
481 req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox( | 481 if nodeIdentifier == self.apg._m.namespace: |
482 requestor, service | 482 # if we subscribe to microblog node, we follow the corresponding account |
483 ) | 483 req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox( |
484 | 484 requestor, service |
485 data = self.apg.createActivity("Follow", req_actor_id, recip_actor_id) | 485 ) |
486 | 486 |
487 resp = await self.apg.signAndPost(inbox, req_actor_id, data) | 487 data = self.apg.createActivity("Follow", req_actor_id, recip_actor_id) |
488 if resp.code >= 300: | 488 |
489 text = await resp.text() | 489 resp = await self.apg.signAndPost(inbox, req_actor_id, data) |
490 raise error.StanzaError("service-unavailable", text=text) | 490 if resp.code >= 300: |
491 return pubsub.Subscription(nodeIdentifier, requestor, "subscribed") | 491 text = await resp.text() |
492 raise error.StanzaError("service-unavailable", text=text) | |
493 return pubsub.Subscription(nodeIdentifier, requestor, "subscribed") | |
492 | 494 |
493 @ensure_deferred | 495 @ensure_deferred |
494 async def unsubscribe(self, requestor, service, nodeIdentifier, subscriber): | 496 async def unsubscribe(self, requestor, service, nodeIdentifier, subscriber): |
495 req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox( | 497 req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox( |
496 requestor, service | 498 requestor, service |