瀏覽代碼

Ugly workaround but it works

pull/38/head
Dashie der otter 2 月之前
父節點
當前提交
58f83ff29a
簽署人: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755
共有 3 個文件被更改,包括 5 次插入4 次删除
  1. 2
    1
      TODO.md
  2. 2
    2
      activitypub/utils.py
  3. 1
    1
      controllers/api/v1/activitypub.py

+ 2
- 1
TODO.md 查看文件

@@ -49,4 +49,5 @@
- this is due being to user.actor[0].followers returns the real followers as .actor (.target == xxx)
- and user.actor[0].followings returns the real followings as .target (.actor == xxx)
- and that build_ordered_collection(list, actor, page) only use .actor because that's how it should work
- for now there is a switch_side=True/False ugly fix

+ 2
- 2
activitypub/utils.py 查看文件

@@ -87,7 +87,7 @@ def clean_activity(activity: ObjectType) -> Dict[str, Any]:
return activity


def build_ordered_collection(items, actor_id, page, limit=50):
def build_ordered_collection(items, actor_id, page, limit=50, switch_side=False):
total_items = len(items)

if total_items <= 0:
@@ -107,7 +107,7 @@ def build_ordered_collection(items, actor_id, page, limit=50):
"type": ap.ActivityType.ORDERED_COLLECTION.value,
"first": {
"id": f"{actor_id}/followers?page=0",
"orderedItems": [item.actor.url for item in items],
"orderedItems": [(item.target.url if switch_side else item.actor.url) for item in items],
"partOf": f"{actor_id}/followers",
"totalItems": total_items,
"type": ap.ActivityType.ORDERED_COLLECTION_PAGE.value,

+ 1
- 1
controllers/api/v1/activitypub.py 查看文件

@@ -94,7 +94,7 @@ def user_followings(name):
actor = user.actor[0]
followings_list = actor.followings

return jsonify(**build_ordered_collection(followings_list, actor.url, request.args.get("page")))
return jsonify(**build_ordered_collection(followings_list, actor.url, request.args.get("page"), switch_side=True))


@bp_ap.route("/user/<string:name>/followers", methods=["GET"])

Loading…
取消
儲存