1 defmodule Pleroma.Web.ActivityPub.Builder do
3 This module builds the objects. Meant to be used for creating local objects.
5 This module encodes our addressing policies and general shape of our objects.
10 alias Pleroma.Web.ActivityPub.Utils
11 alias Pleroma.Web.ActivityPub.Visibility
13 @spec like(User.t(), Object.t()) :: {:ok, map(), keyword()}
14 def like(actor, object) do
15 object_actor = User.get_cached_by_ap_id(object.data["actor"])
17 # Address the actor of the object, and our actor's follower collection if the post is public.
19 if Visibility.is_public?(object) do
20 [actor.follower_address, object.data["actor"]]
22 [object.data["actor"]]
25 # CC everyone who's been addressed in the object, except ourself and the object actor's
28 (object.data["to"] ++ (object.data["cc"] || []))
29 |> List.delete(actor.ap_id)
30 |> List.delete(object_actor.follower_address)
34 "id" => Utils.generate_activity_id(),
35 "actor" => actor.ap_id,
37 "object" => object.data["id"],
40 "context" => object.data["context"]