]> Untitled Git - lemmy.git/blobdiff - server/src/rate_limit/mod.rs
Proxy pictrs requests through Lemmy (fixes #371) (#77)
[lemmy.git] / server / src / rate_limit / mod.rs
index 513c923c6182b006ebedff3cf8c57ac1cbf63f0b..39df726505c02ea03915120747604c003b506f3c 100644 (file)
@@ -45,6 +45,10 @@ impl RateLimit {
     self.kind(RateLimitType::Register)
   }
 
+  pub fn image(&self) -> RateLimited {
+    self.kind(RateLimitType::Image)
+  }
+
   fn kind(&self, type_: RateLimitType) -> RateLimited {
     RateLimited {
       rate_limiter: self.rate_limiter.clone(),
@@ -101,6 +105,15 @@ impl RateLimited {
             true,
           )?;
         }
+        RateLimitType::Image => {
+          limiter.check_rate_limit_full(
+            self.type_,
+            &ip_addr,
+            rate_limit.image,
+            rate_limit.image_per_second,
+            false,
+          )?;
+        }
       };
     }