diff options
Diffstat (limited to 'server/controllers/webfinger.ts')
-rw-r--r-- | server/controllers/webfinger.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts new file mode 100644 index 000000000..1c726f0cb --- /dev/null +++ b/server/controllers/webfinger.ts | |||
@@ -0,0 +1,39 @@ | |||
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.use('/.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 | } | ||