diff sat/plugins/plugin_comp_ap_gateway/http_server.py @ 3793:b5c9021020df

component AP gateway: convert `Delete` AP activities to corresponding Pubsub `retract`: when a `Delete` actity is received, the item is removed from cache, and the corresponding item `retract` is sent to local XMPP subscribers. rel 367
author Goffi <goffi@goffi.org>
date Fri, 17 Jun 2022 14:15:23 +0200
parents 125c7043b277
children 983df907d456
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_ap_gateway/http_server.py	Fri Jun 17 14:15:23 2022 +0200
+++ b/sat/plugins/plugin_comp_ap_gateway/http_server.py	Fri Jun 17 14:15:23 2022 +0200
@@ -232,6 +232,28 @@
             else:
                 log.warning(f"Unmanaged accept type: {type_!r}")
 
+    async def handleDeleteActivity(
+        self,
+        request: "HTTPRequest",
+        data: dict,
+        account_jid: Optional[jid.JID],
+        node: Optional[str],
+        ap_account: Optional[str],
+        ap_url: str,
+        signing_actor: str
+    ):
+        digest = request.getHeader("digest")
+        if digest in self._seen_digest:
+            log.debug(f"Ignoring duplicated request (digest: {digest!r})")
+            return
+        self._seen_digest.append(digest)
+        if node is None:
+            node = self.apg._m.namespace
+        client = await self.apg.getVirtualClient(signing_actor)
+        objects = await self.apg.apGetList(data, "object")
+        for obj in objects:
+            await self.apg.newAPDeleteItem(client, account_jid, node, obj)
+
     async def handleCreateActivity(
         self,
         request: "HTTPRequest",