Merge branch 'attachment-urls' into 'develop'
Fixed attachments URL not honoring media URL See merge request funkwhale/funkwhale!1092
This commit is contained in:
commit
1a752287b7
|
@ -256,14 +256,14 @@ class Attachment(models.Model):
|
||||||
@property
|
@property
|
||||||
def download_url_original(self):
|
def download_url_original(self):
|
||||||
if self.file:
|
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})
|
proxy_url = reverse("api:v1:attachments-proxy", kwargs={"uuid": self.uuid})
|
||||||
return federation_utils.full_url(proxy_url + "?next=original")
|
return federation_utils.full_url(proxy_url + "?next=original")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def download_url_medium_square_crop(self):
|
def download_url_medium_square_crop(self):
|
||||||
if self.file:
|
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})
|
proxy_url = reverse("api:v1:attachments-proxy", kwargs={"uuid": self.uuid})
|
||||||
return federation_utils.full_url(proxy_url + "?next=medium_square_crop")
|
return federation_utils.full_url(proxy_url + "?next=medium_square_crop")
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,17 @@ def join_url(start, end):
|
||||||
return 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={}):
|
def spa_reverse(name, args=[], kwargs={}):
|
||||||
return urls.reverse(name, urlconf=settings.SPA_URLCONF, args=args, kwargs=kwargs)
|
return urls.reverse(name, urlconf=settings.SPA_URLCONF, args=args, kwargs=kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue