mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 01:45:47 +01:00
first part of messaging refactor
This commit is contained in:
27
src/messaging/delete.js
Normal file
27
src/messaging/delete.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var db = require('../database');
|
||||
|
||||
module.exports = function(Messaging) {
|
||||
|
||||
Messaging.deleteMessage = function(mid, roomId, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Messaging.getUidsInRoom(roomId, 0, -1, next);
|
||||
},
|
||||
function (uids, next) {
|
||||
if (!uids.length) {
|
||||
return next();
|
||||
}
|
||||
var keys = uids.map(function(uid) {
|
||||
return 'uid:' + uid + ':chat:room:' + roomId + 'mids';
|
||||
});
|
||||
db.sortedSetsRemove(keys, roomId, next);
|
||||
},
|
||||
function(next) {
|
||||
db.delete('message:' + mid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user