summaryrefslogtreecommitdiff
path: root/lib/pleroma/config.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/config.ex')
-rw-r--r--lib/pleroma/config.ex21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/pleroma/config.ex b/lib/pleroma/config.ex
index 54e332595..2709f39bf 100644
--- a/lib/pleroma/config.ex
+++ b/lib/pleroma/config.ex
@@ -103,4 +103,25 @@ defmodule Pleroma.Config do
def feature_enabled?(feature_name) do
get([:features, feature_name]) not in [nil, false, :disabled, :auto]
end
+
+ @doc """
+ Get the URI directly from application config, bypassing the Endpoint module.
+ """
+ def uri do
+ # `Pleroma.Web.Endpoint` is only being used as a key here (for equality check),
+ # so it's okay to use `Module.concat/1` to have the compiler ignore it.
+ endpoint_key = Module.concat(["Pleroma.Web.Endpoint"])
+
+ url =
+ get([endpoint_key, :url])
+ |> Map.new()
+
+ struct(URI, url)
+ end
+
+ @doc """
+ Similar to `Pleroma.Web.Endpoint.url/0`.
+ May be used where needed to avoid a compile-time dep on Endpoint.
+ """
+ def url, do: URI.to_string(uri())
end