Add a route to get the list of inbox entries
This commit is contained in:
@ -14,3 +14,24 @@ pub async fn create(auth: AuthExtractor, req: web::Json<UpdateInboxEntryQuery>)
|
||||
|
||||
Ok(HttpResponse::Created().finish())
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct GetInboxQuery {
|
||||
#[serde(default)]
|
||||
include_attached: bool,
|
||||
}
|
||||
|
||||
/// Get inbox content
|
||||
pub async fn get_list(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(list))
|
||||
}
|
||||
|
Reference in New Issue
Block a user