mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #5510
This commit is contained in:
@@ -146,6 +146,24 @@ topicsController.get = function (req, res, callback) {
|
|||||||
next(null, data.topicData);
|
next(null, data.topicData);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
function (topicData, next) {
|
||||||
|
if (!topicData.deleterUid) {
|
||||||
|
return next(null, topicData);
|
||||||
|
}
|
||||||
|
|
||||||
|
user.getUserFields(topicData.deleterUid, ['username', 'userslug'], function(err, deleter) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
topicData.deleter = deleter;
|
||||||
|
topicData.deleter.timestampISO = topicData.deletedTimestampISO
|
||||||
|
delete topicData.deleterUid;
|
||||||
|
delete topicData.deletedTimestampISO;
|
||||||
|
|
||||||
|
next(null, topicData);
|
||||||
|
});
|
||||||
|
},
|
||||||
function (topicData, next) {
|
function (topicData, next) {
|
||||||
function findPost(index) {
|
function findPost(index) {
|
||||||
for (var i = 0; i < topicData.posts.length; i += 1) {
|
for (var i = 0; i < topicData.posts.length; i += 1) {
|
||||||
|
|||||||
@@ -86,4 +86,8 @@ module.exports = function (Topics) {
|
|||||||
Topics.deleteTopicField = function (tid, field, callback) {
|
Topics.deleteTopicField = function (tid, field, callback) {
|
||||||
db.deleteObjectField('topic:' + tid, field, callback);
|
db.deleteObjectField('topic:' + tid, field, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Topics.deleteTopicFields = function (tid, fields, callback) {
|
||||||
|
db.deleteObjectFields('topic:' + tid, fields, callback);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function (next) {
|
function (next) {
|
||||||
Topics.setTopicField(tid, 'deleted', 1, next);
|
Topics.setTopicFields(tid, {
|
||||||
|
deleted: 1,
|
||||||
|
deleterUid: uid,
|
||||||
|
deletedTimestampISO: (new Date()).toISOString()
|
||||||
|
}, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetsRemove(['topics:recent', 'topics:posts', 'topics:views'], tid, next);
|
db.sortedSetsRemove(['topics:recent', 'topics:posts', 'topics:views'], tid, next);
|
||||||
@@ -47,6 +51,9 @@ module.exports = function (Topics) {
|
|||||||
function (next) {
|
function (next) {
|
||||||
Topics.setTopicField(tid, 'deleted', 0, next);
|
Topics.setTopicField(tid, 'deleted', 0, next);
|
||||||
},
|
},
|
||||||
|
function (next) {
|
||||||
|
Topics.deleteTopicFields(tid, ['deleterUid', 'deletedTimestampISO'], next);
|
||||||
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Topics.updateRecent(tid, topicData.lastposttime, next);
|
Topics.updateRecent(tid, topicData.lastposttime, next);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user