Restrict public by recipients.
authorlain <lain@soykaf.club>
Mon, 26 Feb 2018 09:09:30 +0000 (10:09 +0100)
committerlain <lain@soykaf.club>
Mon, 26 Feb 2018 09:09:30 +0000 (10:09 +0100)
This is much faster than going through the json. This does break
unlisted, for which we'll probably have to add another table field.

lib/pleroma/web/activity_pub/activity_pub.ex

index 667f8fc1519a07a75522aa5297187269ff322b48..965f2cc9b0ad0af935c807f52f24b34bcb3ddb95 100644 (file)
@@ -155,11 +155,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     Repo.all(query)
   end
 
+  # TODO: Make this work properly with unlisted.
   def fetch_public_activities(opts \\ %{}) do
-    public = %{to: ["https://www.w3.org/ns/activitystreams#Public"]}
-    q = fetch_activities_query([], opts)
-    q = from activity in q,
-      where: fragment(~s(? @> ?), activity.data, ^public)
+    q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
     q
     |> Repo.all
     |> Enum.reverse