Federation of avatars

This commit is contained in:
Eliot Berriot 2020-01-23 16:38:04 +01:00
parent b86971c305
commit f107656586
No known key found for this signature in database
GPG key ID: 6B501DFD73514E14
20 changed files with 214 additions and 126 deletions

View file

@ -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: