Skip to content

Node.js based forum software built for the modern web

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

Julian Lam94feb9090ef8
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index f0a1f061dd..0625aaf9b4 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -183,11 +183,14 @@ inbox.update = async (req) => {
postData.tags = await activitypub.notes._normalizeTags(postData._activitypub.tag, postData.cid);
await posts.edit(postData);
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'}`);
+ }
}
const isDeleted = await posts.getPostField(object.id, 'deleted');
if (isDeleted) {