Add route to create inbox entries

This commit is contained in:
2025-05-06 23:15:49 +02:00
parent 68bc15cccc
commit b6281be349
10 changed files with 192 additions and 3 deletions

View File

@ -0,0 +1,16 @@
use crate::controllers::HttpResult;
use crate::extractors::auth_extractor::AuthExtractor;
use crate::services::inbox_service;
use crate::services::inbox_service::UpdateInboxEntryQuery;
use actix_web::{HttpResponse, web};
/// Create a new inbox entry
pub async fn create(auth: AuthExtractor, req: web::Json<UpdateInboxEntryQuery>) -> HttpResult {
if let Some(err) = req.check_error(auth.user_id()).await? {
return Ok(HttpResponse::BadRequest().json(err));
}
inbox_service::create(auth.user_id(), &req).await?;
Ok(HttpResponse::Created().finish())
}

View File

@ -8,6 +8,7 @@ pub mod accounts_controller;
pub mod auth_controller;
pub mod backup_controller;
pub mod files_controller;
pub mod inbox_controller;
pub mod movement_controller;
pub mod server_controller;
pub mod static_controller;

View File

@ -42,6 +42,7 @@ pub struct ServerConstraints {
pub token_max_inactivity: LenConstraints,
pub account_name: LenConstraints,
pub movement_label: LenConstraints,
pub inbox_entry_label: LenConstraints,
pub file_allowed_types: &'static [&'static str],
}
@ -53,6 +54,7 @@ impl Default for ServerConstraints {
token_max_inactivity: LenConstraints::new(3600, 3600 * 24 * 365),
account_name: LenConstraints::not_empty(50),
movement_label: LenConstraints::not_empty(200),
inbox_entry_label: LenConstraints::not_empty(200),
file_allowed_types: &[
"image/jpeg",
"image/png",