1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Config.Loader do
6 @paths ["config/config.exs", "config/#{Mix.env()}.exs"]
12 :configurable_from_database,
17 if Code.ensure_loaded?(Config.Reader) do
18 @spec load(Path.t()) :: keyword()
19 def load(path), do: Config.Reader.read!(path)
21 defp do_merge(conf1, conf2), do: Config.Reader.merge(conf1, conf2)
23 # support for Elixir less than 1.9
24 @spec load(Path.t()) :: keyword()
31 defp do_merge(conf1, conf2), do: Mix.Config.merge(conf1, conf2)
34 @spec load_and_merge() :: keyword()
37 if Pleroma.Config.get(:release),
38 do: @paths ++ ["config/releases.exs"],
42 |> Enum.map(&load(&1))
43 |> Enum.reduce([], &do_merge(&2, &1))
47 defp filter(configs) do
50 |> Enum.reduce([], &Keyword.put(&2, &1, filter_group(&1, configs)))
53 @spec filter_group(atom(), keyword()) :: keyword()
54 def filter_group(group, configs) do
55 Enum.reject(configs[group], fn {key, _v} ->
56 key in @reject_keys or (group == :phoenix and key == :serve_endpoints)