Mercurial > libervia-backend
comparison sat/plugins/plugin_comp_ap_gateway/__init__.py @ 4017:4a2c261646b6
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).
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 20 Mar 2023 11:47:13 +0100 |
parents | 4ef473116499 |
children | 78b5f356900c |
comparison
equal
deleted
inserted
replaced
4016:97df34151c6d | 4017:4a2c261646b6 |
---|---|
2223 if origin_id: | 2223 if origin_id: |
2224 # we need to use origin ID when present to be able to retract the message | 2224 # we need to use origin ID when present to be able to retract the message |
2225 mb_data["id"] = origin_id | 2225 mb_data["id"] = origin_id |
2226 client = self.client.getVirtualClient(mess_data["from"]) | 2226 client = self.client.getVirtualClient(mess_data["from"]) |
2227 ap_item = await self.mb_data_2_ap_item(client, mb_data, public=False) | 2227 ap_item = await self.mb_data_2_ap_item(client, mb_data, public=False) |
2228 ap_item["object"]["to"] = ap_item["to"] = [actor_id] | 2228 ap_object = ap_item["object"] |
2229 ap_object["to"] = ap_item["to"] = [actor_id] | |
2230 # we add a mention to direct message, otherwise peer is not notified in some AP | |
2231 # implementations (notably Mastodon), and the message may be missed easily. | |
2232 ap_object.setdefault("tag", []).append({ | |
2233 "type": TYPE_MENTION, | |
2234 "href": actor_id, | |
2235 "name": f"@{actor_account}", | |
2236 }) | |
2237 | |
2229 await self.signAndPost(inbox, ap_item["actor"], ap_item) | 2238 await self.signAndPost(inbox, ap_item["actor"], ap_item) |
2230 return mess_data | 2239 return mess_data |
2231 | 2240 |
2232 async def _onMessageRetract( | 2241 async def _onMessageRetract( |
2233 self, | 2242 self, |