mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	feat: native parsing of title for topics
This commit is contained in:
		| @@ -5,6 +5,7 @@ const winston = require('winston'); | ||||
| const db = require('../database'); | ||||
| const topics = require('../topics'); | ||||
| const posts = require('../posts'); | ||||
| const utils = require('../utils'); | ||||
|  | ||||
| const activitypub = module.parent.exports; | ||||
| const Notes = module.exports; | ||||
| @@ -91,7 +92,7 @@ Notes.assertTopic = async (uid, id) => { | ||||
| 	 */ | ||||
|  | ||||
| 	const chain = Array.from(await Notes.getParentChain(uid, id)); | ||||
| 	const { pid: tid, uid: authorId, timestamp } = chain[chain.length - 1]; | ||||
| 	const { pid: tid, uid: authorId, timestamp, name, content } = chain[chain.length - 1]; | ||||
|  | ||||
| 	const members = await db.isSortedSetMembers(`tidRemote:${tid}:posts`, chain.map(p => p.pid)); | ||||
| 	if (members.every(Boolean)) { | ||||
| @@ -100,6 +101,11 @@ Notes.assertTopic = async (uid, id) => { | ||||
| 		return tid; | ||||
| 	} | ||||
|  | ||||
| 	let title = name || utils.stripHTMLTags(content); | ||||
| 	if (title.length > 256) { | ||||
| 		title = `${title.slice(0, 256)}...`; | ||||
| 	} | ||||
|  | ||||
| 	const cid = await topics.getTopicField(tid, 'cid'); | ||||
|  | ||||
| 	const unprocessed = chain.filter((p, idx) => !members[idx]); | ||||
| @@ -116,7 +122,7 @@ Notes.assertTopic = async (uid, id) => { | ||||
| 			uid: authorId, | ||||
| 			cid: cid || -1, | ||||
| 			mainPid: tid, | ||||
| 			title: 'TBD', | ||||
| 			title, | ||||
| 			slug: `remote?resource=${encodeURIComponent(tid)}`, | ||||
| 			timestamp, | ||||
| 		}), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user