Compare commits
24 Commits
feature/sa
...
feature/up
Author | SHA1 | Date | |
---|---|---|---|
|
73d552d5eb | ||
|
9d56f2717c | ||
|
fe263d0d00 | ||
|
07ffce0342 | ||
|
7a91877ee4 | ||
|
9411f90398 | ||
|
921d874187 | ||
|
7c6de228dd | ||
|
db699f358f | ||
|
f565854b51 | ||
|
05ef2282d5 | ||
|
567c93a26d | ||
|
481f63a9a7 | ||
|
5835f6d0a4 | ||
|
c425f87717 | ||
|
67f7822b17 | ||
|
68d3d04274 | ||
|
3f9983ee93 | ||
|
63e412ceb5 | ||
|
36d93d691d | ||
|
957a51058b | ||
|
f20c1afe46 | ||
|
f9d9987df8 | ||
|
8827d7a74f |
@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
|
- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Admin API: Added `GET /api/v2/pleroma/admin/config/descriptions` endpoint, differs from `/api/v1/pleroma/admin/config/descriptions` in response format and has additional field with the tabs list.
|
||||||
|
|
||||||
## Unreleased (Patch)
|
## Unreleased (Patch)
|
||||||
|
|
||||||
## [2.3.0] - 2020-03-01
|
## [2.3.0] - 2020-03-01
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1091,9 +1091,10 @@ config :quack,
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## ` GET /api/v1/pleroma/admin/config/descriptions`
|
## `GET /api/v1/pleroma/admin/config/descriptions`
|
||||||
|
|
||||||
|
### Get JSON with config descriptions
|
||||||
|
|
||||||
### Get JSON with config descriptions.
|
|
||||||
Loads json generated from `config/descriptions.exs`.
|
Loads json generated from `config/descriptions.exs`.
|
||||||
|
|
||||||
- Params: none
|
- Params: none
|
||||||
@ -1105,6 +1106,8 @@ Loads json generated from `config/descriptions.exs`.
|
|||||||
"key": "ModuleName", // string
|
"key": "ModuleName", // string
|
||||||
"type": "group", // string or list with possible values,
|
"type": "group", // string or list with possible values,
|
||||||
"description": "Upload general settings", // string
|
"description": "Upload general settings", // string
|
||||||
|
"tab": "mrf",
|
||||||
|
"label": "MRF",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"key": ":uploader", // string or module name `Pleroma.Upload`
|
"key": ":uploader", // string or module name `Pleroma.Upload`
|
||||||
@ -1124,6 +1127,47 @@ Loads json generated from `config/descriptions.exs`.
|
|||||||
}]
|
}]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `GET /api/v2/pleroma/admin/config/descriptions`
|
||||||
|
|
||||||
|
### Get tabs and config descriptions
|
||||||
|
|
||||||
|
Loads json generated from `config/descriptions.exs`.
|
||||||
|
|
||||||
|
- Params: none
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tabs": [{"tab": "activity_pub", "label": "ActivityPub", "path": "activity-pub"}],
|
||||||
|
"descriptions": [
|
||||||
|
{
|
||||||
|
"group": ":pleroma", // string
|
||||||
|
"key": "ModuleName", // string
|
||||||
|
"type": "group", // string or list with possible values,
|
||||||
|
"description": "Upload general settings", // string
|
||||||
|
"tab": "mrf",
|
||||||
|
"label": "MRF",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"key": ":uploader", // string or module name `Pleroma.Upload`
|
||||||
|
"type": "module",
|
||||||
|
"description": "Module which will be used for uploads",
|
||||||
|
"suggestions": ["module1", "module2"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": ":filters",
|
||||||
|
"type": ["list", "module"],
|
||||||
|
"description": "List of filter modules for uploads",
|
||||||
|
"suggestions": [
|
||||||
|
"module1", "module2", "module3"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## `GET /api/v1/pleroma/admin/moderation_log`
|
## `GET /api/v1/pleroma/admin/moderation_log`
|
||||||
|
|
||||||
### Get moderation log
|
### Get moderation log
|
||||||
|
@ -7,7 +7,9 @@ defmodule Pleroma.Docs.JSON do
|
|||||||
@external_resource "config/description.exs"
|
@external_resource "config/description.exs"
|
||||||
@raw_config Pleroma.Config.Loader.read("config/description.exs")
|
@raw_config Pleroma.Config.Loader.read("config/description.exs")
|
||||||
@raw_descriptions @raw_config[:pleroma][:config_description]
|
@raw_descriptions @raw_config[:pleroma][:config_description]
|
||||||
|
@raw_tabs @raw_config[:pleroma][:tabs]
|
||||||
@term __MODULE__.Compiled
|
@term __MODULE__.Compiled
|
||||||
|
@tabs __MODULE__.CompiledTabs
|
||||||
|
|
||||||
@spec compile :: :ok
|
@spec compile :: :ok
|
||||||
def compile do
|
def compile do
|
||||||
@ -16,13 +18,17 @@ defmodule Pleroma.Docs.JSON do
|
|||||||
|> Enum.reduce(@raw_descriptions, fn description, acc -> [description | acc] end)
|
|> Enum.reduce(@raw_descriptions, fn description, acc -> [description | acc] end)
|
||||||
|
|
||||||
:persistent_term.put(@term, Pleroma.Docs.Generator.convert_to_strings(descriptions))
|
:persistent_term.put(@term, Pleroma.Docs.Generator.convert_to_strings(descriptions))
|
||||||
|
:persistent_term.put(@tabs, @raw_tabs)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec compiled_descriptions :: Map.t()
|
@spec compiled_descriptions :: [map()]
|
||||||
def compiled_descriptions do
|
def compiled_descriptions do
|
||||||
:persistent_term.get(@term)
|
:persistent_term.get(@term)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec compiled_tabs() :: [map()]
|
||||||
|
def compiled_tabs, do: :persistent_term.get(@tabs)
|
||||||
|
|
||||||
@spec process(keyword()) :: {:ok, String.t()}
|
@spec process(keyword()) :: {:ok, String.t()}
|
||||||
def process(descriptions) do
|
def process(descriptions) do
|
||||||
with path <- "docs/generated_config.json",
|
with path <- "docs/generated_config.json",
|
||||||
|
@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :policies,
|
key: :policies,
|
||||||
type: [:module, {:list, :module}],
|
type: {:multiple_select, :reduced_labels},
|
||||||
description:
|
description:
|
||||||
"A list of MRF policies enabled. Module names are shortened (removed leading `Pleroma.Web.ActivityPub.MRF.` part), but on adding custom module you need to use full name.",
|
"A list of MRF policies enabled. Module names are shortened (removed leading `Pleroma.Web.ActivityPub.MRF.` part), but on adding custom module you need to use full name.",
|
||||||
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF}
|
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF}
|
||||||
@ -33,7 +33,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||||||
%{
|
%{
|
||||||
key: :transparency_exclusions,
|
key: :transparency_exclusions,
|
||||||
label: "MRF transparency exclusions",
|
label: "MRF transparency exclusions",
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description:
|
description:
|
||||||
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.",
|
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
|
@ -138,7 +138,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :reject,
|
key: :reject,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: """
|
description: """
|
||||||
A list of patterns which result in message being rejected.
|
A list of patterns which result in message being rejected.
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
|
|||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :federated_timeline_removal,
|
key: :federated_timeline_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: """
|
description: """
|
||||||
A list of patterns which result in message being removed from federated timelines (a.k.a unlisted).
|
A list of patterns which result in message being removed from federated timelines (a.k.a unlisted).
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
|
|||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :replace,
|
key: :replace,
|
||||||
type: {:list, :tuple},
|
type: {:keyword, :string},
|
||||||
description: """
|
description: """
|
||||||
**Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.
|
**Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicy do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :actors,
|
key: :actors,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "A list of actors for which any post mentioning them will be dropped",
|
description: "A list of actors for which any post mentioning them will be dropped",
|
||||||
suggestions: ["actor1", "actor2"]
|
suggestions: ["actor1", "actor2"]
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :scrub_policy,
|
key: :scrub_policy,
|
||||||
type: :module,
|
type: :select,
|
||||||
suggestions: [Pleroma.HTML.Scrubber.Default]
|
suggestions: [Pleroma.HTML.Scrubber.Default]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -124,7 +124,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
|
|||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :actions,
|
key: :actions,
|
||||||
type: {:list, :atom},
|
type: :multiple_select,
|
||||||
description:
|
description:
|
||||||
"A list of actions to apply to the post. `:delist` removes the post from public timelines; " <>
|
"A list of actions to apply to the post. `:delist` removes the post from public timelines; " <>
|
||||||
"`:strip_followers` removes followers from the ActivityPub recipient list ensuring they won't be delivered to home timelines; " <>
|
"`:strip_followers` removes followers from the ActivityPub recipient list ensuring they won't be delivered to home timelines; " <>
|
||||||
|
@ -255,63 +255,63 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :media_removal,
|
key: :media_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to strip media attachments from",
|
description: "List of instances to strip media attachments from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :media_nsfw,
|
key: :media_nsfw,
|
||||||
label: "Media NSFW",
|
label: "Media NSFW",
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to tag all media as NSFW (sensitive) from",
|
description: "List of instances to tag all media as NSFW (sensitive) from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :federated_timeline_removal,
|
key: :federated_timeline_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description:
|
description:
|
||||||
"List of instances to remove from the Federated (aka The Whole Known Network) Timeline",
|
"List of instances to remove from the Federated (aka The Whole Known Network) Timeline",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :reject,
|
key: :reject,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to reject activities from (except deletes)",
|
description: "List of instances to reject activities from (except deletes)",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :accept,
|
key: :accept,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to only accept activities from (except deletes)",
|
description: "List of instances to only accept activities from (except deletes)",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :followers_only,
|
key: :followers_only,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "Force posts from the given instances to be visible by followers only",
|
description: "Force posts from the given instances to be visible by followers only",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :report_removal,
|
key: :report_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to reject reports from",
|
description: "List of instances to reject reports from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :avatar_removal,
|
key: :avatar_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to strip avatars from",
|
description: "List of instances to strip avatars from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :banner_removal,
|
key: :banner_removal,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to strip banners from",
|
description: "List of instances to strip banners from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :reject_deletes,
|
key: :reject_deletes,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description: "List of instances to reject deletions from",
|
description: "List of instances to reject deletions from",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicy do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :match_actor,
|
key: :match_actor,
|
||||||
type: {:map, {:list, :string}},
|
type: {:map, :multiple_select},
|
||||||
description: "Matches a series of regular expressions against the actor field",
|
description: "Matches a series of regular expressions against the actor field",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
%{
|
%{
|
||||||
|
@ -51,14 +51,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicy do
|
|||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :accept,
|
key: :accept,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description:
|
description:
|
||||||
"A list of ActivityStreams terms to accept. If empty, all supported messages are accepted.",
|
"A list of ActivityStreams terms to accept. If empty, all supported messages are accepted.",
|
||||||
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
|
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :reject,
|
key: :reject,
|
||||||
type: {:list, :string},
|
type: :multiple_select,
|
||||||
description:
|
description:
|
||||||
"A list of ActivityStreams terms to reject. If empty, no messages are rejected.",
|
"A list of ActivityStreams terms to reject. If empty, no messages are rejected.",
|
||||||
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
|
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
|
||||||
|
@ -15,17 +15,28 @@ defmodule Pleroma.Web.AdminAPI.ConfigController do
|
|||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
%{scopes: ["admin:read"]}
|
%{scopes: ["admin:read"]}
|
||||||
when action in [:show, :descriptions]
|
when action in [:show, :descriptions, :descriptions2]
|
||||||
)
|
)
|
||||||
|
|
||||||
action_fallback(Pleroma.Web.AdminAPI.FallbackController)
|
action_fallback(Pleroma.Web.AdminAPI.FallbackController)
|
||||||
|
|
||||||
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.Admin.ConfigOperation
|
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.Admin.ConfigOperation
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
GET /api/v1/pleroma/admin/config/descriptions
|
||||||
|
"""
|
||||||
def descriptions(conn, _params) do
|
def descriptions(conn, _params) do
|
||||||
descriptions = Enum.filter(Pleroma.Docs.JSON.compiled_descriptions(), &whitelisted_config?/1)
|
json(conn, whitelisted_descriptions())
|
||||||
|
end
|
||||||
|
|
||||||
json(conn, descriptions)
|
@doc """
|
||||||
|
GET /api/v2/pleroma/admin/config/descriptions
|
||||||
|
"""
|
||||||
|
def descriptions2(conn, _params) do
|
||||||
|
json(conn, %{
|
||||||
|
tabs: Pleroma.Docs.JSON.compiled_tabs(),
|
||||||
|
descriptions: whitelisted_descriptions()
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(conn, %{only_db: true}) do
|
def show(conn, %{only_db: true}) do
|
||||||
@ -126,6 +137,10 @@ defmodule Pleroma.Web.AdminAPI.ConfigController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp whitelisted_descriptions do
|
||||||
|
Enum.filter(Pleroma.Docs.JSON.compiled_descriptions(), &whitelisted_config?/1)
|
||||||
|
end
|
||||||
|
|
||||||
defp whitelisted_config?(group, key) do
|
defp whitelisted_config?(group, key) do
|
||||||
if whitelisted_configs = Config.get(:database_config_whitelist) do
|
if whitelisted_configs = Config.get(:database_config_whitelist) do
|
||||||
Enum.any?(whitelisted_configs, fn
|
Enum.any?(whitelisted_configs, fn
|
||||||
|
@ -78,31 +78,68 @@ defmodule Pleroma.Web.ApiSpec.Admin.ConfigOperation do
|
|||||||
parameters: admin_api_params(),
|
parameters: admin_api_params(),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 =>
|
200 =>
|
||||||
|
Operation.response("Config Descriptions", "application/json", descriptions_schema()),
|
||||||
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def descriptions2_operation do
|
||||||
|
%Operation{
|
||||||
|
tags: ["Instance configuration"],
|
||||||
|
summary: "Retrieve config description",
|
||||||
|
operationId: "AdminAPI.ConfigController.descriptions2",
|
||||||
|
security: [%{"oAuth" => ["admin:read"]}],
|
||||||
|
parameters: admin_api_params(),
|
||||||
|
responses: %{
|
||||||
|
200 =>
|
||||||
Operation.response("Config Descriptions", "application/json", %Schema{
|
Operation.response("Config Descriptions", "application/json", %Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
tabs: %Schema{
|
||||||
|
type: :array,
|
||||||
|
items: %Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
tab: %Schema{type: :string},
|
||||||
|
label: %Schema{type: :string},
|
||||||
|
path: %Schema{type: :string}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
descriptions: descriptions_schema()
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp descriptions_schema do
|
||||||
|
%Schema{
|
||||||
|
type: :array,
|
||||||
|
items: %Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
group: %Schema{type: :string},
|
||||||
|
key: %Schema{type: :string},
|
||||||
|
tab: %Schema{type: :string},
|
||||||
|
label: %Schema{type: :string},
|
||||||
|
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
||||||
|
description: %Schema{type: :string},
|
||||||
|
children: %Schema{
|
||||||
type: :array,
|
type: :array,
|
||||||
items: %Schema{
|
items: %Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
group: %Schema{type: :string},
|
|
||||||
key: %Schema{type: :string},
|
key: %Schema{type: :string},
|
||||||
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
||||||
description: %Schema{type: :string},
|
description: %Schema{type: :string},
|
||||||
children: %Schema{
|
suggestions: %Schema{type: :array}
|
||||||
type: :array,
|
|
||||||
items: %Schema{
|
|
||||||
type: :object,
|
|
||||||
properties: %{
|
|
||||||
key: %Schema{type: :string},
|
|
||||||
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
|
||||||
description: %Schema{type: :string},
|
|
||||||
suggestions: %Schema{type: :array}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}
|
||||||
400 => Operation.response("Bad Request", "application/json", ApiError)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -155,6 +155,11 @@ defmodule Pleroma.Web.Router do
|
|||||||
post("/uploader_callback/:upload_path", UploaderController, :callback)
|
post("/uploader_callback/:upload_path", UploaderController, :callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope "/api/v2/pleroma/admin", Pleroma.Web.AdminAPI do
|
||||||
|
pipe_through(:admin_api)
|
||||||
|
get("/config/descriptions", ConfigController, :descriptions2)
|
||||||
|
end
|
||||||
|
|
||||||
scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
|
scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
|
||||||
pipe_through(:admin_api)
|
pipe_through(:admin_api)
|
||||||
|
|
||||||
|
@ -1412,8 +1412,8 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/config/descriptions" do
|
describe "config descriptions" do
|
||||||
test "structure", %{conn: conn} do
|
test "api v1 structure", %{conn: conn} do
|
||||||
conn = get(conn, "/api/pleroma/admin/config/descriptions")
|
conn = get(conn, "/api/pleroma/admin/config/descriptions")
|
||||||
|
|
||||||
assert [child | _others] = json_response_and_validate_schema(conn, 200)
|
assert [child | _others] = json_response_and_validate_schema(conn, 200)
|
||||||
@ -1424,6 +1424,23 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
|||||||
assert child["description"]
|
assert child["description"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "api v2 structure", %{conn: conn} do
|
||||||
|
conn = get(conn, "/api/v2/pleroma/admin/config/descriptions")
|
||||||
|
|
||||||
|
assert %{"tabs" => tabs, "descriptions" => [child | _others]} =
|
||||||
|
json_response_and_validate_schema(conn, 200)
|
||||||
|
|
||||||
|
assert Enum.all?(tabs, fn tab ->
|
||||||
|
Map.has_key?(tab, "tab") and Map.has_key?(tab, "label") and
|
||||||
|
Map.has_key?(tab, "path")
|
||||||
|
end)
|
||||||
|
|
||||||
|
assert child["children"]
|
||||||
|
assert child["key"]
|
||||||
|
assert String.starts_with?(child["group"], ":")
|
||||||
|
assert child["description"]
|
||||||
|
end
|
||||||
|
|
||||||
test "filters by database configuration whitelist", %{conn: conn} do
|
test "filters by database configuration whitelist", %{conn: conn} do
|
||||||
clear_config(:database_config_whitelist, [
|
clear_config(:database_config_whitelist, [
|
||||||
{:pleroma, :instance},
|
{:pleroma, :instance},
|
||||||
|
Loading…
Reference in New Issue
Block a user