Browse Source

Merge branch '2161-block-changes' into 'develop'

ActivityPub: Don't block-filter your own posts

Closes #2161

See merge request pleroma/pleroma!3017
fix/2189-remote-user-deletion
Haelwenn 3 years ago
parent
commit
994ce250c2
2 changed files with 18 additions and 3 deletions
  1. +8
    -1
      lib/pleroma/web/activity_pub/activity_pub.ex
  2. +10
    -2
      test/web/mastodon_api/controllers/timeline_controller_test.exs

+ 8
- 1
lib/pleroma/web/activity_pub/activity_pub.ex View File

@@ -841,7 +841,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
from( from(
[activity, object: o] in query, [activity, object: o] in query,
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids), 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: where:
fragment( fragment(
"recipients_contain_blocked_domains(?, ?) = false", "recipients_contain_blocked_domains(?, ?) = false",


+ 10
- 2
test/web/mastodon_api/controllers/timeline_controller_test.exs View File

@@ -114,8 +114,16 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
{:ok, _reply_from_friend} = {:ok, _reply_from_friend} =
CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee}) 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 end


test "doesn't return replies if follow is posting with users from blocked domain" do test "doesn't return replies if follow is posting with users from blocked domain" do


Loading…
Cancel
Save