aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/actor.ts37
-rw-r--r--server/controllers/api/index.ts2
-rw-r--r--server/controllers/client.ts11
3 files changed, 48 insertions, 2 deletions
diff --git a/server/controllers/api/actor.ts b/server/controllers/api/actor.ts
new file mode 100644
index 000000000..da7f2eb91
--- /dev/null
+++ b/server/controllers/api/actor.ts
@@ -0,0 +1,37 @@
1import * as express from 'express'
2import { JobQueue } from '../../lib/job-queue'
3import { asyncMiddleware } from '../../middlewares'
4import { actorNameWithHostGetValidator } from '../../middlewares/validators'
5
6const actorRouter = express.Router()
7
8actorRouter.get('/:actorName',
9 asyncMiddleware(actorNameWithHostGetValidator),
10 getActor
11)
12
13// ---------------------------------------------------------------------------
14
15export {
16 actorRouter
17}
18
19// ---------------------------------------------------------------------------
20
21function getActor (req: express.Request, res: express.Response) {
22 let accountOrVideoChannel
23
24 if (res.locals.account) {
25 accountOrVideoChannel = res.locals.account
26 }
27
28 if (res.locals.videoChannel) {
29 accountOrVideoChannel = res.locals.videoChannel
30 }
31
32 if (accountOrVideoChannel.isOutdated()) {
33 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: accountOrVideoChannel.Actor.url } })
34 }
35
36 return res.json(accountOrVideoChannel.toFormattedJSON())
37}
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 28378654a..9ffcf1337 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -16,6 +16,7 @@ import { pluginRouter } from './plugins'
16import { searchRouter } from './search' 16import { searchRouter } from './search'
17import { serverRouter } from './server' 17import { serverRouter } from './server'
18import { usersRouter } from './users' 18import { usersRouter } from './users'
19import { actorRouter } from './actor'
19import { videoChannelRouter } from './video-channel' 20import { videoChannelRouter } from './video-channel'
20import { videoPlaylistRouter } from './video-playlist' 21import { videoPlaylistRouter } from './video-playlist'
21import { videosRouter } from './videos' 22import { videosRouter } from './videos'
@@ -40,6 +41,7 @@ apiRouter.use('/bulk', bulkRouter)
40apiRouter.use('/oauth-clients', oauthClientsRouter) 41apiRouter.use('/oauth-clients', oauthClientsRouter)
41apiRouter.use('/config', configRouter) 42apiRouter.use('/config', configRouter)
42apiRouter.use('/users', usersRouter) 43apiRouter.use('/users', usersRouter)
44apiRouter.use('/actors', actorRouter)
43apiRouter.use('/accounts', accountsRouter) 45apiRouter.use('/accounts', accountsRouter)
44apiRouter.use('/video-channels', videoChannelRouter) 46apiRouter.use('/video-channels', videoChannelRouter)
45apiRouter.use('/video-playlists', videoPlaylistRouter) 47apiRouter.use('/video-playlists', videoPlaylistRouter)
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 022a17ff4..35e5af9d1 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -21,8 +21,9 @@ const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html')
21// Do not use a template engine for a so little thing 21// Do not use a template engine for a so little thing
22clientsRouter.use('/videos/watch/playlist/:id', asyncMiddleware(generateWatchPlaylistHtmlPage)) 22clientsRouter.use('/videos/watch/playlist/:id', asyncMiddleware(generateWatchPlaylistHtmlPage))
23clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage)) 23clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage))
24clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) 24clientsRouter.use([ '/accounts/:nameWithHost', '/a/:nameWithHost' ], asyncMiddleware(generateAccountHtmlPage))
25clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) 25clientsRouter.use([ '/video-channels/:nameWithHost', '/c/:nameWithHost' ], asyncMiddleware(generateVideoChannelHtmlPage))
26clientsRouter.use('/@:nameWithHost', asyncMiddleware(generateActorHtmlPage))
26 27
27const embedMiddlewares = [ 28const embedMiddlewares = [
28 CONFIG.CSP.ENABLED 29 CONFIG.CSP.ENABLED
@@ -155,6 +156,12 @@ async function generateVideoChannelHtmlPage (req: express.Request, res: express.
155 return sendHTML(html, res) 156 return sendHTML(html, res)
156} 157}
157 158
159async function generateActorHtmlPage (req: express.Request, res: express.Response) {
160 const html = await ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res)
161
162 return sendHTML(html, res)
163}
164
158async function generateManifest (req: express.Request, res: express.Response) { 165async function generateManifest (req: express.Request, res: express.Response) {
159 const manifestPhysicalPath = join(root(), 'client', 'dist', 'manifest.webmanifest') 166 const manifestPhysicalPath = join(root(), 'client', 'dist', 'manifest.webmanifest')
160 const manifestJson = await readFile(manifestPhysicalPath, 'utf8') 167 const manifestJson = await readFile(manifestPhysicalPath, 'utf8')