Skip to content

Commit

Permalink
feat: Remove limit on number of email recipients for chatmail clients (
Browse files Browse the repository at this point in the history
  • Loading branch information
iequidoo committed May 27, 2024
1 parent adb0dd4 commit 1cc31c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64>::new();
for recipients_chunk in recipients.chunks(chunk_size) {
Expand Down
17 changes: 17 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> {
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<()> {
Expand Down
8 changes: 2 additions & 6 deletions src/sql/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 1cc31c1

Please sign in to comment.