Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Work around weird sequence IDs in thread sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Mar 1, 2023
1 parent 21a2e69 commit 1e760d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions maufbapi/types/graphql/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ class Thread(SerializableAttrs):
can_viewer_reply: bool
can_participants_claim_admin: bool

sync_sequence_id: Optional[str] = None

@property
def updated_timestamp(self) -> int:
return int(self.updated_time_precise)
Expand Down
11 changes: 11 additions & 0 deletions mautrix_facebook/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,17 @@ async def _sync_recent_threads(self, increment_total_backfilled_portals: bool =
# We need to get the sequence ID before we start the listener task.
resp = await self.client.fetch_thread_list()
self.seq_id = int(resp.sync_sequence_id)
thread_seq_ids = list(
{int(thread.sync_sequence_id) for thread in resp.nodes if thread.sync_sequence_id}
)
if len(thread_seq_ids) > 1 or (
len(thread_seq_ids) == 1 and thread_seq_ids[0] != self.seq_id
):
self.seq_id = max(*thread_seq_ids, self.seq_id)
self.log.warning(
f"Got more than one sequence ID in thread list: primary={resp.sync_sequence_id}, "
f"threads={thread_seq_ids}. Using highest value ({self.seq_id})"
)
if self.mqtt:
self.mqtt.seq_id = self.seq_id
self.log.debug(f"Got new seq_id {self.seq_id}")
Expand Down

0 comments on commit 1e760d3

Please sign in to comment.