mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 17:06:35 +03:00
refactor: use let-else in resend_msgs()
This commit is contained in:
46
src/chat.rs
46
src/chat.rs
@@ -3604,29 +3604,31 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
|
|||||||
msgs.push(msg)
|
msgs.push(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(chat_id) = chat_id {
|
let Some(chat_id) = chat_id else {
|
||||||
let chat = Chat::load_from_db(context, chat_id).await?;
|
return Ok(());
|
||||||
for mut msg in msgs {
|
};
|
||||||
if msg.get_showpadlock() && !chat.is_protected() {
|
|
||||||
msg.param.remove(Param::GuaranteeE2ee);
|
let chat = Chat::load_from_db(context, chat_id).await?;
|
||||||
msg.update_param(context).await?;
|
for mut msg in msgs {
|
||||||
}
|
if msg.get_showpadlock() && !chat.is_protected() {
|
||||||
match msg.get_state() {
|
msg.param.remove(Param::GuaranteeE2ee);
|
||||||
MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => {
|
msg.update_param(context).await?;
|
||||||
message::update_msg_state(context, msg.id, MessageState::OutPending).await?
|
}
|
||||||
}
|
match msg.get_state() {
|
||||||
_ => bail!("unexpected message state"),
|
MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => {
|
||||||
}
|
message::update_msg_state(context, msg.id, MessageState::OutPending).await?
|
||||||
context.emit_event(EventType::MsgsChanged {
|
|
||||||
chat_id: msg.chat_id,
|
|
||||||
msg_id: msg.id,
|
|
||||||
});
|
|
||||||
if create_send_msg_job(context, msg.id).await?.is_some() {
|
|
||||||
context
|
|
||||||
.scheduler
|
|
||||||
.interrupt_smtp(InterruptInfo::new(false))
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
_ => bail!("unexpected message state"),
|
||||||
|
}
|
||||||
|
context.emit_event(EventType::MsgsChanged {
|
||||||
|
chat_id: msg.chat_id,
|
||||||
|
msg_id: msg.id,
|
||||||
|
});
|
||||||
|
if create_send_msg_job(context, msg.id).await?.is_some() {
|
||||||
|
context
|
||||||
|
.scheduler
|
||||||
|
.interrupt_smtp(InterruptInfo::new(false))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user