cargo fmt
catapult PR / Check (pull_request) Failing after 28s
catapult PR / Rustfmt (pull_request) Successful in 50s
catapult PR / Clippy (pull_request) Failing after 51s

This commit is contained in:
2026-06-21 22:34:45 -04:00
parent a0724de553
commit da17bab18b
3 changed files with 29 additions and 26 deletions
+21 -21
View File
@@ -1,18 +1,17 @@
/// Seconds to sleep after finising a task
pub const SECONDS_TO_SLEEP: u64 = 5;
pub const APP_NAME: &str = "catapult";
pub struct App {
pub api_url: String,
pub auth_url: String,
pub service_username: String,
pub service_passphrase: String,
pub twilio_config: textsender_models::config::auxiliary::TwilioConfig,
pub api_url: String,
pub auth_url: String,
pub service_username: String,
pub service_passphrase: String,
pub twilio_config: textsender_models::config::auxiliary::TwilioConfig,
}
// TODO: Change this to non-async at some point.
// TODO: Change this to non-async at some point.
// Will require changes in other libraries
pub async fn load_app() -> Result<App, std::io::Error> {
use textsender_models::envy;
@@ -21,7 +20,12 @@ pub async fn load_app() -> Result<App, std::io::Error> {
let service_username_env = envy::environment::get_env("SERVICE_USERNAME").await;
let service_passphrase_env = envy::environment::get_env("SERVICE_PASSPHRASE").await;
let envs = vec![auth_url_env, api_url_env, service_username_env, service_passphrase_env];
let envs = vec![
auth_url_env,
api_url_env,
service_username_env,
service_passphrase_env,
];
let check_envs = |vs: &Vec<envy::EnvVar>| -> (bool, Option<String>) {
for env in vs {
@@ -33,21 +37,17 @@ pub async fn load_app() -> Result<App, std::io::Error> {
};
let (envs_valid, reason) = check_envs(&envs);
if envs_valid {
match textsender_models::config::auxiliary::load_config().await {
Ok(twilio_config) => {
Ok(App {
api_url: String::new(),
auth_url: String::new(),
service_username: String::new(),
service_passphrase: String::new(),
twilio_config: twilio_config
})
}
Err(err) => {
Err(err)
}
Ok(twilio_config) => Ok(App {
api_url: String::new(),
auth_url: String::new(),
service_username: String::new(),
service_passphrase: String::new(),
twilio_config: twilio_config,
}),
Err(err) => Err(err),
}
} else {
Err(std::io::Error::other(reason.unwrap()))
+4 -1
View File
@@ -16,6 +16,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
loop {
catapult::service::do_the_work(&app).await;
tokio::time::sleep(tokio::time::Duration::from_secs(catapult::app::SECONDS_TO_SLEEP)).await;
tokio::time::sleep(tokio::time::Duration::from_secs(
catapult::app::SECONDS_TO_SLEEP,
))
.await;
}
}
+4 -4
View File
@@ -1,8 +1,7 @@
pub async fn do_the_work(_app: &crate::app::App) {
println!("Do some work");
todo!(r#"
todo!(
r#"
Need to finish this
This function should fetch a token, check if the token is valid, and obtain a refresh token if
@@ -18,5 +17,6 @@ pub async fn do_the_work(_app: &crate::app::App) {
6. Get the contact
7. Send the message
8. Record the message event response
"#);
"#
);
}