Added API method to delete subscribers
This commit is contained in:
parent
eab46d758a
commit
c72f03ff5e
4 changed files with 125 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue