Commit 643fae6e authored by kaniini's avatar kaniini

activitypub: allow querying the activity/object graph bounded to a specific to/cc set

parent 9cac7c95
...@@ -410,6 +410,20 @@ defp restrict_tag(query, %{"tag" => tag}) do ...@@ -410,6 +410,20 @@ defp restrict_tag(query, %{"tag" => tag}) do
defp restrict_tag(query, _), do: query defp restrict_tag(query, _), do: query
defp restrict_to_cc(query, recipients_to, recipients_cc) do
from(
activity in query,
where:
fragment(
"(? && ?) or (? && ?)",
^recipients_to,
activity.recipients_to,
^recipients_cc,
activity.recipients_cc
)
)
end
defp restrict_recipients(query, [], _user), do: query defp restrict_recipients(query, [], _user), do: query
defp restrict_recipients(query, recipients, nil) do defp restrict_recipients(query, recipients, nil) do
...@@ -551,6 +565,13 @@ def fetch_activities(recipients, opts \\ %{}) do ...@@ -551,6 +565,13 @@ def fetch_activities(recipients, opts \\ %{}) do
|> Enum.reverse() |> Enum.reverse()
end end
def fetch_activities_bounded(recipients_to, recipients_cc, opts \\ %{}) do
fetch_activities_query([], opts)
|> restrict_to_cc(recipients_to, recipients_cc)
|> Repo.all()
|> Enum.reverse()
end
def upload(file) do def upload(file) do
data = Upload.store(file, Application.get_env(:pleroma, :instance)[:dedupe_media]) data = Upload.store(file, Application.get_env(:pleroma, :instance)[:dedupe_media])
Repo.insert(%Object{data: data}) Repo.insert(%Object{data: data})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment