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
+19 -19
View File
@@ -1,15 +1,14 @@
/// Seconds to sleep after finising a task /// Seconds to sleep after finising a task
pub const SECONDS_TO_SLEEP: u64 = 5; pub const SECONDS_TO_SLEEP: u64 = 5;
pub const APP_NAME: &str = "catapult"; pub const APP_NAME: &str = "catapult";
pub struct App { pub struct App {
pub api_url: String, pub api_url: String,
pub auth_url: String, pub auth_url: String,
pub service_username: String, pub service_username: String,
pub service_passphrase: String, pub service_passphrase: String,
pub twilio_config: textsender_models::config::auxiliary::TwilioConfig, 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.
@@ -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_username_env = envy::environment::get_env("SERVICE_USERNAME").await;
let service_passphrase_env = envy::environment::get_env("SERVICE_PASSPHRASE").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>) { let check_envs = |vs: &Vec<envy::EnvVar>| -> (bool, Option<String>) {
for env in vs { for env in vs {
@@ -36,18 +40,14 @@ pub async fn load_app() -> Result<App, std::io::Error> {
if envs_valid { if envs_valid {
match textsender_models::config::auxiliary::load_config().await { match textsender_models::config::auxiliary::load_config().await {
Ok(twilio_config) => { Ok(twilio_config) => Ok(App {
Ok(App { api_url: String::new(),
api_url: String::new(), auth_url: String::new(),
auth_url: String::new(), service_username: String::new(),
service_username: String::new(), service_passphrase: String::new(),
service_passphrase: String::new(), twilio_config: twilio_config,
twilio_config: twilio_config }),
}) Err(err) => Err(err),
}
Err(err) => {
Err(err)
}
} }
} else { } else {
Err(std::io::Error::other(reason.unwrap())) 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 { loop {
catapult::service::do_the_work(&app).await; 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) { pub async fn do_the_work(_app: &crate::app::App) {
println!("Do some work"); println!("Do some work");
todo!(r#" todo!(
r#"
Need to finish this Need to finish this
This function should fetch a token, check if the token is valid, and obtain a refresh token if 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 6. Get the contact
7. Send the message 7. Send the message
8. Record the message event response 8. Record the message event response
"#); "#
);
} }