remote_interaction API endpoint
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
c97f99ccf2
commit
cd5fb84b76
|
@ -237,4 +237,30 @@ def remote_subscribe_operation do
|
||||||
responses: %{200 => Operation.response("Web Page", "test/html", %Schema{type: :string})}
|
responses: %{200 => Operation.response("Web Page", "test/html", %Schema{type: :string})}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remote_interaction_operation do
|
||||||
|
%Operation{
|
||||||
|
tags: ["Accounts"],
|
||||||
|
summary: "Remote interaction",
|
||||||
|
operationId: "UtilController.remote_interaction",
|
||||||
|
requestBody: request_body("Parameters", remote_interaction_request(), required: true),
|
||||||
|
responses: %{
|
||||||
|
200 =>
|
||||||
|
Operation.response("Remote interaction URL", "application/json", %Schema{type: :object})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp remote_interaction_request do
|
||||||
|
%Schema{
|
||||||
|
title: "RemoteInteractionRequest",
|
||||||
|
description: "POST body for remote interaction",
|
||||||
|
type: :object,
|
||||||
|
required: [:ap_id, :profile],
|
||||||
|
properties: %{
|
||||||
|
ap_id: %Schema{type: :string, description: "Profile or status ActivityPub ID"},
|
||||||
|
profile: %Schema{type: :string, description: "Remote profile webfinger"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -150,6 +150,7 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/emoji", UtilController, :emoji)
|
get("/emoji", UtilController, :emoji)
|
||||||
get("/captcha", UtilController, :captcha)
|
get("/captcha", UtilController, :captcha)
|
||||||
get("/healthcheck", UtilController, :healthcheck)
|
get("/healthcheck", UtilController, :healthcheck)
|
||||||
|
post("/remote_interaction", UtilController, :remote_interaction)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api/v1/pleroma", Pleroma.Web do
|
scope "/api/v1/pleroma", Pleroma.Web do
|
||||||
|
|
|
@ -62,6 +62,15 @@ def remote_subscribe(conn, %{"user" => %{"nickname" => nick, "profile" => profil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remote_interaction(%{body_params: %{ap_id: ap_id, profile: profile}} = conn, _params) do
|
||||||
|
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile) do
|
||||||
|
conn
|
||||||
|
|> json(%{url: String.replace(template, "{uri}", ap_id)})
|
||||||
|
else
|
||||||
|
_e -> json(conn, %{error: "Couldn't find user"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def frontend_configurations(conn, _params) do
|
def frontend_configurations(conn, _params) do
|
||||||
render(conn, "frontend_configurations.json")
|
render(conn, "frontend_configurations.json")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue