GOOGLE
[akkoma] / lib / pleroma / config / holder.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Config.Holder do
6 @config Pleroma.Config.Loader.default_config()
7
8 @spec save_default() :: :ok
9 def save_default do
10 default_config =
11 if System.get_env("RELEASE_NAME") do
12 Pleroma.Config.Loader.merge(@config, release_defaults())
13 else
14 @config
15 end
16
17 Pleroma.Config.put(:default_config, default_config)
18 end
19
20 @spec default_config() :: keyword()
21 def default_config, do: get_default()
22
23 @spec default_config(atom()) :: keyword()
24 def default_config(group), do: Keyword.get(get_default(), group)
25
26 @spec default_config(atom(), atom()) :: keyword()
27 def default_config(group, key), do: get_in(get_default(), [group, key])
28
29 defp get_default, do: Pleroma.Config.get(:default_config)
30
31 @spec release_defaults() :: keyword()
32 def release_defaults do
33 [
34 pleroma: [
35 {:instance, [static_dir: "/var/lib/akkoma/static"]},
36 {Pleroma.Uploaders.Local, [uploads: "/var/lib/akkoma/uploads"]},
37 {:modules, [runtime_dir: "/var/lib/akkoma/modules"]},
38 {:release, true}
39 ]
40 ]
41 end
42 end