diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-12-25 01:32:47 +0000 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-12-25 01:32:47 +0000 |
commit | b4291bce8aa9a2f166b234d0dcc89eb711b79643 (patch) | |
tree | 498b0572f6edb8d09acb471b6b557de6ca9bc638 /lib | |
parent | 1fa616638b8823a6cc0d67d0354cc179da5943f8 (diff) | |
parent | 9775955974171c19e2dd9e6930e96e33f25cb4db (diff) | |
download | pleroma-b4291bce8aa9a2f166b234d0dcc89eb711b79643.tar.gz |
Merge branch 'remote-follow-api' into 'develop'
remote_interaction API endpoint
See merge request pleroma/pleroma!3545
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/api_spec/operations/twitter_util_operation.ex | 26 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 1 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/controllers/util_controller.ex | 9 |
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex b/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex index 5a2b0bc49..2a701066d 100644 --- a/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex +++ b/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex @@ -239,6 +239,32 @@ defmodule Pleroma.Web.ApiSpec.TwitterUtilOperation do } 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 + defp delete_account_request do %Schema{ title: "AccountDeleteRequest", diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 5fbc2509e..965cd507f 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -151,6 +151,7 @@ defmodule Pleroma.Web.Router do get("/emoji", UtilController, :emoji) get("/captcha", UtilController, :captcha) get("/healthcheck", UtilController, :healthcheck) + post("/remote_interaction", UtilController, :remote_interaction) end scope "/api/v1/pleroma", Pleroma.Web do diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index a4e44efdd..ccbef6d9f 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -62,6 +62,15 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do 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 render(conn, "frontend_configurations.json") end |