瀏覽代碼

Ugly workaround but it works

pull/38/head
Dashie der otter 2 月之前
父節點
當前提交
58f83ff29a
簽署人: Dashie <dashie@sigpipe.me> GPG 金鑰 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 @@
49 49
   - this is due being to user.actor[0].followers returns the real followers as .actor (.target == xxx)
50 50
   - and user.actor[0].followings returns the real followings as .target (.actor == xxx)
51 51
   - and that build_ordered_collection(list, actor, page) only use .actor because that's how it should work
52
-  
52
+  - for now there is a switch_side=True/False ugly fix
53
+ 

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

@@ -87,7 +87,7 @@ def clean_activity(activity: ObjectType) -> Dict[str, Any]:
87 87
     return activity
88 88
 
89 89
 
90
-def build_ordered_collection(items, actor_id, page, limit=50):
90
+def build_ordered_collection(items, actor_id, page, limit=50, switch_side=False):
91 91
     total_items = len(items)
92 92
 
93 93
     if total_items <= 0:
@@ -107,7 +107,7 @@ def build_ordered_collection(items, actor_id, page, limit=50):
107 107
             "type": ap.ActivityType.ORDERED_COLLECTION.value,
108 108
             "first": {
109 109
                 "id": f"{actor_id}/followers?page=0",
110
-                "orderedItems": [item.actor.url for item in items],
110
+                "orderedItems": [(item.target.url if switch_side else item.actor.url) for item in items],
111 111
                 "partOf": f"{actor_id}/followers",
112 112
                 "totalItems": total_items,
113 113
                 "type": ap.ActivityType.ORDERED_COLLECTION_PAGE.value,

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

@@ -94,7 +94,7 @@ def user_followings(name):
94 94
     actor = user.actor[0]
95 95
     followings_list = actor.followings
96 96
 
97
-    return jsonify(**build_ordered_collection(followings_list, actor.url, request.args.get("page")))
97
+    return jsonify(**build_ordered_collection(followings_list, actor.url, request.args.get("page"), switch_side=True))
98 98
 
99 99
 
100 100
 @bp_ap.route("/user/<string:name>/followers", methods=["GET"])

Loading…
取消
儲存