removing confusing error
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Wed, 5 Feb 2020 14:06:01 +0000 (17:06 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 6 Feb 2020 09:50:36 +0000 (12:50 +0300)
docs/API/admin_api.md
lib/pleroma/web/admin_api/admin_api_controller.ex
test/web/admin_api/admin_api_controller_test.exs

index e445583cbf3aa12a09dedd3293d8c6c537c0e2d2..fb6dfcb087d48383bcd8c90b80a0c8257a653bd8 100644 (file)
@@ -689,7 +689,6 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
 - Response:
   - On failure:
     - 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
-    - 400 Bad Request `"To use configuration from database migrate your settings to database."`
 
 ```json
 {
index 293f1befc39d7c85cb9ff77386fff6919b18cf8d..c95cd182dddbc79a1f199477e21b506799c26cf3 100644 (file)
@@ -797,16 +797,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
     with :ok <- configurable_from_database(conn) do
       configs = Pleroma.Repo.all(ConfigDB)
 
-      if configs == [] do
-        errors(
-          conn,
-          {:error, "To use configuration from database migrate your settings to database."}
-        )
-      else
-        conn
-        |> put_view(ConfigView)
-        |> render("index.json", %{configs: configs})
-      end
+      conn
+      |> put_view(ConfigView)
+      |> render("index.json", %{configs: configs})
     end
   end
 
@@ -814,45 +807,38 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
     with :ok <- configurable_from_database(conn) do
       configs = ConfigDB.get_all_as_keyword()
 
-      if configs == [] do
-        errors(
-          conn,
-          {:error, "To use configuration from database migrate your settings to database."}
-        )
-      else
-        merged =
-          Pleroma.Config.Holder.config()
-          |> ConfigDB.merge(configs)
-          |> Enum.map(fn {group, values} ->
-            Enum.map(values, fn {key, value} ->
-              db =
-                if configs[group][key] do
-                  ConfigDB.get_db_keys(configs[group][key], key)
-                end
-
-              db_value = configs[group][key]
-
-              merged_value =
-                if !is_nil(db_value) and Keyword.keyword?(db_value) and
-                     ConfigDB.sub_key_full_update?(group, key, Keyword.keys(db_value)) do
-                  ConfigDB.merge_group(group, key, value, db_value)
-                else
-                  value
-                end
-
-              setting = %{
-                group: ConfigDB.convert(group),
-                key: ConfigDB.convert(key),
-                value: ConfigDB.convert(merged_value)
-              }
-
-              if db, do: Map.put(setting, :db, db), else: setting
-            end)
+      merged =
+        Pleroma.Config.Holder.config()
+        |> ConfigDB.merge(configs)
+        |> Enum.map(fn {group, values} ->
+          Enum.map(values, fn {key, value} ->
+            db =
+              if configs[group][key] do
+                ConfigDB.get_db_keys(configs[group][key], key)
+              end
+
+            db_value = configs[group][key]
+
+            merged_value =
+              if !is_nil(db_value) and Keyword.keyword?(db_value) and
+                   ConfigDB.sub_key_full_update?(group, key, Keyword.keys(db_value)) do
+                ConfigDB.merge_group(group, key, value, db_value)
+              else
+                value
+              end
+
+            setting = %{
+              group: ConfigDB.convert(group),
+              key: ConfigDB.convert(key),
+              value: ConfigDB.convert(merged_value)
+            }
+
+            if db, do: Map.put(setting, :db, db), else: setting
           end)
-          |> List.flatten()
+        end)
+        |> List.flatten()
 
-        json(conn, %{configs: merged})
-      end
+      json(conn, %{configs: merged})
     end
   end
 
index 87f1366a468abd0eba472bbb3b7f966333548b74..5fbdf96f6072af4238472ea128fb98e88a6d5bc3 100644 (file)
@@ -1899,13 +1899,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                "To use this endpoint you need to enable configuration from database."
     end
 
-    test "without any settings in db", %{conn: conn} do
-      conn = get(conn, "/api/pleroma/admin/config")
-
-      assert json_response(conn, 400) ==
-               "To use configuration from database migrate your settings to database."
-    end
-
     test "with settings only in db", %{conn: conn} do
       config1 = insert(:config)
       config2 = insert(:config)