From 0acc39ad3552c3e0af05fee9ae3c1c0563be2b9b Mon Sep 17 00:00:00 2001
From: Tulir Asokan <tulir@maunium.net>
Date: Mon, 31 Aug 2020 14:14:59 +0300
Subject: [PATCH] Ignore errors from first call in sync. Fixes #93

---
 mautrix_facebook/user.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mautrix_facebook/user.py b/mautrix_facebook/user.py
index 0634061..b03fedd 100644
--- a/mautrix_facebook/user.py
+++ b/mautrix_facebook/user.py
@@ -311,13 +311,17 @@ class User(BaseUser):
             self.log.exception("Failed to automatically enable custom puppet")
 
         await self._create_community()
-        await self.sync_contacts()
-        await self.sync_threads()
         self.log.debug("Updating own puppet info")
         # TODO this might not be right (if it is, check that we got something sensible?)
-        own_info = await self.client.fetch_thread_info([self.fbid]).__anext__()
+        try:
+            own_info = await self.client.fetch_thread_info([self.fbid]).__anext__()
+        except Exception:
+            self.log.warning("Error fetching own info, retrying...", exc_info=True)
+            own_info = await self.client.fetch_thread_info([self.fbid]).__anext__()
         puppet = pu.Puppet.get_by_fbid(self.fbid, create=True)
         await puppet.update_info(source=self, info=own_info)
+        await self.sync_contacts()
+        await self.sync_threads()
 
     async def _create_community(self) -> None:
         template = config["bridge.community_template"]
-- 
GitLab