diff --git a/src/chat.rs b/src/chat.rs index d809447477..606703084e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2793,29 +2793,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) -> msg.param.remove(Param::ForcePlaintext); msg.update_param(context).await?; } - send_msg_inner(context, chat_id, msg).await -} - -/// Tries to send a message synchronously. -/// -/// Creates jobs in the `smtp` table, then drectly opens an SMTP connection and sends the -/// message. If this fails, the jobs remain in the database for later sending. -pub async fn send_msg_sync(context: &Context, chat_id: ChatId, msg: &mut Message) -> Result { - let rowids = prepare_send_msg(context, chat_id, msg).await?; - if rowids.is_empty() { - return Ok(msg.id); - } - let mut smtp = crate::smtp::Smtp::new(); - for rowid in rowids { - send_msg_to_smtp(context, &mut smtp, rowid) - .await - .context("failed to send message, queued for later sending")?; - } - context.emit_msgs_changed(msg.chat_id, msg.id); - Ok(msg.id) -} -async fn send_msg_inner(context: &Context, chat_id: ChatId, msg: &mut Message) -> Result { // protect all system messages against RTLO attacks if msg.is_system_message() { msg.text = sanitize_bidi_characters(&msg.text); @@ -2836,6 +2814,25 @@ async fn send_msg_inner(context: &Context, chat_id: ChatId, msg: &mut Message) - Ok(msg.id) } +/// Tries to send a message synchronously. +/// +/// Creates jobs in the `smtp` table, then drectly opens an SMTP connection and sends the +/// message. If this fails, the jobs remain in the database for later sending. +pub async fn send_msg_sync(context: &Context, chat_id: ChatId, msg: &mut Message) -> Result { + let rowids = prepare_send_msg(context, chat_id, msg).await?; + if rowids.is_empty() { + return Ok(msg.id); + } + let mut smtp = crate::smtp::Smtp::new(); + for rowid in rowids { + send_msg_to_smtp(context, &mut smtp, rowid) + .await + .context("failed to send message, queued for later sending")?; + } + context.emit_msgs_changed(msg.chat_id, msg.id); + Ok(msg.id) +} + /// Prepares a message to be sent out. /// /// Returns row ids of the `smtp` table.