mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	fix: support reporting remote content in Flag
This commit is contained in:
		| @@ -177,6 +177,20 @@ Helpers.resolveActivity = async (activity, data, id, resolved) => { | |||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | Helpers.mapToLocalType = (type) => { | ||||||
|  | 	if (type === 'Person') { | ||||||
|  | 		return 'user'; | ||||||
|  | 	} | ||||||
|  | 	if (type === 'Group') { | ||||||
|  | 		return 'category'; | ||||||
|  | 	} | ||||||
|  | 	if (type === 'Hashtag') { | ||||||
|  | 		return 'tag'; | ||||||
|  | 	} | ||||||
|  | 	if (activitypub._constants.acceptedPostTypes.includes(type)) { | ||||||
|  | 		return 'post'; | ||||||
|  | 	} | ||||||
|  | }; | ||||||
|  |  | ||||||
| Helpers.resolveObjects = async (ids) => { | Helpers.resolveObjects = async (ids) => { | ||||||
| 	if (!Array.isArray(ids)) { | 	if (!Array.isArray(ids)) { | ||||||
|   | |||||||
| @@ -386,9 +386,9 @@ inbox.flag = async (req) => { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	await Promise.all(objects.map(async (subject, index) => { | 	await Promise.all(objects.map(async (subject, index) => { | ||||||
| 		const { type, id } = await activitypub.helpers.resolveLocalId(subject.id); | 		const { type, id } = await activitypub.helpers.resolveObjects(subject.id); | ||||||
| 		try { | 		try { | ||||||
| 			await flags.create(type, id, actor, content); | 			await flags.create(activitypub.helpers.mapToLocalType(type), id, actor, content); | ||||||
| 		} catch (e) { | 		} catch (e) { | ||||||
| 			reject('Flag', objects[index], actor); | 			reject('Flag', objects[index], actor); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -21,6 +21,9 @@ ActivityPub._constants = Object.freeze({ | |||||||
| 		'application/activity+json', | 		'application/activity+json', | ||||||
| 		'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', | 		'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', | ||||||
| 	], | 	], | ||||||
|  | 	acceptedPostTypes: [ | ||||||
|  | 		'Note', 'Page', 'Article', 'Question', | ||||||
|  | 	], | ||||||
| }); | }); | ||||||
| ActivityPub._cache = requestCache; | ActivityPub._cache = requestCache; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -78,8 +78,7 @@ Mocks.post = async (objects) => { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	const posts = await Promise.all(objects.map(async (object) => { | 	const posts = await Promise.all(objects.map(async (object) => { | ||||||
| 		const acceptedTypes = ['Note', 'Page', 'Article', 'Question']; | 		if (!activitypub._constants.acceptedPostTypes.includes(object.type)) { | ||||||
| 		if (!acceptedTypes.includes(object.type)) { |  | ||||||
| 			return null; | 			return null; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user