mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46: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 db = require('../database');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
const privileges = require('../privileges');
|
const privileges = require('../privileges');
|
||||||
|
const categories = require('../categories');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
const topics = require('../topics');
|
const topics = require('../topics');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
@@ -192,10 +193,16 @@ Notes.assertTopic = async (uid, id) => {
|
|||||||
|
|
||||||
let tags;
|
let tags;
|
||||||
if (!hasTid) {
|
if (!hasTid) {
|
||||||
|
const systemTags = (meta.config.systemTags || '').split(',');
|
||||||
|
const maxTags = cid > 0 ? await categories.getCategoryField(cid, 'maxTags') : null;
|
||||||
tags = (mainPost._activitypub.tag || [])
|
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));
|
.map(o => o.name.slice(1));
|
||||||
|
|
||||||
|
if (maxTags) {
|
||||||
|
tags.length = maxTags;
|
||||||
|
}
|
||||||
|
|
||||||
await topics.post({
|
await topics.post({
|
||||||
tid,
|
tid,
|
||||||
uid: authorId,
|
uid: authorId,
|
||||||
|
|||||||
Reference in New Issue
Block a user