From d5c5ff8b3f2685d6b04baeacccc850e883d7896d Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 8 Jul 2023 22:00:40 +0000 Subject: [PATCH] refactor: accept &mut Message in create_send_msg_job() --- src/chat.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 386814822..ab8263468 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2388,7 +2388,7 @@ async fn prepare_send_msg( ); message::update_msg_state(context, msg.id, MessageState::OutPending).await?; } - let row_id = create_send_msg_job(context, msg.id).await?; + let row_id = create_send_msg_job(context, msg).await?; Ok(row_id) } @@ -2398,10 +2398,10 @@ async fn prepare_send_msg( /// group with only self and no BCC-to-self configured. /// /// The caller has to interrupt SMTP loop or otherwise process a new row. -async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result> { - let mut msg = Message::load_from_db(context, msg_id).await?; - - /* create message */ +pub(crate) async fn create_send_msg_job( + context: &Context, + msg: &mut Message, +) -> Result> { let needs_encryption = msg.param.get_bool(Param::GuaranteeE2ee).unwrap_or_default(); let attach_selfavatar = match shall_attach_selfavatar(context, msg.chat_id).await { @@ -2412,7 +2412,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result Result Ok(res), Err(err) => { - message::set_msg_failed(context, msg_id, &err.to_string()).await?; + message::set_msg_failed(context, msg.id, &err.to_string()).await?; Err(err) } }?; @@ -2452,13 +2453,13 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result Result Result<()> { chat_id: msg.chat_id, msg_id: msg.id, }); - if create_send_msg_job(context, msg.id).await?.is_some() { + if create_send_msg_job(context, &mut msg).await?.is_some() { context .scheduler .interrupt_smtp(InterruptInfo::new(false))