# HG changeset patch # User Goffi # Date 1679309233 -3600 # Node ID 4a2c261646b6b45145ecaecf92f6d331fe6763cb # Parent 97df34151c6df00a7ee55566eb2e04365338a82d 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). diff -r 97df34151c6d -r 4a2c261646b6 sat/plugins/plugin_comp_ap_gateway/__init__.py --- a/sat/plugins/plugin_comp_ap_gateway/__init__.py Sat Mar 18 23:11:28 2023 +0100 +++ b/sat/plugins/plugin_comp_ap_gateway/__init__.py Mon Mar 20 11:47:13 2023 +0100 @@ -2225,7 +2225,16 @@ 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