Full support for message attachments

This commit is contained in:
Andris Reinman 2016-09-09 23:09:04 +03:00
parent bfc6983c93
commit 35bce32529
6 changed files with 229 additions and 106 deletions

View file

@ -374,7 +374,10 @@ module.exports.getAttachments = (campaign, callback) => {
if (err) {
return callback(err);
}
connection.query('SELECT `id`, `filename`, `size`, `created` FROM `attachments` WHERE `campaign`=?', [campaign], (err, rows) => {
let keys = ['id', 'filename', 'content_type', 'size', 'created'];
connection.query('SELECT `' + keys.join('`, `') + '` FROM `attachments` WHERE `campaign`=?', [campaign], (err, rows) => {
connection.release();
if (err) {
return callback(err);
@ -455,14 +458,14 @@ module.exports.deleteAttachment = (id, attachment, callback) => {
});
};
module.exports.getAttachment = (id, attachment, callback) => {
module.exports.getAttachment = (campaign, attachment, callback) => {
db.getConnection((err, connection) => {
if (err) {
return callback(err);
}
let query = 'SELECT `filename`, `content_type`, `content` FROM `attachments` WHERE `id`=? AND `campaign`=? LIMIT 1';
connection.query(query, [attachment, id], (err, rows) => {
let query = 'SELECT * FROM `attachments` WHERE `id`=? AND `campaign`=? LIMIT 1';
connection.query(query, [attachment, campaign], (err, rows) => {
connection.release();
if (err) {
return callback(err);