mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
closes #3259
This commit is contained in:
@@ -39,14 +39,14 @@ module.exports = function(db, module) {
|
|||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) {
|
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) {
|
||||||
if(err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var map = helpers.toMap(data);
|
var map = helpers.toMap(data);
|
||||||
var returnData = [];
|
var returnData = [];
|
||||||
|
|
||||||
for(var i=0; i<keys.length; ++i) {
|
for (var i=0; i<keys.length; ++i) {
|
||||||
returnData.push(map[keys[i]]);
|
returnData.push(map[keys[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ module.exports = function(Posts) {
|
|||||||
var title = data.title.trim();
|
var title = data.title.trim();
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
cid: function(next) {
|
topic: function(next) {
|
||||||
topics.getTopicField(tid, 'cid', next);
|
topics.getTopicFields(tid, ['cid', 'title'], next);
|
||||||
},
|
},
|
||||||
isMain: function(next) {
|
isMain: function(next) {
|
||||||
Posts.isMain(data.pid, next);
|
Posts.isMain(data.pid, next);
|
||||||
@@ -92,14 +92,15 @@ module.exports = function(Posts) {
|
|||||||
if (!results.isMain) {
|
if (!results.isMain) {
|
||||||
return callback(null, {
|
return callback(null, {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
cid: results.cid,
|
cid: results.topic.cid,
|
||||||
isMainPost: false
|
isMainPost: false,
|
||||||
|
renamed: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var topicData = {
|
var topicData = {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
cid: results.cid,
|
cid: results.topic.cid,
|
||||||
uid: postData.uid,
|
uid: postData.uid,
|
||||||
mainPid: data.pid
|
mainPid: data.pid
|
||||||
};
|
};
|
||||||
@@ -131,11 +132,13 @@ module.exports = function(Posts) {
|
|||||||
plugins.fireHook('action:topic.edit', topicData);
|
plugins.fireHook('action:topic.edit', topicData);
|
||||||
next(null, {
|
next(null, {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
cid: results.cid,
|
cid: results.topic.cid,
|
||||||
uid: postData.uid,
|
uid: postData.uid,
|
||||||
title: validator.escape(title),
|
title: validator.escape(title),
|
||||||
|
oldTitle: results.topic.title,
|
||||||
slug: topicData.slug,
|
slug: topicData.slug,
|
||||||
isMainPost: results.isMain,
|
isMainPost: true,
|
||||||
|
renamed: title !== results.topic.title,
|
||||||
tags: tags
|
tags: tags
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,6 +303,16 @@ SocketPosts.edit = function(socket, data, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.topic.renamed) {
|
||||||
|
events.log({
|
||||||
|
type: 'topic-rename',
|
||||||
|
uid: socket.uid,
|
||||||
|
ip: socket.ip,
|
||||||
|
oldTitle: result.topic.oldTitle,
|
||||||
|
newTitle: result.topic.title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (parseInt(result.post.deleted) !== 1) {
|
if (parseInt(result.post.deleted) !== 1) {
|
||||||
websockets.in('topic_' + result.topic.tid).emit('event:post_edited', result);
|
websockets.in('topic_' + result.topic.tid).emit('event:post_edited', result);
|
||||||
return callback(null, result.post);
|
return callback(null, result.post);
|
||||||
|
|||||||
Reference in New Issue
Block a user