Skip to content

Commit 7ce291f

Browse files
authored
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
1 parent b88042a commit 7ce291f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changes
66
- limit the rate of MDN sending #3402
7+
- ignore ratelimits for bots #3439
78
- remove `msgs_mdns` references to deleted messages during housekeeping #3387
89

910
### Fixes

src/smtp/send.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use super::Smtp;
44
use async_smtp::{EmailAddress, Envelope, SendableEmail, Transport};
55

6+
use crate::config::Config;
67
use crate::constants::DEFAULT_MAX_SMTP_RCPT_TO;
78
use crate::context::Context;
89
use crate::events::EventType;
@@ -32,10 +33,12 @@ impl Smtp {
3233
message: &[u8],
3334
rowid: i64,
3435
) -> Result<()> {
35-
// Notify ratelimiter about sent message regardless of whether quota is exceeded or not.
36-
// Checking whether sending is allowed for low-priority messages should be done by the
37-
// caller.
38-
context.ratelimit.write().await.send();
36+
if !context.get_config_bool(Config::Bot).await? {
37+
// Notify ratelimiter about sent message regardless of whether quota is exceeded or not.
38+
// Checking whether sending is allowed for low-priority messages should be done by the
39+
// caller.
40+
context.ratelimit.write().await.send();
41+
}
3942

4043
let message_len_bytes = message.len();
4144

0 commit comments

Comments
 (0)