From 5b18ffb7ec7a097f2e8d59248737b0339ccbc19b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 11 Dec 2022 13:36:17 +0200 Subject: [PATCH] Fix handling UpdateUserName --- mautrix_telegram/abstract_user.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mautrix_telegram/abstract_user.py b/mautrix_telegram/abstract_user.py index 9fb9b795..67af83f8 100644 --- a/mautrix_telegram/abstract_user.py +++ b/mautrix_telegram/abstract_user.py @@ -504,7 +504,13 @@ class AbstractUser(ABC): # TODO duplication not checked puppet = await pu.Puppet.get_by_tgid(TelegramID(update.user_id)) if isinstance(update, UpdateUserName): - puppet.username = update.username + if len(update.usernames) > 1: + self.log.warning( + "Got update with multiple usernames (%s) for %s, only saving first one", + update.usernames, + update.user_id, + ) + puppet.username = update.usernames[0] if update.usernames else None if await puppet.update_displayname(self, update): await puppet.save() await puppet.update_portals_meta()