aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-09 12:05:17 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-09 12:05:17 +0200
commita22f2e683b5e77eb563f0ca05a2160578ed2ac82 (patch)
tree6c8c7be15acfe106097b3e3b2fcb0d83624196cf /lib
parent95cedd60004893fd646735d17f7196297c38e22c (diff)
downloadpleroma-a22f2e683b5e77eb563f0ca05a2160578ed2ac82.tar.gz
Add type restriction to activitypub fetcher
Mainly because Mastodon only returns notes, not the other activities.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index db1302738..8ae321658 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -133,6 +133,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
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
base_query = from activity in Activity,
limit: 20,
@@ -144,6 +150,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> restrict_local(opts)
|> restrict_max(opts)
|> restrict_actor(opts)
+ |> restrict_type(opts)
|> Repo.all
|> Enum.reverse
end