forked from YokaiRick/akkoma
removing migrate_from_db endpoint from admin api
This commit is contained in:
parent
49e80a1537
commit
5db6ac8ee4
5 changed files with 2 additions and 74 deletions
|
@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- **Breaking**: OStatus protocol support
|
||||
- **Breaking**: MDII uploader
|
||||
- **Breaking**: Using third party engines for user recommendation
|
||||
- **Breaking**: AdminAPI: migrate_from_db endpoint.
|
||||
|
||||
### Changed
|
||||
- **Breaking:** Pleroma won't start if it detects unapplied migrations
|
||||
|
|
|
@ -678,21 +678,6 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
{}
|
||||
```
|
||||
|
||||
## `GET /api/pleroma/admin/config/migrate_from_db`
|
||||
|
||||
### Run mix task pleroma.config migrate_from_db
|
||||
|
||||
Copies all settings from database to `config/{env}.exported_from_db.secret.exs` with deletion from the table. Where `{env}` is the environment in which `pleroma` is running.
|
||||
|
||||
- Params: none
|
||||
- Response:
|
||||
- On failure:
|
||||
- 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
## `GET /api/pleroma/admin/config`
|
||||
|
||||
### Get list of merged default settings with saved in database.
|
||||
|
|
|
@ -97,7 +97,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
plug(
|
||||
OAuthScopesPlug,
|
||||
%{scopes: ["read"], admin: true}
|
||||
when action in [:config_show, :migrate_from_db, :list_log]
|
||||
when action in [:config_show, :list_log]
|
||||
)
|
||||
|
||||
plug(
|
||||
|
@ -793,19 +793,6 @@ def config_descriptions(conn, _params) do
|
|||
|> Plug.Conn.send_resp(200, @descriptions_json)
|
||||
end
|
||||
|
||||
def migrate_from_db(conn, _params) do
|
||||
with :ok <- configurable_from_database(conn) do
|
||||
Mix.Tasks.Pleroma.Config.run([
|
||||
"migrate_from_db",
|
||||
"--env",
|
||||
to_string(Pleroma.Config.get(:env)),
|
||||
"-d"
|
||||
])
|
||||
|
||||
json(conn, %{})
|
||||
end
|
||||
end
|
||||
|
||||
def config_show(conn, %{"only_db" => true}) do
|
||||
with :ok <- configurable_from_database(conn) do
|
||||
configs = Pleroma.Repo.all(ConfigDB)
|
||||
|
|
|
@ -196,7 +196,6 @@ defmodule Pleroma.Web.Router do
|
|||
get("/config", AdminAPIController, :config_show)
|
||||
post("/config", AdminAPIController, :config_update)
|
||||
get("/config/descriptions", AdminAPIController, :config_descriptions)
|
||||
get("/config/migrate_from_db", AdminAPIController, :migrate_from_db)
|
||||
get("/restart", AdminAPIController, :restart)
|
||||
|
||||
get("/moderation_log", AdminAPIController, :list_log)
|
||||
|
|
|
@ -2984,50 +2984,6 @@ test "proxy tuple ip", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "config mix tasks run" do
|
||||
setup do
|
||||
Mix.shell(Mix.Shell.Quiet)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(Mix.Shell.IO)
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
clear_config([:feed, :post_title]) do
|
||||
Pleroma.Config.put([:feed, :post_title], %{max_length: 100, omission: "…"})
|
||||
end
|
||||
|
||||
test "transfer settings to DB and to file", %{conn: conn} do
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||
assert Repo.aggregate(Pleroma.ConfigDB, :count, :id) > 0
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
assert json_response(conn, 200) == %{}
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
end
|
||||
|
||||
test "returns error if configuration from database is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get(:configurable_from_database)
|
||||
on_exit(fn -> Pleroma.Config.put(:configurable_from_database, initial) end)
|
||||
Pleroma.Config.put(:configurable_from_database, false)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
assert json_response(conn, 400) ==
|
||||
"To use this endpoint you need to enable configuration from database."
|
||||
|
||||
assert Repo.all(Pleroma.ConfigDB) == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/restart" do
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
|
|
Loading…
Reference in a new issue