forked from AkkomaGang/akkoma
Simplify the logic
This commit is contained in:
parent
af612bd006
commit
65843d92c4
1 changed files with 6 additions and 13 deletions
|
@ -114,24 +114,15 @@ defp build_csp_multimedia_source_list do
|
||||||
add_source(acc, host)
|
add_source(acc, host)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
media_proxy_base_url =
|
media_proxy_base_url = build_csp_param(Config.get([:media_proxy, :base_url]))
|
||||||
if Config.get([:media_proxy, :base_url]),
|
|
||||||
do: build_csp_param(Config.get([:media_proxy, :base_url]))
|
|
||||||
|
|
||||||
upload_base_url =
|
upload_base_url = build_csp_param(Config.get([Pleroma.Upload, :base_url]))
|
||||||
if Config.get([Pleroma.Upload, :base_url]),
|
|
||||||
do: build_csp_param(Config.get([Pleroma.Upload, :base_url]))
|
|
||||||
|
|
||||||
s3_endpoint =
|
s3_endpoint = build_csp_param(Config.get([Pleroma.Uploaders.S3, :public_endpoint]))
|
||||||
if Config.get([Pleroma.Upload, :uploader]) == Pleroma.Uploaders.S3,
|
|
||||||
do: build_csp_param(Config.get([Pleroma.Uploaders.S3, :public_endpoint]))
|
|
||||||
|
|
||||||
captcha_method = Config.get([Pleroma.Captcha, :method])
|
captcha_method = Config.get([Pleroma.Captcha, :method])
|
||||||
|
|
||||||
captcha_endpoint =
|
captcha_endpoint = build_csp_param(Config.get([captcha_method, :endpoint]))
|
||||||
if Config.get([Pleroma.Captcha, :enabled]) &&
|
|
||||||
captcha_method != "Pleroma.Captcha.Native",
|
|
||||||
do: build_csp_param(Config.get([captcha_method, :endpoint]))
|
|
||||||
|
|
||||||
[]
|
[]
|
||||||
|> add_source(media_proxy_base_url)
|
|> add_source(media_proxy_base_url)
|
||||||
|
@ -148,6 +139,8 @@ defp add_csp_param(csp_iodata, nil), do: csp_iodata
|
||||||
|
|
||||||
defp add_csp_param(csp_iodata, param), do: [[param, ?;] | csp_iodata]
|
defp add_csp_param(csp_iodata, param), do: [[param, ?;] | csp_iodata]
|
||||||
|
|
||||||
|
defp build_csp_param(nil), do: nil
|
||||||
|
|
||||||
defp build_csp_param(url) when is_binary(url) do
|
defp build_csp_param(url) when is_binary(url) do
|
||||||
%{host: host, scheme: scheme} = URI.parse(url)
|
%{host: host, scheme: scheme} = URI.parse(url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue