mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
closes #5133
This commit is contained in:
@@ -464,7 +464,7 @@ var utils = require('../public/src/utils');
|
|||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications[modifyIndex].path = set[set.length - 1].path;
|
notifications[modifyIndex].path = set[0].path;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'new_register':
|
case 'new_register':
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var _ = require('underscore');
|
|||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var topics = require('../topics');
|
var topics = require('../topics');
|
||||||
var user = require('../user');
|
var user = require('../user');
|
||||||
|
var notifications = require('../notifications');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
|
|
||||||
module.exports = function (Posts) {
|
module.exports = function (Posts) {
|
||||||
@@ -126,7 +127,7 @@ module.exports = function (Posts) {
|
|||||||
function (data, next) {
|
function (data, next) {
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function (next) {
|
function (next) {
|
||||||
deletePostFromTopicAndUser(pid, next);
|
deletePostFromTopicUserNotification(pid, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
deletePostFromCategoryRecentPosts(pid, next);
|
deletePostFromCategoryRecentPosts(pid, next);
|
||||||
@@ -138,18 +139,7 @@ module.exports = function (Posts) {
|
|||||||
deletePostFromUsersVotes(pid, next);
|
deletePostFromUsersVotes(pid, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Posts.getPostField(pid, 'toPid', function (err, toPid) {
|
deletePostFromReplies(pid, next);
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
if (!parseInt(toPid, 10)) {
|
|
||||||
return next(null);
|
|
||||||
}
|
|
||||||
async.parallel([
|
|
||||||
async.apply(db.sortedSetRemove, 'pid:' + toPid + ':replies', pid),
|
|
||||||
async.apply(db.decrObjectField, 'post:' + toPid, 'replies')
|
|
||||||
], next);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetsRemove(['posts:pid', 'posts:flagged'], pid, next);
|
db.sortedSetsRemove(['posts:pid', 'posts:flagged'], pid, next);
|
||||||
@@ -168,26 +158,24 @@ module.exports = function (Posts) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
function deletePostFromTopicAndUser(pid, callback) {
|
function deletePostFromTopicUserNotification(pid, callback) {
|
||||||
Posts.getPostFields(pid, ['tid', 'uid'], function (err, postData) {
|
var postData;
|
||||||
if (err) {
|
async.waterfall([
|
||||||
return callback(err);
|
function (next) {
|
||||||
}
|
Posts.getPostFields(pid, ['tid', 'uid'], next);
|
||||||
|
},
|
||||||
|
function (_postData, next) {
|
||||||
|
postData = _postData;
|
||||||
db.sortedSetsRemove([
|
db.sortedSetsRemove([
|
||||||
'tid:' + postData.tid + ':posts',
|
'tid:' + postData.tid + ':posts',
|
||||||
'tid:' + postData.tid + ':posts:votes',
|
'tid:' + postData.tid + ':posts:votes',
|
||||||
'uid:' + postData.uid + ':posts'
|
'uid:' + postData.uid + ':posts'
|
||||||
], pid, function (err) {
|
], pid, next);
|
||||||
if (err) {
|
},
|
||||||
return callback(err);
|
function (next) {
|
||||||
}
|
topics.getTopicFields(postData.tid, ['tid', 'cid', 'pinned'], next);
|
||||||
|
},
|
||||||
topics.getTopicFields(postData.tid, ['tid', 'cid', 'pinned'], function (err, topicData) {
|
function (topicData, next) {
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.decrObjectField('global', 'postCount', next);
|
db.decrObjectField('global', 'postCount', next);
|
||||||
@@ -212,10 +200,14 @@ module.exports = function (Posts) {
|
|||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
user.incrementUserPostCountBy(postData.uid, -1, next);
|
user.incrementUserPostCountBy(postData.uid, -1, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
notifications.rescind('new_post:tid:' + postData.tid + ':pid:' + pid + ':uid:' + postData.uid, next);
|
||||||
}
|
}
|
||||||
], callback);
|
], next);
|
||||||
});
|
}
|
||||||
});
|
], function (err) {
|
||||||
|
callback(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,4 +280,20 @@ module.exports = function (Posts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deletePostFromReplies(pid, callback) {
|
||||||
|
Posts.getPostField(pid, 'toPid', function (err, toPid) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
if (!parseInt(toPid, 10)) {
|
||||||
|
return callback(null);
|
||||||
|
}
|
||||||
|
async.parallel([
|
||||||
|
async.apply(db.sortedSetRemove, 'pid:' + toPid + ':replies', pid),
|
||||||
|
async.apply(db.decrObjectField, 'post:' + toPid, 'replies')
|
||||||
|
], callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user