diff --git a/lib/models/subscriptions.js b/lib/models/subscriptions.js index 5a538f13..5b159c89 100644 --- a/lib/models/subscriptions.js +++ b/lib/models/subscriptions.js @@ -193,18 +193,23 @@ module.exports.subscribe = (cid, optInIp, callback) => { optInIp, optInCountry, status: 1 - }, subscription, err => { + }, subscription, (err, result) => { if (err) { return callback(err); } + if (!result.entryId) { + return callback(new Error('Could not save subscription')); + } + db.getConnection((err, connection) => { if (err) { return callback(err); } connection.query('DELETE FROM confirmations WHERE `cid`=? LIMIT 1', [cid], () => { connection.release(); - callback(null, subscription); + // reload full data from db in case it was an update, not insert + return module.exports.getById(listId, result.entryId, callback); }); }); }); @@ -371,6 +376,38 @@ module.exports.get = (listId, cid, callback) => { } let subscription = tools.convertKeys(rows[0]); + // ensure list id in response + subscription.list = subscription.list || listId; + return callback(null, subscription); + }); + }); +}; + +module.exports.getById = (listId, id, callback) => { + id = Number(id) || 0; + + if (!id) { + return callback(new Error('Missing Subbscription ID')); + } + + db.getConnection((err, connection) => { + if (err) { + return callback(err); + } + + connection.query('SELECT * FROM `subscription__' + listId + '` WHERE id=?', [id], (err, rows) => { + connection.release(); + if (err) { + return callback(err); + } + + if (!rows || !rows.length) { + return callback(null, false); + } + + let subscription = tools.convertKeys(rows[0]); + // ensure list id in response + subscription.list = subscription.list || listId; return callback(null, subscription); }); }); diff --git a/routes/segments.js b/routes/segments.js index f9c5d48d..7ca1937b 100644 --- a/routes/segments.js +++ b/routes/segments.js @@ -236,7 +236,6 @@ router.get('/:list/rules/:segment/create', passport.csrfProtection, (req, res) = segment.csrfToken = req.csrfToken(); - console.log(segment); segment.list = list; res.render('lists/segments/rule-create', segment); diff --git a/routes/webhooks.js b/routes/webhooks.js index 331b95f6..7dc3bc37 100644 --- a/routes/webhooks.js +++ b/routes/webhooks.js @@ -152,8 +152,6 @@ router.post('/sparkpost', (req, res, next) => { }); router.post('/sendgrid', (req, res, next) => { - console.log(require('util').inspect(req.body, false, 22)); // eslint-disable-line - let events = [].concat(req.body || []); let pos = 0; diff --git a/services/feedcheck.js b/services/feedcheck.js index 6cd96298..660bcc63 100644 --- a/services/feedcheck.js +++ b/services/feedcheck.js @@ -46,7 +46,7 @@ function feedLoop() { message = 'Feed error: ' + err.message; } else if (result) { log.verbose('Feed', 'Added %s new campaigns for %s', result, parent.id); - message = 'Found ' + result + ' new campaing messages from feed'; + message = 'Found ' + result + ' new campaign messages from feed'; } else { message = 'Found nothing new from the feed'; } diff --git a/views/campaigns/view.hbs b/views/campaigns/view.hbs index 6fa800d2..5ecbb8e2 100644 --- a/views/campaigns/view.hbs +++ b/views/campaigns/view.hbs @@ -42,6 +42,16 @@ {{#if isRss}}
Feed URL
{{sourceUrl}}
+
Last check
+
+ {{#if lastCheck}}{{lastCheck}}{{else}} + Not yet checked{{/if}} + {{#unless isActive}}(feed is only checked if RSS campaign is active){{/unless}} +
+ {{#if checkStatus}} +
RSS status
+
{{checkStatus}}
+ {{/if}} {{/if}}
Email "from name"
diff --git a/views/emails/confirm-html.hbs b/views/emails/confirm-html.hbs index 92b3dcbd..2e9cb0cd 100644 --- a/views/emails/confirm-html.hbs +++ b/views/emails/confirm-html.hbs @@ -7,11 +7,17 @@ @@ -101,10 +107,10 @@ body {
-

{{title}}

+

{{title}}

Please Confirm Subscription

-

Yes, subscribe me to this list

+

Yes, subscribe me to this list

If you received this email by mistake, simply delete it. You won't be subscribed if you don't click the confirmation link above.

diff --git a/views/emails/password-reset-html.hbs b/views/emails/password-reset-html.hbs index 5fe8dd2f..cadbcc21 100644 --- a/views/emails/password-reset-html.hbs +++ b/views/emails/password-reset-html.hbs @@ -7,11 +7,17 @@ @@ -100,12 +106,10 @@ body {
- -

Change your password

- +

Change your password

We have received a password change request for your Mailtrain account {{username}}.

-

Reset password

+

Reset password

If you did not ask to change your password, then you can ignore this email and your password will not be changed.

diff --git a/views/emails/subscription-confirmed-html.hbs b/views/emails/subscription-confirmed-html.hbs index 241c42cf..9496d6a0 100644 --- a/views/emails/subscription-confirmed-html.hbs +++ b/views/emails/subscription-confirmed-html.hbs @@ -7,11 +7,17 @@ @@ -100,9 +106,7 @@ body {
- -

{{title}}

- +

{{title}}

Your subscription to our list has been confirmed.

@@ -110,9 +114,9 @@ body {

- manage your preferences - or - unsubscribe here + manage your preferences + or + unsubscribe here

For questions about this list, please contact: diff --git a/views/emails/unsubscribe-confirmed-html.hbs b/views/emails/unsubscribe-confirmed-html.hbs index 69c4fbef..2554a993 100644 --- a/views/emails/unsubscribe-confirmed-html.hbs +++ b/views/emails/unsubscribe-confirmed-html.hbs @@ -7,11 +7,17 @@ @@ -100,16 +106,14 @@ body {

- -

{{title}}

- +

{{title}}

We have removed your email address from our list.

If you unsubscribed by mistake, you can re-subscribe at:

-

Subscribe

+

Subscribe

For questions about this list, please contact:
{{contactAddress}}