var path = require('path'); var database = require(path.join(__dirname, '../../database.js')); module.exports = class NotificationNotice { getData(params, cb) { let query = `SELECT LOWER(ct.code) countryCode, c.email recipient, nc.name categoryName, recipient.name recipientName, sender.name senderName FROM client c JOIN account.user recipient ON recipient.id = c.id JOIN country ct ON ct.id = c.countryFk JOIN noticeCategory nc ON nc.keyName = ? JOIN account.user sender ON sender.id = ? WHERE c.id = ?`; database.pool.query(query, [params.category, params.sender, params.recipient], (error, result) => { if (error || result.length == 0) return cb({status: 'REJECT', data: {message: 'No data found', error: error}}); Object.assign(this, result[0]); this.message = params.message; cb({status: 'ACCEPT', data: {}}); }); } };