mirror of https://gitlab.com/litecord/litecord.git
users: use to_update instead of manual checks to avatar field
Closes #20. - schemas: change avatar's type to str instead of b64_icon
This commit is contained in:
parent
54120bce0c
commit
eccc82afcc
|
|
@ -173,7 +173,17 @@ async def patch_me():
|
|||
""", j['email'], user_id)
|
||||
user['email'] = j['email']
|
||||
|
||||
if 'avatar' in j and j['avatar']:
|
||||
# only update if values are different
|
||||
# from what the user gave.
|
||||
|
||||
# this will return false if the client
|
||||
# sends j['avatar'] as the user's
|
||||
# original avatar hash, as they're the
|
||||
# same.
|
||||
|
||||
# IconManager.update will take care of validating
|
||||
# the value once put()-ing
|
||||
if to_update(j, user, 'avatar'):
|
||||
new_icon = await app.icons.update(
|
||||
'user', user_id, j['avatar'], size=(128, 128))
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,8 @@ USER_UPDATE = {
|
|||
},
|
||||
|
||||
'avatar': {
|
||||
'type': 'b64_icon', 'required': False,
|
||||
# can be both b64_icon or string (just the hash)
|
||||
'type': 'string', 'required': False,
|
||||
'nullable': True
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue