# HG changeset patch # User Goffi # Date 1657796130 -7200 # Node ID cc13efdd8360e5d84909b880df57274c356a2ae3 # Parent 4f9d4650eab5e3e1f6aa59c5bfb630bf77407adc component AP gateway: return item when `item` URL is used: a request on an `item` type URL will return the suitable cached item. rel 370 diff -r 4f9d4650eab5 -r cc13efdd8360 sat/plugins/plugin_comp_ap_gateway/__init__.py --- 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 @@ -70,6 +70,7 @@ TYPE_FOLLOWERS, TYPE_TOMBSTONE, TYPE_MENTION, + NS_AP, NS_AP_PUBLIC, PUBLIC_TUPLE ) @@ -822,7 +823,7 @@ 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", + "@context": NS_AP, "actor": actor_id, "id": activity_id, "type": activity, diff -r 4f9d4650eab5 -r cc13efdd8360 sat/plugins/plugin_comp_ap_gateway/constants.py --- a/sat/plugins/plugin_comp_ap_gateway/constants.py Thu Jul 14 12:55:30 2022 +0200 +++ b/sat/plugins/plugin_comp_ap_gateway/constants.py Thu Jul 14 12:55:30 2022 +0200 @@ -30,7 +30,8 @@ TYPE_TOMBSTONE = "Tombstone" TYPE_MENTION = "Mention" MEDIA_TYPE_AP = "application/activity+json" -NS_AP_PUBLIC = "https://www.w3.org/ns/activitystreams#Public" +NS_AP = "https://www.w3.org/ns/activitystreams" +NS_AP_PUBLIC = f"{NS_AP}#Public" # 3 values can be used, see https://www.w3.org/TR/activitypub/#public-addressing PUBLIC_TUPLE = (NS_AP_PUBLIC, "as:Public", "Public") AP_REQUEST_TYPES = { diff -r 4f9d4650eab5 -r cc13efdd8360 sat/plugins/plugin_comp_ap_gateway/http_server.py --- a/sat/plugins/plugin_comp_ap_gateway/http_server.py Thu Jul 14 12:55:30 2022 +0200 +++ b/sat/plugins/plugin_comp_ap_gateway/http_server.py Thu Jul 14 12:55:30 2022 +0200 @@ -39,7 +39,7 @@ from sat.memory.sqla_mapping import SubscriptionState from .constants import ( - CONTENT_TYPE_AP, TYPE_ACTOR, TYPE_INBOX, TYPE_SHARED_INBOX, TYPE_OUTBOX, + NS_AP, CONTENT_TYPE_AP, TYPE_ACTOR, TYPE_INBOX, TYPE_SHARED_INBOX, TYPE_OUTBOX, AP_REQUEST_TYPES, PAGE_SIZE, ACTIVITY_TYPES_LOWER, ACTIVIY_NO_ACCOUNT_ALLOWED, SIGN_HEADERS, HS2019, SIGN_EXP, TYPE_FOLLOWERS, TYPE_FOLLOWING ) @@ -706,6 +706,9 @@ avatar_filename = extra_args[0] avatar_path = self.apg.host.common_cache.getPath(avatar_filename) return static.File(str(avatar_path)).render(request) + elif request_type == "item": + ret_data = await self.apg.apGetLocalObject(ap_url) + ret_data["@context"] = NS_AP else: if len(extra_args) > 1: log.warning(f"unexpected extra arguments: {extra_args!r}")