mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fix: #13076, allow pulling in of topics by their topic URL
fix: reapply fixes that were part of since-reverted 4fd7a9dc59
			
			
This commit is contained in:
		| @@ -27,11 +27,16 @@ Contexts.get = async (uid, id) => { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	try { | 	try { | ||||||
| 		({ context } = await activitypub.get('uid', uid, id, { headers })); | 		({ id, type, context } = await activitypub.get('uid', uid, id, { headers })); | ||||||
| 		if (!context) { | 		if (acceptableTypes.includes(type)) { // is context | ||||||
|  | 			activitypub.helpers.log(`[activitypub/context] ${id} is the context.`); | ||||||
|  | 			return { context: id }; | ||||||
|  | 		} else if (!context) { | ||||||
| 			activitypub.helpers.log(`[activitypub/context] ${id} contains no context.`); | 			activitypub.helpers.log(`[activitypub/context] ${id} contains no context.`); | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		// context provided; try to resolve it. | ||||||
| 		({ type } = await activitypub.get('uid', uid, context)); | 		({ type } = await activitypub.get('uid', uid, context)); | ||||||
| 	} catch (e) { | 	} catch (e) { | ||||||
| 		if (e.code === 'ap_get_304') { | 		if (e.code === 'ap_get_304') { | ||||||
| @@ -98,9 +103,13 @@ Contexts.getItems = async (uid, id, options) => { | |||||||
| 	const inputId = activitypub.helpers.isUri(options.input) ? options.input : options.input.id; | 	const inputId = activitypub.helpers.isUri(options.input) ? options.input : options.input.id; | ||||||
| 	const inCollection = Array.from(chain).map(p => p.pid).includes(inputId); | 	const inCollection = Array.from(chain).map(p => p.pid).includes(inputId); | ||||||
| 	if (!inCollection) { | 	if (!inCollection) { | ||||||
| 		chain.add(activitypub.helpers.isUri(options.input) ? | 		const item = activitypub.helpers.isUri(options.input) ? | ||||||
| 			await parseString(uid, options.input) : | 			await parseString(uid, options.input) : | ||||||
| 			await parseItem(uid, options.input)); | 			await parseItem(uid, options.input); | ||||||
|  |  | ||||||
|  | 		if (item) { | ||||||
|  | 			chain.add(item); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return chain; | 	return chain; | ||||||
|   | |||||||
| @@ -42,11 +42,11 @@ module.exports = function (app, middleware, controllers) { | |||||||
|  |  | ||||||
| 	app.get('/topic/:tid/:slug?', [...middlewares, middleware.assert.topic], controllers.activitypub.actors.topic); | 	app.get('/topic/:tid/:slug?', [...middlewares, middleware.assert.topic], controllers.activitypub.actors.topic); | ||||||
|  |  | ||||||
| 	app.get('/category/:cid/:slug?', [...middlewares, middleware.assert.category], controllers.activitypub.actors.category); |  | ||||||
| 	app.get('/category/:cid/inbox', [...middlewares, middleware.assert.category], controllers.activitypub.getInbox); | 	app.get('/category/:cid/inbox', [...middlewares, middleware.assert.category], controllers.activitypub.getInbox); | ||||||
| 	app.post('/category/:cid/inbox', [...inboxMiddlewares, middleware.assert.category, ...inboxMiddlewares], controllers.activitypub.postInbox); | 	app.post('/category/:cid/inbox', [...inboxMiddlewares, middleware.assert.category, ...inboxMiddlewares], controllers.activitypub.postInbox); | ||||||
| 	app.get('/category/:cid/outbox', [...middlewares, middleware.assert.category], controllers.activitypub.getCategoryOutbox); | 	app.get('/category/:cid/outbox', [...middlewares, middleware.assert.category], controllers.activitypub.getCategoryOutbox); | ||||||
| 	app.post('/category/:cid/outbox', [...middlewares, middleware.assert.category], controllers.activitypub.postOutbox); | 	app.post('/category/:cid/outbox', [...middlewares, middleware.assert.category], controllers.activitypub.postOutbox); | ||||||
|  | 	app.get('/category/:cid/:slug?', [...middlewares, middleware.assert.category], controllers.activitypub.actors.category); | ||||||
|  |  | ||||||
| 	app.get('/message/:mid', [...middlewares, middleware.assert.message], controllers.activitypub.actors.message); | 	app.get('/message/:mid', [...middlewares, middleware.assert.message], controllers.activitypub.actors.message); | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user