Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
86ce4afd
Verified
Commit
86ce4afd
authored
Sep 09, 2020
by
minibikini
Browse files
Improve backup urls
parent
2c73bfe1
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex
View file @
86ce4afd
...
...
@@ -69,9 +69,9 @@ defp backup do
example:
%{
"content_type"
=>
"application/zip"
,
"file_name"
=>
"archive-
cofe
-20200908T1
95819-1lWrJyJqpsj8-KuHFr7N03lfsYYa5nf2NL-7A9-ddFU
.zip"
,
"file_size"
=>
10
24
,
"inserted_at"
=>
"2020-09-08T1
9:58:20
"
,
"
https://cofe.fe:4000/media/backups/
archive-
foobar
-20200908T1
64207-Yr7vuT5Wycv-sN3kSN2iJ0k-9pMo60j9qmvRCdDqIew
.zip"
,
"file_size"
=>
4
10
5
,
"inserted_at"
=>
"2020-09-08T1
6:42:07.000Z
"
,
"processed"
=>
true
}
}
...
...
lib/pleroma/web/pleroma_api/views/backup_view.ex
View file @
86ce4afd
...
...
@@ -11,7 +11,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupView do
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
)
...
...
@@ -21,4 +21,8 @@ def render("show.json", %{backup: %Backup{} = backup}) do
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
test/web/pleroma_api/controllers/backup_controller_test.exs
View file @
86ce4afd
...
...
@@ -6,6 +6,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
use
Pleroma
.
Web
.
ConnCase
alias
Pleroma
.
Backup
alias
Pleroma
.
Web
.
PleromaAPI
.
BackupView
setup
do
clear_config
([
Pleroma
.
Upload
,
:uploader
])
...
...
@@ -26,20 +27,20 @@ test "GET /api/pleroma/backups", %{user: user, conn: conn} do
assert
[
%{
"content_type"
=>
"application/zip"
,
"
file_name"
=>
file_name
,
"
url"
=>
url
,
"file_size"
=>
0
,
"processed"
=>
false
,
"inserted_at"
=>
_
}
]
=
response
assert
file_name
==
b
ackup
.
file_name
assert
url
==
B
ackup
View
.
download_url
(
backup
)
Pleroma
.
Tests
.
ObanHelpers
.
perform_all
()
assert
[
%{
"
file_name"
=>
^
file_name
,
"
url"
=>
^
url
,
"processed"
=>
true
}
]
=
...
...
@@ -52,7 +53,7 @@ test "POST /api/pleroma/backups", %{user: _user, conn: conn} do
assert
[
%{
"content_type"
=>
"application/zip"
,
"
file_name"
=>
file_name
,
"
url"
=>
url
,
"file_size"
=>
0
,
"processed"
=>
false
,
"inserted_at"
=>
_
...
...
@@ -66,7 +67,7 @@ test "POST /api/pleroma/backups", %{user: _user, conn: conn} do
assert
[
%{
"
file_name"
=>
^
file_name
,
"
url"
=>
^
url
,
"processed"
=>
true
}
]
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment