]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/videos.ts
Fix broken local actors
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / videos.ts
index 66330a9649beb40233b9a77cbdb4878ed85ecbd3..c29bcc52843eeef9302e2009456e28b4453b7aac 100644 (file)
@@ -336,10 +336,15 @@ async function updateVideoFromAP (options: {
 
       videoFieldsSave = video.toJSON()
 
-      // Check actor has the right to update the video
-      const videoChannel = video.VideoChannel
-      if (videoChannel.Account.id !== account.id) {
-        throw new Error('Account ' + account.Actor.url + ' does not own video channel ' + videoChannel.Actor.url)
+      // Check we can update the channel: we trust the remote server
+      const oldVideoChannel = video.VideoChannel
+
+      if (!oldVideoChannel.Actor.serverId || !channel.Actor.serverId) {
+        throw new Error('Cannot check old channel/new channel validity because `serverId` is null')
+      }
+
+      if (oldVideoChannel.Actor.serverId !== channel.Actor.serverId) {
+        throw new Error('New channel ' + channel.Actor.url + ' is not on the same server than new channel ' + oldVideoChannel.Actor.url)
       }
 
       const to = overrideTo || videoObject.to
@@ -912,7 +917,7 @@ function getTrackerUrls (object: VideoObject, video: MVideoWithHost) {
 
   const trackers = object.url.filter(u => isAPVideoTrackerUrlObject(u))
     .map((u: ActivityTrackerUrlObject) => {
-      if (u.rel.includes('websocket')) wsFound = true
+      if (isArray(u.rel) && u.rel.includes('websocket')) wsFound = true
 
       return u.href
     })