Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send company name in sender name if present #37

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading