X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fviews%2Fobject_view.ex;h=e555e9999fbf841f963bd5fb67b050838f461092;hb=d77fd6b3d0f0d13e601244bab46152420f598080;hp=6028b773cf3d41ef36eb24c34c790800f9f0c4ec;hpb=a32bcab04bed54984b76dc9ad59dd02e41f1e04d;p=akkoma
diff --git a/lib/pleroma/web/activity_pub/views/object_view.ex b/lib/pleroma/web/activity_pub/views/object_view.ex
index 6028b773c..e555e9999 100644
--- a/lib/pleroma/web/activity_pub/views/object_view.ex
+++ b/lib/pleroma/web/activity_pub/views/object_view.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectView do
@@ -15,7 +15,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do
Map.merge(base, additional)
end
- def render("object.json", %{object: %Activity{data: %{"type" => "Create"}} = activity}) do
+ def render("object.json", %{object: %Activity{data: %{"type" => activity_type}} = activity})
+ when activity_type in ["Create", "Listen"] do
base = Pleroma.Web.ActivityPub.Utils.make_json_ld_header()
object = Object.normalize(activity)
@@ -36,38 +37,4 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do
Map.merge(base, additional)
end
-
- def render("likes.json", ap_id, likes, page) do
- collection(likes, "#{ap_id}/likes", page)
- |> Map.merge(Pleroma.Web.ActivityPub.Utils.make_json_ld_header())
- end
-
- def render("likes.json", ap_id, likes) do
- %{
- "id" => "#{ap_id}/likes",
- "type" => "OrderedCollection",
- "totalItems" => length(likes),
- "first" => collection(likes, "#{ap_id}/likes", 1)
- }
- |> Map.merge(Pleroma.Web.ActivityPub.Utils.make_json_ld_header())
- end
-
- def collection(collection, iri, page) do
- offset = (page - 1) * 10
- items = Enum.slice(collection, offset, 10)
- items = Enum.map(items, fn object -> Transmogrifier.prepare_object(object.data) end)
- total = length(collection)
-
- map = %{
- "id" => "#{iri}?page=#{page}",
- "type" => "OrderedCollectionPage",
- "partOf" => iri,
- "totalItems" => total,
- "orderedItems" => items
- }
-
- if offset < total do
- Map.put(map, "next", "#{iri}?page=#{page + 1}")
- end
- end
end