@@ -16,11 +16,13 @@ use crate::{
1616use super :: DbConnection ;
1717
1818const DAY : Duration = Duration :: from_secs ( 24 * 60 * 60 ) ;
19- const UNCLAIMED_RATE_LIMIT : u32 = u8:: MAX as u32 ;
20- const CLAIMED_RATE_LIMIT : u32 = u16:: MAX as u32 ;
19+ const USER_LIMIT : u32 = u8:: MAX as u32 ;
20+ const UNCLAIMED_LIMIT : u32 = u8:: MAX as u32 ;
21+ const CLAIMED_LIMIT : u32 = u16:: MAX as u32 ;
2122
2223pub struct RateLimiting {
2324 pub window : Duration ,
25+ pub user_limit : u32 ,
2426 pub unclaimed_limit : u32 ,
2527 pub claimed_limit : u32 ,
2628}
@@ -69,13 +71,15 @@ impl From<JsonRateLimiting> for RateLimiting {
6971 fn from ( json : JsonRateLimiting ) -> Self {
7072 let JsonRateLimiting {
7173 window,
74+ user_limit,
7275 unclaimed_limit,
7376 claimed_limit,
7477 } = json;
7578 Self {
7679 window : window. map ( u64:: from) . map_or ( DAY , Duration :: from_secs) ,
77- unclaimed_limit : unclaimed_limit. unwrap_or ( UNCLAIMED_RATE_LIMIT ) ,
78- claimed_limit : claimed_limit. unwrap_or ( CLAIMED_RATE_LIMIT ) ,
80+ user_limit : user_limit. unwrap_or ( USER_LIMIT ) ,
81+ unclaimed_limit : unclaimed_limit. unwrap_or ( UNCLAIMED_LIMIT ) ,
82+ claimed_limit : claimed_limit. unwrap_or ( CLAIMED_LIMIT ) ,
7983 }
8084 }
8185}
@@ -84,8 +88,9 @@ impl Default for RateLimiting {
8488 fn default ( ) -> Self {
8589 Self {
8690 window : DAY ,
87- unclaimed_limit : UNCLAIMED_RATE_LIMIT ,
88- claimed_limit : CLAIMED_RATE_LIMIT ,
91+ user_limit : USER_LIMIT ,
92+ unclaimed_limit : UNCLAIMED_LIMIT ,
93+ claimed_limit : CLAIMED_LIMIT ,
8994 }
9095 }
9196}
0 commit comments