aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
commit99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch)
treec9e04ccfcc5496d2300d7c26db5833e494b4cdad /server/controllers/client.js
parentfcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff)
parent91cc839af88730ba55f84997c56b85ea100070a7 (diff)
downloadPeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.gz
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.zst
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.zip
Merge branch 'postgresql'
Diffstat (limited to 'server/controllers/client.js')
-rw-r--r--server/controllers/client.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/server/controllers/client.js b/server/controllers/client.js
index 572db6133..8c242af07 100644
--- a/server/controllers/client.js
+++ b/server/controllers/client.js
@@ -3,13 +3,12 @@
3const parallel = require('async/parallel') 3const parallel = require('async/parallel')
4const express = require('express') 4const express = require('express')
5const fs = require('fs') 5const fs = require('fs')
6const mongoose = require('mongoose')
7const path = require('path') 6const path = require('path')
8const validator = require('express-validator').validator 7const validator = require('express-validator').validator
9 8
10const constants = require('../initializers/constants') 9const constants = require('../initializers/constants')
10const db = require('../initializers/database')
11 11
12const Video = mongoose.model('Video')
13const router = express.Router() 12const router = express.Router()
14 13
15const opengraphComment = '<!-- opengraph tags -->' 14const opengraphComment = '<!-- opengraph tags -->'
@@ -45,14 +44,14 @@ function addOpenGraphTags (htmlStringPage, video) {
45 if (video.isOwned()) { 44 if (video.isOwned()) {
46 basePreviewUrlHttp = constants.CONFIG.WEBSERVER.URL 45 basePreviewUrlHttp = constants.CONFIG.WEBSERVER.URL
47 } else { 46 } else {
48 basePreviewUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podHost 47 basePreviewUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.Author.Pod.host
49 } 48 }
50 49
51 // We fetch the remote preview (bigger than the thumbnail) 50 // We fetch the remote preview (bigger than the thumbnail)
52 // This should not overhead the remote server since social websites put in a cache the OpenGraph tags 51 // This should not overhead the remote server since social websites put in a cache the OpenGraph tags
53 // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example) 52 // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example)
54 const previewUrl = basePreviewUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName() 53 const previewUrl = basePreviewUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName()
55 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' + video._id 54 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' + video.id
56 55
57 const metaTags = { 56 const metaTags = {
58 'og:type': 'video', 57 'og:type': 'video',
@@ -86,7 +85,7 @@ function generateWatchHtmlPage (req, res, next) {
86 const videoId = req.params.id 85 const videoId = req.params.id
87 86
88 // Let Angular application handle errors 87 // Let Angular application handle errors
89 if (!validator.isMongoId(videoId)) return res.sendFile(indexPath) 88 if (!validator.isUUID(videoId, 4)) return res.sendFile(indexPath)
90 89
91 parallel({ 90 parallel({
92 file: function (callback) { 91 file: function (callback) {
@@ -94,7 +93,7 @@ function generateWatchHtmlPage (req, res, next) {
94 }, 93 },
95 94
96 video: function (callback) { 95 video: function (callback) {
97 Video.load(videoId, callback) 96 db.Video.loadAndPopulateAuthorAndPodAndTags(videoId, callback)
98 } 97 }
99 }, function (err, results) { 98 }, function (err, results) {
100 if (err) return next(err) 99 if (err) return next(err)