Add type restriction to activitypub fetcher
Mainly because Mastodon only returns notes, not the other activities.
This commit is contained in:
parent
95cedd6000
commit
a22f2e683b
|
@ -133,6 +133,12 @@ defp restrict_actor(query, %{"actor_id" => actor_id}) do
|
||||||
end
|
end
|
||||||
defp restrict_actor(query, _), do: query
|
defp restrict_actor(query, _), do: query
|
||||||
|
|
||||||
|
defp restrict_type(query, %{"type" => type}) do
|
||||||
|
from activity in query,
|
||||||
|
where: fragment("?->>'type' = ?", activity.data, ^type)
|
||||||
|
end
|
||||||
|
defp restrict_type(query, _), do: query
|
||||||
|
|
||||||
def fetch_activities(recipients, opts \\ %{}) do
|
def fetch_activities(recipients, opts \\ %{}) do
|
||||||
base_query = from activity in Activity,
|
base_query = from activity in Activity,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
|
@ -144,6 +150,7 @@ def fetch_activities(recipients, opts \\ %{}) do
|
||||||
|> restrict_local(opts)
|
|> restrict_local(opts)
|
||||||
|> restrict_max(opts)
|
|> restrict_max(opts)
|
||||||
|> restrict_actor(opts)
|
|> restrict_actor(opts)
|
||||||
|
|> restrict_type(opts)
|
||||||
|> Repo.all
|
|> Repo.all
|
||||||
|> Enum.reverse
|
|> Enum.reverse
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue