Mastodon API: fix the public timeline returning an error when the `reply_visibility...
authoreugenijm <eugenijm@protonmail.com>
Tue, 15 Sep 2020 10:00:07 +0000 (13:00 +0300)
committereugenijm <eugenijm@protonmail.com>
Tue, 15 Sep 2020 10:00:56 +0000 (13:00 +0300)
CHANGELOG.md
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index 82f64d441093b767a552f570cdeb57e68a933439..f7a372e1110dc3587054fc52d71fb598d9cf681e 100644 (file)
@@ -24,6 +24,7 @@ switched to a new configuration mechanism, however it was not officially removed
 ### Fixed
 
 - Welcome Chat messages preventing user registration with MRF Simple Policy applied to the local instance
+- Mastodon API: the public timeline returning an error when the `reply_visibility` parameter is set to `self` for an unauthenticated user
 
 ## [2.1.1] - 2020-09-08
 
index 66a9f78a3c0ba993f1720d1e993f7afdeeb2b60f..5aac3f53b020c63ef76154854bbf33fa60c9229c 100644 (file)
@@ -767,7 +767,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(
@@ -783,7 +783,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 d8caa0b00b0d6162b38426f5fd93bd695a98e448..7bdad3810d960df6f8337d0d75d02a5835276203 100644 (file)
@@ -1810,6 +1810,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