From 845f3d226f24356484abb45f84964bc5436ad8e6 Mon Sep 17 00:00:00 2001 From: NEETzsche Date: Wed, 24 Nov 2021 07:33:42 +0000 Subject: [PATCH 1/3] Don't blow up when there are nil pinned objects on a user --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index d10f30c07f..a0a8891253 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -641,7 +641,7 @@ defp fetch_activities_for_user(user, reading_user, params) do |> Map.put(:type, ["Create", "Announce"]) |> Map.put(:user, reading_user) |> Map.put(:actor_id, user.ap_id) - |> Map.put(:pinned_object_ids, Map.keys(user.pinned_objects)) + |> Map.put(:pinned_object_ids, (if user.pinned_objects, do: Map.keys(user.pinned_objects), else: [])) params = if User.blocks?(reading_user, user) do From 8612f0ac797a4f22637554c716a7384a7ad48ea7 Mon Sep 17 00:00:00 2001 From: NEETzsche Date: Wed, 24 Nov 2021 07:41:44 +0000 Subject: [PATCH 2/3] Format activity_pub.ex --- lib/pleroma/web/activity_pub/activity_pub.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index a0a8891253..a112ada84f 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -641,7 +641,10 @@ defp fetch_activities_for_user(user, reading_user, params) do |> Map.put(:type, ["Create", "Announce"]) |> Map.put(:user, reading_user) |> Map.put(:actor_id, user.ap_id) - |> Map.put(:pinned_object_ids, (if user.pinned_objects, do: Map.keys(user.pinned_objects), else: [])) + |> Map.put( + :pinned_object_ids, + if(user.pinned_objects, do: Map.keys(user.pinned_objects), else: []) + ) params = if User.blocks?(reading_user, user) do From fb0bddfe08cdeb711784339f6edfff53f7c00421 Mon Sep 17 00:00:00 2001 From: NEETzsche Date: Wed, 24 Nov 2021 17:01:54 +0000 Subject: [PATCH 3/3] Refactor pinned_object_ids into a variable --- lib/pleroma/web/activity_pub/activity_pub.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index a112ada84f..1aa6f6bf95 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -636,15 +636,14 @@ def fetch_user_activities(user, reading_user, params) do end defp fetch_activities_for_user(user, reading_user, params) do + pinned_object_ids = if user.pinned_objects, do: Map.keys(user.pinned_objects), else: [] + params = params |> Map.put(:type, ["Create", "Announce"]) |> Map.put(:user, reading_user) |> Map.put(:actor_id, user.ap_id) - |> Map.put( - :pinned_object_ids, - if(user.pinned_objects, do: Map.keys(user.pinned_objects), else: []) - ) + |> Map.put(:pinned_object_ids, pinned_object_ids) params = if User.blocks?(reading_user, user) do