kopia lustrzana https://github.com/jointakahe/takahe
add featured collection endpoint and AP link
rodzic
017bdf1509
commit
2d58fdff10
|
@ -603,6 +603,7 @@ def canonicalise(json_data: dict, include_security: bool = False) -> dict:
|
|||
"sensitive": "as:sensitive",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"votersCount": "toot:votersCount",
|
||||
"featured": {"@id": "toot:featured", "@type": "@id"},
|
||||
},
|
||||
]
|
||||
if include_security:
|
||||
|
|
|
@ -240,6 +240,7 @@ urlpatterns = [
|
|||
path("@<handle>/", identity.ViewIdentity.as_view()),
|
||||
path("@<handle>/inbox/", activitypub.Inbox.as_view()),
|
||||
path("@<handle>/outbox/", activitypub.Outbox.as_view()),
|
||||
path("@<handle>/collections/featured/", activitypub.FeaturedCollection.as_view()),
|
||||
path("@<handle>/rss/", identity.IdentityFeed()),
|
||||
path("@<handle>/following/", identity.IdentityFollows.as_view(inbound=False)),
|
||||
path("@<handle>/followers/", identity.IdentityFollows.as_view(inbound=True)),
|
||||
|
|
|
@ -498,6 +498,7 @@ class Identity(StatorModel):
|
|||
"type": self.actor_type.title(),
|
||||
"inbox": self.actor_uri + "inbox/",
|
||||
"outbox": self.actor_uri + "outbox/",
|
||||
"featured": self.actor_uri + "collections/featured/",
|
||||
"preferredUsername": self.username,
|
||||
"publicKey": {
|
||||
"id": self.public_key_id,
|
||||
|
|
|
@ -222,6 +222,38 @@ class Outbox(View):
|
|||
)
|
||||
|
||||
|
||||
class FeaturedCollection(View):
|
||||
"""
|
||||
An ordered collection of all pinned posts of an identity
|
||||
"""
|
||||
|
||||
def get(self, request, handle):
|
||||
self.identity = by_handle_or_404(
|
||||
request,
|
||||
handle,
|
||||
local=False,
|
||||
fetch=True,
|
||||
)
|
||||
if not self.identity.local:
|
||||
raise Http404("Not a local identity")
|
||||
posts = list(
|
||||
self.identity.posts.not_hidden()
|
||||
.public(include_replies=True)
|
||||
.filter(object_uri__in=self.identity.pinned)
|
||||
)
|
||||
return JsonResponse(
|
||||
canonicalise(
|
||||
{
|
||||
"type": "OrderedCollection",
|
||||
"id": self.identity.actor_uri + "collections/featured/",
|
||||
"totalItems": len(posts),
|
||||
"orderedItems": [post.to_ap() for post in posts],
|
||||
}
|
||||
),
|
||||
content_type="application/activity+json",
|
||||
)
|
||||
|
||||
|
||||
@method_decorator(cache_control(max_age=60 * 15), name="dispatch")
|
||||
class EmptyOutbox(StaticContentView):
|
||||
"""
|
||||
|
|
Ładowanie…
Reference in New Issue