]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/controllers/webfinger.ts
Translated using Weblate (Kabyle)
[github/Chocobozzz/PeerTube.git] / server / controllers / webfinger.ts
... / ...
CommitLineData
1import * as cors from 'cors'
2import * as express from 'express'
3import { WEBSERVER } from '@server/initializers/constants'
4import { asyncMiddleware } from '../middlewares'
5import { webfingerValidator } from '../middlewares/validators'
6
7const webfingerRouter = express.Router()
8
9webfingerRouter.use(cors())
10
11webfingerRouter.get('/.well-known/webfinger',
12 asyncMiddleware(webfingerValidator),
13 webfingerController
14)
15
16// ---------------------------------------------------------------------------
17
18export {
19 webfingerRouter
20}
21
22// ---------------------------------------------------------------------------
23
24function webfingerController (req: express.Request, res: express.Response) {
25 const actor = res.locals.actorUrl
26
27 const json = {
28 subject: req.query.resource,
29 aliases: [ actor.url ],
30 links: [
31 {
32 rel: 'self',
33 type: 'application/activity+json',
34 href: actor.url
35 },
36 {
37 rel: 'http://ostatus.org/schema/1.0/subscribe',
38 template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
39 }
40 ]
41 }
42
43 return res.json(json)
44}