Skip to content

Commit

Permalink
Merge pull request #37 from mainmatter/send-company-in-name
Browse files Browse the repository at this point in the history
send company name in sender name if present
  • Loading branch information
marcoow authored Aug 7, 2024
2 parents a643473 + 0be4ebd commit 6035960
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ where
} else {
"".to_owned()
};
let mut subject = if !service.is_empty() && service.to_lowercase() != "other" {

let subject = if !service.is_empty() && service.to_lowercase() != "other" {
format!("Mainmatter inquiry for {service}")
} else {
"Mainmatter inquiry".to_owned()
};

subject = if let Some(company) = payload.company {
format!("{} from {}", subject, company)
let name = if let Some(company) = payload.company {
format!("{} ({}) via mainmatter.com", payload.name, company)
} else {
subject
format!("{} via mainmatter.com", payload.name)
};

let data = json!({
Expand All @@ -96,7 +97,7 @@ where
{ "email": zapier_email }
]
}],
"from": { "email": "[email protected]", "name": format!("{} via mainmatter.com", payload.name) },
"from": { "email": "[email protected]", "name": name },
"reply_to": { "email": payload.email, "name": payload.name },
"subject": subject,
"content": [{
Expand Down
4 changes: 2 additions & 2 deletions tests/send_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ async fn it_adds_company_to_the_subject_if_one_is_provided() {
{ "email": "[email protected]" }
]
}],
"from": { "email": "[email protected]", "name": "name via mainmatter.com" },
"from": { "email": "[email protected]", "name": "name (Company) via mainmatter.com" },
"reply_to": { "email": "[email protected]", "name": "name" },
"subject": "Mainmatter inquiry from Company",
"subject": "Mainmatter inquiry",
"content": [{
"type": "text/plain",
"value": "Hi!"
Expand Down

0 comments on commit 6035960

Please sign in to comment.