Log the source and reason of user displayname changes
This commit is contained in:
@@ -256,19 +256,24 @@ class Puppet(CustomPuppetMixin):
|
|||||||
) -> bool:
|
) -> bool:
|
||||||
if self.disable_updates:
|
if self.disable_updates:
|
||||||
return False
|
return False
|
||||||
allow_source = (source.is_relaybot
|
if source.is_relaybot or source.is_bot:
|
||||||
or self.displayname_source == source.tgid
|
allow_because = "user is bot"
|
||||||
# User is not a contact, so there's no custom name
|
elif self.displayname_source == source.tgid:
|
||||||
or not info.contact
|
allow_because = "user is the primary source"
|
||||||
# No displayname source, so just trust anything
|
elif not info.contact:
|
||||||
or self.displayname_source is None)
|
allow_because = "user is not a contact"
|
||||||
if not allow_source:
|
elif self.displayname_source is None:
|
||||||
|
allow_because = "no primary source set"
|
||||||
|
else:
|
||||||
return False
|
return False
|
||||||
elif isinstance(info, UpdateUserName):
|
|
||||||
|
if isinstance(info, UpdateUserName):
|
||||||
info = await source.client.get_entity(PeerUser(self.tgid))
|
info = await source.client.get_entity(PeerUser(self.tgid))
|
||||||
|
|
||||||
displayname = self.get_displayname(info)
|
displayname = self.get_displayname(info)
|
||||||
if displayname != self.displayname:
|
if displayname != self.displayname:
|
||||||
|
self.log.debug(f"Updating displayname of {self.id} (src: {source.tgid}, allowed "
|
||||||
|
f"because {allow_because}) from {displayname} to {self.displayname}")
|
||||||
self.displayname = displayname
|
self.displayname = displayname
|
||||||
self.displayname_source = source.tgid
|
self.displayname_source = source.tgid
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user