mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
e381c3fe52
* create NewsletterSubscription Model * create subscribe and unsubcribe actions, update cloud-sdk, policies & routes * Add newsletter email layout * add newsletter form, update styles and page script * Update cloud.setup.js * lint fixes * Update homepage.less * unsubscribe-from-newsletter » unsubscribe-from-all-newsletters * remove unused exit * comment out unused attributes, update assets/.eslintrc * update layout * update layout after updating from main * Update actions and routes * lint fix
57 lines
1.2 KiB
JavaScript
Vendored
57 lines
1.2 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Create or update one newsletter subscription',
|
|
|
|
|
|
description: 'Creates or updates a NewsletterSubscription record for the provided email address',
|
|
|
|
|
|
inputs: {
|
|
emailAddress: {
|
|
type: 'string',
|
|
required: true,
|
|
},
|
|
|
|
subscribeTo: {
|
|
type: 'string',
|
|
required: true,
|
|
description: 'The type of content that this user is changing their subscription for',
|
|
isIn: ['releases']
|
|
}
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
description: 'A user has successfully changed their subscription to the Fleet newsletter'
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function ({emailAddress, subscribeTo}) {
|
|
|
|
|
|
await NewsletterSubscription.create({emailAddress: emailAddress})
|
|
.tolerate('E_UNIQUE');
|
|
|
|
let argins = {};
|
|
|
|
// Update the NewsletterSubscription record for this email address with `isSubscribedTo____` boolean attributes based on the subscribeTo input
|
|
if(subscribeTo === 'releases') {
|
|
argins.isSubscribedToReleases = true;
|
|
}
|
|
// FUTURE: Handle more types of subscribeTo inputs
|
|
|
|
await NewsletterSubscription.updateOne({emailAddress: emailAddress}).set(argins);
|
|
|
|
// All done.
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
};
|