fix: add explicit limit for adding relays (5 at the moment) (#7611)

closes https://github.com/chatmail/core/issues/7608
This commit is contained in:
Simon Laux
2025-12-15 11:35:23 +01:00
committed by GitHub
parent 525a3539d2
commit a09fd4577a
2 changed files with 38 additions and 0 deletions

View File

@@ -45,6 +45,10 @@ use crate::transport::{
use crate::{EventType, stock_str};
use crate::{chat, provider};
/// Maximum number of relays
/// see <https://github.com/chatmail/core/issues/7608>
pub(crate) const MAX_TRANSPORT_RELAYS: usize = 5;
macro_rules! progress {
($context:tt, $progress:expr, $comment:expr) => {
assert!(
@@ -283,6 +287,18 @@ impl Context {
"To use additional relays, set the legacy option \"Settings / Advanced / Show Classic Emails\" to \"All\"."
);
}
if self
.sql
.count("SELECT COUNT(*) FROM transports", ())
.await?
>= MAX_TRANSPORT_RELAYS
{
bail!(
"You have reached the maximum number of relays ({}).",
MAX_TRANSPORT_RELAYS
)
}
}
let provider = match configure(self, param).await {