&ip_addr,
rate_limit.message,
rate_limit.message_per_second,
- false,
)?;
drop(limiter);
&ip_addr,
rate_limit.post,
rate_limit.post_per_second,
- false,
)?;
}
RateLimitType::Register => {
&ip_addr,
rate_limit.register,
rate_limit.register_per_second,
- false,
)?;
}
RateLimitType::Image => {
&ip_addr,
rate_limit.image,
rate_limit.image_per_second,
- false,
)?;
}
RateLimitType::Comment => {
&ip_addr,
rate_limit.comment,
rate_limit.comment_per_second,
- false,
)?;
}
};
ip: &IpAddr,
rate: i32,
per: i32,
- check_only: bool,
) -> Result<(), LemmyError> {
self.insert_ip(ip);
if let Some(bucket) = self.buckets.get_mut(&type_) {
rate_limit.last_checked = current;
rate_limit.allowance += time_passed * (rate as f64 / per as f64);
- if !check_only && rate_limit.allowance > rate as f64 {
+ if rate_limit.allowance > rate as f64 {
rate_limit.allowance = rate as f64;
}
"too_many_requests",
))
} else {
- if !check_only {
- rate_limit.allowance -= 1.0;
- }
+ rate_limit.allowance -= 1.0;
Ok(())
}
} else {