activitypub: announce: add new public parameter

This commit is contained in:
William Pitcock 2019-01-17 23:12:42 +00:00
parent ce2efd1ee2
commit 2479e88815
2 changed files with 8 additions and 5 deletions

View file

@ -224,10 +224,11 @@ def announce(
%User{ap_id: _} = user, %User{ap_id: _} = user,
%Object{data: %{"id" => _}} = object, %Object{data: %{"id" => _}} = object,
activity_id \\ nil, activity_id \\ nil,
local \\ true local \\ true,
public \\ true
) do ) do
with true <- is_public?(object), with true <- is_public?(object),
announce_data <- make_announce_data(user, object, activity_id), announce_data <- make_announce_data(user, object, activity_id, public),
{:ok, activity} <- insert(announce_data, local), {:ok, activity} <- insert(announce_data, local),
{:ok, object} <- add_announce_to_object(activity, object), {:ok, object} <- add_announce_to_object(activity, object),
:ok <- maybe_federate(activity) do :ok <- maybe_federate(activity) do

View file

@ -386,9 +386,10 @@ def get_existing_announce(actor, %{data: %{"id" => id}}) do
""" """
# for relayed messages, we only want to send to subscribers # for relayed messages, we only want to send to subscribers
def make_announce_data( def make_announce_data(
%User{ap_id: ap_id, nickname: nil} = user, %User{ap_id: ap_id} = user,
%Object{data: %{"id" => id}} = object, %Object{data: %{"id" => id}} = object,
activity_id activity_id,
false
) do ) do
data = %{ data = %{
"type" => "Announce", "type" => "Announce",
@ -405,7 +406,8 @@ def make_announce_data(
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,
activity_id activity_id,
true
) do ) do
data = %{ data = %{
"type" => "Announce", "type" => "Announce",