]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/client.ts
Correctly set the activity audience in outbox
[github/Chocobozzz/PeerTube.git] / server / controllers / client.ts
index 9a72fe8e085180b0e093ccf5b31f305e7014829f..c85bd8a5ed79c94d880cd260837a2f5e18287169 100644 (file)
@@ -1,15 +1,9 @@
+import * as Bluebird from 'bluebird'
 import * as express from 'express'
 import { join } from 'path'
 import * as validator from 'validator'
-import * as Bluebird from 'bluebird'
-import {
-  CONFIG,
-  STATIC_PATHS,
-  STATIC_MAX_AGE,
-  OPENGRAPH_AND_OEMBED_COMMENT,
-  EMBED_SIZE
-} from '../initializers'
-import { root, readFileBufferPromise, escapeHTML } from '../helpers'
+import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils'
+import { CONFIG, EMBED_SIZE, OPENGRAPH_AND_OEMBED_COMMENT, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers'
 import { asyncMiddleware } from '../middlewares'
 import { VideoModel } from '../models/video/video'
 
@@ -90,17 +84,35 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
     }
   ]
 
+  const schemaTags = {
+    '@context': 'http://schema.org',
+    '@type': 'VideoObject',
+    name: videoNameEscaped,
+    description: videoDescriptionEscaped,
+    duration: video.getActivityStreamDuration(),
+    thumbnailURL: previewUrl,
+    contentURL: videoUrl,
+    embedURL: embedUrl,
+    uploadDate: video.createdAt
+  }
+
   let tagsString = ''
+
+  // Opengraph
   Object.keys(openGraphMetaTags).forEach(tagName => {
     const tagValue = openGraphMetaTags[tagName]
 
     tagsString += `<meta property="${tagName}" content="${tagValue}" />`
   })
 
+  // OEmbed
   for (const oembedLinkTag of oembedLinkTags) {
     tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />`
   }
 
+  // Schema.org
+  tagsString += `<script type="application/ld+json">${JSON.stringify(schemaTags)}</script>`
+
   return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
 }