diff options
Diffstat (limited to 'server/middlewares/validators/webfinger.ts')
-rw-r--r-- | server/middlewares/validators/webfinger.ts | 37 |
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 @@ | |||
1 | import express from 'express' | ||
2 | import { query } from 'express-validator' | ||
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | ||
4 | import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' | ||
5 | import { getHostWithPort } from '../../helpers/express-utils' | ||
6 | import { ActorModel } from '../../models/actor/actor' | ||
7 | import { areValidationErrors } from './shared' | ||
8 | |||
9 | const 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 | |||
35 | export { | ||
36 | webfingerValidator | ||
37 | } | ||