Mercurial > libervia-backend
changeset 3845:4f9d4650eab5
component AP gateway: use `createActivity` in `mbdata2APitem`
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 14 Jul 2022 12:55:30 +0200 |
parents | 65e5718e7710 |
children | cc13efdd8360 |
files | sat/plugins/plugin_comp_ap_gateway/__init__.py |
diffstat | 1 files changed, 6 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ -802,6 +802,7 @@ actor_id: str, object_: Optional[Union[str, dict]] = None, target: Optional[Union[str, dict]] = None, + activity_id: Optional[str] = None, **kwargs, ) -> Dict[str, Any]: """Generate base data for an activity @@ -818,7 +819,8 @@ raise exceptions.InternalError( f'"target" is mandatory for activity {activity!r}' ) - activity_id = f"{actor_id}#{activity.lower()}_{shortuuid.uuid()}" + if activity_id is None: + activity_id = f"{actor_id}#{activity.lower()}_{shortuuid.uuid()}" data: Dict[str, Any] = { "@context": "https://www.w3.org/ns/activitystreams", "actor": actor_id, @@ -1615,15 +1617,9 @@ mb_data ) - ap_item = { - "@context": "https://www.w3.org/ns/activitystreams", - "id": url_item, - "type": "Create", - "actor": url_actor, - "object": ap_object - } - - return ap_item + return self.createActivity( + "Create", url_actor, ap_object, activity_id=url_item + ) async def publishMessage( self,