Commit 3d3f7d06 authored by Morgan McMillian's avatar Morgan McMillian

Check for existing avatar entry to properly update fixes #39

parent f21e153b
......@@ -194,8 +194,12 @@ def set_matrix_avatar(user):
try:
matrix_api.set_avatar_url(matrix_id, ul['content_uri'])
avatar = Avatars(pnut_user=user.username, avatar=user.content.avatar_image.link)
db_session.add(avatar)
avatar = Avatars.query.filter(Avatars.pnut_user == user.username).one_or_none()
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()
except MatrixRequestError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment