mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
change the way group member posts are stored
This commit is contained in:
@@ -6,6 +6,7 @@ var _ = require('underscore');
|
||||
var db = require('../database');
|
||||
var topics = require('../topics');
|
||||
var user = require('../user');
|
||||
var groups = require('../groups');
|
||||
var notifications = require('../notifications');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
@@ -141,6 +142,9 @@ module.exports = function (Posts) {
|
||||
function (next) {
|
||||
deletePostFromReplies(pid, next);
|
||||
},
|
||||
function (next) {
|
||||
deletePostFromGroups(pid, next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetsRemove(['posts:pid', 'posts:flagged'], pid, next);
|
||||
},
|
||||
@@ -294,4 +298,27 @@ module.exports = function (Posts) {
|
||||
], callback);
|
||||
});
|
||||
}
|
||||
|
||||
function deletePostFromGroups(pid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Posts.getPostField(pid, 'uid', next);
|
||||
},
|
||||
function (uid, next) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback();
|
||||
}
|
||||
groups.getUserGroupMembership('groups:visible:createtime', [uid], next);
|
||||
},
|
||||
function (groupNames, next) {
|
||||
groupNames = groupNames[0];
|
||||
var keys = groupNames.map(function (groupName) {
|
||||
return 'group:' + groupName + ':member:pids';
|
||||
});
|
||||
|
||||
db.sortedSetsRemove(keys, pid, next);
|
||||
},
|
||||
], callback);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user