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=0d63f0707c2aa15ca7fc6f06bca957640a8b977c;hpb=a15b9cbef1b8b06f4fdbfb224f783ea78d1ce27a;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 0d63f0707..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,40 +37,4 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do
Map.merge(base, additional)
end
-
- def render("likes.json", %{ap_id: ap_id, likes: likes, page: 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: ap_id, likes: 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 + length(items) < total do
- Map.put(map, "next", "#{iri}?page=#{page + 1}")
- else
- map
- end
- end
end