mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
merge
This commit is contained in:
@@ -86,7 +86,7 @@ topicsController.get = function(req, res, next) {
|
|||||||
function (topicData, next) {
|
function (topicData, next) {
|
||||||
var description = '';
|
var description = '';
|
||||||
|
|
||||||
if(topicData.posts.length) {
|
if (topicData.posts[0] && topicData.posts[0].content) {
|
||||||
description = S(topicData.posts[0].content).stripTags().decodeHTMLEntities().s;
|
description = S(topicData.posts[0].content).stripTags().decodeHTMLEntities().s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ topicsController.get = function(req, res, next) {
|
|||||||
var ogImageUrl = '';
|
var ogImageUrl = '';
|
||||||
if (topicData.thumb) {
|
if (topicData.thumb) {
|
||||||
ogImageUrl = topicData.thumb;
|
ogImageUrl = topicData.thumb;
|
||||||
} else if(topicData.posts.length && topicData.posts[0].user && topicData.posts[0].user.picture){
|
} else if(topicData.posts.length && topicData.posts[0] && topicData.posts[0].user && topicData.posts[0].user.picture){
|
||||||
ogImageUrl = topicData.posts[0].user.picture;
|
ogImageUrl = topicData.posts[0].user.picture;
|
||||||
} else if(meta.config['brand:logo']) {
|
} else if(meta.config['brand:logo']) {
|
||||||
ogImageUrl = meta.config['brand:logo'];
|
ogImageUrl = meta.config['brand:logo'];
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ var async = require('async'),
|
|||||||
if (!data || !Array.isArray(data.posts)) {
|
if (!data || !Array.isArray(data.posts)) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
|
data.posts = data.posts.filter(Boolean);
|
||||||
callback(null, data.posts);
|
callback(null, data.posts);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ module.exports = function(Topics) {
|
|||||||
Topics.addPostData = function(postData, uid, callback) {
|
Topics.addPostData = function(postData, uid, callback) {
|
||||||
var pids = postData.map(function(post) {
|
var pids = postData.map(function(post) {
|
||||||
return post && post.pid;
|
return post && post.pid;
|
||||||
}).filter(Boolean);
|
});
|
||||||
|
|
||||||
if (!Array.isArray(pids) || !pids.length) {
|
if (!Array.isArray(pids) || !pids.length) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
@@ -56,7 +56,7 @@ module.exports = function(Topics) {
|
|||||||
var uids = [];
|
var uids = [];
|
||||||
|
|
||||||
for(var i=0; i<postData.length; ++i) {
|
for(var i=0; i<postData.length; ++i) {
|
||||||
if (uids.indexOf(postData[i].uid) === -1) {
|
if (postData[i] && uids.indexOf(postData[i].uid) === -1) {
|
||||||
uids.push(postData[i].uid);
|
uids.push(postData[i].uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ module.exports = function(Topics) {
|
|||||||
editors: function(next) {
|
editors: function(next) {
|
||||||
var editors = [];
|
var editors = [];
|
||||||
for(var i=0; i<postData.length; ++i) {
|
for(var i=0; i<postData.length; ++i) {
|
||||||
if (postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
|
if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
|
||||||
editors.push(postData[i].editor);
|
editors.push(postData[i].editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ module.exports = function(Topics) {
|
|||||||
var editorData = {};
|
var editorData = {};
|
||||||
editors.forEach(function(editor) {
|
editors.forEach(function(editor) {
|
||||||
editorData[editor.uid] = editor;
|
editorData[editor.uid] = editor;
|
||||||
})
|
});
|
||||||
next(null, editorData);
|
next(null, editorData);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -105,20 +105,21 @@ module.exports = function(Topics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < postData.length; ++i) {
|
for (var i = 0; i < postData.length; ++i) {
|
||||||
postData[i].index = results.indices[i];
|
if (postData[i]) {
|
||||||
postData[i].deleted = parseInt(postData[i].deleted, 10) === 1;
|
postData[i].deleted = parseInt(postData[i].deleted, 10) === 1;
|
||||||
postData[i].user = results.userData[postData[i].uid];
|
postData[i].user = results.userData[postData[i].uid];
|
||||||
postData[i].editor = postData[i].editor ? results.editors[postData[i].editor] : null;
|
postData[i].editor = postData[i].editor ? results.editors[postData[i].editor] : null;
|
||||||
postData[i].favourited = results.favourites[i];
|
postData[i].favourited = results.favourites[i];
|
||||||
postData[i].upvoted = results.voteData.upvotes[i];
|
postData[i].upvoted = results.voteData.upvotes[i];
|
||||||
postData[i].downvoted = results.voteData.downvotes[i];
|
postData[i].downvoted = results.voteData.downvotes[i];
|
||||||
postData[i].votes = postData[i].votes || 0;
|
postData[i].votes = postData[i].votes || 0;
|
||||||
postData[i].display_moderator_tools = results.privileges[i].editable;
|
postData[i].display_moderator_tools = results.privileges[i].editable;
|
||||||
postData[i].display_move_tools = results.privileges[i].move && postData[i].index !== 0;
|
postData[i].display_move_tools = results.privileges[i].move && postData[i].index !== 0;
|
||||||
postData[i].selfPost = parseInt(uid, 10) === parseInt(postData[i].uid, 10);
|
postData[i].selfPost = parseInt(uid, 10) === parseInt(postData[i].uid, 10);
|
||||||
|
|
||||||
if(postData[i].deleted && !results.privileges[i].view_deleted) {
|
if(postData[i].deleted && !results.privileges[i].view_deleted) {
|
||||||
postData[i].content = '[[topic:post_is_deleted]]';
|
postData[i].content = '[[topic:post_is_deleted]]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user