MCPcopy Create free account
hub / github.com/chatmail/core / send_msg_sync

Function send_msg_sync

src/chat.rs:2643–2656  ·  view source on GitHub ↗

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.

(context: &Context, chat_id: ChatId, msg: &mut Message)

Source from the content-addressed store, hash-verified

2641/// Creates jobs in the `smtp` table, then drectly opens an SMTP connection and sends the
2642/// message. If this fails, the jobs remain in the database for later sending.
2643pub async fn send_msg_sync(context: &Context, chat_id: ChatId, msg: &mut Message) -> Result<MsgId> {
2644 let rowids = prepare_send_msg(context, chat_id, msg).await?;
2645 if rowids.is_empty() {
2646 return Ok(msg.id);
2647 }
2648 let mut smtp = crate::smtp::Smtp::new();
2649 for rowid in rowids {
2650 send_msg_to_smtp(context, &mut smtp, rowid)
2651 .await
2652 .context("failed to send message, queued for later sending")?;
2653 }
2654 context.emit_msgs_changed(msg.chat_id, msg.id);
2655 Ok(msg.id)
2656}
2657
2658/// Prepares a message to be sent out.
2659///

Callers 2

cmdlineFunction · 0.85
dc_send_msg_syncFunction · 0.85

Calls 4

prepare_send_msgFunction · 0.85
send_msg_to_smtpFunction · 0.85
emit_msgs_changedMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected