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
This commit is contained in:
parent
7bd01dd06c
commit
f4af47a929
3 changed files with 8 additions and 3 deletions
|
|
@ -70,6 +70,7 @@ from .constants import (
|
|||
TYPE_FOLLOWERS,
|
||||
TYPE_TOMBSTONE,
|
||||
TYPE_MENTION,
|
||||
NS_AP,
|
||||
NS_AP_PUBLIC,
|
||||
PUBLIC_TUPLE
|
||||
)
|
||||
|
|
@ -822,7 +823,7 @@ class APGateway:
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ TYPE_ITEM = "item"
|
|||
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 = {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ from sat.tools.common import date_utils, uri
|
|||
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 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
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}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue