do not use ratelimiter for bots (#3439)

* do not use ratelimiter for bots

i tried some other approaches as having optional ratelimiter
or handle `can_send()` for bots differently,
but all that results in _far_ more code and/or indirections -
esp. as the "bot" config can change and is also persisted -
and the ratelimiter is created
at a point where the database is not yet available ...

of course, all that could be refactored as well,
but this two-liner also does the job :)

* update CHANGELOG
This commit is contained in:
bjoern
2022-06-20 16:16:26 +02:00
committed by GitHub
parent b88042a902
commit 7ce291fac5
2 changed files with 8 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
use super::Smtp;
use async_smtp::{EmailAddress, Envelope, SendableEmail, Transport};
use crate::config::Config;
use crate::constants::DEFAULT_MAX_SMTP_RCPT_TO;
use crate::context::Context;
use crate::events::EventType;
@@ -32,10 +33,12 @@ impl Smtp {
message: &[u8],
rowid: i64,
) -> Result<()> {
// Notify ratelimiter about sent message regardless of whether quota is exceeded or not.
// Checking whether sending is allowed for low-priority messages should be done by the
// caller.
context.ratelimit.write().await.send();
if !context.get_config_bool(Config::Bot).await? {
// Notify ratelimiter about sent message regardless of whether quota is exceeded or not.
// Checking whether sending is allowed for low-priority messages should be done by the
// caller.
context.ratelimit.write().await.send();
}
let message_len_bytes = message.len();