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)
| 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. |
| 2643 | pub 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 | /// |
no test coverage detected