- // before
- {
- let mut limiter = self.rate_limiter.lock().await;
-
- match self.type_ {
- RateLimitType::Message => {
- limiter.check_rate_limit_full(
- self.type_,
- &ip_addr,
- rate_limit.message,
- rate_limit.message_per_second,
- )?;
-
- drop(limiter);
- return fut.await;
- }
- RateLimitType::Post => {
- limiter.check_rate_limit_full(
- self.type_,
- &ip_addr,
- rate_limit.post,
- rate_limit.post_per_second,
- )?;
- }
- RateLimitType::Register => {
- limiter.check_rate_limit_full(
- self.type_,
- &ip_addr,
- rate_limit.register,
- rate_limit.register_per_second,
- )?;
- }
- RateLimitType::Image => {
- limiter.check_rate_limit_full(
- self.type_,
- &ip_addr,
- rate_limit.image,
- rate_limit.image_per_second,
- )?;
- }
- RateLimitType::Comment => {
- limiter.check_rate_limit_full(
- self.type_,
- &ip_addr,
- rate_limit.comment,
- rate_limit.comment_per_second,
- )?;
- }
- };
- }
-
- let res = fut.await;