Work in progress on subscriptions
This commit is contained in:
parent
eecb3cd067
commit
b22a87e712
18 changed files with 1729 additions and 884 deletions
|
@ -16,6 +16,53 @@ async function listDTAjax(context, params) {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
module.exports.get = (start, limit, search, callback) => {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
search = '%' + search + '%';
|
||||
connection.query('SELECT SQL_CALC_FOUND_ROWS `email` FROM blacklist WHERE `email` LIKE ? ORDER BY `email` LIMIT ? OFFSET ?', [search, limit, start], (err, rows) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
connection.query('SELECT FOUND_ROWS() AS total', (err, total) => {
|
||||
connection.release();
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
let emails = [];
|
||||
rows.forEach(email => {
|
||||
emails.push(email.email);
|
||||
});
|
||||
return callback(null, emails, total && total[0] && total[0].total);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
*/
|
||||
|
||||
async function search(context, start, limit, search) {
|
||||
return await knex.transaction(async tx => {
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
|
||||
search = '%' + search + '%';
|
||||
|
||||
const count = await tx('blacklist').where('email', 'like', search).count();
|
||||
// FIXME - the count won't likely work;
|
||||
console.log(count);
|
||||
|
||||
const rows = await tx('blacklist').where('email', 'like', search).offset(start).limit(limit);
|
||||
|
||||
return {
|
||||
emails: rows.map(row => row.email),
|
||||
total: count
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function add(context, email) {
|
||||
return await knex.transaction(async tx => {
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
|
@ -56,6 +103,7 @@ module.exports = {
|
|||
listDTAjax,
|
||||
add,
|
||||
remove,
|
||||
search,
|
||||
isBlacklisted,
|
||||
serverValidate
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue