plugin identity: added "filename" metadata for avatar
This commit is contained in:
parent
81a11ba6d6
commit
92aa584e4c
1 changed files with 9 additions and 1 deletions
|
|
@ -145,6 +145,9 @@ class Identity:
|
|||
cache_uid = value['cache_uid']
|
||||
if not cache_uid:
|
||||
raise ValueError
|
||||
filename = value['filename']
|
||||
if not filename:
|
||||
raise ValueError
|
||||
except (ValueError, KeyError):
|
||||
log.warning(
|
||||
f"invalid data for {entity} avatar, it will be deleted: "
|
||||
|
|
@ -464,6 +467,7 @@ class Identity:
|
|||
raise ValueError(f"There is no file at {file_path} to use as avatar")
|
||||
avatar_data = {
|
||||
'path': file_path,
|
||||
'filename': file_path.name,
|
||||
'media_type': image.guess_type(file_path),
|
||||
}
|
||||
media_type = avatar_data['media_type']
|
||||
|
|
@ -499,6 +503,7 @@ class Identity:
|
|||
|
||||
return {
|
||||
"path": path,
|
||||
"filename": path.name,
|
||||
"media_type": media_type,
|
||||
"cache_uid": cache_uid,
|
||||
}
|
||||
|
|
@ -509,7 +514,7 @@ class Identity:
|
|||
async def avatarUpdateDataFilter(self, client, entity, data):
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError(f"Invalid data type ({type(data)}), a dict is expected")
|
||||
mandatory_keys = {'path', 'cache_uid'}
|
||||
mandatory_keys = {'path', 'filename', 'cache_uid'}
|
||||
if not data.keys() >= mandatory_keys:
|
||||
raise ValueError(f"missing avatar data keys: {mandatory_keys - data.keys()}")
|
||||
return data
|
||||
|
|
|
|||
Loading…
Reference in a new issue