]> 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 39e046727291714afa75ded7b1a0945dfd8f859b..c85bd8a5ed79c94d880cd260837a2f5e18287169 100644 (file)
@@ -84,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)
 }