visibility: improve visibility functions since the SQL one is gone now
This commit is contained in:
parent
079f1c3aa2
commit
dd904ab8fa
@ -14,7 +14,10 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
|
|||||||
def is_public?(%Object{data: data}), do: is_public?(data)
|
def is_public?(%Object{data: data}), do: is_public?(data)
|
||||||
def is_public?(%Activity{data: data}), do: is_public?(data)
|
def is_public?(%Activity{data: data}), do: is_public?(data)
|
||||||
def is_public?(%{"directMessage" => true}), do: false
|
def is_public?(%{"directMessage" => true}), do: false
|
||||||
def is_public?(data), do: Pleroma.Constants.as_public() in (data["to"] ++ (data["cc"] || []))
|
def is_public?(%{"to" => to} = data), do: Pleroma.Constants.as_public() in (to ++ (data["cc"] || []))
|
||||||
|
def is_public?(%{"type" => "Create"}), do: false
|
||||||
|
def is_public?(%{"type" => _}), do: true
|
||||||
|
def is_public?(_), do: false
|
||||||
|
|
||||||
def is_private?(activity) do
|
def is_private?(activity) do
|
||||||
with false <- is_public?(activity),
|
with false <- is_public?(activity),
|
||||||
@ -53,7 +56,7 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
|
|||||||
|
|
||||||
def visible_for_user?(activity, user) do
|
def visible_for_user?(activity, user) do
|
||||||
x = [user.ap_id | user.following]
|
x = [user.ap_id | user.following]
|
||||||
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
|
y = [activity.actor] ++ activity.recipients
|
||||||
visible_for_user?(activity, nil) || Enum.any?(x, &(&1 in y))
|
visible_for_user?(activity, nil) || Enum.any?(x, &(&1 in y))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user