Introduce get_by_id in Activity, replace newlines with spaces
[akkoma] / lib / pleroma / web / activity_pub / activity_pub_controller.ex
index a3f736fee1043891744ed02796134cf75e609443..73ca07e84a893c436e04d3122ec58c8de31943bb 100644 (file)
@@ -54,6 +54,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
     end
   end
 
+  def activity(conn, %{"uuid" => uuid}) do
+    with ap_id <- o_status_url(conn, :activity, uuid),
+         %Activity{} = activity <- Activity.normalize(ap_id),
+         {_, true} <- {:public?, ActivityPub.is_public?(activity)} do
+      conn
+      |> put_resp_header("content-type", "application/activity+json")
+      |> json(ObjectView.render("object.json", %{object: activity}))
+    else
+      {:public?, false} ->
+        {:error, :not_found}
+    end
+  end
+
   def following(conn, %{"nickname" => nickname, "page" => page}) do
     with %User{} = user <- User.get_cached_by_nickname(nickname),
          {:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do