mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	fix: #8763
This commit is contained in:
		| @@ -82,9 +82,23 @@ async function getBestPosts(callerUid, userData) { | ||||
| async function getPosts(callerUid, userData, setSuffix) { | ||||
| 	const cids = await categories.getCidsByPrivilege('categories:cid', callerUid, 'topics:read'); | ||||
| 	const keys = cids.map(c => 'cid:' + c + ':uid:' + userData.uid + ':' + setSuffix); | ||||
| 	const pids = await db.getSortedSetRevRange(keys, 0, 9); | ||||
| 	const postData = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false }); | ||||
| 	return postData.filter(p => p && !p.deleted && p.topic && !p.topic.deleted); | ||||
| 	let hasMorePosts = true; | ||||
| 	let start = 0; | ||||
| 	const count = 10; | ||||
| 	const postData = []; | ||||
| 	do { | ||||
| 		/* eslint-disable no-await-in-loop */ | ||||
| 		const pids = await db.getSortedSetRevRange(keys, start, start + count - 1); | ||||
| 		if (!pids.length || pids.length < count) { | ||||
| 			hasMorePosts = false; | ||||
| 		} | ||||
| 		if (pids.length) { | ||||
| 			const p = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false }); | ||||
| 			postData.push(...p.filter(p => p && !p.deleted && p.topic && !p.topic.deleted)); | ||||
| 		} | ||||
| 		start += count; | ||||
| 	} while (postData.length < count && hasMorePosts); | ||||
| 	return postData.slice(0, count); | ||||
| } | ||||
|  | ||||
| function addMetaTags(res, userData) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user