From 7aa56c727b0ca3716b46c167d6e0ba7e69141685 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 14 Mar 2024 13:17:26 -0400 Subject: [PATCH] fix: filter out system tags and prune extra tags beyond number allowed, when creating topic from remote data --- src/activitypub/notes.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 10d35ca80a..8b9318b08e 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -6,6 +6,7 @@ const crypto = require('crypto'); const db = require('../database'); const meta = require('../meta'); const privileges = require('../privileges'); +const categories = require('../categories'); const user = require('../user'); const topics = require('../topics'); const posts = require('../posts'); @@ -192,10 +193,16 @@ Notes.assertTopic = async (uid, id) => { let tags; if (!hasTid) { + const systemTags = (meta.config.systemTags || '').split(','); + const maxTags = cid > 0 ? await categories.getCategoryField(cid, 'maxTags') : null; tags = (mainPost._activitypub.tag || []) - .filter(o => o.type === 'Hashtag') + .filter(o => o.type === 'Hashtag' && !systemTags.include(o.name.slice(1))) .map(o => o.name.slice(1)); + if (maxTags) { + tags.length = maxTags; + } + await topics.post({ tid, uid: authorId,