Merge branch 'admin-changes' into 'develop'
Admin changes See merge request pleroma/pleroma!1489
This commit is contained in:
commit
373a7c6739
6 changed files with 74 additions and 1 deletions
|
@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Admin API: Return avatar and display name when querying users
|
- Admin API: Return avatar and display name when querying users
|
||||||
- Admin API: Allow querying user by ID
|
- Admin API: Allow querying user by ID
|
||||||
- Admin API: Added support for `tuples`.
|
- Admin API: Added support for `tuples`.
|
||||||
|
- Admin API: Added endpoints to run mix tasks pleroma.config migrate_to_db & pleroma.config migrate_from_db
|
||||||
- Added synchronization of following/followers counters for external users
|
- Added synchronization of following/followers counters for external users
|
||||||
- Configuration: `enabled` option for `Pleroma.Emails.Mailer`, defaulting to `false`.
|
- Configuration: `enabled` option for `Pleroma.Emails.Mailer`, defaulting to `false`.
|
||||||
- Configuration: Pleroma.Plugs.RateLimiter `bucket_name`, `params` options.
|
- Configuration: Pleroma.Plugs.RateLimiter `bucket_name`, `params` options.
|
||||||
|
|
|
@ -575,6 +575,29 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
- 404 Not Found `"Not found"`
|
- 404 Not Found `"Not found"`
|
||||||
- On success: 200 OK `{}`
|
- On success: 200 OK `{}`
|
||||||
|
|
||||||
|
|
||||||
|
## `/api/pleroma/admin/config/migrate_to_db`
|
||||||
|
### Run mix task pleroma.config migrate_to_db
|
||||||
|
Copy settings on key `:pleroma` to DB.
|
||||||
|
- Method `GET`
|
||||||
|
- Params: none
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `/api/pleroma/admin/config/migrate_from_db`
|
||||||
|
### Run mix task pleroma.config migrate_from_db
|
||||||
|
Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with deletion from DB.
|
||||||
|
- Method `GET`
|
||||||
|
- Params: none
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
## `/api/pleroma/admin/config`
|
## `/api/pleroma/admin/config`
|
||||||
### List config settings
|
### List config settings
|
||||||
List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
|
List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`.
|
||||||
|
|
|
@ -15,7 +15,7 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
|
|
||||||
mix pleroma.config migrate_to_db
|
mix pleroma.config migrate_to_db
|
||||||
|
|
||||||
## Transfers config from DB to file.
|
## Transfers config from DB to file `config/env.exported_from_db.secret.exs`
|
||||||
|
|
||||||
mix pleroma.config migrate_from_db ENV
|
mix pleroma.config migrate_from_db ENV
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -379,6 +379,16 @@ def status_delete(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def migrate_to_db(conn, _params) do
|
||||||
|
Mix.Tasks.Pleroma.Config.run(["migrate_to_db"])
|
||||||
|
json(conn, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
def migrate_from_db(conn, _params) do
|
||||||
|
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", Pleroma.Config.get(:env), "true"])
|
||||||
|
json(conn, %{})
|
||||||
|
end
|
||||||
|
|
||||||
def config_show(conn, _params) do
|
def config_show(conn, _params) do
|
||||||
configs = Pleroma.Repo.all(Config)
|
configs = Pleroma.Repo.all(Config)
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,8 @@ defmodule Pleroma.Web.Router do
|
||||||
|
|
||||||
get("/config", AdminAPIController, :config_show)
|
get("/config", AdminAPIController, :config_show)
|
||||||
post("/config", AdminAPIController, :config_update)
|
post("/config", AdminAPIController, :config_update)
|
||||||
|
get("/config/migrate_to_db", AdminAPIController, :migrate_to_db)
|
||||||
|
get("/config/migrate_from_db", AdminAPIController, :migrate_from_db)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", Pleroma.Web.TwitterAPI do
|
scope "/", Pleroma.Web.TwitterAPI do
|
||||||
|
|
|
@ -1916,6 +1916,43 @@ test "queues key as atom", %{conn: conn} do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "config mix tasks run" do
|
||||||
|
setup %{conn: conn} do
|
||||||
|
admin = insert(:user, info: %{is_admin: true})
|
||||||
|
|
||||||
|
temp_file = "config/test.exported_from_db.secret.exs"
|
||||||
|
|
||||||
|
on_exit(fn ->
|
||||||
|
:ok = File.rm(temp_file)
|
||||||
|
end)
|
||||||
|
|
||||||
|
dynamic = Pleroma.Config.get([:instance, :dynamic_configuration])
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||||
|
|
||||||
|
on_exit(fn ->
|
||||||
|
Pleroma.Config.put([:instance, :dynamic_configuration], dynamic)
|
||||||
|
end)
|
||||||
|
|
||||||
|
%{conn: assign(conn, :user, admin), admin: admin}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "transfer settings to DB and to file", %{conn: conn, admin: admin} do
|
||||||
|
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||||
|
conn = get(conn, "/api/pleroma/admin/config/migrate_to_db")
|
||||||
|
assert json_response(conn, 200) == %{}
|
||||||
|
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) > 0
|
||||||
|
|
||||||
|
conn =
|
||||||
|
build_conn()
|
||||||
|
|> assign(:user, admin)
|
||||||
|
|> get("/api/pleroma/admin/config/migrate_from_db")
|
||||||
|
|
||||||
|
assert json_response(conn, 200) == %{}
|
||||||
|
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/users/:nickname/statuses" do
|
describe "GET /api/pleroma/admin/users/:nickname/statuses" do
|
||||||
setup do
|
setup do
|
||||||
admin = insert(:user, info: %{is_admin: true})
|
admin = insert(:user, info: %{is_admin: true})
|
||||||
|
|
Loading…
Reference in a new issue