From ba9fe4c6f2b8ce3631bc9a827ee27c8672bc9fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 25 Sep 2022 22:01:34 +0200 Subject: [PATCH] Fix participation requests query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- lib/pleroma/web/activity_pub/activity_pub.ex | 7 +++++++ .../web/pleroma_api/controllers/event_controller.ex | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 6234a66009..00c04f798c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1246,6 +1246,12 @@ defp restrict_filtered(query, %{blocking_user: %User{} = user}) do defp restrict_filtered(query, _), do: query + defp restrict_object(query, %{object: object}) do + from(activity in query, where: fragment("?->>'object' = ?", activity.data, ^object)) + end + + defp restrict_object(query, _), do: query + defp restrict_quote_url(query, %{quote_url: quote_url}) do from([_activity, object] in query, where: fragment("(?)->'quoteUrl' = ?", object.data, ^quote_url) @@ -1417,6 +1423,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do |> restrict_instance(opts) |> restrict_announce_object_actor(opts) |> restrict_filtered(opts) + |> restrict_object(opts) |> restrict_quote_url(opts) |> Activity.restrict_deactivated_users() |> exclude_poll_votes(opts) diff --git a/lib/pleroma/web/pleroma_api/controllers/event_controller.ex b/lib/pleroma/web/pleroma_api/controllers/event_controller.ex index 6045b2891f..75bd9c62af 100644 --- a/lib/pleroma/web/pleroma_api/controllers/event_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/event_controller.ex @@ -129,10 +129,12 @@ def participation_requests( case activity do %Activity{actor: ^user_ap_id, data: %{"object" => ap_id}} -> params = - params - |> Map.put(:type, "Join") - |> Map.put(:object, ap_id) - |> Map.put(:state, "pending") + Map.merge(params, %{ + type: "Join", + object: ap_id, + state: "pending", + skip_preload: true + }) activities = []