mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Upload.base_url: Don't pass nil to Path.join(), don't return nil
This commit is contained in:
parent
3e7f05d0b1
commit
66ac2e9b81
1 changed files with 10 additions and 5 deletions
|
@ -249,14 +249,16 @@ defmodule Pleroma.Upload do
|
||||||
|
|
||||||
defp url_from_spec(_upload, _base_url, {:url, url}), do: url
|
defp url_from_spec(_upload, _base_url, {:url, url}), do: url
|
||||||
|
|
||||||
|
@spec base_url() :: binary
|
||||||
def base_url do
|
def base_url do
|
||||||
uploader = @config_impl.get([Pleroma.Upload, :uploader])
|
uploader = @config_impl.get([Pleroma.Upload, :uploader])
|
||||||
upload_base_url = @config_impl.get([Pleroma.Upload, :base_url])
|
upload_fallback_url = Pleroma.Web.Endpoint.url() <> "/media/"
|
||||||
|
upload_base_url = @config_impl.get([Pleroma.Upload, :base_url]) || upload_fallback_url
|
||||||
public_endpoint = @config_impl.get([uploader, :public_endpoint])
|
public_endpoint = @config_impl.get([uploader, :public_endpoint])
|
||||||
|
|
||||||
case uploader do
|
case uploader do
|
||||||
Pleroma.Uploaders.Local ->
|
Pleroma.Uploaders.Local ->
|
||||||
upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
upload_base_url
|
||||||
|
|
||||||
Pleroma.Uploaders.S3 ->
|
Pleroma.Uploaders.S3 ->
|
||||||
bucket = @config_impl.get([Pleroma.Uploaders.S3, :bucket])
|
bucket = @config_impl.get([Pleroma.Uploaders.S3, :bucket])
|
||||||
|
@ -268,11 +270,14 @@ defmodule Pleroma.Upload do
|
||||||
!is_nil(truncated_namespace) ->
|
!is_nil(truncated_namespace) ->
|
||||||
truncated_namespace
|
truncated_namespace
|
||||||
|
|
||||||
!is_nil(namespace) ->
|
!is_nil(namespace) and !is_nil(bucket) ->
|
||||||
namespace <> ":" <> bucket
|
namespace <> ":" <> bucket
|
||||||
|
|
||||||
true ->
|
!is_nil(bucket) ->
|
||||||
bucket
|
bucket
|
||||||
|
|
||||||
|
true ->
|
||||||
|
""
|
||||||
end
|
end
|
||||||
|
|
||||||
if public_endpoint do
|
if public_endpoint do
|
||||||
|
@ -285,7 +290,7 @@ defmodule Pleroma.Upload do
|
||||||
@config_impl.get([Pleroma.Uploaders.IPFS, :get_gateway_url])
|
@config_impl.get([Pleroma.Uploaders.IPFS, :get_gateway_url])
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
public_endpoint || upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
public_endpoint || upload_base_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue