cargo fmt
This commit is contained in:
@@ -31,7 +31,9 @@ pub mod request {
|
||||
|
||||
impl CreateScheduleMessageEventRequest {
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.contact_id.is_nil() || !self.message_id.is_nil() || !self.scheduled_message_id.is_nil()
|
||||
!self.contact_id.is_nil()
|
||||
|| !self.message_id.is_nil()
|
||||
|| !self.scheduled_message_id.is_nil()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,9 +62,9 @@ pub mod response {
|
||||
}
|
||||
|
||||
pub mod endpoint {
|
||||
use crate::repo::contact as contact_repo;
|
||||
use crate::repo::message as message_repo;
|
||||
use message_repo::scheduling as scheduling_repo;
|
||||
use crate::repo::contact as contact_repo;
|
||||
|
||||
/// Endpoint to create a Scheudled Message
|
||||
#[utoipa::path(
|
||||
@@ -196,7 +198,6 @@ pub mod endpoint {
|
||||
.is_some_and(|t| t - time::OffsetDateTime::now_utc() >= time::Duration::minutes(10))
|
||||
}
|
||||
|
||||
|
||||
/// Endpoint to create a Scheudled Message Event
|
||||
#[utoipa::path(
|
||||
post,
|
||||
@@ -223,38 +224,29 @@ pub mod endpoint {
|
||||
|
||||
if payload.is_valid() {
|
||||
match scheduling_repo::get(&pool, &payload.scheduled_message_id).await {
|
||||
Ok(_) => { }
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Scheduled Message does not exist");
|
||||
return (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response),
|
||||
);
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Scheduled Message does not exist");
|
||||
return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response));
|
||||
}
|
||||
}
|
||||
|
||||
match contact_repo::get(&pool, &payload.contact_id).await {
|
||||
Ok(_) => { }
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Contact does not exist");
|
||||
return (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response),
|
||||
);
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Contact does not exist");
|
||||
return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response));
|
||||
}
|
||||
}
|
||||
|
||||
match message_repo::get(&pool, &payload.message_id).await {
|
||||
Ok(_) => { }
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Contact does not exist");
|
||||
return (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response),
|
||||
);
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Contact does not exist");
|
||||
return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,12 +265,12 @@ pub mod endpoint {
|
||||
(axum::http::StatusCode::CREATED, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Error inserting");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = String::from("Error inserting");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user