v1.11.0
This commit is contained in:
parent
3fa0e109af
commit
9bd6db2624
13 changed files with 201 additions and 51 deletions
|
@ -40,6 +40,44 @@ module.exports.list = (listId, start, limit, callback) => {
|
|||
});
|
||||
};
|
||||
|
||||
module.exports.listTestUsers = (listId, callback) => {
|
||||
listId = Number(listId) || 0;
|
||||
|
||||
if (listId < 1) {
|
||||
return callback(new Error('Missing List ID'));
|
||||
}
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
connection.query('SELECT id, cid, email, first_name, last_name FROM `subscription__' + listId + '` WHERE is_test=1 LIMIT 100', (err, rows) => {
|
||||
connection.release();
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!rows || !rows.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
let subscribers = rows.map(subscriber => {
|
||||
subscriber = tools.convertKeys(subscriber);
|
||||
let fullName = [].concat(subscriber.firstName || []).concat(subscriber.lastName || []).join(' ');
|
||||
if (fullName) {
|
||||
subscriber.displayName = fullName + ' <' + subscriber.email + '>';
|
||||
} else {
|
||||
subscriber.displayName = subscriber.email;
|
||||
}
|
||||
return subscriber;
|
||||
});
|
||||
return callback(null, subscribers);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports.filter = (listId, request, columns, segmentId, callback) => {
|
||||
listId = Number(listId) || 0;
|
||||
segmentId = Number(segmentId) || 0;
|
||||
|
@ -291,13 +329,16 @@ module.exports.insert = (listId, meta, subscription, callback) => {
|
|||
let keys = [];
|
||||
let values = [];
|
||||
|
||||
let allowedKeys = ['first_name', 'last_name', 'tz'];
|
||||
let allowedKeys = ['first_name', 'last_name', 'tz', 'is_test'];
|
||||
Object.keys(subscription).forEach(key => {
|
||||
let value = subscription[key];
|
||||
key = tools.toDbKey(key);
|
||||
if (key === 'tz') {
|
||||
value = (value || '').toString().toLowerCase().trim();
|
||||
}
|
||||
if (key === 'is_test') {
|
||||
value = value ? '1' : '0';
|
||||
}
|
||||
if (allowedKeys.indexOf(key) >= 0) {
|
||||
keys.push(key);
|
||||
values.push(value);
|
||||
|
@ -551,7 +592,7 @@ module.exports.update = (listId, cid, updates, allowEmail, callback) => {
|
|||
return callback(err);
|
||||
}
|
||||
|
||||
let allowedKeys = ['first_name', 'last_name', 'tz'];
|
||||
let allowedKeys = ['first_name', 'last_name', 'tz', 'is_test'];
|
||||
|
||||
if (allowEmail) {
|
||||
allowedKeys.unshift('email');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue