projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'fix/unsubscribe-route' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
visibility.ex
diff --git
a/lib/pleroma/web/activity_pub/visibility.ex
b/lib/pleroma/web/activity_pub/visibility.ex
index 2666edc7ce0934302011cc748aafb0bf3959d413..e172f6d3f2b6196338900b6448e80e17083b9b83 100644
(file)
--- a/
lib/pleroma/web/activity_pub/visibility.ex
+++ b/
lib/pleroma/web/activity_pub/visibility.ex
@@
-7,15
+7,17
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
+ alias Pleroma.Web.ActivityPub.Utils
+ require Pleroma.Constants
+
+ @spec is_public?(Object.t() | Activity.t() | map()) :: boolean()
def is_public?(%Object{data: %{"type" => "Tombstone"}}), do: false
def is_public?(%Object{data: data}), do: is_public?(data)
def is_public?(%Object{data: %{"type" => "Tombstone"}}), do: false
def is_public?(%Object{data: data}), do: is_public?(data)
+ def is_public?(%Activity{data: %{"type" => "Move"}}), do: true
def is_public?(%Activity{data: data}), do: is_public?(data)
def is_public?(%{"directMessage" => true}), do: false
def is_public?(%Activity{data: data}), do: is_public?(data)
def is_public?(%{"directMessage" => true}), do: false
-
- def is_public?(data) do
- "https://www.w3.org/ns/activitystreams#Public" in (data["to"] ++ (data["cc"] || []))
- end
+ def is_public?(data), do: Utils.label_in_message?(Pleroma.Constants.as_public(), data)
def is_private?(activity) do
with false <- is_public?(activity),
def is_private?(activity) do
with false <- is_public?(activity),
@@
-27,6
+29,11
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
end
end
end
end
+ def is_announceable?(activity, user, public \\ true) do
+ is_public?(activity) ||
+ (!public && is_private?(activity) && activity.data["actor"] == user.ap_id)
+ end
+
def is_direct?(%Activity{data: %{"directMessage" => true}}), do: true
def is_direct?(%Object{data: %{"directMessage" => true}}), do: true
def is_direct?(%Activity{data: %{"directMessage" => true}}), do: true
def is_direct?(%Object{data: %{"directMessage" => true}}), do: true
@@
-53,7
+60,7
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
end
def visible_for_user?(activity, user) do
end
def visible_for_user?(activity, user) do
- x = [user.ap_id |
user.following
]
+ x = [user.ap_id |
User.following(user)
]
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
visible_for_user?(activity, nil) || Enum.any?(x, &(&1 in y))
end
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
visible_for_user?(activity, nil) || Enum.any?(x, &(&1 in y))
end
@@
-69,15
+76,14
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
end
def get_visibility(object) do
end
def get_visibility(object) do
- public = "https://www.w3.org/ns/activitystreams#Public"
to = object.data["to"] || []
cc = object.data["cc"] || []
cond do
to = object.data["to"] || []
cc = object.data["cc"] || []
cond do
-
public
in to ->
+
Pleroma.Constants.as_public()
in to ->
"public"
"public"
-
public
in cc ->
+
Pleroma.Constants.as_public()
in cc ->
"unlisted"
# this should use the sql for the object's activity
"unlisted"
# this should use the sql for the object's activity