Skip to content

Node.js based forum software built for the modern web

fix: guard title regeneration in inbox.update behind posts.isMain

Julian Lam295cdef36435
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index 4fe734d256..b6ce91a6d7 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -244,11 +244,14 @@ inbox.update = async (req) => {
await posts.edit(postData);
await activitypub.feps.announce(object.id, req.body);
const tid = await posts.getPostField(object.id, 'tid');
- const { generatedTitle } = await topics.getTopicFields(tid, ['generatedTitle']);
- if (generatedTitle && (!postData.title || !postData.title.trim())) {
- const newTitle = activitypub.helpers.generateTitle(postData.sourceContent || postData.content);
- await topics.setTopicField(tid, 'title', newTitle);
- await topics.setTopicField(tid, 'slug', `${tid}/${slugify(newTitle) || 'topic'}`);
+ const isMain = await posts.isMain(object.id);
+ if (isMain) {
+ const { generatedTitle } = await topics.getTopicFields(tid, ['generatedTitle']);
+ if (generatedTitle && (!postData.title || !postData.title.trim())) {
+ const newTitle = activitypub.helpers.generateTitle(postData.sourceContent || postData.content);
+ await topics.setTopicField(tid, 'title', newTitle);
+ await topics.setTopicField(tid, 'slug', `${tid}/${slugify(newTitle) || 'topic'}`);
+ }
}
break;
}