mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-18 07:48:19 +00:00
Fix URL generated for backup files, try to create a source of truth we can reuse throughout the codebase
This commit is contained in:
parent
5822338f3a
commit
ad79983614
|
@ -31,6 +31,7 @@ defmodule Pleroma.Upload do
|
|||
|
||||
"""
|
||||
alias Ecto.UUID
|
||||
alias Pleroma.Config
|
||||
require Logger
|
||||
|
||||
@type source ::
|
||||
|
@ -228,4 +229,29 @@ defmodule Pleroma.Upload do
|
|||
end
|
||||
|
||||
defp url_from_spec(_upload, _base_url, {:url, url}), do: url
|
||||
|
||||
def base_url do
|
||||
uploader = Config.get([Pleroma.Upload, :uploader])
|
||||
upload_base_url = Config.get([Pleroma.Upload, :base_url])
|
||||
|
||||
case uploader do
|
||||
Pleroma.Uploaders.Local ->
|
||||
cond do
|
||||
!is_nil(upload_base_url) ->
|
||||
upload_base_url
|
||||
|
||||
true ->
|
||||
Pleroma.Web.base_url() <> "/media/"
|
||||
end
|
||||
|
||||
_ ->
|
||||
cond do
|
||||
!is_nil(Config.get([uploader, :public_endpoint])) ->
|
||||
Config.get([uploader, :public_endpoint])
|
||||
|
||||
true ->
|
||||
upload_base_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,6 @@ defmodule Pleroma.Web.PleromaAPI.BackupView do
|
|||
end
|
||||
|
||||
def download_url(%Backup{file_name: file_name}) do
|
||||
Pleroma.Web.Endpoint.url() <> "/media/backups/" <> file_name
|
||||
Pleroma.Upload.base_url() <> "/backups/" <> file_name
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue