mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: filter out system tags and prune extra tags beyond number allowed, when creating topic from remote data
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user