atom keys with leading :

This commit is contained in:
Alex S 2019-07-15 11:00:55 +03:00
parent 46ef8f0216
commit c66044b923
3 changed files with 47 additions and 8 deletions

View file

@ -59,11 +59,11 @@ defmodule Mix.Tasks.Pleroma.Config do
do: ",", do: ",",
else: ":" else: ":"
key = String.trim_leading(config.key, ":")
IO.write( IO.write(
file, file,
"config :#{config.group}, #{config.key}#{mark} #{ "config :#{config.group}, #{key}#{mark} #{inspect(Config.from_binary(config.value))}\r\n"
inspect(Config.from_binary(config.value))
}\r\n"
) )
if delete? do if delete? do

View file

@ -35,7 +35,7 @@ defmodule Pleroma.Config.TransferTask do
if String.starts_with?(setting.key, "Pleroma.") do if String.starts_with?(setting.key, "Pleroma.") do
"Elixir." <> setting.key "Elixir." <> setting.key
else else
setting.key String.trim_leading(setting.key, ":")
end end
group = String.to_existing_atom(setting.group) group = String.to_existing_atom(setting.group)

View file

@ -1720,7 +1720,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
configs: [ configs: [
%{ %{
"group" => "pleroma", "group" => "pleroma",
"key" => "key1", "key" => ":key1",
"value" => [ "value" => [
%{"tuple" => [":key2", "some_val"]}, %{"tuple" => [":key2", "some_val"]},
%{ %{
@ -1750,7 +1750,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
"configs" => [ "configs" => [
%{ %{
"group" => "pleroma", "group" => "pleroma",
"key" => "key1", "key" => ":key1",
"value" => [ "value" => [
%{"tuple" => [":key2", "some_val"]}, %{"tuple" => [":key2", "some_val"]},
%{ %{
@ -1782,7 +1782,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
configs: [ configs: [
%{ %{
"group" => "pleroma", "group" => "pleroma",
"key" => "key1", "key" => ":key1",
"value" => %{"key" => "some_val"} "value" => %{"key" => "some_val"}
} }
] ]
@ -1793,7 +1793,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
"configs" => [ "configs" => [
%{ %{
"group" => "pleroma", "group" => "pleroma",
"key" => "key1", "key" => ":key1",
"value" => %{"key" => "some_val"} "value" => %{"key" => "some_val"}
} }
] ]
@ -1862,6 +1862,45 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
] ]
} }
end 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
end end