Runtime configuration
Related to #85 Everything should now be configured at runtime, with the exception of the `Pleroma.HTML` scrubbers (the scrubbers used can be changed at runtime, but their configuration is compile-time) because it's building a module with a macro.
This commit is contained in:
parent
25512aa29c
commit
5bb88fd174
18 changed files with 190 additions and 163 deletions
|
|
@ -1,11 +1,9 @@
|
|||
defmodule Pleroma.Uploaders.Swift.Keystone do
|
||||
use HTTPoison.Base
|
||||
|
||||
@settings Application.get_env(:pleroma, Pleroma.Uploaders.Swift)
|
||||
|
||||
def process_url(url) do
|
||||
Enum.join(
|
||||
[Keyword.fetch!(@settings, :auth_url), url],
|
||||
[Pleroma.Config.get!([Pleroma.Uploaders.Swift, :auth_url]), url],
|
||||
"/"
|
||||
)
|
||||
end
|
||||
|
|
@ -16,9 +14,10 @@ defmodule Pleroma.Uploaders.Swift.Keystone do
|
|||
end
|
||||
|
||||
def get_token() do
|
||||
username = Keyword.fetch!(@settings, :username)
|
||||
password = Keyword.fetch!(@settings, :password)
|
||||
tenant_id = Keyword.fetch!(@settings, :tenant_id)
|
||||
settings = Pleroma.Config.get(Pleroma.Uploaders.Swift)
|
||||
username = Keyword.fetch!(settings, :username)
|
||||
password = Keyword.fetch!(settings, :password)
|
||||
tenant_id = Keyword.fetch!(settings, :tenant_id)
|
||||
|
||||
case post(
|
||||
"/tokens",
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
defmodule Pleroma.Uploaders.Swift.Client do
|
||||
use HTTPoison.Base
|
||||
|
||||
@settings Application.get_env(:pleroma, Pleroma.Uploaders.Swift)
|
||||
|
||||
def process_url(url) do
|
||||
Enum.join(
|
||||
[Keyword.fetch!(@settings, :storage_url), url],
|
||||
[Pleroma.Config.get!([Pleroma.Uploaders.Swift, :storage_url]), url],
|
||||
"/"
|
||||
)
|
||||
end
|
||||
|
||||
def upload_file(filename, body, content_type) do
|
||||
object_url = Keyword.fetch!(@settings, :object_url)
|
||||
object_url = Pleroma.Config.get!([Pleroma.Uploaders.Swift, :object_url])
|
||||
token = Pleroma.Uploaders.Swift.Keystone.get_token()
|
||||
|
||||
case put("#{filename}", body, "X-Auth-Token": token, "Content-Type": content_type) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue