mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
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:
15
src/chat.rs
15
src/chat.rs
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user