atom keys with leading :
authorAlex S <alex.strizhakov@gmail.com>
Mon, 15 Jul 2019 08:00:55 +0000 (11:00 +0300)
committerAlex S <alex.strizhakov@gmail.com>
Mon, 15 Jul 2019 08:00:55 +0000 (11:00 +0300)
lib/mix/tasks/pleroma/config.ex
lib/pleroma/config/transfer_task.ex
test/web/admin_api/admin_api_controller_test.exs

index a71bcd447bb648a4e9b9649273811910f4a1459e..4868866d6a6ad10630ad35ede42161cb4f1751d6 100644 (file)
@@ -59,11 +59,11 @@ defmodule Mix.Tasks.Pleroma.Config do
              do: ",",
              else: ":"
 
+        key = String.trim_leading(config.key, ":")
+
         IO.write(
           file,
-          "config :#{config.group}, #{config.key}#{mark} #{
-            inspect(Config.from_binary(config.value))
-          }\r\n"
+          "config :#{config.group}, #{key}#{mark} #{inspect(Config.from_binary(config.value))}\r\n"
         )
 
         if delete? do
index 3c13a055800d51479b53470140f36c0a9cac2aa6..7799b2a7887f5c1d3ce25254c85a070eb002e76e 100644 (file)
@@ -35,7 +35,7 @@ defmodule Pleroma.Config.TransferTask do
         if String.starts_with?(setting.key, "Pleroma.") do
           "Elixir." <> setting.key
         else
-          setting.key
+          String.trim_leading(setting.key, ":")
         end
 
       group = String.to_existing_atom(setting.group)
index 1b71cbff384835fb033489f71d90b41b452c82c8..ee48b752c29e631157baa7d11803e32058d6a3cb 100644 (file)
@@ -1720,7 +1720,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
           configs: [
             %{
               "group" => "pleroma",
-              "key" => "key1",
+              "key" => ":key1",
               "value" => [
                 %{"tuple" => [":key2", "some_val"]},
                 %{
@@ -1750,7 +1750,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                  "configs" => [
                    %{
                      "group" => "pleroma",
-                     "key" => "key1",
+                     "key" => ":key1",
                      "value" => [
                        %{"tuple" => [":key2", "some_val"]},
                        %{
@@ -1782,7 +1782,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
           configs: [
             %{
               "group" => "pleroma",
-              "key" => "key1",
+              "key" => ":key1",
               "value" => %{"key" => "some_val"}
             }
           ]
@@ -1793,7 +1793,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                  "configs" => [
                    %{
                      "group" => "pleroma",
-                     "key" => "key1",
+                     "key" => ":key1",
                      "value" => %{"key" => "some_val"}
                    }
                  ]
@@ -1862,6 +1862,45 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
                ]
              }
     end
+
+    test "queues key as atom", %{conn: conn} do
+      conn =
+        post(conn, "/api/pleroma/admin/config", %{
+          configs: [
+            %{
+              "group" => "pleroma_job_queue",
+              "key" => ":queues",
+              "value" => [
+                %{"tuple" => [":federator_incoming", 50]},
+                %{"tuple" => [":federator_outgoing", 50]},
+                %{"tuple" => [":web_push", 50]},
+                %{"tuple" => [":mailer", 10]},
+                %{"tuple" => [":transmogrifier", 20]},
+                %{"tuple" => [":scheduled_activities", 10]},
+                %{"tuple" => [":background", 5]}
+              ]
+            }
+          ]
+        })
+
+      assert json_response(conn, 200) == %{
+               "configs" => [
+                 %{
+                   "group" => "pleroma_job_queue",
+                   "key" => ":queues",
+                   "value" => [
+                     %{"tuple" => [":federator_incoming", 50]},
+                     %{"tuple" => [":federator_outgoing", 50]},
+                     %{"tuple" => [":web_push", 50]},
+                     %{"tuple" => [":mailer", 10]},
+                     %{"tuple" => [":transmogrifier", 20]},
+                     %{"tuple" => [":scheduled_activities", 10]},
+                     %{"tuple" => [":background", 5]}
+                   ]
+                 }
+               ]
+             }
+    end
   end
 end