Reset quota endpoint

This commit is contained in:
mdecimus
2025-01-17 16:04:58 +01:00
parent 2eb388674d
commit 61e63d1ead
4 changed files with 90 additions and 4 deletions

View File

@@ -287,6 +287,26 @@ impl ManageStore for Server {
}))
.into_http_response())
}
(Some("quota"), Some(account_id), None, method @ (&Method::GET | &Method::DELETE)) => {
let account_id = self
.core
.storage
.data
.get_principal_id(decode_path_element(account_id).as_ref())
.await?
.ok_or_else(|| trc::ManageEvent::NotFound.into_err())?;
if method == Method::DELETE {
self.recalculate_quota(account_id).await?;
}
let result = self.get_used_quota(account_id).await?;
Ok(JsonResponse::new(json!({
"data": result,
}))
.into_http_response())
}
_ => Err(trc::ResourceEvent::NotFound.into_err()),
}
}