mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 07:59:17 +02:00
Federation of avatars
This commit is contained in:
parent
b86971c305
commit
f107656586
20 changed files with 214 additions and 126 deletions
|
@ -327,8 +327,11 @@ def attach_file(obj, field, file_data, fetch=False):
|
|||
extensions = {"image/jpeg": "jpg", "image/png": "png", "image/gif": "gif"}
|
||||
extension = extensions.get(file_data["mimetype"], "jpg")
|
||||
attachment = models.Attachment(mimetype=file_data["mimetype"])
|
||||
|
||||
filename = "cover-{}.{}".format(obj.uuid, extension)
|
||||
name_fields = ["uuid", "full_username", "pk"]
|
||||
name = [getattr(obj, field) for field in name_fields if getattr(obj, field, None)][
|
||||
0
|
||||
]
|
||||
filename = "{}-{}.{}".format(field, name, extension)
|
||||
if "url" in file_data:
|
||||
attachment.url = file_data["url"]
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue