]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-format-utils.ts
Fix embed on mastodon
[github/Chocobozzz/PeerTube.git] / server / models / video / video-format-utils.ts
index 9fed2d49da8b2b1ece13d75a02f52216fe32f7ee..67395e5c0ced50d4a1b15c84fe52b83635cae2fc 100644 (file)
@@ -270,7 +270,15 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject {
     }
   }
 
-  const url: ActivityUrlObject[] = []
+  const url: ActivityUrlObject[] = [
+    // HTML url should be the first element in the array so Mastodon correctly displays the embed
+    {
+      type: 'Link',
+      mediaType: 'text/html',
+      href: WEBSERVER.URL + '/videos/watch/' + video.uuid
+    }
+  ]
+
   addVideoFilesInAPAcc(url, video, baseUrlHttp, baseUrlWs, video.VideoFiles || [])
 
   for (const playlist of (video.VideoStreamingPlaylists || [])) {
@@ -296,13 +304,6 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject {
     })
   }
 
-  // Add video url too
-  url.push({
-    type: 'Link',
-    mediaType: 'text/html',
-    href: WEBSERVER.URL + '/videos/watch/' + video.uuid
-  })
-
   const subtitleLanguage = []
   for (const caption of video.VideoCaptions) {
     subtitleLanguage.push({
@@ -338,7 +339,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject {
     subtitleLanguage,
     icon: {
       type: 'Image',
-      url: miniature.getFileUrl(),
+      url: miniature.getFileUrl(video.isOwned()),
       mediaType: 'image/jpeg',
       width: miniature.width,
       height: miniature.height