Skip to content

Node.js based forum software built for the modern web

refactor: load tid once

Barış Soner Uşaklı98cb25828c4e
diff --git a/src/posts/uploads.js b/src/posts/uploads.js
index bfb46d46bc..c0daa32bd3 100644
--- a/src/posts/uploads.js
+++ b/src/posts/uploads.js
@@ -58,7 +58,7 @@ module.exports = function (Posts) {
// Scans a post's content and updates sorted set of uploads
const [postData, isMainPost] = await Promise.all([
- Posts.getPostFields(pid, ['content', 'uploads']),
+ Posts.getPostFields(pid, ['tid', 'content', 'uploads']),
Posts.isMain(pid),
]);
@@ -75,8 +75,7 @@ module.exports = function (Posts) {
// Main posts can contain topic thumbs, which are also tracked by pid
if (isMainPost) {
- const tid = await Posts.getPostField(pid, 'tid');
- let thumbs = await topics.thumbs.get(tid, { thumbsOnly: true });
+ let thumbs = await topics.thumbs.get(postData.tid, { thumbsOnly: true });
thumbs = thumbs.map(thumb => thumb.path).filter(path => !validator.isURL(path, {
require_protocol: true,
}));