Apply 4 suggestion(s) to 2 file(s)

This commit is contained in:
feld 2021-01-10 01:34:54 +00:00
parent e8bf060e6e
commit fa63f1b55b
2 changed files with 12 additions and 27 deletions

View File

@ -237,13 +237,7 @@ def base_url do
case uploader do case uploader do
Pleroma.Uploaders.Local -> Pleroma.Uploaders.Local ->
cond do upload_base_url || Pleroma.Web.base_url() <> "/media/"
!is_nil(upload_base_url) ->
upload_base_url
true ->
Pleroma.Web.base_url() <> "/media/"
end
Pleroma.Uploaders.S3 -> Pleroma.Uploaders.S3 ->
bucket = Config.get([Pleroma.Uploaders.S3, :bucket]) bucket = Config.get([Pleroma.Uploaders.S3, :bucket])
@ -260,22 +254,14 @@ def base_url do
bucket bucket
end end
cond do if public_endpoint do
!is_nil(public_endpoint) ->
Path.join([public_endpoint, bucket_with_namespace]) Path.join([public_endpoint, bucket_with_namespace])
else
true ->
Path.join([upload_base_url, bucket_with_namespace]) Path.join([upload_base_url, bucket_with_namespace])
end end
_ -> _ ->
cond do public_endpoint || upload_base_url
!is_nil(public_endpoint) ->
public_endpoint
true ->
upload_base_url
end
end end
end end
end end

View File

@ -80,12 +80,11 @@ def whitelisted?(url) do
|> Enum.map(&maybe_get_domain_from_url/1) |> Enum.map(&maybe_get_domain_from_url/1)
whitelist_domains = whitelist_domains =
cond do base_url = Upload.base_url()
Web.base_url() == Upload.base_url() -> if Web.base_url() == base_url do
mediaproxy_whitelist_domains mediaproxy_whitelist_domains
else
true -> %{host: base_domain} = URI.parse(base_url)
%{host: base_domain} = URI.parse(Upload.base_url())
[base_domain | mediaproxy_whitelist_domains] [base_domain | mediaproxy_whitelist_domains]
end end