diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-11-26 20:19:29 -0600 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-11-26 20:19:29 -0600 |
commit | aee55b9a8bc3e643377d5843a1ff5d379aecf0e3 (patch) | |
tree | 5c30720ab7e79a915ccea1a23dbc4e4ad6aabc93 /lib/pleroma/web/mastodon_api | |
parent | da06e1a17fe45407cd82f83223dc68b8920e1fe8 (diff) | |
download | pleroma-aee55b9a8bc3e643377d5843a1ff5d379aecf0e3.tar.gz |
v2 Suggestions: dismiss a suggestion
Diffstat (limited to 'lib/pleroma/web/mastodon_api')
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex b/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex index 4f92c1f46..4ebfc737c 100644 --- a/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex @@ -5,11 +5,13 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionController do use Pleroma.Web, :controller alias Pleroma.User + alias Pleroma.UserRelationship require Logger plug(Pleroma.Web.ApiSpec.CastAndValidate) plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: ["read"]} when action in [:index, :index2]) + plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: ["write"]} when action in [:dismiss]) def open_api_operation(action) do operation = String.to_existing_atom("#{action}_operation") @@ -38,6 +40,26 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionController do } end + def dismiss_operation do + %OpenApiSpex.Operation{ + tags: ["Suggestions"], + summary: "Remove a suggestion", + operationId: "SuggestionController.dismiss", + parameters: [ + OpenApiSpex.Operation.parameter( + :account_id, + :path, + %OpenApiSpex.Schema{type: :string}, + "Account to dismiss", + required: true + ) + ], + responses: %{ + 200 => Pleroma.Web.ApiSpec.Helpers.empty_object_response() + } + } + end + @doc "GET /api/v1/suggestions" def index(conn, params), do: Pleroma.Web.MastodonAPI.MastodonAPIController.empty_array(conn, params) @@ -53,4 +75,12 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionController do render(conn, "index.json", %{users: users, source: :staff, for: user}) end + + @doc "DELETE /api/v1/suggestions/:account_id" + def dismiss(%{assigns: %{user: source}} = conn, %{account_id: user_id}) do + with %User{} = target <- User.get_cached_by_id(user_id), + {:ok, _} <- UserRelationship.create(:suggestion_dismiss, source, target) do + json(conn, %{}) + end + end end |