Skip to content

Node.js based forum software built for the modern web

fix: proper attachment generation on replies, fixed replies getting thumb attachment when it wasn't part of it

Julian Lam69c5f94193fa
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index 19a20991c1..7aad23fb6f 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -735,12 +735,21 @@ Mocks.notes.public = async (post) => {
const plaintext = posts.sanitizePlaintext(content);
const isArticle = post.pid === post.topic.mainPid && plaintext.length > 500;
- const thumbs = await topics.thumbs.get(post.tid);
- thumbs.forEach(({ name, path }) => {
- const mediaType = mime.getType(name);
- const url = `${nconf.get('url') + nconf.get('upload_url')}${path}`;
- attachment.push({ mediaType, url });
- });
+ if (post.isMainPost) {
+ const thumbs = await topics.thumbs.get(post.tid);
+ thumbs.forEach(({ name, path }) => {
+ const mediaType = mime.getType(name);
+ const url = `${nconf.get('url') + nconf.get('upload_url')}${path}`;
+ attachment.push({ mediaType, url });
+ });
+ } else {
+ const uploads = await posts.uploads.listWithSizes(post.pid);
+ uploads.forEach(({ name, width, height }) => {
+ const mediaType = mime.getType(name);
+ const url = `${nconf.get('url') + nconf.get('upload_url')}${name}`;
+ attachment.push({ mediaType, url, width, height });
+ });
+ }
// Inspect post content for external imagery as well
let match = posts.imgRegex.exec(post.content);