mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	fix: local pids not always converted to absolute URLs on topic actor controller
This commit is contained in:
		| @@ -136,6 +136,7 @@ Actors.topic = async function (req, res, next) { | |||||||
| 		let collection; | 		let collection; | ||||||
| 		let pids; | 		let pids; | ||||||
| 		try { | 		try { | ||||||
|  | 			// pids are used in generation of digest only. | ||||||
| 			([collection, pids] = await Promise.all([ | 			([collection, pids] = await Promise.all([ | ||||||
| 				activitypub.helpers.generateCollection({ | 				activitypub.helpers.generateCollection({ | ||||||
| 					set: `tid:${req.params.tid}:posts`, | 					set: `tid:${req.params.tid}:posts`, | ||||||
| @@ -151,7 +152,6 @@ Actors.topic = async function (req, res, next) { | |||||||
| 		} | 		} | ||||||
| 		pids.push(mainPid); | 		pids.push(mainPid); | ||||||
| 		pids = pids.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid)); | 		pids = pids.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid)); | ||||||
| 		collection.totalItems += 1; // account for mainPid |  | ||||||
|  |  | ||||||
| 		// Generate digest for ETag | 		// Generate digest for ETag | ||||||
| 		const digest = activitypub.helpers.generateDigest(new Set(pids)); | 		const digest = activitypub.helpers.generateDigest(new Set(pids)); | ||||||
| @@ -168,14 +168,17 @@ Actors.topic = async function (req, res, next) { | |||||||
| 		} | 		} | ||||||
| 		res.set('ETag', digest); | 		res.set('ETag', digest); | ||||||
|  |  | ||||||
| 		// Convert pids to urls | 		// Add OP to collection on first (or only) page | ||||||
| 		if (page || collection.totalItems < perPage) { | 		if (page || collection.totalItems < perPage) { | ||||||
| 			collection.orderedItems = collection.orderedItems || []; | 			collection.orderedItems = collection.orderedItems || []; | ||||||
| 			if (!page || page === 1) { // add OP to collection | 			if (!page || page === 1) { | ||||||
| 				collection.orderedItems.unshift(mainPid); | 				collection.orderedItems.unshift(mainPid); | ||||||
|  | 				collection.totalItems += 1; | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// Convert pids to urls | ||||||
| 		collection.orderedItems = collection.orderedItems.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid)); | 		collection.orderedItems = collection.orderedItems.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid)); | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		const object = { | 		const object = { | ||||||
| 			'@context': 'https://www.w3.org/ns/activitystreams', | 			'@context': 'https://www.w3.org/ns/activitystreams', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user