mirror of https://github.com/Chocobozzz/PeerTube
Move webfinger controller in well known router
parent
2a950cde89
commit
5bfe684e76
|
@ -109,7 +109,6 @@ import {
|
|||
servicesRouter,
|
||||
objectStorageProxyRouter,
|
||||
pluginsRouter,
|
||||
webfingerRouter,
|
||||
trackerRouter,
|
||||
createWebsocketTrackerServer,
|
||||
botsRouter,
|
||||
|
@ -231,7 +230,6 @@ app.use('/', pluginsRouter)
|
|||
|
||||
app.use('/', activityPubRouter)
|
||||
app.use('/', feedsRouter)
|
||||
app.use('/', webfingerRouter)
|
||||
app.use('/', trackerRouter)
|
||||
app.use('/', botsRouter)
|
||||
|
||||
|
|
|
@ -11,5 +11,4 @@ export * from './plugins'
|
|||
export * from './services'
|
||||
export * from './static'
|
||||
export * from './tracker'
|
||||
export * from './webfinger'
|
||||
export * from './well-known'
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { WEBSERVER } from '@server/initializers/constants'
|
||||
import { asyncMiddleware } from '../middlewares'
|
||||
import { webfingerValidator } from '../middlewares/validators'
|
||||
|
||||
const webfingerRouter = express.Router()
|
||||
|
||||
webfingerRouter.use(cors())
|
||||
|
||||
webfingerRouter.get('/.well-known/webfinger',
|
||||
asyncMiddleware(webfingerValidator),
|
||||
webfingerController
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
webfingerRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function webfingerController (req: express.Request, res: express.Response) {
|
||||
const actor = res.locals.actorUrl
|
||||
|
||||
const json = {
|
||||
subject: req.query.resource,
|
||||
aliases: [ actor.url ],
|
||||
links: [
|
||||
{
|
||||
rel: 'self',
|
||||
type: 'application/activity+json',
|
||||
href: actor.url
|
||||
},
|
||||
{
|
||||
rel: 'http://ostatus.org/schema/1.0/subscribe',
|
||||
template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return res.json(json)
|
||||
}
|
|
@ -1,16 +1,21 @@
|
|||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { join } from 'path'
|
||||
import { asyncMiddleware, handleStaticError, webfingerValidator } from '@server/middlewares'
|
||||
import { root } from '@shared/core-utils'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
|
||||
import { cacheRoute } from '../middlewares/cache/cache'
|
||||
import { handleStaticError } from '@server/middlewares'
|
||||
|
||||
const wellKnownRouter = express.Router()
|
||||
|
||||
wellKnownRouter.use(cors())
|
||||
|
||||
wellKnownRouter.get('/.well-known/webfinger',
|
||||
asyncMiddleware(webfingerValidator),
|
||||
webfingerController
|
||||
)
|
||||
|
||||
wellKnownRouter.get('/.well-known/security.txt',
|
||||
cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT),
|
||||
(_, res: express.Response) => {
|
||||
|
@ -81,3 +86,27 @@ wellKnownRouter.use('/.well-known/',
|
|||
export {
|
||||
wellKnownRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function webfingerController (req: express.Request, res: express.Response) {
|
||||
const actor = res.locals.actorUrl
|
||||
|
||||
const json = {
|
||||
subject: req.query.resource,
|
||||
aliases: [ actor.url ],
|
||||
links: [
|
||||
{
|
||||
rel: 'self',
|
||||
type: 'application/activity+json',
|
||||
href: actor.url
|
||||
},
|
||||
{
|
||||
rel: 'http://ostatus.org/schema/1.0/subscribe',
|
||||
template: WEBSERVER.URL + '/remote-interaction?uri={uri}'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return res.json(json)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue