Handle update_info errors inside entity instead of in user
This commit is contained in:
@@ -521,6 +521,7 @@ class PortalMetadata(BasePortal, ABC):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.log.debug("Updating info")
|
self.log.debug("Updating info")
|
||||||
|
try:
|
||||||
if not entity:
|
if not entity:
|
||||||
entity = await self.get_entity(user)
|
entity = await self.get_entity(user)
|
||||||
self.log.debug(f"Fetched data: {entity}")
|
self.log.debug(f"Fetched data: {entity}")
|
||||||
@@ -536,6 +537,8 @@ class PortalMetadata(BasePortal, ABC):
|
|||||||
|
|
||||||
if isinstance(entity.photo, ChatPhoto):
|
if isinstance(entity.photo, ChatPhoto):
|
||||||
changed = await self._update_avatar(user, entity.photo) or changed
|
changed = await self._update_avatar(user, entity.photo) or changed
|
||||||
|
except Exception:
|
||||||
|
self.log.exception(f"Failed to update info from source {user.tgid}")
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
self.save()
|
self.save()
|
||||||
|
|||||||
@@ -234,9 +234,12 @@ class Puppet(CustomPuppetMixin):
|
|||||||
self.username = info.username
|
self.username = info.username
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
try:
|
||||||
changed = await self.update_displayname(source, info) or changed
|
changed = await self.update_displayname(source, info) or changed
|
||||||
if isinstance(info.photo, UserProfilePhoto):
|
if isinstance(info.photo, UserProfilePhoto):
|
||||||
changed = await self.update_avatar(source, info.photo) or changed
|
changed = await self.update_avatar(source, info.photo) or changed
|
||||||
|
except Exception:
|
||||||
|
self.log.exception(f"Failed to update info from source {source.tgid}")
|
||||||
|
|
||||||
self.is_bot = info.bot
|
self.is_bot = info.bot
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user