diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 831e13b7e..cb2e1e078 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -240,11 +240,16 @@ defmodule Pleroma.Web.ActivityPub.Utils do activity in Activity, where: fragment( - "? @> ?", - activity.data, - ^%{type: "Follow", object: followed_id} + "? ->> 'type' = 'Follow'", + activity.data ), where: activity.actor == ^follower_id, + where: + fragment( + "? @> ?", + activity.data, + ^%{object: followed_id} + ), order_by: [desc: :id], limit: 1 ) @@ -365,11 +370,16 @@ defmodule Pleroma.Web.ActivityPub.Utils do activity in Activity, where: fragment( - "? @> ?", - activity.data, - ^%{type: "Block", object: blocked_id} + "? ->> 'type' = 'Block'", + activity.data ), where: activity.actor == ^blocker_id, + where: + fragment( + "? @> ?", + activity.data, + ^%{object: blocked_id} + ), order_by: [desc: :id], limit: 1 ) diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index b597e6e0a..a5da271b3 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -1,4 +1,4 @@ -defmodule Pleroma.Web.CommonAPI.UtilsTest do +defmodule Pleroma.Web.CommonAPI.Test do use Pleroma.DataCase alias Pleroma.Web.CommonAPI