Make followers/following collections public (paginated format)
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 39s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 39s
Mastodon requires OrderedCollection with a `first` page link to consider the collection public. Without it, it shows "This user has chosen to not make this information available." Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -353,13 +353,28 @@ def register(url_prefix="/users"):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
domain = _domain()
|
domain = _domain()
|
||||||
|
collection_id = f"https://{domain}/users/{username}/followers"
|
||||||
follower_list = await services.federation.get_followers(g.s, username)
|
follower_list = await services.federation.get_followers(g.s, username)
|
||||||
|
page_param = request.args.get("page")
|
||||||
|
|
||||||
|
if not page_param:
|
||||||
|
return Response(
|
||||||
|
response=json.dumps({
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"type": "OrderedCollection",
|
||||||
|
"id": collection_id,
|
||||||
|
"totalItems": len(follower_list),
|
||||||
|
"first": f"{collection_id}?page=1",
|
||||||
|
}),
|
||||||
|
content_type=AP_CONTENT_TYPE,
|
||||||
|
)
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
response=json.dumps({
|
response=json.dumps({
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"type": "OrderedCollection",
|
"type": "OrderedCollectionPage",
|
||||||
"id": f"https://{domain}/users/{username}/followers",
|
"id": f"{collection_id}?page=1",
|
||||||
|
"partOf": collection_id,
|
||||||
"totalItems": len(follower_list),
|
"totalItems": len(follower_list),
|
||||||
"orderedItems": [f.follower_actor_url for f in follower_list],
|
"orderedItems": [f.follower_actor_url for f in follower_list],
|
||||||
}),
|
}),
|
||||||
@@ -373,11 +388,27 @@ def register(url_prefix="/users"):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
domain = _domain()
|
domain = _domain()
|
||||||
|
collection_id = f"https://{domain}/users/{username}/following"
|
||||||
|
page_param = request.args.get("page")
|
||||||
|
|
||||||
|
if not page_param:
|
||||||
|
return Response(
|
||||||
|
response=json.dumps({
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"type": "OrderedCollection",
|
||||||
|
"id": collection_id,
|
||||||
|
"totalItems": 0,
|
||||||
|
"first": f"{collection_id}?page=1",
|
||||||
|
}),
|
||||||
|
content_type=AP_CONTENT_TYPE,
|
||||||
|
)
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
response=json.dumps({
|
response=json.dumps({
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"type": "OrderedCollection",
|
"type": "OrderedCollectionPage",
|
||||||
"id": f"https://{domain}/users/{username}/following",
|
"id": f"{collection_id}?page=1",
|
||||||
|
"partOf": collection_id,
|
||||||
"totalItems": 0,
|
"totalItems": 0,
|
||||||
"orderedItems": [],
|
"orderedItems": [],
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user