Federate video abuses
[oweals/peertube.git] / server / controllers / webfinger.ts
1 import * as express from 'express'
2
3 import { CONFIG, PREVIEWS_SIZE, EMBED_SIZE } from '../initializers'
4 import { oembedValidator } from '../middlewares'
5 import { VideoInstance } from '../models'
6 import { webfingerValidator } from '../middlewares/validators/webfinger'
7 import { AccountInstance } from '../models/account/account-interface'
8
9 const webfingerRouter = express.Router()
10
11 webfingerRouter.get('/.well-known/webfinger',
12   webfingerValidator,
13   webfingerController
14 )
15
16 // ---------------------------------------------------------------------------
17
18 export {
19   webfingerRouter
20 }
21
22 // ---------------------------------------------------------------------------
23
24 function webfingerController (req: express.Request, res: express.Response, next: express.NextFunction) {
25   const account: AccountInstance = res.locals.account
26
27   const json = {
28     subject: req.query.resource,
29     aliases: [ account.url ],
30     links: [
31       {
32         rel: 'self',
33         href: account.url
34       }
35     ]
36   }
37
38   return res.json(json).end()
39 }