From 4e412a705a2d480e6b1fa8c18b92b48c26f9e62f Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 26 Aug 2019 05:10:16 +0000 Subject: [PATCH] activitypub: dont include the actor on the recipient_users list --- lib/pleroma/web/activity_pub/activity_pub.ex | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 18e7a5ce3..a16699c93 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -61,8 +61,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {recipients, to, cc} end - defp get_recipient_users(recipients), - do: Enum.filter(recipients, fn recipient -> !is_nil(User.get_cached_by_ap_id(recipient)) end) + defp get_recipient_users(recipients, actor), + do: + Enum.filter(recipients, fn recipient -> + actor != recipient && !is_nil(User.get_cached_by_ap_id(recipient)) + end) defp check_actor_is_active(actor) do if not is_nil(actor) do @@ -129,7 +132,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {_, true} <- {:remote_limit_error, check_remote_limit(map)}, {:ok, map} <- MRF.filter(map), {recipients, _, _} = get_recipients(map), - recipient_users <- get_recipient_users(recipients), + recipient_users <- get_recipient_users(recipients, map["actor"]), {:fake, false, map, recipients} <- {:fake, fake, map, recipients}, :ok <- Containment.contain_child(map), {:ok, map, object} <- insert_full_object(map) do @@ -718,12 +721,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do [activity, object] in query, where: fragment( - "? && ? and (?->>'inReplyTo' is null or ? <@ ?)", + "? && ? and (?->>'inReplyTo' is null or ? && ? or ? = ?)", ^recipients, activity.recipients, object.data, activity.recipient_users, - ^reply_recipients + ^reply_recipients, + activity.actor, + ^user.ap_id ) ) end @@ -739,14 +744,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do [activity, object] in query, where: fragment( - "? && ? and (?->>'inReplyTo' is null or ? && ? or ? <@ ?)", + "? && ? and (?->>'inReplyTo' is null or ? && ? or ? && ? or ? = ?)", ^recipients, activity.recipients, object.data, activity.recipients, ^public_recipients, activity.recipient_users, - ^reply_recipients + ^reply_recipients, + activity.actor, + ^user.ap_id ) ) end