Don't return blocked users' activities in contexts.
This commit is contained in:
parent
a47727adde
commit
8ef58a266b
2 changed files with 6 additions and 2 deletions
|
@ -93,10 +93,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_activities_for_context(context) do
|
def fetch_activities_for_context(context, opts \\ %{}) do
|
||||||
query = from activity in Activity,
|
query = from activity in Activity,
|
||||||
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
||||||
order_by: [desc: :id]
|
order_by: [desc: :id]
|
||||||
|
query = restrict_blocked(query, opts)
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
{:ok, activity_two} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
|
{:ok, activity_two} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
|
||||||
{:ok, _activity_three} = ActivityBuilder.insert(%{"type" => "Create", "context" => "3hu"})
|
{:ok, _activity_three} = ActivityBuilder.insert(%{"type" => "Create", "context" => "3hu"})
|
||||||
{:ok, _activity_four} = ActivityBuilder.insert(%{"type" => "Announce", "context" => "2hu"})
|
{:ok, _activity_four} = ActivityBuilder.insert(%{"type" => "Announce", "context" => "2hu"})
|
||||||
|
activity_five = insert(:note_activity)
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
activities = ActivityPub.fetch_activities_for_context("2hu")
|
{:ok, user} = User.block(user, %{ap_id: activity_five.data["actor"]})
|
||||||
|
|
||||||
|
activities = ActivityPub.fetch_activities_for_context("2hu", %{"blocking_user" => user})
|
||||||
assert activities == [activity_two, activity]
|
assert activities == [activity_two, activity]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue