fix: ChatId::maybe_delete_draft: Don't delete message if it's not a draft anymore (#6053)

Follow-up to 07fa9c35ee.
This commit is contained in:
iequidoo
2024-10-17 18:48:52 -03:00
committed by iequidoo
parent 65b970a191
commit df4fd82140
4 changed files with 35 additions and 23 deletions

View File

@@ -866,13 +866,14 @@ impl ChatId {
///
/// Returns `true`, if message was deleted, `false` otherwise.
async fn maybe_delete_draft(self, context: &Context) -> Result<bool> {
match self.get_draft_msg_id(context).await? {
Some(msg_id) => {
msg_id.delete_from_db(context).await?;
Ok(true)
}
None => Ok(false),
}
Ok(context
.sql
.execute(
"DELETE FROM msgs WHERE chat_id=? AND state=?",
(self, MessageState::OutDraft),
)
.await?
> 0)
}
/// Set provided message as draft message for specified chat.