40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use crate::nats_types::ValidateMapfixRequest;
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Debug)]
|
|
pub enum Error{
|
|
ApiActionMapfixValidate(submissions_api::Error),
|
|
}
|
|
impl std::fmt::Display for Error{
|
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
write!(f,"{self:?}")
|
|
}
|
|
}
|
|
impl std::error::Error for Error{}
|
|
|
|
impl crate::message_handler::MessageHandler{
|
|
pub async fn validate_mapfix(&self,validate_info:ValidateMapfixRequest)->Result<(),Error>{
|
|
let mapfix_id=validate_info.MapfixID;
|
|
let validate_result=self.validate_inner(validate_info.into()).await;
|
|
|
|
// update the mapfix depending on the result
|
|
match &validate_result{
|
|
Ok(())=>{
|
|
// update the mapfix model status to validated
|
|
self.api.action_mapfix_validated(
|
|
submissions_api::types::MapfixID(mapfix_id)
|
|
).await.map_err(Error::ApiActionMapfixValidate)?;
|
|
},
|
|
Err(e)=>{
|
|
// update the mapfix model status to accepted
|
|
self.api.action_mapfix_accepted(submissions_api::types::ActionMapfixAcceptedRequest{
|
|
MapfixID:mapfix_id,
|
|
ErrorMessage:e.to_string(),
|
|
}).await.map_err(Error::ApiActionMapfixValidate)?;
|
|
},
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|