ActivityPub: Don't block-filter your own posts
authorlain <lain@soykaf.club>
Mon, 21 Sep 2020 14:08:38 +0000 (16:08 +0200)
committerlain <lain@soykaf.club>
Mon, 21 Sep 2020 14:08:38 +0000 (16:08 +0200)
We are filtering out replies to people you block, but that should
not include your own posts.

lib/pleroma/web/activity_pub/activity_pub.ex
test/web/mastodon_api/controllers/timeline_controller_test.exs

index 06e8e1a7cf84513b3b20672ef05c9eebf483c2fc..aacd58d0310d3dbed462c61f9da6073caf3fea43 100644 (file)
@@ -841,7 +841,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     from(
       [activity, object: o] in query,
       where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
-      where: fragment("not (? && ?)", activity.recipients, ^blocked_ap_ids),
+      where:
+        fragment(
+          "((not (? && ?)) or ? = ?)",
+          activity.recipients,
+          ^blocked_ap_ids,
+          activity.actor,
+          ^user.ap_id
+        ),
       where:
         fragment(
           "recipients_contain_blocked_domains(?, ?) = false",
index 517cabcff3d8aca9750099d72814cccd191e0956..c6e0268fdbdaa80fd885a93976d27f704a98260e 100644 (file)
@@ -114,8 +114,16 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       {:ok, _reply_from_friend} =
         CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee})
 
-      res_conn = get(conn, "/api/v1/timelines/public")
-      [%{"id" => ^activity_id}] = json_response_and_validate_schema(res_conn, 200)
+      # Still shows replies from yourself
+      {:ok, %{id: reply_from_me}} =
+        CommonAPI.post(blocker, %{status: "status", in_reply_to_status_id: reply_from_blockee})
+
+      response =
+        get(conn, "/api/v1/timelines/public")
+        |> json_response_and_validate_schema(200)
+
+      assert length(response) == 2
+      [%{"id" => ^reply_from_me}, %{"id" => ^activity_id}] = response
     end
 
     test "doesn't return replies if follow is posting with users from blocked domain" do