comment: 6
# Interval length for comment limit, in seconds
comment_per_second: 600
+ search: 6
+ # Interval length for search limit, in seconds
+ search_per_second: 600
}
# Settings related to activitypub federation
federation: {
self.kind(RateLimitType::Comment)
}
+ pub fn search(&self) -> RateLimited {
+ self.kind(RateLimitType::Search)
+ }
+
fn kind(&self, type_: RateLimitType) -> RateLimited {
RateLimited {
rate_limiter: self.rate_limiter.clone(),
RateLimitType::Register => (rate_limit.register, rate_limit.register_per_second),
RateLimitType::Image => (rate_limit.image, rate_limit.image_per_second),
RateLimitType::Comment => (rate_limit.comment, rate_limit.comment_per_second),
+ RateLimitType::Search => (rate_limit.search, rate_limit.search_per_second),
};
let mut limiter = self.rate_limiter.lock();
Post,
Image,
Comment,
+ Search,
}
/// Rate limiting based on rate type and IP addr
/// Interval length for comment limit, in seconds
#[default(600)]
pub comment_per_second: i32,
+ #[default(6)]
+ pub search: i32,
+ /// Interval length for search limit, in seconds
+ #[default(600)]
+ pub search_per_second: i32,
}
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
let user_operation = UserOperation::from_str(op)?;
let passed = match user_operation {
UserOperation::GetCaptcha => rate_limiter.post().check(ip),
+ UserOperation::Search => rate_limiter.search().check(ip),
_ => true,
};
let fut = (message_handler)(context, msg.id, user_operation, data);
)
.service(
web::resource("/search")
- .wrap(rate_limit.message())
+ .wrap(rate_limit.search())
.route(web::get().to(route_get::<Search>)),
)
.service(