Files
NodeBB/src/messaging/delete.js

27 lines
602 B
JavaScript
Raw Normal View History

2015-12-15 14:10:32 +02:00
'use strict';
var async = require('async');
var db = require('../database');
module.exports = function (Messaging) {
Messaging.deleteMessage = function (mid, roomId, callback) {
2015-12-15 14:10:32 +02:00
async.waterfall([
function (next) {
Messaging.getUidsInRoom(roomId, 0, -1, next);
},
function (uids, next) {
if (!uids.length) {
return next();
}
var keys = uids.map(function (uid) {
2017-08-21 16:39:24 -04:00
return 'uid:' + uid + ':chat:room:' + roomId + ':mids';
2015-12-15 14:10:32 +02:00
});
2017-08-21 16:48:18 -04:00
db.sortedSetsRemove(keys, mid, next);
2015-12-15 14:10:32 +02:00
},
function (next) {
2015-12-15 14:10:32 +02:00
db.delete('message:' + mid, next);
2017-02-17 19:31:21 -07:00
},
2015-12-15 14:10:32 +02:00
], callback);
};
2017-02-18 02:30:48 -07:00
};