From fa63f1b55bad4da8d1c8c51e980109ad5352f71e Mon Sep 17 00:00:00 2001 From: feld Date: Sun, 10 Jan 2021 01:34:54 +0000 Subject: [PATCH] Apply 4 suggestion(s) to 2 file(s) --- lib/pleroma/upload.ex | 26 ++++++-------------------- lib/pleroma/web/media_proxy.ex | 13 ++++++------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index a52b698bf..51ca97f41 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -237,13 +237,7 @@ def base_url do case uploader do Pleroma.Uploaders.Local -> - cond do - !is_nil(upload_base_url) -> - upload_base_url - - true -> - Pleroma.Web.base_url() <> "/media/" - end + upload_base_url || Pleroma.Web.base_url() <> "/media/" Pleroma.Uploaders.S3 -> bucket = Config.get([Pleroma.Uploaders.S3, :bucket]) @@ -260,22 +254,14 @@ def base_url do bucket end - cond do - !is_nil(public_endpoint) -> - Path.join([public_endpoint, bucket_with_namespace]) - - true -> - Path.join([upload_base_url, bucket_with_namespace]) + if public_endpoint do + Path.join([public_endpoint, bucket_with_namespace]) + else + Path.join([upload_base_url, bucket_with_namespace]) end _ -> - cond do - !is_nil(public_endpoint) -> - public_endpoint - - true -> - upload_base_url - end + public_endpoint || upload_base_url end end end diff --git a/lib/pleroma/web/media_proxy.ex b/lib/pleroma/web/media_proxy.ex index 95e3f4231..e4d7f8aa8 100644 --- a/lib/pleroma/web/media_proxy.ex +++ b/lib/pleroma/web/media_proxy.ex @@ -80,13 +80,12 @@ def whitelisted?(url) do |> Enum.map(&maybe_get_domain_from_url/1) whitelist_domains = - cond do - Web.base_url() == Upload.base_url() -> - mediaproxy_whitelist_domains - - true -> - %{host: base_domain} = URI.parse(Upload.base_url()) - [base_domain | mediaproxy_whitelist_domains] + base_url = Upload.base_url() + if Web.base_url() == base_url do + mediaproxy_whitelist_domains + else + %{host: base_domain} = URI.parse(base_url) + [base_domain | mediaproxy_whitelist_domains] end domain in whitelist_domains