mirror of
https://github.com/v0l/route96.git
synced 2025-06-15 16:03:00 +00:00
fix: disable quota checks when not configured
This commit is contained in:
@ -364,13 +364,10 @@ async fn process_upload(
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check quota
|
// check quota (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
{
|
if let Some(payment_config) = &settings.payments {
|
||||||
let free_quota = settings
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.payments
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|p| p.free_quota_bytes)
|
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||||
|
|
||||||
@ -442,13 +439,11 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Post-upload quota check if we didn't have size information before upload
|
// Post-upload quota check if we didn't have size information before upload (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
let free_quota = settings
|
if let Some(payment_config) = &settings.payments {
|
||||||
.payments
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.as_ref()
|
|
||||||
.and_then(|p| p.free_quota_bytes)
|
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
|
|
||||||
match db.check_user_quota(pubkey, upload.size, free_quota).await {
|
match db.check_user_quota(pubkey, upload.size, free_quota).await {
|
||||||
@ -469,6 +464,7 @@ where
|
|||||||
Ok(true) => {} // Quota check passed
|
Ok(true) => {} // Quota check passed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if let Err(e) = db.add_file(&upload, user_id).await {
|
if let Err(e) = db.add_file(&upload, user_id).await {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
BlossomResponse::error(format!("Error saving file (db): {}", e))
|
BlossomResponse::error(format!("Error saving file (db): {}", e))
|
||||||
|
@ -205,11 +205,10 @@ async fn upload(
|
|||||||
|
|
||||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||||
|
|
||||||
// check quota
|
// check quota (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
{
|
if let Some(payment_config) = &settings.payments {
|
||||||
let free_quota = settings.payments.as_ref()
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.and_then(|p| p.free_quota_bytes)
|
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
|
|
||||||
if upload_size > 0 {
|
if upload_size > 0 {
|
||||||
@ -255,11 +254,11 @@ async fn upload(
|
|||||||
Err(e) => return Nip96Response::error(&format!("Could not save user: {}", e)),
|
Err(e) => return Nip96Response::error(&format!("Could not save user: {}", e)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Post-upload quota check if we didn't have size information before upload
|
// Post-upload quota check if we didn't have size information before upload (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
if upload_size == 0 {
|
if upload_size == 0 {
|
||||||
let free_quota = settings.payments.as_ref()
|
if let Some(payment_config) = &settings.payments {
|
||||||
.and_then(|p| p.free_quota_bytes)
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
|
|
||||||
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
||||||
@ -280,6 +279,7 @@ async fn upload(
|
|||||||
Ok(true) => {} // Quota check passed
|
Ok(true) => {} // Quota check passed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Err(e) = db.add_file(&upload, user_id).await {
|
if let Err(e) = db.add_file(&upload, user_id).await {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
|
Reference in New Issue
Block a user