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
This commit is contained in:
Goffi 2022-07-21 18:05:20 +02:00
commit a945d3cb67

View file

@ -478,17 +478,19 @@ class APPubsubService(rsm.PubSubService):
f"unmanaged subscription state: {subscription.state}"
)
req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox(
requestor, service
)
if nodeIdentifier == self.apg._m.namespace:
# if we subscribe to microblog node, we follow the corresponding account
req_actor_id, recip_actor_id, inbox = await self.getAPActorIdsAndInbox(
requestor, service
)
data = self.apg.createActivity("Follow", req_actor_id, recip_actor_id)
data = self.apg.createActivity("Follow", req_actor_id, recip_actor_id)
resp = await self.apg.signAndPost(inbox, req_actor_id, data)
if resp.code >= 300:
text = await resp.text()
raise error.StanzaError("service-unavailable", text=text)
return pubsub.Subscription(nodeIdentifier, requestor, "subscribed")
resp = await self.apg.signAndPost(inbox, req_actor_id, data)
if resp.code >= 300:
text = await resp.text()
raise error.StanzaError("service-unavailable", text=text)
return pubsub.Subscription(nodeIdentifier, requestor, "subscribed")
@ensure_deferred
async def unsubscribe(self, requestor, service, nodeIdentifier, subscriber):