Merge branch 'kaniini/pleroma-bugfix/unlisted-statuses' into develop
This commit is contained in:
commit
7e9f14bf3c
|
@ -211,11 +211,11 @@ def fetch_activities_for_context(context, opts \\ %{}) do
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Make this work properly with unlisted.
|
|
||||||
def fetch_public_activities(opts \\ %{}) do
|
def fetch_public_activities(opts \\ %{}) do
|
||||||
q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
|
q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
|
||||||
|
|
||||||
q
|
q
|
||||||
|
|> restrict_unlisted()
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.reverse()
|
|> Enum.reverse()
|
||||||
end
|
end
|
||||||
|
@ -322,6 +322,18 @@ defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
|
||||||
|
|
||||||
defp restrict_blocked(query, _), do: query
|
defp restrict_blocked(query, _), do: query
|
||||||
|
|
||||||
|
defp restrict_unlisted(query) do
|
||||||
|
from(
|
||||||
|
activity in query,
|
||||||
|
where:
|
||||||
|
fragment(
|
||||||
|
"(?->'to' \\?| ?)",
|
||||||
|
activity.data,
|
||||||
|
^["https://www.w3.org/ns/activitystreams#Public"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_activities_query(recipients, opts \\ %{}) do
|
def fetch_activities_query(recipients, opts \\ %{}) do
|
||||||
base_query =
|
base_query =
|
||||||
from(
|
from(
|
||||||
|
|
|
@ -171,6 +171,16 @@ test "doesn't return blocked activities" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "public fetch activities" do
|
describe "public fetch activities" do
|
||||||
|
test "doesn't retrieve unlisted activities" do
|
||||||
|
user = insert(:user)
|
||||||
|
{:ok, unlisted_activity} = CommonAPI.post(user, %{"status" => "yeah", "visibility" => "unlisted"})
|
||||||
|
{:ok, listed_activity} = CommonAPI.post(user, %{"status" => "yeah"})
|
||||||
|
|
||||||
|
[activity] = ActivityPub.fetch_public_activities()
|
||||||
|
|
||||||
|
assert activity == listed_activity
|
||||||
|
end
|
||||||
|
|
||||||
test "retrieves public activities" do
|
test "retrieves public activities" do
|
||||||
_activities = ActivityPub.fetch_public_activities()
|
_activities = ActivityPub.fetch_public_activities()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue