From 182fef1134e44c64f1f9ff3d88b7c32bb03ec1c5 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 20 Mar 2023 11:47:13 +0100 Subject: [PATCH] component AP gateway: add mention to direct messages: when a direct (not public) message is sent to AP peer, a mention should be present otherwise the peer won't receive a notification in most AP implementation (notably Mastodon). --- sat/plugins/plugin_comp_ap_gateway/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sat/plugins/plugin_comp_ap_gateway/__init__.py b/sat/plugins/plugin_comp_ap_gateway/__init__.py index fa0e1b2f..d77f046e 100644 --- a/sat/plugins/plugin_comp_ap_gateway/__init__.py +++ b/sat/plugins/plugin_comp_ap_gateway/__init__.py @@ -2225,7 +2225,16 @@ class APGateway: mb_data["id"] = origin_id client = self.client.getVirtualClient(mess_data["from"]) ap_item = await self.mb_data_2_ap_item(client, mb_data, public=False) - ap_item["object"]["to"] = ap_item["to"] = [actor_id] + ap_object = ap_item["object"] + ap_object["to"] = ap_item["to"] = [actor_id] + # we add a mention to direct message, otherwise peer is not notified in some AP + # implementations (notably Mastodon), and the message may be missed easily. + ap_object.setdefault("tag", []).append({ + "type": TYPE_MENTION, + "href": actor_id, + "name": f"@{actor_account}", + }) + await self.signAndPost(inbox, ap_item["actor"], ap_item) return mess_data