X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fviews%2Fuser_view.ex;h=fe82481072659c17057f5292d8ea169e32333469;hb=42612b1c8d356843b9e8785d3a91072f38fb50cf;hp=f0c268755ceace9ae7ba3758856a33868eff0c21;hpb=922abcda61298a7bca48894cb9a51a52fdeab1ed;p=akkoma
diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex
index f0c268755..fe8248107 100644
--- a/lib/pleroma/web/activity_pub/views/user_view.ex
+++ b/lib/pleroma/web/activity_pub/views/user_view.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.UserView do
@@ -176,6 +176,53 @@ defmodule Pleroma.Web.ActivityPub.UserView do
end
end
+ def render("inbox.json", %{user: user, max_id: max_qid}) do
+ params = %{
+ "limit" => "10"
+ }
+
+ params =
+ if max_qid != nil do
+ Map.put(params, "max_id", max_qid)
+ else
+ params
+ end
+
+ activities = ActivityPub.fetch_activities([user.ap_id | user.following], params)
+
+ min_id = Enum.at(Enum.reverse(activities), 0).id
+ max_id = Enum.at(activities, 0).id
+
+ collection =
+ Enum.map(activities, fn act ->
+ {:ok, data} = Transmogrifier.prepare_outgoing(act.data)
+ data
+ end)
+
+ iri = "#{user.ap_id}/inbox"
+
+ page = %{
+ "id" => "#{iri}?max_id=#{max_id}",
+ "type" => "OrderedCollectionPage",
+ "partOf" => iri,
+ "totalItems" => -1,
+ "orderedItems" => collection,
+ "next" => "#{iri}?max_id=#{min_id - 1}"
+ }
+
+ if max_qid == nil do
+ %{
+ "id" => iri,
+ "type" => "OrderedCollection",
+ "totalItems" => -1,
+ "first" => page
+ }
+ |> Map.merge(Utils.make_json_ld_header())
+ else
+ page |> Map.merge(Utils.make_json_ld_header())
+ end
+ end
+
def collection(collection, iri, page, show_items \\ true, total \\ nil) do
offset = (page - 1) * 10
items = Enum.slice(collection, offset, 10)