projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add spec for AccountController.update_credentials
[akkoma]
/
lib
/
pleroma
/
web
/
mastodon_api
/
controllers
/
app_controller.ex
diff --git
a/lib/pleroma/web/mastodon_api/controllers/app_controller.ex
b/lib/pleroma/web/mastodon_api/controllers/app_controller.ex
index 13a30a34d498f066d281f17a83bf611b8f54e242..005c604447e3999cf756ec2dd1b842930d46df5e 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/controllers/app_controller.ex
+++ b/
lib/pleroma/web/mastodon_api/controllers/app_controller.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AppController do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AppController do
@@
-14,17
+14,20
@@
defmodule Pleroma.Web.MastodonAPI.AppController do
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
plug(OAuthScopesPlug, %{scopes: ["read"]} when action == :verify_credentials)
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
plug(OAuthScopesPlug, %{scopes: ["read"]} when action == :verify_credentials)
+ plug(OpenApiSpex.Plug.CastAndValidate)
@local_mastodon_name "Mastodon-Local"
@local_mastodon_name "Mastodon-Local"
+ defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.AppOperation
+
@doc "POST /api/v1/apps"
@doc "POST /api/v1/apps"
- def create(
conn,
params) do
+ def create(
%{body_params: params} = conn, _
params) do
scopes = Scopes.fetch_scopes(params, ["read"])
app_attrs =
params
scopes = Scopes.fetch_scopes(params, ["read"])
app_attrs =
params
- |> Map.
drop(["scope", "scopes"
])
- |> Map.put(
"scopes"
, scopes)
+ |> Map.
take([:client_name, :redirect_uris, :website
])
+ |> Map.put(
:scopes
, scopes)
with cs <- App.register_changeset(%App{}, app_attrs),
false <- cs.changes[:client_name] == @local_mastodon_name,
with cs <- App.register_changeset(%App{}, app_attrs),
false <- cs.changes[:client_name] == @local_mastodon_name,