Closes: https://github.com/fleetdm/confidential/issues/16057 Changes: - Added `email-application-submitted`, an email template that is used to reply to users who fill out the "Apply" form - Updated the `deliver-application-submission` action to return an `invalidEmailDomain` response if a user's email address is on the bannedEmailDomainsForContactFormSubmissions list, and to send a "Thank you for applying to Fleet" email to the user who submitted the form. - Stubbed a new custom config variable: `applicationReplyEmailAddress` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Applicants receive a "Thanks for applying to Fleet" confirmation email with a personalized greeting and ~7-day expectation. * Added an application-submitted email template and preview using the email layout. * **Improvements** * Added a hidden honeypot field to the application form; submissions with it filled are silently discarded. * Added email-domain validation with a specific form error and clearer error rendering. * Redirected jobs to the internal handbook open-positions section. * **Chores** * Added a commented placeholder for an application reply email setting. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
127 lines
3.4 KiB
JavaScript
Vendored
127 lines
3.4 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Deliver application submission',
|
|
|
|
|
|
description: 'Delivers form submissions from the application form on the contact page to a Zapier webhook.',
|
|
|
|
|
|
inputs: {
|
|
|
|
firstName: {
|
|
required: true,
|
|
type: 'string',
|
|
description: 'The first name of the applicant.',
|
|
},
|
|
|
|
lastName: {
|
|
required: true,
|
|
type: 'string',
|
|
description: 'The last name of the applicant.',
|
|
},
|
|
|
|
emailAddress: {
|
|
required: true,
|
|
isEmail: true,
|
|
type: 'string',
|
|
description: 'A return email address where we can respond.',
|
|
},
|
|
|
|
position: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'The open position this applicant is applying for.'
|
|
},
|
|
|
|
linkedinProfileUrl: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'The URL of the applicant\'s LinkedIn profile.'
|
|
},
|
|
|
|
location: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'The location of the applicant'
|
|
},
|
|
|
|
message: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'The applican\'ts cover letter in plain text.',
|
|
},
|
|
|
|
websiteUrl: {
|
|
type: 'string',
|
|
description: 'Honeypot field. If filled, the submission is silently discarded.'
|
|
}
|
|
|
|
},
|
|
|
|
|
|
exits: {
|
|
success: {
|
|
description: 'A job application was successfully submitted.',
|
|
},
|
|
invalidEmailDomain: {
|
|
description: 'This email address is on a denylist of domains and was not delivered.',
|
|
responseType: 'badRequest'
|
|
},
|
|
},
|
|
|
|
|
|
fn: async function ({ firstName, lastName, emailAddress, position, linkedinProfileUrl, location, message, websiteUrl}) {
|
|
|
|
if (websiteUrl) { return; }// Honeypot input provided — return a success response
|
|
|
|
let emailDomain = emailAddress.split('@')[1];
|
|
if(_.includes(sails.config.custom.bannedEmailDomainsForContactFormSubmissions, emailDomain.toLowerCase())){
|
|
throw 'invalidEmailDomain';
|
|
}
|
|
|
|
|
|
// Send the submitted information to a Zapier webhook.
|
|
await sails.helpers.http.post.with({
|
|
url: 'https://hooks.zapier.com/hooks/catch/3627242/uwc77dr/',
|
|
data: {
|
|
firstName,
|
|
lastName,
|
|
emailAddress,
|
|
position: position.replace(/🧑🚀|🚀|🌦️|🎐|🫧|🐋|🦢|🌐/, ''),// Remove the emoji from the job title.
|
|
linkedinProfileUrl,
|
|
location,
|
|
message,
|
|
webhookSecret: sails.config.custom.zapierWebhookSecret
|
|
}
|
|
})
|
|
.timeout(5000)
|
|
.tolerate(['non200Response', 'requestFailed', {name: 'TimeoutError'}], (err)=>{
|
|
// Note that Zapier responds with a 2xx status code even if something goes wrong, so just because this message is not logged doesn't mean everything is hunky dory. More info: https://github.com/fleetdm/fleet/pull/6380#issuecomment-1204395762
|
|
sails.log.warn(`When a user submitted the application form, an error occurred while sending a request to Zapier. Raw error: ${require('util').inspect(err)}`);
|
|
return;
|
|
});
|
|
|
|
|
|
// Send a "Thanks for applying to Fleet" email to the user who submitted the form.
|
|
await sails.helpers.sendTemplateEmail.with({
|
|
to: emailAddress,
|
|
subject: 'Thanks for applying to Fleet',
|
|
template: 'email-application-submitted',
|
|
layout: 'layout-email',
|
|
from: sails.config.custom.applicationReplyEmailAddress,
|
|
templateData: {
|
|
firstName: firstName,
|
|
},
|
|
ensureAck: true,
|
|
});
|
|
|
|
|
|
// All done.
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
};
|