mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 03:46:32 +03:00
add imap metadata reading of smtp max recipients
This commit is contained in:
@@ -204,9 +204,6 @@ pub const MAX_RCVD_IMAGE_PIXELS: u32 = 50_000_000;
|
|||||||
// `max_smtp_rcpt_to` in the provider db.
|
// `max_smtp_rcpt_to` in the provider db.
|
||||||
pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50;
|
pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50;
|
||||||
|
|
||||||
/// Same as `DEFAULT_MAX_SMTP_RCPT_TO`, but for chatmail relays.
|
|
||||||
pub(crate) const DEFAULT_CHATMAIL_MAX_SMTP_RCPT_TO: usize = 999;
|
|
||||||
|
|
||||||
/// How far the last quota check needs to be in the past to be checked by the background function (in seconds).
|
/// How far the last quota check needs to be in the past to be checked by the background function (in seconds).
|
||||||
pub(crate) const DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT: u64 = 12 * 60 * 60; // 12 hours
|
pub(crate) const DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT: u64 = 12 * 60 * 60; // 12 hours
|
||||||
|
|
||||||
|
|||||||
@@ -589,18 +589,26 @@ impl Context {
|
|||||||
|
|
||||||
/// Returns maximum number of recipients the provider allows to send a single email to.
|
/// 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> {
|
pub(crate) async fn get_max_smtp_rcpt_to(&self) -> Result<usize> {
|
||||||
let is_chatmail = self.is_chatmail().await?;
|
if let Some(limit) = self
|
||||||
|
.sql
|
||||||
|
.query_row_optional(
|
||||||
|
"SELECT t.max_smtp_rcpt_to
|
||||||
|
FROM transports t
|
||||||
|
JOIN config c ON c.keyname='configured_addr' AND c.value=t.addr",
|
||||||
|
(),
|
||||||
|
|row| row.get::<_, Option<u32>>(0),
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
.flatten()
|
||||||
|
{
|
||||||
|
return Ok(limit as usize);
|
||||||
|
}
|
||||||
|
|
||||||
let val = self
|
let val = self
|
||||||
.get_configured_provider()
|
.get_configured_provider()
|
||||||
.await?
|
.await?
|
||||||
.and_then(|provider| provider.opt.max_smtp_rcpt_to)
|
.and_then(|provider| provider.opt.max_smtp_rcpt_to)
|
||||||
.map_or_else(
|
.map_or(constants::DEFAULT_MAX_SMTP_RCPT_TO, usize::from);
|
||||||
|| match is_chatmail {
|
|
||||||
true => constants::DEFAULT_CHATMAIL_MAX_SMTP_RCPT_TO,
|
|
||||||
false => constants::DEFAULT_MAX_SMTP_RCPT_TO,
|
|
||||||
},
|
|
||||||
usize::from,
|
|
||||||
);
|
|
||||||
Ok(val)
|
Ok(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/imap.rs
17
src/imap.rs
@@ -1503,7 +1503,7 @@ impl Session {
|
|||||||
.get_metadata(
|
.get_metadata(
|
||||||
mailbox,
|
mailbox,
|
||||||
options,
|
options,
|
||||||
"(/shared/comment /shared/admin /shared/vendor/deltachat/irohrelay /shared/vendor/deltachat/turn)",
|
"(/shared/comment /shared/admin /shared/vendor/deltachat/irohrelay /shared/vendor/deltachat/turn /shared/vendor/deltachat/maxsmtprecipients)",
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
for m in metadata {
|
for m in metadata {
|
||||||
@@ -1539,6 +1539,21 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"/shared/vendor/deltachat/maxsmtprecipients" => {
|
||||||
|
if let Some(value) = m.value.and_then(|v| v.parse::<u32>().ok()) {
|
||||||
|
let transport_id = self.transport_id();
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.execute(
|
||||||
|
"UPDATE transports \
|
||||||
|
SET max_smtp_rcpt_to=? WHERE id=?",
|
||||||
|
(value, transport_id),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.log_err(context)
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2385,6 +2385,15 @@ UPDATE msgs SET state=19 WHERE state=24; -- Change OutPreparing to OutFailed.
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inc_and_check(&mut migration_version, 153)?;
|
||||||
|
if dbversion < migration_version {
|
||||||
|
sql.execute_migration(
|
||||||
|
"ALTER TABLE transports ADD COLUMN max_smtp_rcpt_to INTEGER DEFAULT NULL",
|
||||||
|
migration_version,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
let new_version = sql
|
let new_version = sql
|
||||||
.get_raw_config_int(VERSION_CFG)
|
.get_raw_config_int(VERSION_CFG)
|
||||||
.await?
|
.await?
|
||||||
|
|||||||
Reference in New Issue
Block a user