Skip to content
Snippets Groups Projects
Commit ce435511 authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Update fbchat. Should help a bit with #93

parent 39bdac82
No related branches found
No related tags found
No related merge requests found
...@@ -257,6 +257,8 @@ class User(BaseUser): ...@@ -257,6 +257,8 @@ class User(BaseUser):
if self.listen_task: if self.listen_task:
await self.listen_task await self.listen_task
self.listener = None self.listener = None
if self.client:
self.client.sequence_id_callback = None
if self.temp_disconnect_notices or force_notice: if self.temp_disconnect_notices or force_notice:
event_id = await self.send_bridge_notice("Refreshing session...", edit=event_id) event_id = await self.send_bridge_notice("Refreshing session...", edit=event_id)
try: try:
...@@ -377,7 +379,8 @@ class User(BaseUser): ...@@ -377,7 +379,8 @@ class User(BaseUser):
} }
async def sync_threads(self) -> None: async def sync_threads(self) -> None:
if self._prev_thread_sync + 10 > time.monotonic(): if ((self._prev_thread_sync + 10 > time.monotonic()
and self.listener._sequence_id_wait is None)):
self.log.debug("Previous thread sync was less than 10 seconds ago, not re-syncing") self.log.debug("Previous thread sync was less than 10 seconds ago, not re-syncing")
return return
self._prev_thread_sync = time.monotonic() self._prev_thread_sync = time.monotonic()
...@@ -506,6 +509,7 @@ class User(BaseUser): ...@@ -506,6 +509,7 @@ class User(BaseUser):
async def _listen(self) -> None: async def _listen(self) -> None:
if not self.listener: if not self.listener:
self.listener = fbchat.Listener(session=self.session, chat_on=True, foreground=False) self.listener = fbchat.Listener(session=self.session, chat_on=True, foreground=False)
self.client.sequence_id_callback = self.listener.set_sequence_id
self.log.debug("Starting fbchat listener") self.log.debug("Starting fbchat listener")
async for event in self.listener.listen(): async for event in self.listener.listen():
...@@ -561,6 +565,8 @@ class User(BaseUser): ...@@ -561,6 +565,8 @@ class User(BaseUser):
if self.listen_task: if self.listen_task:
self.listen_task.cancel() self.listen_task.cancel()
self.listener = None self.listener = None
if self.client:
self.client.sequence_id_callback = None
self.listen_task = None self.listen_task = None
async def on_logged_in(self, session: fbchat.Session) -> None: async def on_logged_in(self, session: fbchat.Session) -> None:
......
...@@ -5,4 +5,4 @@ ruamel.yaml>=0.15.94,<0.17 ...@@ -5,4 +5,4 @@ ruamel.yaml>=0.15.94,<0.17
commonmark>=0.8,<0.10 commonmark>=0.8,<0.10
python-magic>=0.4,<0.5 python-magic>=0.4,<0.5
mautrix==0.7.0rc2 mautrix==0.7.0rc2
fbchat-asyncio>=0.6.10,<0.7 fbchat-asyncio>=0.6.12,<0.7
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment