SideEffects: Handle ChatMessage creation.
[akkoma] / lib / pleroma / web / activity_pub / builder.ex
index 1787f151013824403b7de6807ffa3f6fe553a2d7..f0a6c1e1b8eca57fa1a6f4b7eb0ce13413bf705e 100644 (file)
@@ -5,10 +5,32 @@ defmodule Pleroma.Web.ActivityPub.Builder do
   This module encodes our addressing policies and general shape of our objects.
   """
 
+  alias Pleroma.Object
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
-  alias Pleroma.User
-  alias Pleroma.Object
+
+  def create(actor, object_id, recipients) do
+    {:ok,
+     %{
+       "id" => Utils.generate_activity_id(),
+       "actor" => actor.ap_id,
+       "to" => recipients,
+       "object" => object_id,
+       "type" => "Create"
+     }, []}
+  end
+
+  def chat_message(actor, recipient, content) do
+    {:ok,
+     %{
+       "id" => Utils.generate_object_id(),
+       "actor" => actor.ap_id,
+       "type" => "ChatMessage",
+       "to" => [recipient],
+       "content" => content
+     }, []}
+  end
 
   @spec like(User.t(), Object.t()) :: {:ok, map(), keyword()}
   def like(actor, object) do