end
end
- def fetch_activities_for_context(context) do
+ def fetch_activities_for_context(context, opts \\ %{}) do
query = from activity in Activity,
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
order_by: [desc: :id]
+ query = restrict_blocked(query, opts)
Repo.all(query)
end
{:ok, activity_two} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
{:ok, _activity_three} = ActivityBuilder.insert(%{"type" => "Create", "context" => "3hu"})
{: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]
end
end