1 defmodule Pleroma.Web.ActivityPub.ActivityPubController do
2 use Pleroma.Web, :controller
3 alias Pleroma.{User, Repo, Object, Activity}
4 alias Pleroma.Web.ActivityPub.{ObjectView, UserView, Transmogrifier}
5 alias Pleroma.Web.ActivityPub.ActivityPub
6 alias Pleroma.Web.Federator
10 action_fallback :errors
12 def user(conn, %{"nickname" => nickname}) do
13 with %User{} = user <- User.get_cached_by_nickname(nickname),
14 {:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do
16 |> put_resp_header("content-type", "application/activity+json")
17 |> json(UserView.render("user.json", %{user: user}))
21 def object(conn, %{"uuid" => uuid}) do
22 with ap_id <- o_status_url(conn, :object, uuid),
23 %Object{} = object <- Object.get_cached_by_ap_id(ap_id) do
25 |> put_resp_header("content-type", "application/activity+json")
26 |> json(ObjectView.render("object.json", %{object: object}))
30 # TODO: Ensure that this inbox is a recipient of the message
31 def inbox(%{assigns: %{valid_signature: true}} = conn, params) do
32 Federator.enqueue(:incoming_ap_doc, params)
36 def inbox(conn, params) do
37 Logger.info("Signature error.")
38 Logger.info(inspect(conn.req_headers))
42 def errors(conn, _e) do