mirror of
https://git.youjo.love/youjo/youjo-be.git
synced 2024-11-20 05:49:54 +01:00
Add fetching of activities in context.
This commit is contained in:
parent
ae50b165cc
commit
866a2663d4
2 changed files with 18 additions and 0 deletions
|
@ -60,4 +60,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
Repo.all(query)
|
||||
|> Enum.reverse
|
||||
end
|
||||
|
||||
def fetch_activities_for_context(context) do
|
||||
query = from activity in Activity,
|
||||
where: fragment("? @> ?", activity.data, ^%{ context: context })
|
||||
Repo.all(query)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,6 +49,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "fetch activities in context" do
|
||||
test "retrieves activities that have a given context" do
|
||||
{:ok, activity} = ActivityBuilder.insert(%{"context" => "2hu"})
|
||||
{:ok, activity_two} = ActivityBuilder.insert(%{"context" => "2hu"})
|
||||
{:ok, _activity_three} = ActivityBuilder.insert(%{"context" => "3hu"})
|
||||
|
||||
activities = ActivityPub.fetch_activities_for_context("2hu")
|
||||
|
||||
assert activities == [activity, activity_two]
|
||||
end
|
||||
end
|
||||
|
||||
describe "public fetch activities" do
|
||||
test "retrieves public activities" do
|
||||
%{public: public} = ActivityBuilder.public_and_non_public
|
||||
|
|
Loading…
Reference in a new issue