projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Undoing: Move undoing blocks to the pipeline everywhere.
[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..453a6842edbc88d83f9bc740ddd1875c2b0aa590 100644
(file)
--- a/
lib/pleroma/web/activity_pub/visibility.ex
+++ b/
lib/pleroma/web/activity_pub/visibility.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Visibility do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Visibility do
@@
-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
@@
-37,6
+44,7
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
def is_list?(%{data: %{"listMessage" => _}}), do: true
def is_list?(_), do: false
def is_list?(%{data: %{"listMessage" => _}}), do: true
def is_list?(_), do: false
+ @spec visible_for_user?(Activity.t(), User.t() | nil) :: boolean()
def visible_for_user?(%{actor: ap_id}, %User{ap_id: ap_id}), do: true
def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{} = user) do
def visible_for_user?(%{actor: ap_id}, %User{ap_id: ap_id}), do: true
def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{} = user) do
@@
-48,14
+56,21
@@
defmodule Pleroma.Web.ActivityPub.Visibility do
def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false
def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false
- def visible_for_user?(activity, nil) do
- is_public?(activity)
+ def visible_for_user?(%{local: local} = activity, nil) do
+ cfg_key =
+ if local,
+ do: :local,
+ else: :remote
+
+ if Pleroma.Config.get([:restrict_unauthenticated, :activities, cfg_key]),
+ do: false,
+ else: is_public?(activity)
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"] || [])
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
-
visible_for_user?(activity, nil
) || Enum.any?(x, &(&1 in y))
+
is_public?(activity
) || Enum.any?(x, &(&1 in y))
end
def entire_thread_visible_for_user?(%Activity{} = activity, %User{} = user) do
end
def entire_thread_visible_for_user?(%Activity{} = activity, %User{} = user) do
@@
-69,15
+84,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