# HG changeset patch # User Goffi # Date 1657796130 -7200 # Node ID bc7f9d0a404f598a660e7285c4b918280e102e4c # Parent 54305ebf5b94909e4a3a291d3e8c73f765b2b0bf component AP gateway: when a repeated blog post is retracted, it converted to suitable Activity: when a retract item is received, the former item is now retrieve from cache, and if it was a "repeat" blog post, it is converted to the suitable `Undo` of `Announce` activity (instead of the default `Delete` activity). rel 370 diff -r 54305ebf5b94 -r bc7f9d0a404f sat/plugins/plugin_comp_ap_gateway/__init__.py --- a/sat/plugins/plugin_comp_ap_gateway/__init__.py Thu Jul 14 12:55:30 2022 +0200 +++ b/sat/plugins/plugin_comp_ap_gateway/__init__.py Thu Jul 14 12:55:30 2022 +0200 @@ -1778,8 +1778,37 @@ @param public: if True, the activity will be addressed to public namespace @return: actor_id of the entity deleting the item, activity to send """ + if node is None: + node = self._m.namespace + author_account = await self.getAPAccountFromJidAndNode(jid_, node) author_actor_id = self.buildAPURL(TYPE_ACTOR, author_account) + + items = await self.host.memory.storage.searchPubsubItems({ + "profiles": [self.client.profile], + "services": [jid_], + "names": [item_id] + }) + if not items: + log.warning( + f"Deleting an unknown item at service {jid_}, node {node} and id " + f"{item_id}" + ) + else: + try: + mb_data = await self._m.item2mbdata(self.client, items[0].data, jid_, node) + if "repeated" in mb_data["extra"]: + # we are deleting a repeated item, we must translate this to an + # "Undo" of the "Announce" activity instead of a "Delete" one + announce = await self.repeatedMB2APItem(mb_data) + undo = self.createActivity("Undo", author_actor_id, announce) + return author_actor_id, undo + except Exception as e: + log.debug( + f"Can't parse item, maybe it's not a blog item: {e}\n" + f"{items[0].toXml()}" + ) + url_item = self.buildAPURL(TYPE_ITEM, author_account, item_id) ap_item = self.createActivity( "Delete", @@ -1791,8 +1820,7 @@ ) if public: ap_item["to"] = [NS_AP_PUBLIC] - url_actor = author_actor_id - return url_actor, ap_item + return author_actor_id, ap_item def _messageReceivedTrigger( self,