mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-21 17:06:36 +03:00
Fix PERSISTENT_TIMESTAMP_EMPTY for new entries with pts 1, count 0
Because Telegram can't actually use 0 for the pts, it uses 1, even if the count is 0. This forces the next update to use 2, or else it could not be fetched when using an offset of 1 (despite the count being 0 on the first update, which should not have bumped the second update to use 2). This caused Telethon to create an initial state of 0 for the new entry (and also "incorrectly" detected following updates as gaps, which would quickly trigger the call to get difference with a bad pts). Now Telethon is aware of this special-case and will not initialize state as 0, even if that's not the "correct" thing to do.
This commit is contained in:
parent
061a84bef2
commit
6d2a5dada5
|
@ -572,8 +572,14 @@ class MessageBox:
|
|||
if pts.entry in self.map:
|
||||
self.map[pts.entry].pts = pts.pts
|
||||
else:
|
||||
# When a chat is migrated to a megagroup, the first update can be a `ReadChannelInbox`
|
||||
# with `pts = 1, pts_count = 0` followed by a `NewChannelMessage` with `pts = 2, pts_count=1`.
|
||||
# Note how the `pts` for the message is 2 and not 1 unlike the case described before!
|
||||
# This is likely because the `pts` cannot be 0 (or it would fail with PERSISTENT_TIMESTAMP_EMPTY),
|
||||
# which forces the first update to be 1. But if we got difference with 1 and the second update
|
||||
# also used 1, we would miss it, so Telegram probably uses 2 to work around that.
|
||||
self.map[pts.entry] = State(
|
||||
pts=pts.pts - (0 if pts.pts_count else 1),
|
||||
pts=(pts.pts - (0 if pts.pts_count else 1)) or 1,
|
||||
deadline=next_updates_deadline()
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user