Get only the number of inbox entries
This commit is contained in:
@ -37,6 +37,26 @@ pub async fn get_list(auth: AuthExtractor, query: web::Query<GetInboxQuery>) ->
|
||||
Ok(HttpResponse::Ok().json(list))
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct InboxCount {
|
||||
count: usize,
|
||||
}
|
||||
|
||||
/// Count the number of inbox entries
|
||||
pub async fn count_entries(auth: AuthExtractor, query: web::Query<GetInboxQuery>) -> HttpResult {
|
||||
let mut list = inbox_service::get_list_user(auth.user_id()).await?;
|
||||
|
||||
list.retain(|entry| {
|
||||
if !query.include_attached && entry.movement_id().is_some() {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
});
|
||||
|
||||
Ok(HttpResponse::Ok().json(InboxCount { count: list.len() }))
|
||||
}
|
||||
|
||||
/// Get a single inbox entry
|
||||
pub async fn get_single(entry: InboxEntryInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(entry.as_ref()))
|
||||
|
Reference in New Issue
Block a user