ratelimit: reduce the number of string allocations

not a huge deal, but this is technically a bit nicer
This commit is contained in:
William Casarin 2024-11-18 10:57:28 -08:00
parent 77c2a8906c
commit 778c5a053b

View file

@ -63,14 +63,15 @@ impl NoteFilter for RateLimit {
} }
if entry.tokens == 0 { if entry.tokens == 0 {
let message = self
.message
.as_deref()
.unwrap_or("rate-limited: you are noting too much");
return OutputMessage::new( return OutputMessage::new(
msg.event.id.clone(), msg.event.id.clone(),
Action::Reject, Action::Reject,
Some( Some(message.to_owned()),
self.message
.clone()
.unwrap_or("rate-limited: you are noting too much".to_string()),
),
); );
} }