fleet/website/api/controllers/view-contact.js
Eric 9fdb2d0511
Website: update contact form for Fleet premium subscribers (#26361)
Changes:
- Updated the contact page to only display the "Send a message" form for
users who have a Fleet premium subscription
- Updated the deliver-contact-form-message action to include details
about a user's subscription if the user has purchased a Fleet premium
license, and to also send an email to our support email address (in
addition to sending a message to our Slack)
2025-02-17 13:35:53 -06:00

53 lines
966 B
JavaScript
Vendored

module.exports = {
friendlyName: 'View contact',
description: 'Display "Contact" page.',
inputs: {
sendMessage: {
type: 'boolean',
description: 'A boolean that determines whether or not to display the talk to us form when the contact page loads.',
defaultsTo: false,
},
},
exits: {
success: {
viewTemplatePath: 'pages/contact'
}
},
fn: async function ({sendMessage}) {
let formToShow = 'talk-to-us';
let userIsLoggedIn = !! this.req.me;
let userHasPremiumSubscription = false;
if(userIsLoggedIn) {
let thisSubscription = await Subscription.findOne({user: this.req.me.id});
if(thisSubscription){
formToShow = 'contact';
userHasPremiumSubscription = true;
}
}
if(sendMessage) {
formToShow = 'contact';
}
// Respond with view.
return {
formToShow,
userIsLoggedIn,
userHasPremiumSubscription
};
}
};