Fix displayname not updating for some users

Users who the bridge only saw via logged in users with the target user
in their contact lists wouldn't get their displayname updated due to an
invalid condition in the update_displayname function.
This commit is contained in:
Tulir Asokan
2019-07-04 22:32:30 +03:00
parent 78dd4e0086
commit 28bed96e40
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -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)
+7 -5
View File
@@ -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))