mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
minor tweaks
This commit is contained in:
@@ -43,12 +43,15 @@ var winston = require('winston'),
|
||||
|
||||
async.parallel({
|
||||
post: function(next) {
|
||||
posts.setPostFields(data.pid, {
|
||||
var d = {
|
||||
edited: Date.now(),
|
||||
editor: data.uid,
|
||||
handle: data.handle,
|
||||
content: postData.content
|
||||
}, next);
|
||||
};
|
||||
if (data.handle) {
|
||||
d.handle = data.handle;
|
||||
}
|
||||
posts.setPostFields(data.pid, d, next);
|
||||
},
|
||||
topic: function(next) {
|
||||
var tid = postData.tid;
|
||||
|
||||
@@ -14,7 +14,6 @@ module.exports = function(Posts) {
|
||||
Posts.create = function(data, callback) {
|
||||
var uid = data.uid,
|
||||
tid = data.tid,
|
||||
handle = data.uid ? null : data.handle, // Only guests have handles!
|
||||
content = data.content,
|
||||
timestamp = data.timestamp || Date.now();
|
||||
|
||||
@@ -51,8 +50,8 @@ module.exports = function(Posts) {
|
||||
postData.ip = data.ip;
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
postData.handle = handle;
|
||||
if (parseInt(uid, 10) === 0 && data.handle) {
|
||||
postData.handle = data.handle;
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:post.save', postData, next);
|
||||
|
||||
@@ -155,7 +155,7 @@ module.exports = function(Topics) {
|
||||
});
|
||||
},
|
||||
topicData: function(next) {
|
||||
Topics.getTopicsByTids([postData.tid], 0, next);
|
||||
Topics.getTopicsByTids([postData.tid], uid, next);
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
|
||||
@@ -108,15 +108,15 @@ module.exports = function(Topics) {
|
||||
posts.getPostIndices(postData, uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
postData = postData.map(function(postObj, i) {
|
||||
postData.forEach(function(postObj, i) {
|
||||
if (postObj) {
|
||||
postObj.index = results.indices[i];
|
||||
postObj.deleted = parseInt(postObj.deleted, 10) === 1;
|
||||
postObj.user = _.clone(results.userData[postObj.uid]);
|
||||
postObj.user = parseInt(postObj.uid, 10) ? results.userData[postObj.uid] : _.clone(results.userData[postObj.uid]);
|
||||
postObj.editor = postObj.editor ? results.editors[postObj.editor] : null;
|
||||
postObj.favourited = results.favourites[i];
|
||||
postObj.upvoted = results.voteData.upvotes[i];
|
||||
@@ -135,9 +135,7 @@ module.exports = function(Topics) {
|
||||
postObj.user.username = postObj.handle;
|
||||
}
|
||||
}
|
||||
|
||||
return postObj;
|
||||
}).filter(Boolean);
|
||||
});
|
||||
|
||||
callback(null, postData);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user