feat: For bots, wait with emitting IncomingMsg until the Post-Msg arrived

This commit is contained in:
Hocuri
2026-04-08 14:43:13 +02:00
parent 60bc4011f7
commit e1f7af6db5
5 changed files with 97 additions and 5 deletions

View File

@@ -1146,6 +1146,12 @@ ORDER BY m.timestamp DESC,m.id DESC",
///
/// Blocked contacts and chats are excluded,
/// but self-sent messages and contact requests are included in the results.
///
/// Note that this returns the pre-message's id as soon as it arrives.
/// The bot needs to wait for the post-message by itself if it wants to use this API
/// to get fully downloaded messages.
/// If the bot doesn't want this, then it should instead use the [`EventType::IncomingMsg`]
/// event for getting notified about new messages.
pub async fn get_next_msgs(&self) -> Result<Vec<MsgId>> {
let last_msg_id = match self.get_config(Config::LastMsgId).await? {
Some(s) => MsgId::new(s.parse()?),