Got it working
This commit is contained in:
@@ -62,14 +62,17 @@ pub mod endpoint {
|
|||||||
} else {
|
} else {
|
||||||
if can_schedule(&payload.scheduled) {
|
if can_schedule(&payload.scheduled) {
|
||||||
let mut scheduled_message = textsender_models::message::scheduling::ScheduledMessage {
|
let mut scheduled_message = textsender_models::message::scheduling::ScheduledMessage {
|
||||||
user_id: payload.user_id,
|
scheduled: payload.scheduled,
|
||||||
|
status: payload.status,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
match scheduling_repo::insert(&pool, &scheduled_message, &payload.user_id).await {
|
match scheduling_repo::insert(&pool, &scheduled_message, &payload.user_id).await {
|
||||||
Ok((id, created)) => {
|
Ok((id, created)) => {
|
||||||
scheduled_message.id = id;
|
scheduled_message.id = id;
|
||||||
scheduled_message.created = Some(created);
|
scheduled_message.created = Some(created);
|
||||||
|
scheduled_message.user_id = payload.user_id;
|
||||||
response.message = String::from("Message scheduled");
|
response.message = String::from("Message scheduled");
|
||||||
|
response.data.push(scheduled_message);
|
||||||
(axum::http::StatusCode::CREATED, axum::Json(response))
|
(axum::http::StatusCode::CREATED, axum::Json(response))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ pub mod endpoints {
|
|||||||
/// Constant for getting messages endpoint
|
/// Constant for getting messages endpoint
|
||||||
pub const GET_MESSAGE: &str = "/api/v1/message";
|
pub const GET_MESSAGE: &str = "/api/v1/message";
|
||||||
/// Constant for scheduling message endpoint
|
/// Constant for scheduling message endpoint
|
||||||
pub const SCHEDULE_MESSAGE: &str = "api/v1/schedule/message";
|
pub const SCHEDULE_MESSAGE: &str = "/api/v1/schedule/message";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ pub mod init {
|
|||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
crate::caller::endpoints::SCHEDULE_MESSAGE,
|
crate::caller::endpoints::SCHEDULE_MESSAGE,
|
||||||
get(scheduling_endpoints::schedule_message).route_layer(axum::middleware::from_fn(
|
post(scheduling_endpoints::schedule_message).route_layer(axum::middleware::from_fn(
|
||||||
crate::auth::auth::<axum::body::Body>,
|
crate::auth::auth::<axum::body::Body>,
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user