forked from AkkomaGang/akkoma
activitypub: do not show observable effects of non-public boosts
This commit is contained in:
parent
aea23468c6
commit
de6be63b1b
1 changed files with 26 additions and 1 deletions
|
@ -302,6 +302,24 @@ def get_existing_announce(actor, %{data: %{"id" => id}}) do
|
||||||
@doc """
|
@doc """
|
||||||
Make announce activity data for the given actor and object
|
Make announce activity data for the given actor and object
|
||||||
"""
|
"""
|
||||||
|
# for relayed messages, we only want to send to subscribers
|
||||||
|
def make_announce_data(
|
||||||
|
%User{ap_id: ap_id, nickname: nil} = user,
|
||||||
|
%Object{data: %{"id" => id}} = object,
|
||||||
|
activity_id
|
||||||
|
) do
|
||||||
|
data = %{
|
||||||
|
"type" => "Announce",
|
||||||
|
"actor" => ap_id,
|
||||||
|
"object" => id,
|
||||||
|
"to" => [user.follower_address],
|
||||||
|
"cc" => [],
|
||||||
|
"context" => object.data["context"]
|
||||||
|
}
|
||||||
|
|
||||||
|
if activity_id, do: Map.put(data, "id", activity_id), else: data
|
||||||
|
end
|
||||||
|
|
||||||
def make_announce_data(
|
def make_announce_data(
|
||||||
%User{ap_id: ap_id} = user,
|
%User{ap_id: ap_id} = user,
|
||||||
%Object{data: %{"id" => id}} = object,
|
%Object{data: %{"id" => id}} = object,
|
||||||
|
@ -356,12 +374,19 @@ def make_unlike_data(
|
||||||
if activity_id, do: Map.put(data, "id", activity_id), else: data
|
if activity_id, do: Map.put(data, "id", activity_id), else: data
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_announce_to_object(%Activity{data: %{"actor" => actor}}, object) do
|
def add_announce_to_object(
|
||||||
|
%Activity{
|
||||||
|
data: %{"actor" => actor, "cc" => ["https://www.w3.org/ns/activitystreams#Public"]}
|
||||||
|
},
|
||||||
|
object
|
||||||
|
) do
|
||||||
with announcements <- [actor | object.data["announcements"] || []] |> Enum.uniq() do
|
with announcements <- [actor | object.data["announcements"] || []] |> Enum.uniq() do
|
||||||
update_element_in_object("announcement", announcements, object)
|
update_element_in_object("announcement", announcements, object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_announce_to_object(_, object), do: {:ok, object}
|
||||||
|
|
||||||
def remove_announce_from_object(%Activity{data: %{"actor" => actor}}, object) do
|
def remove_announce_from_object(%Activity{data: %{"actor" => actor}}, object) do
|
||||||
with announcements <- (object.data["announcements"] || []) |> List.delete(actor) do
|
with announcements <- (object.data["announcements"] || []) |> List.delete(actor) do
|
||||||
update_element_in_object("announcement", announcements, object)
|
update_element_in_object("announcement", announcements, object)
|
||||||
|
|
Loading…
Reference in a new issue