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,32 +289,21 @@ async function addTags(topicData, req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function addOGImageTags(res, topicData, postAtIndex) {
|
async function addOGImageTags(res, topicData, postAtIndex) {
|
||||||
const images = [];
|
const uploads = postAtIndex ? await posts.uploads.listWithSizes(postAtIndex.pid) : [];
|
||||||
|
const images = uploads.map((upload) => {
|
||||||
async.series([
|
upload.name = nconf.get('url') + nconf.get('upload_url') + '/files/' + upload.name;
|
||||||
async function () {
|
return upload;
|
||||||
const uploads = await posts.uploads.listWithSizes(postAtIndex.pid);
|
|
||||||
uploads.forEach((upload) => {
|
|
||||||
upload.name = nconf.get('url') + nconf.get('upload_url') + '/files/' + upload.name;
|
|
||||||
images.push(upload);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function (next) {
|
|
||||||
if (topicData.thumb) {
|
|
||||||
images.push(topicData.thumb);
|
|
||||||
}
|
|
||||||
if (topicData.category.backgroundImage && (!postAtIndex || !postAtIndex.index)) {
|
|
||||||
images.push(topicData.category.backgroundImage);
|
|
||||||
}
|
|
||||||
if (postAtIndex && postAtIndex.user && postAtIndex.user.picture) {
|
|
||||||
images.push(postAtIndex.user.picture);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.nextTick(next);
|
|
||||||
},
|
|
||||||
], function () {
|
|
||||||
images.forEach(path => addOGImageTag(res, path));
|
|
||||||
});
|
});
|
||||||
|
if (topicData.thumb) {
|
||||||
|
images.push(topicData.thumb);
|
||||||
|
}
|
||||||
|
if (topicData.category.backgroundImage && (!postAtIndex || !postAtIndex.index)) {
|
||||||
|
images.push(topicData.category.backgroundImage);
|
||||||
|
}
|
||||||
|
if (postAtIndex && postAtIndex.user && postAtIndex.user.picture) {
|
||||||
|
images.push(postAtIndex.user.picture);
|
||||||
|
}
|
||||||
|
images.forEach(path => addOGImageTag(res, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOGImageTag(res, image) {
|
function addOGImageTag(res, image) {
|
||||||
|
|||||||
Reference in New Issue
Block a user