mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	feat: add id to follows and verify accepts
This commit is contained in:
		| @@ -255,9 +255,15 @@ inbox.accept = async (req) => { | ||||
| 	} | ||||
|  | ||||
| 	if (type === 'Follow') { | ||||
| 		if (!await db.isSortedSetMember(`followRequests:${uid}`, actor)) { | ||||
| 			throw new Error('[[error:activitypub.get-failed]]'); | ||||
| 		} | ||||
| 		const now = Date.now(); | ||||
| 		await db.sortedSetAdd(`followingRemote:${uid}`, now, actor); | ||||
| 		await db.sortedSetAdd(`followersRemote:${actor}`, now, uid); // for followers backreference and notes assertion checking | ||||
| 		await Promise.all([ | ||||
| 			db.sortedSetRemove(`followRequests:${uid}`, actor), | ||||
| 			db.sortedSetAdd(`followingRemote:${uid}`, now, actor), | ||||
| 			db.sortedSetAdd(`followersRemote:${actor}`, now, uid), // for followers backreference and notes assertion checking | ||||
| 		]); | ||||
| 		const followingRemoteCount = await db.sortedSetCard(`followingRemote:${uid}`); | ||||
| 		await user.setUserField(uid, 'followingRemoteCount', followingRemoteCount); | ||||
| 	} | ||||
| @@ -351,7 +357,6 @@ inbox.undo = async (req) => { | ||||
| 		} | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| inbox.flag = async (req) => { | ||||
| 	const { actor, object, content } = req.body; | ||||
| 	const objects = Array.isArray(object) ? object : [object]; | ||||
|   | ||||
| @@ -38,9 +38,12 @@ activitypubApi.follow = enabledCheck(async (caller, { uid } = {}) => { | ||||
| 	} | ||||
|  | ||||
| 	await activitypub.send('uid', caller.uid, [result.actorUri], { | ||||
| 		id: `${nconf.get('url')}/uid/${caller.uid}#activity/follow/${result.username}@${result.hostname}`, | ||||
| 		type: 'Follow', | ||||
| 		object: result.actorUri, | ||||
| 	}); | ||||
|  | ||||
| 	await db.sortedSetAdd(`followRequests:${caller.uid}`, Date.now(), result.actorUri); | ||||
| }); | ||||
|  | ||||
| // should be .undo.follow | ||||
| @@ -109,14 +112,14 @@ activitypubApi.create.post = enabledCheck(async (caller, { pid }) => { | ||||
|  | ||||
| 	const payloads = { | ||||
| 		create: { | ||||
| 			id: `${object.id}#create`, | ||||
| 			id: `${object.id}#activity/create`, | ||||
| 			type: 'Create', | ||||
| 			to: object.to, | ||||
| 			cc: object.cc, | ||||
| 			object, | ||||
| 		}, | ||||
| 		announce: { | ||||
| 			id: `${object.id}#announce`, | ||||
| 			id: `${object.id}#activity/announce`, | ||||
| 			type: 'Announce', | ||||
| 			to: [`${nconf.get('url')}/category/${cid}/followers`], | ||||
| 			cc: [activitypub._constants.publicAddress], | ||||
| @@ -157,7 +160,7 @@ activitypubApi.update.note = enabledCheck(async (caller, { post }) => { | ||||
| 	} | ||||
|  | ||||
| 	const payload = { | ||||
| 		id: `${object.id}#update/${post.edited}`, | ||||
| 		id: `${object.id}#activity/update/${post.edited}`, | ||||
| 		type: 'Update', | ||||
| 		to: object.to, | ||||
| 		cc: object.cc, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user