feat: send result to multiple email addresses
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -5,6 +5,7 @@ use chrono::{self, Timelike};
|
|||||||
use dotenv;
|
use dotenv;
|
||||||
use ipaddress;
|
use ipaddress;
|
||||||
use itertools::{self, Itertools};
|
use itertools::{self, Itertools};
|
||||||
|
use lettre::message::Mailboxes;
|
||||||
use lettre::{self, message};
|
use lettre::{self, message};
|
||||||
use reqwest;
|
use reqwest;
|
||||||
use serde_json::{self, json};
|
use serde_json::{self, json};
|
||||||
@@ -317,6 +318,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
}).reduce(|acc, e|{format!("{}\n{}",acc,e)})
|
}).reduce(|acc, e|{format!("{}\n{}",acc,e)})
|
||||||
.unwrap_or("".to_string());
|
.unwrap_or("".to_string());
|
||||||
|
|
||||||
|
// return Ok(());
|
||||||
// Open file and write to it
|
// Open file and write to it
|
||||||
let header = "NOME;ID_TALK;TEMPO DE RESPOSTA;TRANFERENCIA PELO BOT;PRIMEIRA RESPOSTA DO AGENTE";
|
let header = "NOME;ID_TALK;TEMPO DE RESPOSTA;TRANFERENCIA PELO BOT;PRIMEIRA RESPOSTA DO AGENTE";
|
||||||
let mut response_time_file = std::fs::OpenOptions::new().write(true).open(format!("./evaluations/{formatted_day_before}/response_time.csv")).expect("Failed to open response time file for write");
|
let mut response_time_file = std::fs::OpenOptions::new().write(true).open(format!("./evaluations/{formatted_day_before}/response_time.csv")).expect("Failed to open response time file for write");
|
||||||
@@ -325,7 +327,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
filtered_chats
|
filtered_chats
|
||||||
.clone()
|
.clone()
|
||||||
.skip(0)
|
.skip(0)
|
||||||
.take(15)
|
.take(10)
|
||||||
.for_each(|result| {
|
.for_each(|result| {
|
||||||
let json = result.unwrap();
|
let json = result.unwrap();
|
||||||
let talk_histories = &json["talk_histories"];
|
let talk_histories = &json["talk_histories"];
|
||||||
@@ -400,7 +402,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
&formatted_day_before,
|
&formatted_day_before,
|
||||||
&BOT_EMAIL,
|
&BOT_EMAIL,
|
||||||
&BOT_EMAIL_PASSWORD,
|
&BOT_EMAIL_PASSWORD,
|
||||||
"Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>",
|
"Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Isadora Moura de Moura <isadora.moura@nova.net.br>",
|
||||||
&output_zip_file_str,
|
&output_zip_file_str,
|
||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -592,11 +594,13 @@ fn send_email(
|
|||||||
let filebody = std::fs::read(zip_file_name).unwrap();
|
let filebody = std::fs::read(zip_file_name).unwrap();
|
||||||
let content_type = ContentType::parse("application/zip").unwrap();
|
let content_type = ContentType::parse("application/zip").unwrap();
|
||||||
let attachment = Attachment::new(zip_file_name.to_string()).body(filebody, content_type);
|
let attachment = Attachment::new(zip_file_name.to_string()).body(filebody, content_type);
|
||||||
|
let mailboxes : Mailboxes = to.parse().unwrap();
|
||||||
|
let to_header: message::header::To = mailboxes.into();
|
||||||
|
|
||||||
let email = Message::builder()
|
let email = Message::builder()
|
||||||
.from(format!("PipeRUN bot <{bot_email}>").parse().unwrap())
|
.from(format!("PipeRUN bot <{bot_email}>").parse().unwrap())
|
||||||
.reply_to(format!("PipeRUN bot <{bot_email}>").parse().unwrap())
|
.reply_to(format!("PipeRUN bot <{bot_email}>").parse().unwrap())
|
||||||
.to(format!("{to}").parse().unwrap())
|
.mailbox(to_header)
|
||||||
.subject(format!("Avaliacao atendimentos {day_before}"))
|
.subject(format!("Avaliacao atendimentos {day_before}"))
|
||||||
.multipart(
|
.multipart(
|
||||||
MultiPart::mixed()
|
MultiPart::mixed()
|
||||||
|
|||||||
Reference in New Issue
Block a user