Skip to content
Snippets Groups Projects
Commit b6e0208e authored by Marvin Weiler's avatar Marvin Weiler
Browse files

Fixed compile errors

parent bcbd1ca8
No related branches found
No related tags found
No related merge requests found
......@@ -25,14 +25,14 @@ struct Config {
#[tokio::main]
async fn main() {
let config = Config::read_config();
let filters = config.filters;
let filters = &config.filters;
let products = get_html_products().await.unwrap();
let filtered: Vec<Product> = products
.into_iter()
.filter(|el| {
for s in &filters {
for s in filters {
if el.name.contains(s) {
return el.available;
}
......@@ -43,17 +43,18 @@ async fn main() {
if filtered.len() > 0 {
println!("Found {} products.\nSending mail.", filtered.len());
send_email(filtered);
send_email(config, filtered);
} else {
println!("Sorry, all products are out of stock. :/");
}
}
async fn get_html_products() -> Result<Vec<Product>, CmdError> {
println!("Fetching items from amd Website");
// start the geckodriver
let mut geckodriver = Command::new("sh")
.arg("-c")
.arg("./geckodriver")
.arg("./geckodriver --log fatal")
.spawn()
.expect("sh command failed to start geckodriver");
......@@ -118,10 +119,10 @@ fn send_email(config: Config, products: Vec<Product>) -> () {
.parse()
.expect(format!("To adress: {} is invalid", recipient).as_str()))
.subject("Products are available at the AMD website")
.body(message)
.body(String::from(&message))
.expect("Failed to construct email message");
let creds = Credentials::new(config.smtp_user, config.smtp_pass);
let creds = Credentials::new(config.smtp_user.to_string(), config.smtp_pass.to_string());
let mailer = SmtpTransport::relay(&config.smtp_host)
.expect("Failed to connect to mailerver")
.credentials(creds)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment