ratelimit: make message configurable
Changelog-Added: Make ratelimit message configurable Closes: https://github.com/damus-io/noteguard/pull/15
This commit is contained in:
parent
3b73e9aa00
commit
77c2a8906c
2 changed files with 7 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ pipeline = ["protected_events", "kinds", "content", "whitelist", "ratelimit"]
|
||||||
[filters.ratelimit]
|
[filters.ratelimit]
|
||||||
posts_per_minute = 8
|
posts_per_minute = 8
|
||||||
whitelist = ["127.0.0.1"]
|
whitelist = ["127.0.0.1"]
|
||||||
|
message = "rate-limited: you note too much"
|
||||||
|
|
||||||
[filters.content]
|
[filters.content]
|
||||||
filters = ["https://cdn.nostr.build/i/some-spammy-or-abusive-image-image.png"]
|
filters = ["https://cdn.nostr.build/i/some-spammy-or-abusive-image-image.png"]
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ pub struct Tokens {
|
||||||
pub struct RateLimit {
|
pub struct RateLimit {
|
||||||
pub posts_per_minute: i32,
|
pub posts_per_minute: i32,
|
||||||
pub whitelist: Option<Vec<String>>,
|
pub whitelist: Option<Vec<String>>,
|
||||||
|
pub message: Option<String>,
|
||||||
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub sources: HashMap<String, Tokens>,
|
pub sources: HashMap<String, Tokens>,
|
||||||
|
|
@ -65,7 +66,11 @@ impl NoteFilter for RateLimit {
|
||||||
return OutputMessage::new(
|
return OutputMessage::new(
|
||||||
msg.event.id.clone(),
|
msg.event.id.clone(),
|
||||||
Action::Reject,
|
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()),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue