comparison sat/plugins/plugin_comp_ap_gateway/__init__.py @ 3852:384ad98ea9fe

component AP gateway: we need to use `actor` and not `attributedTo` for activities: `attributedTo` may not be filled, notably when the object is a string URL
author Goffi <goffi@goffi.org>
date Thu, 14 Jul 2022 12:55:30 +0200
parents ef824b1091f3
children a56d5ad466b3
comparison
equal deleted inserted replaced
3851:ef824b1091f3 3852:384ad98ea9fe
968 for comment_data in mb_data.get("comments", []): 968 for comment_data in mb_data.get("comments", []):
969 comment_service = jid.JID(comment_data["service"]) 969 comment_service = jid.JID(comment_data["service"])
970 comment_node = comment_data["node"] 970 comment_node = comment_data["node"]
971 await self._p.subscribe(client, comment_service, comment_node) 971 await self._p.subscribe(client, comment_service, comment_node)
972 ap_item = await self.mbdata2APitem(client, mb_data) 972 ap_item = await self.mbdata2APitem(client, mb_data)
973 url_actor = ap_item["object"]["attributedTo"] 973 url_actor = ap_item["actor"]
974 elif item.name == "retract": 974 elif item.name == "retract":
975 url_actor, ap_item = await self.apDeleteItem( 975 url_actor, ap_item = await self.apDeleteItem(
976 client.jid, node, item["id"] 976 client.jid, node, item["id"]
977 ) 977 )
978 else: 978 else:
1688 inbox_url = ap_actor_data["endpoints"]["sharedInbox"] 1688 inbox_url = ap_actor_data["endpoints"]["sharedInbox"]
1689 except KeyError: 1689 except KeyError:
1690 raise exceptions.DataError("Can't get ActivityPub actor inbox") 1690 raise exceptions.DataError("Can't get ActivityPub actor inbox")
1691 1691
1692 item_data = await self.mbdata2APitem(client, mess_data) 1692 item_data = await self.mbdata2APitem(client, mess_data)
1693 url_actor = item_data["object"]["attributedTo"] 1693 url_actor = item_data["actor"]
1694 resp = await self.signAndPost(inbox_url, url_actor, item_data) 1694 resp = await self.signAndPost(inbox_url, url_actor, item_data)
1695 if resp.code != 202: 1695 if resp.code != 202:
1696 raise exceptions.NetworkError(f"unexpected return code: {resp.code}") 1696 raise exceptions.NetworkError(f"unexpected return code: {resp.code}")
1697 1697
1698 async def apDeleteItem( 1698 async def apDeleteItem(