summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2020-12-05 00:30:10 +0100
committerSanto Cariotti <santo@dcariotti.me>2020-12-05 00:30:10 +0100
commitf7fc1d5dfd8f5ca2aac10554ef13f6ecb082f998 (patch)
treecf919223ba2452c7544abdecc57f689f1b83db45 /src
parentfcd222a0fc8731bb34e46dd5f7948a7f84156100 (diff)
fix: person to give the gift to
AFFECTED AREA: Email body ROOT CAUSE: Printed name of sender FIX: Retrieve name from mapped `HashMap` members
Diffstat (limited to 'src')
-rw-r--r--src/main.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index a6db4e7..b30231a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -91,13 +91,18 @@ fn main() {
.credentials(creds)
.build();
- for (email, name) in members.into_iter() {
+ for (email, name) in members.iter() {
loop {
match my_gift_to(&mut emails) {
- Some(gift_to) => {
- if gift_to.to_string() != email.to_string()
- && !done.iter().any(|v| v == gift_to)
+ Some(gift_to_email) => {
+ if gift_to_email.to_string() != email.to_string()
+ && !done.iter().any(|v| v == gift_to_email)
{
+ let gift_to_name;
+ match members.get(&gift_to_email[..]) {
+ Some(v) => gift_to_name = v,
+ None => continue
+ }
let mail = Message::builder()
.from(
format!("{} <{}>", config_name, config_email)
@@ -106,13 +111,13 @@ fn main() {
)
.to(format!("{} <{}>", name, email).parse().unwrap())
.subject("Secret Santa!")
- .body(format!("You're the Secret Santa of:\n{}", name))
+ .body(format!("You're the Secret Santa of:\n{}", gift_to_name))
.unwrap();
match mailer.send(&mail) {
Ok(_) => println!("Email sent successfully to {}!", email),
Err(e) => panic!("Could not send email: {:?}", e),
}
- done.push(gift_to.to_string());
+ done.push(gift_to_email.to_string());
break;
}
}