Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jovuit
funkwhale
Commits
96086df1
Unverified
Commit
96086df1
authored
Apr 15, 2020
by
Agate
💬
Browse files
Fixed attachments URL not honoring media URL
parent
975e281d
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/common/models.py
View file @
96086df1
...
...
@@ -256,14 +256,14 @@ class Attachment(models.Model):
@
property
def
download_url_original
(
self
):
if
self
.
file
:
return
federation_
utils
.
full
_url
(
self
.
file
.
url
)
return
utils
.
media
_url
(
self
.
file
.
url
)
proxy_url
=
reverse
(
"api:v1:attachments-proxy"
,
kwargs
=
{
"uuid"
:
self
.
uuid
})
return
federation_utils
.
full_url
(
proxy_url
+
"?next=original"
)
@
property
def
download_url_medium_square_crop
(
self
):
if
self
.
file
:
return
federation_
utils
.
full
_url
(
self
.
file
.
crop
[
"200x200"
].
url
)
return
utils
.
media
_url
(
self
.
file
.
crop
[
"200x200"
].
url
)
proxy_url
=
reverse
(
"api:v1:attachments-proxy"
,
kwargs
=
{
"uuid"
:
self
.
uuid
})
return
federation_utils
.
full_url
(
proxy_url
+
"?next=medium_square_crop"
)
...
...
api/funkwhale_api/common/utils.py
View file @
96086df1
...
...
@@ -134,6 +134,17 @@ def join_url(start, end):
return
start
+
end
def
media_url
(
path
):
if
settings
.
MEDIA_URL
.
startswith
(
"http://"
)
or
settings
.
MEDIA_URL
.
startswith
(
"https://"
):
return
join_url
(
settings
.
MEDIA_URL
,
path
)
from
funkwhale_api.federation
import
utils
as
federation_utils
return
federation_utils
.
full_url
(
path
)
def
spa_reverse
(
name
,
args
=
[],
kwargs
=
{}):
return
urls
.
reverse
(
name
,
urlconf
=
settings
.
SPA_URLCONF
,
args
=
args
,
kwargs
=
kwargs
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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