activitypub: c2s: add /api/ap/whoami endpoint for andstatus
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 4 Feb 2019 22:58:29 +0000 (22:58 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 4 Feb 2019 22:58:29 +0000 (22:58 +0000)
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/router.ex

index 4dea6ab83ee21ac87ee92f750151ef9751d8a76e..2cdf132e2dc998520548ed70d654ca1881ee36f9 100644 (file)
@@ -198,6 +198,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
     end
   end
 
+  def whoami(%{assigns: %{user: %User{} = user}} = conn, _params) do
+    conn
+    |> put_resp_header("content-type", "application/activity+json")
+    |> json(UserView.render("user.json", %{user: user}))
+  end
+
+  def whoami(_conn, _params), do: {:error, :not_found}
+
   def read_inbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do
     if nickname == user.nickname do
       conn
index c6b4d37ab8eddb24c442c7530498218d3b8a177d..7f606ac404683c389a7328f991cbaf1d1e69ff87 100644 (file)
@@ -454,6 +454,7 @@ defmodule Pleroma.Web.Router do
   scope "/", Pleroma.Web.ActivityPub do
     pipe_through([:activitypub_client])
 
+    get("/api/ap/whoami", ActivityPubController, :whoami)
     get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
     post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
   end