diff --git a/src/chat.rs b/src/chat.rs index f2ab03582..0c183d2cc 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2995,11 +2995,7 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) - msg.subject.clone_from(&rendered_msg.subject); msg.update_subject(context).await?; - let chunk_size = context - .get_configured_provider() - .await? - .and_then(|provider| provider.opt.max_smtp_rcpt_to) - .map_or(constants::DEFAULT_MAX_SMTP_RCPT_TO, usize::from); + let chunk_size = context.get_max_smtp_rcpt_to().await?; let trans_fn = |t: &mut rusqlite::Transaction| { let mut row_ids = Vec::::new(); for recipients_chunk in recipients.chunks(chunk_size) { diff --git a/src/context.rs b/src/context.rs index b4e5e50e5..fd86f84b6 100644 --- a/src/context.rs +++ b/src/context.rs @@ -498,6 +498,23 @@ impl Context { self.get_config_bool(Config::IsChatmail).await } + /// Returns maximum number of recipients the provider allows to send a single email to. + pub(crate) async fn get_max_smtp_rcpt_to(&self) -> Result { + let is_chatmail = self.is_chatmail().await?; + let val = self + .get_configured_provider() + .await? + .and_then(|provider| provider.opt.max_smtp_rcpt_to) + .map_or_else( + || match is_chatmail { + true => usize::MAX, + false => constants::DEFAULT_MAX_SMTP_RCPT_TO, + }, + usize::from, + ); + Ok(val) + } + /// Does a background fetch /// pauses the scheduler and does one imap fetch, then unpauses and returns pub async fn background_fetch(&self) -> Result<()> { diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 144282aa2..8d702a275 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -5,7 +5,7 @@ use deltachat_contact_tools::EmailAddress; use rusqlite::OptionalExtension; use crate::config::Config; -use crate::constants::{self, ShowEmails}; +use crate::constants::ShowEmails; use crate::context::Context; use crate::imap; use crate::message::MsgId; @@ -839,11 +839,7 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid); if dbversion < 108 { let version = 108; - let chunk_size = context - .get_configured_provider() - .await? - .and_then(|provider| provider.opt.max_smtp_rcpt_to) - .map_or(constants::DEFAULT_MAX_SMTP_RCPT_TO, usize::from); + let chunk_size = context.get_max_smtp_rcpt_to().await?; sql.transaction(move |trans| { Sql::set_db_version_trans(trans, version)?; let id_max =