List messages must be visible for mentioned users
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 15 Jul 2019 07:54:40 +0000 (14:54 +0700)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 15 Jul 2019 07:54:40 +0000 (14:54 +0700)
lib/pleroma/web/activity_pub/visibility.ex
lib/pleroma/web/common_api/utils.ex
test/web/activity_pub/visibilty_test.exs

index e0282d758d3b0082d9404abc20561f62eaf879c2..2666edc7ce0934302011cc748aafb0bf3959d413 100644 (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?(%{data: %{"listMessage" => list_ap_id}}, %User{} = user) do
-    list_ap_id
-    |> Pleroma.List.get_by_ap_id()
-    |> Pleroma.List.member?(user)
+  def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{} = user) do
+    user.ap_id in activity.data["to"] ||
+      list_ap_id
+      |> Pleroma.List.get_by_ap_id()
+      |> Pleroma.List.member?(user)
   end
 
   def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false
index fed5f9de7925f41b355177406644916eeb3be6f8..f28a963203ccca697d2b0a389c81ec4ccd60af6b 100644 (file)
@@ -100,7 +100,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     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
     User.get_ap_ids_by_nicknames(to)
index 2ce6928c49e575bc645842bfc285f43d6e05ae3e..b62a89e688712028950185ee525fb2a0234049f0 100644 (file)
@@ -126,13 +126,13 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
     assert Visibility.visible_for_user?(direct, 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?(private, mentioned)
     assert Visibility.visible_for_user?(unlisted, 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