Moved Merge Tag Helpers to helpers.js

… to satisfy ESLint top-level module scope.
This commit is contained in:
witzig 2017-03-04 21:50:44 +01:00
parent d9c1d8e595
commit 8fdb2840c4
4 changed files with 81 additions and 75 deletions

View file

@ -20,8 +20,6 @@ module.exports = {
formatMessage,
getMessageLinks,
prepareHtml,
getDefaultMergeTags,
getListMergeTags,
workers: new Set()
};
@ -224,73 +222,3 @@ function prepareHtml(html, callback) {
return callback(null, juice(preparedHtml));
});
}
function getDefaultMergeTags(callback) {
// Using a callback for the sake of future-proofness
callback(null, [
{
key: 'LINK_UNSUBSCRIBE',
value: 'URL that points to the unsubscribe page'
}, {
key: 'LINK_PREFERENCES',
value: 'URL that points to the preferences page of the subscriber'
}, {
key: 'LINK_BROWSER',
value: 'URL to preview the message in a browser'
}, {
key: 'EMAIL',
value: 'Email address'
}, {
key: 'FIRST_NAME',
value: 'First name'
}, {
key: 'LAST_NAME',
value: 'Last name'
}, {
key: 'FULL_NAME',
value: 'Full name (first and last name combined)'
}, {
key: 'SUBSCRIPTION_ID',
value: 'Unique ID that identifies the recipient'
}, {
key: 'LIST_ID',
value: 'Unique ID that identifies the list used for this campaign'
}, {
key: 'CAMPAIGN_ID',
value: 'Unique ID that identifies current campaign'
}
]);
}
function getListMergeTags(listId, callback) {
let lists = require('./models/lists');
let fields = require('./models/fields');
lists.get(listId, (err, list) => {
if (err) {
return callback(err);
}
if (!list) {
list = {
id: listId
};
}
fields.list(list.id, (err, fieldList) => {
if (err && !fieldList) {
fieldList = [];
}
let mergeTags = [];
fieldList.forEach(field => {
mergeTags.push({
key: field.key,
value: field.name
});
});
return callback(null, mergeTags);
});
});
}