Added API method to delete subscribers

This commit is contained in:
Andris Reinman 2016-06-24 14:29:07 +03:00
parent eab46d758a
commit c72f03ff5e
4 changed files with 125 additions and 1 deletions

View file

@ -531,6 +531,34 @@ module.exports.getById = (listId, id, callback) => {
});
};
module.exports.getByEmail = (listId, email, callback) => {
if (!email) {
return callback(new Error('Missing Subbscription email address'));
}
db.getConnection((err, connection) => {
if (err) {
return callback(err);
}
connection.query('SELECT * FROM `subscription__' + listId + '` WHERE email=?', [email], (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);
});
});
};
module.exports.getWithMergeTags = (listId, cid, callback) => {
module.exports.get(listId, cid, (err, subscription) => {
if (err) {