aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r--server/controllers/client.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index d42e8396d..ac722a578 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -78,7 +78,7 @@ function addOpenGraphTags (htmlStringPage: string, video: VideoInstance) {
78 } 78 }
79 79
80 let tagsString = '' 80 let tagsString = ''
81 Object.keys(metaTags).forEach(function (tagName) { 81 Object.keys(metaTags).forEach(tagName => {
82 const tagValue = metaTags[tagName] 82 const tagValue = metaTags[tagName]
83 83
84 tagsString += '<meta property="' + tagName + '" content="' + tagValue + '" />' 84 tagsString += '<meta property="' + tagName + '" content="' + tagValue + '" />'
@@ -89,13 +89,20 @@ function addOpenGraphTags (htmlStringPage: string, video: VideoInstance) {
89 89
90function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) { 90function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) {
91 const videoId = '' + req.params.id 91 const videoId = '' + req.params.id
92 let videoPromise: Promise<VideoInstance>
92 93
93 // Let Angular application handle errors 94 // Let Angular application handle errors
94 if (!validator.isUUID(videoId, 4)) return res.sendFile(indexPath) 95 if (validator.isUUID(videoId, 4)) {
96 videoPromise = db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(videoId)
97 } else if (validator.isInt(videoId)) {
98 videoPromise = db.Video.loadAndPopulateAuthorAndPodAndTags(+videoId)
99 } else {
100 return res.sendFile(indexPath)
101 }
95 102
96 Promise.all([ 103 Promise.all([
97 readFileBufferPromise(indexPath), 104 readFileBufferPromise(indexPath),
98 db.Video.loadAndPopulateAuthorAndPodAndTags(videoId) 105 videoPromise
99 ]) 106 ])
100 .then(([ file, video ]) => { 107 .then(([ file, video ]) => {
101 file = file as Buffer 108 file = file as Buffer