From 13315b8b726a3de4662bc34d157f44724f4ef726 Mon Sep 17 00:00:00 2001 From: Shamil Mingaliev Date: Fri, 13 Dec 2019 16:32:17 +0300 Subject: [PATCH] [ST] syntax fixes --- lib/models/subscriptions.js | 7 +++---- lib/tools.js | 16 ++++++++-------- services/sender.js | 7 +++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/models/subscriptions.js b/lib/models/subscriptions.js index 3b9a0125..e11d2631 100644 --- a/lib/models/subscriptions.js +++ b/lib/models/subscriptions.js @@ -353,14 +353,13 @@ module.exports.getWithMergeTags = (listId, cid, callback) => { return fieldList = []; } - subscription.mergeTags = { + subscription.mergeTags = Object.assign({ EMAIL: subscription.email, FIRST_NAME: subscription.firstName, LAST_NAME: subscription.lastName, FULL_NAME: [].concat(subscription.firstName || []).concat(subscription.lastName || []).join(' '), - TIMEZONE: subscription.tz || '', - ...tools.artstationMergeTags(subscription), - }; + TIMEZONE: subscription.tz || '' + }, tools.artstationMergeTags(subscription)); fields.getRow(fieldList, subscription, false, true).forEach(field => { if (field.mergeTag) { diff --git a/lib/tools.js b/lib/tools.js index 523b4496..2928d081 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -326,13 +326,13 @@ function mergeTemplateIntoLayout(template, layout, callback) { } function artstationMergeTags(subscription) { - const iv = crypto.randomBytes(16) - const cipher = crypto.createCipheriv('aes-256-cbc', process.env.ARTSTATION_SECRET, iv) - let encrypted_email = cipher.update(subscription.email, 'utf8', 'hex') - encrypted_email += cipher.final('hex') + const iv = crypto.randomBytes(16); + const cipher = crypto.createCipheriv('aes-256-cbc', process.env.ARTSTATION_SECRET, iv); + let encrypted_email = cipher.update(subscription.email, 'utf8', 'hex'); + encrypted_email += cipher.final('hex'); - return { - ENCRYPTED_EMAIL: encrypted_email, - IV: iv.toString('hex'), - } + return { + ENCRYPTED_EMAIL: encrypted_email, + IV: iv.toString('hex'), + }; } diff --git a/services/sender.js b/services/sender.js index 4226af8b..7da6b397 100644 --- a/services/sender.js +++ b/services/sender.js @@ -324,13 +324,12 @@ function formatMessage(message, callback) { return callback(err); } - message.subscription.mergeTags = { + message.subscription.mergeTags = Object.assign({ EMAIL: message.subscription.email, FIRST_NAME: message.subscription.firstName, LAST_NAME: message.subscription.lastName, - FULL_NAME: [].concat(message.subscription.firstName || []).concat(message.subscription.lastName || []).join(' '), - ...tools.artstationMergeTags(message.subscription), - }; + FULL_NAME: [].concat(message.subscription.firstName || []).concat(message.subscription.lastName || []).join(' ') + }, tools.artstationMergeTags(message.subscription)); let encryptionKeys = []; fields.getRow(fieldList, message.subscription, false, true).forEach(field => {