activitypub: dont include the actor on the recipient_users list

This commit is contained in:
Ariadne Conill 2019-08-26 05:10:16 +00:00
parent dd904ab8fa
commit 4e412a705a

View File

@ -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