diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 5558867a..60e9aff9 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -1774,7 +1774,7 @@ class Portal: return if sender and not sender.displayname: - self.log.debug(f"Telegram user {sender.tgid} sent a message, but doesn't have a" + self.log.debug(f"Telegram user {sender.tgid} sent a message, but doesn't have a " "displayname, updating info...") entity = await source.client.get_entity(PeerUser(sender.tgid)) await sender.update_info(source, entity) diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index b715ada0..9cdac8fe 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -363,11 +363,13 @@ class Puppet: ) -> bool: if self.disable_updates: return False - is_main_source = (source.is_relaybot or (self.displayname_source is not None - and self.displayname_source == source.tgid)) - # No phone -> not in contact list -> can't set custom name -> name is trustworthy - is_trustworthy_source = isinstance(info, User) and info.phone is None - if not is_main_source and not is_trustworthy_source: + allow_source = (source.is_relaybot + or self.displayname_source == source.tgid + # No displayname source, so just trust anything + or self.displayname_source is None + # No phone -> not in contact list -> can't set custom name + or (isinstance(info, User) and info.phone is None)) + if not allow_source: return False elif isinstance(info, UpdateUserName): info = await source.client.get_entity(PeerUser(self.tgid))