1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Config.Loader do
10 :configurable_from_database,
20 if Code.ensure_loaded?(Config.Reader) do
23 def read(path), do: @reader.read!(path)
25 # support for Elixir less than 1.9
34 @spec read(Path.t()) :: keyword()
36 @spec merge(keyword(), keyword()) :: keyword()
37 def merge(c1, c2), do: @reader.merge(c1, c2)
39 @spec default_config() :: keyword()
46 defp filter(configs) do
49 |> Enum.reduce([], &Keyword.put(&2, &1, filter_group(&1, configs)))
52 @spec filter_group(atom(), keyword()) :: keyword()
53 def filter_group(group, configs) do
54 Enum.reject(configs[group], fn {key, _v} ->
55 key in @reject_keys or group in @reject_groups or
56 (group == :phoenix and key == :serve_endpoints)