output repeats at ActivityPub outbox
[akkoma] / lib / pleroma / web / activity_pub / views / user_view.ex
index 156a12f2621160483fc40400673ab0527369c09e..011ae18a35877478c28067c99b799148af969086 100644 (file)
@@ -98,20 +98,18 @@ defmodule Pleroma.Web.ActivityPub.UserView do
     info = User.user_info(user)
 
     params = %{
-      "type" => ["Create", "Announce"],
-      "actor_id" => user.ap_id,
-      "whole_db" => true,
       "limit" => "10"
     }
 
-    if max_qid != nil do
-      params = Map.put(params, "max_id", max_qid)
-    end
-
-    activities = ActivityPub.fetch_public_activities(params)
-    min_id = Enum.at(activities, 0).id
+    params =
+      if max_qid != nil do
+        Map.put(params, "max_id", max_qid)
+      else
+        params
+      end
 
-    activities = Enum.reverse(activities)
+    activities = ActivityPub.fetch_public_activities(user, nil, params)
+    min_id = Enum.at(Enum.reverse(activities), 0).id
     max_id = Enum.at(activities, 0).id
 
     collection =
@@ -144,21 +142,21 @@ defmodule Pleroma.Web.ActivityPub.UserView do
     end
   end
 
-  def collection(collection, iri, page, _total \\ nil) do
+  def collection(collection, iri, page, total \\ nil) do
     offset = (page - 1) * 10
     items = Enum.slice(collection, offset, 10)
     items = Enum.map(items, fn user -> user.ap_id end)
-    total = _total || length(collection)
+    total = total || length(collection)
 
     map = %{
       "id" => "#{iri}?page=#{page}",
       "type" => "OrderedCollectionPage",
       "partOf" => iri,
-      "totalItems" => length(collection),
+      "totalItems" => total,
       "orderedItems" => items
     }
 
-    if offset < length(collection) do
+    if offset < total do
       Map.put(map, "next", "#{iri}?page=#{page + 1}")
     end
   end