example: %{
"content_type" => "application/zip",
"file_name" =>
- "archive-cofe-20200908T195819-1lWrJyJqpsj8-KuHFr7N03lfsYYa5nf2NL-7A9-ddFU.zip",
- "file_size" => 1024,
- "inserted_at" => "2020-09-08T19:58:20",
+ "https://cofe.fe:4000/media/backups/archive-foobar-20200908T164207-Yr7vuT5Wycv-sN3kSN2iJ0k-9pMo60j9qmvRCdDqIew.zip",
+ "file_size" => 4105,
+ "inserted_at" => "2020-09-08T16:42:07.000Z",
"processed" => true
}
}
def render("show.json", %{backup: %Backup{} = backup}) do
%{
content_type: backup.content_type,
- file_name: backup.file_name,
+ url: download_url(backup),
file_size: backup.file_size,
processed: backup.processed,
inserted_at: Utils.to_masto_date(backup.inserted_at)
def render("index.json", %{backups: backups}) do
render_many(backups, __MODULE__, "show.json")
end
+
+ def download_url(%Backup{file_name: file_name}) do
+ Pleroma.Web.Endpoint.url() <> "/media/backups/" <> file_name
+ end
end
use Pleroma.Web.ConnCase
alias Pleroma.Backup
+ alias Pleroma.Web.PleromaAPI.BackupView
setup do
clear_config([Pleroma.Upload, :uploader])
assert [
%{
"content_type" => "application/zip",
- "file_name" => file_name,
+ "url" => url,
"file_size" => 0,
"processed" => false,
"inserted_at" => _
}
] = response
- assert file_name == backup.file_name
+ assert url == BackupView.download_url(backup)
Pleroma.Tests.ObanHelpers.perform_all()
assert [
%{
- "file_name" => ^file_name,
+ "url" => ^url,
"processed" => true
}
] =
assert [
%{
"content_type" => "application/zip",
- "file_name" => file_name,
+ "url" => url,
"file_size" => 0,
"processed" => false,
"inserted_at" => _
assert [
%{
- "file_name" => ^file_name,
+ "url" => ^url,
"processed" => true
}
] =