ActivityPub-federated video streaming platform using P2P directly in your web browser
Server: use preview image for opengraph
Chocobozzz41b5da1d8cb4
diff --git a/server/controllers/client.js b/server/controllers/client.jsindex 68ffdbcd57..746c9b62bb 100644--- a/server/controllers/client.js+++ b/server/controllers/client.js@@ -33,25 +33,36 @@ module.exports = router// ---------------------------------------------------------------------------function addOpenGraphTags (htmlStringPage, video) {- const thumbnailUrl = constants.CONFIG.WEBSERVER.URL + video.thumbnailPathconst videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/'+ let baseUrlHttp++ if (video.isOwned()) {+ baseUrlHttp = constants.CONFIG.WEBSERVER.URL+ } else {+ baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podUrl+ }++ // We fetch the remote preview (bigger than the thumbnail)+ // This should not overhead the remote server since social websites put in a cache the OpenGraph tags+ // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example)+ const previewUrl = baseUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName()const metaTags = {'og:type': 'video','og:title': video.name,- 'og:image': thumbnailUrl,+ 'og:image': previewUrl,'og:url': videoUrl,'og:description': video.description,'name': video.name,'description': video.description,- 'image': thumbnailUrl,+ 'image': previewUrl,'twitter:card': 'summary_large_image','twitter:site': '@Chocobozzz','twitter:title': video.name,'twitter:description': video.description,- 'twitter:image': thumbnailUrl+ 'twitter:image': previewUrl}let tagsString = ''diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.jsindex 166158ef37..45acb7686d 100644--- a/server/helpers/custom-validators/videos.js+++ b/server/helpers/custom-validators/videos.js@@ -31,7 +31,7 @@ function isEachRemoteVideosValid (requests) {isVideoDateValid(video.createdDate) &&isVideoDescriptionValid(video.description) &&isVideoDurationValid(video.duration) &&- isVideoMagnetValid(video.magnetUri) &&+ isVideoMagnetValid(video.magnet) &&isVideoNameValid(video.name) &&isVideoPodUrlValid(video.podUrl) &&isVideoTagsValid(video.tags) &&@@ -63,7 +63,7 @@ function isVideoDurationValid (value) {}function isVideoMagnetValid (value) {- return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.XT)+ return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.INFO_HASH)}function isVideoNameValid (value) {diff --git a/server/initializers/constants.js b/server/initializers/constants.jsindex 55129fa3e3..c808aff5f5 100644--- a/server/initializers/constants.js+++ b/server/initializers/constants.js@@ -67,7 +67,7 @@ const CONSTRAINTS_FIELDS = {NAME: { min: 3, max: 50 }, // LengthDESCRIPTION: { min: 3, max: 250 }, // LengthMAGNET: {- XT: { min: 10 } // Length+ INFO_HASH: { min: 10, max: 50 } // Length},DURATION: { min: 1, max: 7200 }, // NumberTAGS: { min: 1, max: 3 }, // Number of total tagsdiff --git a/server/models/video.js b/server/models/video.jsindex 4f2be5c964..0da2cb8ab5 100644--- a/server/models/video.js+++ b/server/models/video.js@@ -160,7 +160,7 @@ function generateMagnetUri () {baseUrlHttp = constants.CONFIG.WEBSERVER.URLbaseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT} else {- baseUrlHttp = constants.REMOTE_SCHEME.HTTP + this.podUrl+ baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + this.podUrlbaseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl}