Code refactoring
This commit is contained in:
@@ -12,8 +12,6 @@ pub struct App {
|
||||
pub twilio_config: textsender_models::config::auxiliary::TwilioConfig,
|
||||
}
|
||||
|
||||
// TODO: Change this to non-async at some point.
|
||||
// Will require changes in other libraries
|
||||
pub fn load_app() -> Result<App, std::io::Error> {
|
||||
use textsender_models::envy;
|
||||
let auth_url_env = envy::environment::get_env("AUTH_URL");
|
||||
|
||||
+1
-27
@@ -5,7 +5,6 @@ pub struct Service {
|
||||
|
||||
impl Service {
|
||||
pub async fn do_the_work(&mut self) {
|
||||
println!("Do some work");
|
||||
println!("Checking queue");
|
||||
|
||||
use textsender_models::message::scheduling::ScheduledMessage;
|
||||
@@ -148,39 +147,14 @@ impl Service {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
todo!(
|
||||
r#"
|
||||
Need to finish this
|
||||
|
||||
[X] - This function should fetch a token, check if the token is valid, and obtain a refresh token if
|
||||
it has expired.
|
||||
|
||||
Then do the real work.
|
||||
|
||||
1. Check the queue - Done
|
||||
2. If there is an item, get the data - Done
|
||||
3. Evaluate if it is schedulable - Done
|
||||
4. Get the events and iterate each one - Done
|
||||
5. Starting with the message - Done
|
||||
6. Get the contact - Done
|
||||
7. Send the message
|
||||
8. Record the message event response - Added, not used
|
||||
9. Add to scheduler
|
||||
"#
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
fn is_schedulable(
|
||||
&self,
|
||||
queue_item: &textsender_models::message::scheduling::ScheduledMessage,
|
||||
) -> bool {
|
||||
let now = time::OffsetDateTime::now_utc();
|
||||
|
||||
match queue_item.scheduled {
|
||||
Some(date) => date > now,
|
||||
Some(date) => date > time::OffsetDateTime::now_utc(),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user