forked from AkkomaGang/akkoma
Don't show unlisted in public.
This commit is contained in:
parent
c974f6544f
commit
5729233c36
1 changed files with 12 additions and 3 deletions
|
@ -136,8 +136,13 @@ def fetch_activities_for_context(context, opts \\ %{}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_public_activities(opts \\ %{}) do
|
def fetch_public_activities(opts \\ %{}) do
|
||||||
public = ["https://www.w3.org/ns/activitystreams#Public"]
|
public = %{to: ["https://www.w3.org/ns/activitystreams#Public"]}
|
||||||
fetch_activities(public, opts)
|
q = fetch_activities_query([], opts)
|
||||||
|
q = from activity in q,
|
||||||
|
where: fragment(~s(? @> ?), activity.data, ^public)
|
||||||
|
q
|
||||||
|
|> Repo.all
|
||||||
|
|> Enum.reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_since(query, %{"since_id" => since_id}) do
|
defp restrict_since(query, %{"since_id" => since_id}) do
|
||||||
|
@ -215,7 +220,7 @@ defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
|
||||||
end
|
end
|
||||||
defp restrict_blocked(query, _), do: query
|
defp restrict_blocked(query, _), do: query
|
||||||
|
|
||||||
def fetch_activities(recipients, opts \\ %{}) do
|
def fetch_activities_query(recipients, opts \\ %{}) do
|
||||||
base_query = from activity in Activity,
|
base_query = from activity in Activity,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
order_by: [fragment("? desc nulls last", activity.id)]
|
order_by: [fragment("? desc nulls last", activity.id)]
|
||||||
|
@ -232,6 +237,10 @@ def fetch_activities(recipients, opts \\ %{}) do
|
||||||
|> restrict_recent(opts)
|
|> restrict_recent(opts)
|
||||||
|> restrict_blocked(opts)
|
|> restrict_blocked(opts)
|
||||||
|> restrict_media(opts)
|
|> restrict_media(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_activities(recipients, opts \\ %{}) do
|
||||||
|
fetch_activities_query(recipients, opts)
|
||||||
|> Repo.all
|
|> Repo.all
|
||||||
|> Enum.reverse
|
|> Enum.reverse
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue