@@ -8,10 +8,6 @@ use tokio::sync::RwLock;
88use crate :: cache:: cache:: BytesCache ;
99use crate :: models:: user:: { UserCompact , UserId } ;
1010
11- // todo: add these to config.
12- const IMAGE_CACHE_USER_QUOTA_PERIOD_SECONDS : u64 = 3600 ;
13- const IMAGE_CACHE_USER_QUOTA_BYTES : usize = 64_000_000 ;
14-
1511static ERROR_IMAGE_LOADER : Once = Once :: new ( ) ;
1612static mut ERROR_IMAGE_UNAUTHENTICATED : Bytes = Bytes :: new ( ) ;
1713
@@ -79,7 +75,9 @@ impl ImageCacheQuota {
7975
8076pub struct ImageCacheManagerConfig {
8177 pub max_image_request_timeout_ms : u64 ,
82- pub max_image_size : usize
78+ pub max_image_size : usize ,
79+ pub user_quota_period_seconds : u64 ,
80+ pub user_quota_bytes : usize
8381}
8482
8583pub struct ImageCacheManager {
@@ -171,8 +169,8 @@ impl ImageCacheManager {
171169 . cloned ( )
172170 . unwrap_or ( ImageCacheQuota :: new (
173171 user. user_id ,
174- IMAGE_CACHE_USER_QUOTA_BYTES ,
175- IMAGE_CACHE_USER_QUOTA_PERIOD_SECONDS )
172+ self . config . user_quota_bytes ,
173+ self . config . user_quota_period_seconds )
176174 ) ;
177175
178176 let _ = quota. add_usage ( image_bytes. len ( ) ) ;
0 commit comments