ratelimit: make message configurable
Changelog-Added: Make ratelimit message configurable Closes: https://github.com/damus-io/noteguard/pull/15
This commit is contained in:
committed by
William Casarin
parent
3b73e9aa00
commit
77c2a8906c
@@ -4,6 +4,7 @@ pipeline = ["protected_events", "kinds", "content", "whitelist", "ratelimit"]
|
||||
[filters.ratelimit]
|
||||
posts_per_minute = 8
|
||||
whitelist = ["127.0.0.1"]
|
||||
message = "rate-limited: you note too much"
|
||||
|
||||
[filters.content]
|
||||
filters = ["https://cdn.nostr.build/i/some-spammy-or-abusive-image-image.png"]
|
||||
|
||||
@@ -12,6 +12,7 @@ pub struct Tokens {
|
||||
pub struct RateLimit {
|
||||
pub posts_per_minute: i32,
|
||||
pub whitelist: Option<Vec<String>>,
|
||||
pub message: Option<String>,
|
||||
|
||||
#[serde(skip)]
|
||||
pub sources: HashMap<String, Tokens>,
|
||||
@@ -65,7 +66,11 @@ impl NoteFilter for RateLimit {
|
||||
return OutputMessage::new(
|
||||
msg.event.id.clone(),
|
||||
Action::Reject,
|
||||
Some("rate-limited: you are noting too much".to_string()),
|
||||
Some(
|
||||
self.message
|
||||
.clone()
|
||||
.unwrap_or("rate-limited: you are noting too much".to_string()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user