Check for existing avatar entry to properly update fixes #39
This commit is contained in:
parent
f21e153beb
commit
3d3f7d0681
1 changed files with 6 additions and 2 deletions
|
@ -194,8 +194,12 @@ def set_matrix_avatar(user):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
matrix_api.set_avatar_url(matrix_id, ul['content_uri'])
|
matrix_api.set_avatar_url(matrix_id, ul['content_uri'])
|
||||||
avatar = Avatars(pnut_user=user.username, avatar=user.content.avatar_image.link)
|
avatar = Avatars.query.filter(Avatars.pnut_user == user.username).one_or_none()
|
||||||
db_session.add(avatar)
|
if avatar is None:
|
||||||
|
avatar = Avatars(pnut_user=user.username, avatar=user.content.avatar_image.link)
|
||||||
|
db_session.add(avatar)
|
||||||
|
else:
|
||||||
|
avatar.avatar = user.content.avatar_image.link
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
|
||||||
except MatrixRequestError:
|
except MatrixRequestError:
|
||||||
|
|
Loading…
Reference in a new issue