Announcements: Handle through common pipeline.

This commit is contained in:
lain 2020-05-20 15:44:37 +02:00
commit e42bc5f557
11 changed files with 135 additions and 79 deletions

View file

@ -10,6 +10,8 @@ defmodule Pleroma.Web.ActivityPub.Builder do
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.Visibility
require Pleroma.Constants
@spec emoji_react(User.t(), Object.t(), String.t()) :: {:ok, map(), keyword()}
def emoji_react(actor, object, emoji) do
with {:ok, data, meta} <- object_action(actor, object) do
@ -83,9 +85,17 @@ defmodule Pleroma.Web.ActivityPub.Builder do
end
end
def announce(actor, object) do
def announce(actor, object, options \\ []) do
public? = Keyword.get(options, :public, false)
to = [actor.follower_address, object.data["actor"]]
to =
if public? do
[Pleroma.Constants.as_public() | to]
else
to
end
{:ok,
%{
"id" => Utils.generate_activity_id(),
@ -93,7 +103,8 @@ defmodule Pleroma.Web.ActivityPub.Builder do
"object" => object.data["id"],
"to" => to,
"context" => object.data["context"],
"type" => "Announce"
"type" => "Announce",
"published" => Utils.make_date()
}, []}
end