diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-12 15:20:03 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-12 15:20:03 +0100 |
commit | 99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch) | |
tree | c9e04ccfcc5496d2300d7c26db5833e494b4cdad /server/controllers/client.js | |
parent | fcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff) | |
parent | 91cc839af88730ba55f84997c56b85ea100070a7 (diff) | |
download | PeerTube-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.js | 11 |
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 @@ | |||
3 | const parallel = require('async/parallel') | 3 | const parallel = require('async/parallel') |
4 | const express = require('express') | 4 | const express = require('express') |
5 | const fs = require('fs') | 5 | const fs = require('fs') |
6 | const mongoose = require('mongoose') | ||
7 | const path = require('path') | 6 | const path = require('path') |
8 | const validator = require('express-validator').validator | 7 | const validator = require('express-validator').validator |
9 | 8 | ||
10 | const constants = require('../initializers/constants') | 9 | const constants = require('../initializers/constants') |
10 | const db = require('../initializers/database') | ||
11 | 11 | ||
12 | const Video = mongoose.model('Video') | ||
13 | const router = express.Router() | 12 | const router = express.Router() |
14 | 13 | ||
15 | const opengraphComment = '<!-- opengraph tags -->' | 14 | const 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) |