mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	feat: ability to query remote users by webfinger handle
This commit is contained in:
		| @@ -15,6 +15,7 @@ const ttl = require('../cache/ttl'); | ||||
| const user = require('../user'); | ||||
| const activitypub = require('.'); | ||||
|  | ||||
| const webfingerRegex = /^(@|acct:)?\w+@.+$/; | ||||
| const webfingerCache = ttl({ ttl: 1000 * 60 * 60 * 24 }); // 24 hours | ||||
|  | ||||
| const Helpers = module.exports; | ||||
| @@ -33,6 +34,21 @@ Helpers.isUri = (value) => { | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| Helpers.isWebfinger = (value) => { | ||||
| 	// N.B. returns normalized handle, so truthy check! | ||||
| 	if (webfingerRegex.test(value) && !Helpers.isUri(value)) { | ||||
| 		if (value.startsWith('@')) { | ||||
| 			return value.slice(1); | ||||
| 		} else if (value.startsWith('acct:')) { | ||||
| 			return value.slice(5); | ||||
| 		} | ||||
|  | ||||
| 		return value; | ||||
| 	} | ||||
|  | ||||
| 	return false; | ||||
| }; | ||||
|  | ||||
| Helpers.query = async (id) => { | ||||
| 	const isUri = Helpers.isUri(id); | ||||
| 	// username@host ids use acct: URI schema | ||||
|   | ||||
		Reference in New Issue
	
	Block a user