mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: remove async.series, dont crash if postAtIndex is undefined
This commit is contained in:
@@ -289,17 +289,11 @@ async function addTags(topicData, req, res) {
|
||||
}
|
||||
|
||||
async function addOGImageTags(res, topicData, postAtIndex) {
|
||||
const images = [];
|
||||
|
||||
async.series([
|
||||
async function () {
|
||||
const uploads = await posts.uploads.listWithSizes(postAtIndex.pid);
|
||||
uploads.forEach((upload) => {
|
||||
const uploads = postAtIndex ? await posts.uploads.listWithSizes(postAtIndex.pid) : [];
|
||||
const images = uploads.map((upload) => {
|
||||
upload.name = nconf.get('url') + nconf.get('upload_url') + '/files/' + upload.name;
|
||||
images.push(upload);
|
||||
return upload;
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
if (topicData.thumb) {
|
||||
images.push(topicData.thumb);
|
||||
}
|
||||
@@ -309,12 +303,7 @@ async function addOGImageTags(res, topicData, postAtIndex) {
|
||||
if (postAtIndex && postAtIndex.user && postAtIndex.user.picture) {
|
||||
images.push(postAtIndex.user.picture);
|
||||
}
|
||||
|
||||
process.nextTick(next);
|
||||
},
|
||||
], function () {
|
||||
images.forEach(path => addOGImageTag(res, path));
|
||||
});
|
||||
}
|
||||
|
||||
function addOGImageTag(res, image) {
|
||||
|
||||
Reference in New Issue
Block a user