From 709756b8e183f67ef9bf8f7bc149af4736260350 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Jul 2017 16:57:28 +0200 Subject: Async signature and various fixes --- server/controllers/api/remote/videos.ts | 9 ++++----- server/controllers/client.ts | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/remote/videos.ts b/server/controllers/api/remote/videos.ts index ebe4eca36..eb033637e 100644 --- a/server/controllers/api/remote/videos.ts +++ b/server/controllers/api/remote/videos.ts @@ -64,8 +64,7 @@ function remoteVideos (req: express.Request, res: express.Response, next: expres const fromPod = res.locals.secure.pod // We need to process in the same order to keep consistency - // TODO: optimization - Promise.mapSeries(requests, (request: any) => { + Promise.each(requests, (request: any) => { const data = request.data // Get the function we need to call in order to process the request @@ -79,7 +78,7 @@ function remoteVideos (req: express.Request, res: express.Response, next: expres }) .catch(err => logger.error('Error managing remote videos.', { error: err })) - // We don't need to keep the other pod waiting + // Don't block the other pod return res.type('json').status(204).end() } @@ -87,7 +86,7 @@ function remoteVideosQadu (req: express.Request, res: express.Response, next: ex const requests = req.body.data const fromPod = res.locals.secure.pod - Promise.mapSeries(requests, (request: any) => { + Promise.each(requests, (request: any) => { const videoData = request.data return quickAndDirtyUpdateVideoRetryWrapper(videoData, fromPod) @@ -101,7 +100,7 @@ function remoteVideosEvents (req: express.Request, res: express.Response, next: const requests = req.body.data const fromPod = res.locals.secure.pod - Promise.mapSeries(requests, (request: any) => { + Promise.each(requests, (request: any) => { const eventData = request.data return processVideosEventsRetryWrapper(eventData, fromPod) diff --git a/server/controllers/client.ts b/server/controllers/client.ts index e4d69eae7..d42e8396d 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -8,15 +8,14 @@ import { CONFIG, REMOTE_SCHEME, STATIC_PATHS, - STATIC_MAX_AGE + STATIC_MAX_AGE, + OPENGRAPH_COMMENT } from '../initializers' import { root, readFileBufferPromise } from '../helpers' import { VideoInstance } from '../models' const clientsRouter = express.Router() -// TODO: move to constants -const opengraphComment = '' const distPath = join(root(), 'client', 'dist') const embedPath = join(distPath, 'standalone', 'videos', 'embed.html') const indexPath = join(distPath, 'index.html') @@ -85,7 +84,7 @@ function addOpenGraphTags (htmlStringPage: string, video: VideoInstance) { tagsString += '' }) - return htmlStringPage.replace(opengraphComment, tagsString) + return htmlStringPage.replace(OPENGRAPH_COMMENT, tagsString) } function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) { -- cgit v1.2.3