ActivityPub: Don't block-filter your own posts

We are filtering out replies to people you block, but that should
not include your own posts.
This commit is contained in:
lain 2020-09-21 16:08:38 +02:00
parent 882c1fc6bd
commit f2f0a0260f
2 changed files with 18 additions and 3 deletions

View File

@ -841,7 +841,14 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) 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",

View File

@ -114,8 +114,16 @@ test "doesn't return replies if follower is posting with blocked user" 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") # Still shows replies from yourself
[%{"id" => ^activity_id}] = json_response_and_validate_schema(res_conn, 200) {: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