Quote posting (#113)
[akkoma] / lib / pleroma / web / activity_pub / builder.ex
index 8c51b8d6330e0fd5ea678bf5bbba4041096c0656..97ceaf08ecfa8ec008d753948bd0a502903162e4 100644 (file)
@@ -168,6 +168,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
         "tag" => Keyword.values(draft.tags) |> Enum.uniq()
       }
       |> add_in_reply_to(draft.in_reply_to)
+      |> add_quote(draft.quote)
       |> Map.merge(draft.extra)
 
     {:ok, data, []}
@@ -183,6 +184,16 @@ defmodule Pleroma.Web.ActivityPub.Builder do
     end
   end
 
+  defp add_quote(object, nil), do: object
+
+  defp add_quote(object, quote) do
+    with %Object{} = quote_object <- Object.normalize(quote, fetch: false) do
+      Map.put(object, "quoteUri", quote_object.data["id"])
+    else
+      _ -> object
+    end
+  end
+
   def answer(user, object, name) do
     {:ok,
      %{