Merge branch 'reply-visibility-user-guard' into 'develop'
authorlain <lain@soykaf.club>
Tue, 15 Sep 2020 12:21:38 +0000 (12:21 +0000)
committerrinpatch <rinpatch@sdf.org>
Thu, 17 Sep 2020 16:49:08 +0000 (19:49 +0300)
Mastodon API: fix the public timeline returning an error when the `reply_visibility` parameter is set to `self` for an unauthenticated user

See merge request pleroma/pleroma!2999

lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index 624a508ae3d907438d0df2301cdb1ea458580257..e4eafc8ac943fcd720b52507638ae59758445fbc 100644 (file)
@@ -744,7 +744,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   end
 
   defp restrict_replies(query, %{
-         reply_filtering_user: user,
+         reply_filtering_user: %User{} = user,
          reply_visibility: "self"
        }) do
     from(
@@ -760,7 +760,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   end
 
   defp restrict_replies(query, %{
-         reply_filtering_user: user,
+         reply_filtering_user: %User{} = user,
          reply_visibility: "following"
        }) do
     from(
index 03f968aafa3be3a4f7a3d068decd70e36f0ac763..b579bb0bb861a2770071e46d16368e4035a2352e 100644 (file)
@@ -1773,6 +1773,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
         |> Enum.map(& &1.id)
 
       assert activities_ids == []
+
+      activities_ids =
+        %{}
+        |> Map.put(:reply_visibility, "self")
+        |> Map.put(:reply_filtering_user, nil)
+        |> ActivityPub.fetch_public_activities()
+
+      assert activities_ids == []
     end
 
     test "home timeline", %{users: %{u1: user}} do