Skip to content

Commit 742dce5

Browse files
committed
Fix BotInlineSend updates breaking seq
1 parent 550ab88 commit 742dce5

File tree

1 file changed

+11
-1
lines changed
  • lib/grammers-session/src/message_box

1 file changed

+11
-1
lines changed

lib/grammers-session/src/message_box/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use crate::message_box::defs::PossibleGap;
3333
pub(crate) use defs::Entry;
3434
pub use defs::{Gap, MessageBox};
3535
use defs::{NO_DATE, NO_PTS, NO_SEQ, POSSIBLE_GAP_TIMEOUT, PtsInfo, State};
36+
use grammers_tl_types::enums::Update;
3637
use grammers_tl_types as tl;
3738
use log::{debug, info, trace, warn};
3839
use std::cmp::Ordering;
@@ -485,6 +486,7 @@ impl MessageBox {
485486
// which the deadlines should be reset, and determines whether any local pts was changed
486487
// so that the seq can be updated too (which could otherwise have been done earlier).
487488
let mut any_pts_applied = false;
489+
let mut force_update_seq = false;
488490
let mut reset_deadlines_for = mem::take(&mut self.tmp_entries);
489491
for update in updates {
490492
let (entry, update) = self.apply_pts_info(update);
@@ -495,8 +497,16 @@ impl MessageBox {
495497
reset_deadlines_for.insert(entry);
496498
}
497499
if let Some(update) = update {
500+
// BotInlineSend updates are sent with `seq` != NO_SEQ. `seq` must be updated in
501+
// that case, otherwise every other BotInlineSend update will be counted as a gap
502+
// and dropped.
503+
match update {
504+
Update::BotInlineSend(_) => force_update_seq = true,
505+
_ => {},
506+
}
498507
result.push(update);
499508
any_pts_applied |= entry.is_some();
509+
500510
}
501511
}
502512
self.reset_deadlines(&reset_deadlines_for, next_updates_deadline());
@@ -510,7 +520,7 @@ impl MessageBox {
510520
// Updates which can be applied in any order, such as `UpdateChat`,
511521
// should not cause `seq` to be updated (or upcoming updates such as
512522
// `UpdateChatParticipant` could be missed).
513-
if any_pts_applied {
523+
if any_pts_applied || force_update_seq {
514524
if date != NO_DATE {
515525
self.date = date;
516526
}

0 commit comments

Comments
 (0)