Code cleanup

This commit is contained in:
2026-06-21 21:11:38 -04:00
parent 2a894e582c
commit 1b376248d3
+12 -47
View File
@@ -81,21 +81,21 @@ pub mod endpoint {
match message_repo::get(&pool, &payload.message_id).await {
Ok(message) => {
println!("Valid message");
let t_config = match load_config().await {
Ok(config) => config,
Err(err) => {
eprintln!("Error: {err:?}");
response.message = String::from("Error getting config");
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
);
}
};
let t_config =
match textsender_models::config::auxiliary::load_config().await {
Ok(config) => config,
Err(err) => {
eprintln!("Error: {err:?}");
response.message = String::from("Error getting config");
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
);
}
};
let mut results: Vec<
textsender_models::message::event::MessageEventResponse,
> = Vec::new();
// let mut results: Vec<serde_json::Value> = Vec::new();
let pp = swoosh::twilio::types::Parameters {
schedule: false,
schedule_at: None,
@@ -108,9 +108,7 @@ pub mod endpoint {
.await
{
Ok(result) => {
println!("Response: {result:?}");
let val = swoosh::twilio::api::response_to_json(result).await;
// results.push(val);
let mer = textsender_models::message::event::MessageEventResponse {
user_id: payload.user_id,
// TODO: Make this more accurate
@@ -170,37 +168,4 @@ pub mod endpoint {
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
async fn load_config()
-> Result<textsender_models::config::auxiliary::TwilioConfig, std::io::Error> {
let mut config = textsender_models::config::auxiliary::TwilioConfig {
..Default::default()
};
let auth_sid_var = textsender_models::envy::environment::get_env("TWILIO_AUTH_SID").await;
println!("{auth_sid_var:?}");
let service_sid_var =
textsender_models::envy::environment::get_env("TWILIO_SERVICE_SID").await;
println!("{service_sid_var:?}");
let auth_token_var =
textsender_models::envy::environment::get_env("TWILIO_AUTH_TOKEN").await;
println!("{auth_token_var:?}");
let phone_number_var =
textsender_models::envy::environment::get_env("TWILIO_PHONE_NUMBER").await;
println!("{phone_number_var:?}");
if auth_sid_var.value.is_empty()
|| service_sid_var.value.is_empty()
|| auth_token_var.value.is_empty()
|| phone_number_var.value.is_empty()
{
Err(std::io::Error::other("Config not set"))
} else {
config.account_sid = auth_sid_var.value;
config.service_sid = service_sid_var.value;
config.auth_token = auth_token_var.value;
config.phone_number = phone_number_var.value;
Ok(config)
}
}
}