aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/webfinger.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/webfinger.ts')
-rw-r--r--server/middlewares/validators/webfinger.ts37
1 files changed, 0 insertions, 37 deletions
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
deleted file mode 100644
index dcfba99fa..000000000
--- a/server/middlewares/validators/webfinger.ts
+++ /dev/null
@@ -1,37 +0,0 @@
1import express from 'express'
2import { query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
5import { getHostWithPort } from '../../helpers/express-utils'
6import { ActorModel } from '../../models/actor/actor'
7import { areValidationErrors } from './shared'
8
9const webfingerValidator = [
10 query('resource')
11 .custom(isWebfingerLocalResourceValid),
12
13 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
14 if (areValidationErrors(req, res)) return
15
16 // Remove 'acct:' from the beginning of the string
17 const nameWithHost = getHostWithPort(req.query.resource.substr(5))
18 const [ name ] = nameWithHost.split('@')
19
20 const actor = await ActorModel.loadLocalUrlByName(name)
21 if (!actor) {
22 return res.fail({
23 status: HttpStatusCode.NOT_FOUND_404,
24 message: 'Actor not found'
25 })
26 }
27
28 res.locals.actorUrl = actor
29 return next()
30 }
31]
32
33// ---------------------------------------------------------------------------
34
35export {
36 webfingerValidator
37}