RSS campaigns
This commit is contained in:
parent
2486f7b9d8
commit
8bc85a0b63
9 changed files with 92 additions and 30 deletions
|
@ -193,18 +193,23 @@ module.exports.subscribe = (cid, optInIp, callback) => {
|
||||||
optInIp,
|
optInIp,
|
||||||
optInCountry,
|
optInCountry,
|
||||||
status: 1
|
status: 1
|
||||||
}, subscription, err => {
|
}, subscription, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!result.entryId) {
|
||||||
|
return callback(new Error('Could not save subscription'));
|
||||||
|
}
|
||||||
|
|
||||||
db.getConnection((err, connection) => {
|
db.getConnection((err, connection) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
connection.query('DELETE FROM confirmations WHERE `cid`=? LIMIT 1', [cid], () => {
|
connection.query('DELETE FROM confirmations WHERE `cid`=? LIMIT 1', [cid], () => {
|
||||||
connection.release();
|
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]);
|
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);
|
return callback(null, subscription);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -236,7 +236,6 @@ router.get('/:list/rules/:segment/create', passport.csrfProtection, (req, res) =
|
||||||
|
|
||||||
segment.csrfToken = req.csrfToken();
|
segment.csrfToken = req.csrfToken();
|
||||||
|
|
||||||
console.log(segment);
|
|
||||||
segment.list = list;
|
segment.list = list;
|
||||||
|
|
||||||
res.render('lists/segments/rule-create', segment);
|
res.render('lists/segments/rule-create', segment);
|
||||||
|
|
|
@ -152,8 +152,6 @@ router.post('/sparkpost', (req, res, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/sendgrid', (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 events = [].concat(req.body || []);
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ function feedLoop() {
|
||||||
message = 'Feed error: ' + err.message;
|
message = 'Feed error: ' + err.message;
|
||||||
} else if (result) {
|
} else if (result) {
|
||||||
log.verbose('Feed', 'Added %s new campaigns for %s', result, parent.id);
|
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 {
|
} else {
|
||||||
message = 'Found nothing new from the feed';
|
message = 'Found nothing new from the feed';
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,16 @@
|
||||||
{{#if isRss}}
|
{{#if isRss}}
|
||||||
<dt>Feed URL</dt>
|
<dt>Feed URL</dt>
|
||||||
<dd><a href="{{sourceUrl}}">{{sourceUrl}}</a></dd>
|
<dd><a href="{{sourceUrl}}">{{sourceUrl}}</a></dd>
|
||||||
|
<dt>Last check</dt>
|
||||||
|
<dd>
|
||||||
|
{{#if lastCheck}}<span class="datestring" data-date="{{lastCheck}}" title="{{lastCheck}}">{{lastCheck}}</span>{{else}}
|
||||||
|
Not yet checked{{/if}}
|
||||||
|
{{#unless isActive}}<span class="text-muted">(feed is only checked if RSS campaign is active)</span>{{/unless}}
|
||||||
|
</dd>
|
||||||
|
{{#if checkStatus}}
|
||||||
|
<dt>RSS status</dt>
|
||||||
|
<dd>{{checkStatus}}</dd>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<dt>Email "from name"</dt>
|
<dt>Email "from name"</dt>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue