Handle update_info errors inside entity instead of in user

This commit is contained in:
Tulir Asokan
2019-08-13 14:44:24 +03:00
parent 1ac1bf5b60
commit 2a327cc29e
2 changed files with 20 additions and 14 deletions
+3
View File
@@ -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()
+3
View File
@@ -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