aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/activity_pub/views
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-19 13:39:29 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-19 13:39:29 -0500
commite343b46ea041ce6a542b23100df2e9c11e262c75 (patch)
tree7bd219409244d97e51ad58f800889c65f41837a0 /lib/pleroma/web/activity_pub/views
parenta5bbebda588a54cb76d1a75239523db676980eb0 (diff)
parent8e9f032f25251d910b59c55226d10a305bad3cba (diff)
downloadpleroma-instance-view-recompilation.tar.gz
Merge remote-tracking branch 'pleroma/develop' into instance-view-recompilationinstance-view-recompilation
Diffstat (limited to 'lib/pleroma/web/activity_pub/views')
-rw-r--r--lib/pleroma/web/activity_pub/views/user_view.ex21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex
index 8adc9878a..462f3b4a7 100644
--- a/lib/pleroma/web/activity_pub/views/user_view.ex
+++ b/lib/pleroma/web/activity_pub/views/user_view.ex
@@ -6,8 +6,10 @@ defmodule Pleroma.Web.ActivityPub.UserView do
use Pleroma.Web, :view
alias Pleroma.Keys
+ alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.ObjectView
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Endpoint
@@ -97,6 +99,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
"followers" => "#{user.ap_id}/followers",
"inbox" => "#{user.ap_id}/inbox",
"outbox" => "#{user.ap_id}/outbox",
+ "featured" => "#{user.ap_id}/collections/featured",
"preferredUsername" => user.nickname,
"name" => user.name,
"summary" => user.bio,
@@ -245,6 +248,24 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|> Map.merge(pagination)
end
+ def render("featured.json", %{
+ user: %{featured_address: featured_address, pinned_objects: pinned_objects}
+ }) do
+ objects =
+ pinned_objects
+ |> Enum.sort_by(fn {_, pinned_at} -> pinned_at end, &>=/2)
+ |> Enum.map(fn {id, _} ->
+ ObjectView.render("object.json", %{object: Object.get_cached_by_ap_id(id)})
+ end)
+
+ %{
+ "id" => featured_address,
+ "type" => "OrderedCollection",
+ "orderedItems" => objects
+ }
+ |> Map.merge(Utils.make_json_ld_header())
+ end
+
defp maybe_put_total_items(map, false, _total), do: map
defp maybe_put_total_items(map, true, total) do