Restrict public by recipients.

This is much faster than going through the json. This does break
unlisted, for which we'll probably have to add another table field.
This commit is contained in:
lain 2018-02-26 10:09:30 +01:00
parent a17ba0ee0d
commit 1377b2e569
1 changed files with 2 additions and 4 deletions

View File

@ -155,11 +155,9 @@ def fetch_activities_for_context(context, opts \\ %{}) 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