Can update inbox entry information
This commit is contained in:
		@@ -41,3 +41,18 @@ pub async fn get_list(auth: AuthExtractor, query: web::Query<GetInboxQuery>) ->
 | 
				
			|||||||
pub async fn get_single(entry: InboxEntryInPath) -> HttpResult {
 | 
					pub async fn get_single(entry: InboxEntryInPath) -> HttpResult {
 | 
				
			||||||
    Ok(HttpResponse::Ok().json(entry.as_ref()))
 | 
					    Ok(HttpResponse::Ok().json(entry.as_ref()))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Update a single inbox entry information
 | 
				
			||||||
 | 
					pub async fn update(
 | 
				
			||||||
 | 
					    auth: AuthExtractor,
 | 
				
			||||||
 | 
					    inbox_entry: InboxEntryInPath,
 | 
				
			||||||
 | 
					    req: web::Json<UpdateInboxEntryQuery>,
 | 
				
			||||||
 | 
					) -> HttpResult {
 | 
				
			||||||
 | 
					    if let Some(err) = req.check_error(auth.user_id()).await? {
 | 
				
			||||||
 | 
					        return Ok(HttpResponse::BadRequest().json(err));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inbox_service::update(inbox_entry.as_ref().id(), &req).await?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Ok(HttpResponse::Ok().json(inbox_service::get_by_id(inbox_entry.as_ref().id()).await?))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ impl Default for ServerConstraints {
 | 
				
			|||||||
            token_max_inactivity: LenConstraints::new(3600, 3600 * 24 * 365),
 | 
					            token_max_inactivity: LenConstraints::new(3600, 3600 * 24 * 365),
 | 
				
			||||||
            account_name: LenConstraints::not_empty(50),
 | 
					            account_name: LenConstraints::not_empty(50),
 | 
				
			||||||
            movement_label: LenConstraints::not_empty(200),
 | 
					            movement_label: LenConstraints::not_empty(200),
 | 
				
			||||||
            inbox_entry_label: LenConstraints::not_empty(200),
 | 
					            inbox_entry_label: LenConstraints::max_only(200),
 | 
				
			||||||
            file_allowed_types: &[
 | 
					            file_allowed_types: &[
 | 
				
			||||||
                "image/jpeg",
 | 
					                "image/jpeg",
 | 
				
			||||||
                "image/png",
 | 
					                "image/png",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,6 +162,10 @@ async fn main() -> std::io::Result<()> {
 | 
				
			|||||||
                "/api/inbox/{inbox_id}",
 | 
					                "/api/inbox/{inbox_id}",
 | 
				
			||||||
                web::get().to(inbox_controller::get_single),
 | 
					                web::get().to(inbox_controller::get_single),
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					            .route(
 | 
				
			||||||
 | 
					                "/api/inbox/{inbox_id}",
 | 
				
			||||||
 | 
					                web::put().to(inbox_controller::update),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
            // Statistics controller
 | 
					            // Statistics controller
 | 
				
			||||||
            .route("/api/stats/global", web::get().to(stats_controller::global))
 | 
					            .route("/api/stats/global", web::get().to(stats_controller::global))
 | 
				
			||||||
            .route(
 | 
					            .route(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ impl UpdateInboxEntryQuery {
 | 
				
			|||||||
        // Check inbox entry label
 | 
					        // Check inbox entry label
 | 
				
			||||||
        if let Some(label) = &self.label {
 | 
					        if let Some(label) = &self.label {
 | 
				
			||||||
            if !constraints.inbox_entry_label.check_str(label) {
 | 
					            if !constraints.inbox_entry_label.check_str(label) {
 | 
				
			||||||
                return Ok(Some("Invalid inbox entry  label length!"));
 | 
					                return Ok(Some("Invalid inbox entry label length!"));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user