2020-01-21 14:49:22 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-02 05:08:45 +00:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2020-01-21 14:49:22 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-01-17 08:45:44 +00:00
|
|
|
defmodule Pleroma.Config.Holder do
|
2020-03-11 13:25:53 +00:00
|
|
|
@config Pleroma.Config.Loader.default_config()
|
2020-01-17 08:45:44 +00:00
|
|
|
|
2020-03-11 14:22:50 +00:00
|
|
|
@spec save_default() :: :ok
|
|
|
|
def save_default do
|
2020-03-11 13:25:53 +00:00
|
|
|
default_config =
|
|
|
|
if System.get_env("RELEASE_NAME") do
|
|
|
|
release_config =
|
|
|
|
[:code.root_dir(), "releases", System.get_env("RELEASE_VSN"), "releases.exs"]
|
|
|
|
|> Path.join()
|
|
|
|
|> Pleroma.Config.Loader.read()
|
2020-01-17 08:45:44 +00:00
|
|
|
|
2020-03-11 13:25:53 +00:00
|
|
|
Pleroma.Config.Loader.merge(@config, release_config)
|
|
|
|
else
|
|
|
|
@config
|
|
|
|
end
|
|
|
|
|
2020-03-11 14:22:50 +00:00
|
|
|
Pleroma.Config.put(:default_config, default_config)
|
2020-03-11 13:25:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@spec default_config() :: keyword()
|
2020-03-11 14:22:50 +00:00
|
|
|
def default_config, do: get_default()
|
2020-03-11 13:25:53 +00:00
|
|
|
|
|
|
|
@spec default_config(atom()) :: keyword()
|
2020-03-11 14:22:50 +00:00
|
|
|
def default_config(group), do: Keyword.get(get_default(), group)
|
2020-03-11 13:25:53 +00:00
|
|
|
|
|
|
|
@spec default_config(atom(), atom()) :: keyword()
|
2020-03-11 14:22:50 +00:00
|
|
|
def default_config(group, key), do: get_in(get_default(), [group, key])
|
2020-03-11 13:25:53 +00:00
|
|
|
|
2020-03-11 14:22:50 +00:00
|
|
|
defp get_default, do: Pleroma.Config.get(:default_config)
|
2020-01-17 08:45:44 +00:00
|
|
|
end
|