aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/client.js19
-rw-r--r--server/helpers/custom-validators/videos.js4
-rw-r--r--server/initializers/constants.js2
-rw-r--r--server/models/video.js2
4 files changed, 19 insertions, 8 deletions
diff --git a/server/controllers/client.js b/server/controllers/client.js
index 68ffdbcd5..746c9b62b 100644
--- a/server/controllers/client.js
+++ b/server/controllers/client.js
@@ -33,25 +33,36 @@ module.exports = router
33// --------------------------------------------------------------------------- 33// ---------------------------------------------------------------------------
34 34
35function addOpenGraphTags (htmlStringPage, video) { 35function addOpenGraphTags (htmlStringPage, video) {
36 const thumbnailUrl = constants.CONFIG.WEBSERVER.URL + video.thumbnailPath
37 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' 36 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/'
37 let baseUrlHttp
38
39 if (video.isOwned()) {
40 baseUrlHttp = constants.CONFIG.WEBSERVER.URL
41 } else {
42 baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podUrl
43 }
44
45 // We fetch the remote preview (bigger than the thumbnail)
46 // This should not overhead the remote server since social websites put in a cache the OpenGraph tags
47 // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example)
48 const previewUrl = baseUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName()
38 49
39 const metaTags = { 50 const metaTags = {
40 'og:type': 'video', 51 'og:type': 'video',
41 'og:title': video.name, 52 'og:title': video.name,
42 'og:image': thumbnailUrl, 53 'og:image': previewUrl,
43 'og:url': videoUrl, 54 'og:url': videoUrl,
44 'og:description': video.description, 55 'og:description': video.description,
45 56
46 'name': video.name, 57 'name': video.name,
47 'description': video.description, 58 'description': video.description,
48 'image': thumbnailUrl, 59 'image': previewUrl,
49 60
50 'twitter:card': 'summary_large_image', 61 'twitter:card': 'summary_large_image',
51 'twitter:site': '@Chocobozzz', 62 'twitter:site': '@Chocobozzz',
52 'twitter:title': video.name, 63 'twitter:title': video.name,
53 'twitter:description': video.description, 64 'twitter:description': video.description,
54 'twitter:image': thumbnailUrl 65 'twitter:image': previewUrl
55 } 66 }
56 67
57 let tagsString = '' 68 let tagsString = ''
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js
index 166158ef3..45acb7686 100644
--- a/server/helpers/custom-validators/videos.js
+++ b/server/helpers/custom-validators/videos.js
@@ -31,7 +31,7 @@ function isEachRemoteVideosValid (requests) {
31 isVideoDateValid(video.createdDate) && 31 isVideoDateValid(video.createdDate) &&
32 isVideoDescriptionValid(video.description) && 32 isVideoDescriptionValid(video.description) &&
33 isVideoDurationValid(video.duration) && 33 isVideoDurationValid(video.duration) &&
34 isVideoMagnetValid(video.magnetUri) && 34 isVideoMagnetValid(video.magnet) &&
35 isVideoNameValid(video.name) && 35 isVideoNameValid(video.name) &&
36 isVideoPodUrlValid(video.podUrl) && 36 isVideoPodUrlValid(video.podUrl) &&
37 isVideoTagsValid(video.tags) && 37 isVideoTagsValid(video.tags) &&
@@ -63,7 +63,7 @@ function isVideoDurationValid (value) {
63} 63}
64 64
65function isVideoMagnetValid (value) { 65function isVideoMagnetValid (value) {
66 return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.XT) 66 return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.INFO_HASH)
67} 67}
68 68
69function isVideoNameValid (value) { 69function isVideoNameValid (value) {
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 55129fa3e..c808aff5f 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -67,7 +67,7 @@ const CONSTRAINTS_FIELDS = {
67 NAME: { min: 3, max: 50 }, // Length 67 NAME: { min: 3, max: 50 }, // Length
68 DESCRIPTION: { min: 3, max: 250 }, // Length 68 DESCRIPTION: { min: 3, max: 250 }, // Length
69 MAGNET: { 69 MAGNET: {
70 XT: { min: 10 } // Length 70 INFO_HASH: { min: 10, max: 50 } // Length
71 }, 71 },
72 DURATION: { min: 1, max: 7200 }, // Number 72 DURATION: { min: 1, max: 7200 }, // Number
73 TAGS: { min: 1, max: 3 }, // Number of total tags 73 TAGS: { min: 1, max: 3 }, // Number of total tags
diff --git a/server/models/video.js b/server/models/video.js
index 4f2be5c96..0da2cb8ab 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -160,7 +160,7 @@ function generateMagnetUri () {
160 baseUrlHttp = constants.CONFIG.WEBSERVER.URL 160 baseUrlHttp = constants.CONFIG.WEBSERVER.URL
161 baseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT 161 baseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT
162 } else { 162 } else {
163 baseUrlHttp = constants.REMOTE_SCHEME.HTTP + this.podUrl 163 baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + this.podUrl
164 baseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl 164 baseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl
165 } 165 }
166 166