From: William Pitcock Date: Mon, 4 Feb 2019 22:58:29 +0000 (+0000) Subject: activitypub: c2s: add /api/ap/whoami endpoint for andstatus X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=db1165f70f76b5892c4f3a2861db90549e2291a6;p=akkoma activitypub: c2s: add /api/ap/whoami endpoint for andstatus --- diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 4dea6ab83..2cdf132e2 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -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 diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index c6b4d37ab..7f606ac40 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -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