List messages must be visible for mentioned users

This commit is contained in:
Egor Kislitsyn 2019-07-15 14:54:40 +07:00
parent 04f18a144b
commit de13c9bb8f
3 changed files with 8 additions and 7 deletions

View file

@ -39,10 +39,11 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
def visible_for_user?(%{actor: ap_id}, %User{ap_id: ap_id}), do: true def visible_for_user?(%{actor: ap_id}, %User{ap_id: ap_id}), do: true
def visible_for_user?(%{data: %{"listMessage" => list_ap_id}}, %User{} = user) do def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{} = user) do
list_ap_id user.ap_id in activity.data["to"] ||
|> Pleroma.List.get_by_ap_id() list_ap_id
|> Pleroma.List.member?(user) |> Pleroma.List.get_by_ap_id()
|> Pleroma.List.member?(user)
end end
def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false

View file

@ -100,7 +100,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
end end
end end
def get_to_and_cc(_user, _mentions, _inReplyTo, _), do: {[], []} def get_to_and_cc(_user, mentions, _inReplyTo, {:list, _}), do: {mentions, []}
def get_addressed_users(_, to) when is_list(to) do def get_addressed_users(_, to) when is_list(to) do
User.get_ap_ids_by_nicknames(to) User.get_ap_ids_by_nicknames(to)

View file

@ -126,13 +126,13 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
assert Visibility.visible_for_user?(direct, user) assert Visibility.visible_for_user?(direct, user)
assert Visibility.visible_for_user?(list, user) assert Visibility.visible_for_user?(list, user)
# All visible to a mentioned user, except when it's a list activity # All visible to a mentioned user
assert Visibility.visible_for_user?(public, mentioned) assert Visibility.visible_for_user?(public, mentioned)
assert Visibility.visible_for_user?(private, mentioned) assert Visibility.visible_for_user?(private, mentioned)
assert Visibility.visible_for_user?(unlisted, mentioned) assert Visibility.visible_for_user?(unlisted, mentioned)
assert Visibility.visible_for_user?(direct, mentioned) assert Visibility.visible_for_user?(direct, mentioned)
refute(Visibility.visible_for_user?(list, mentioned)) assert Visibility.visible_for_user?(list, mentioned)
# DM not visible for just follower # DM not visible for just follower