]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix publishedAt value after following a new instance
authorChocobozzz <me@florianbigard.com>
Mon, 28 May 2018 16:50:44 +0000 (18:50 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 28 May 2018 16:50:44 +0000 (18:50 +0200)
server/lib/activitypub/videos.ts
server/tests/api/videos/multiple-servers.ts
server/tests/utils/videos/videos.ts

index be6794cef93620110ae2b7ab76e21ec214e9f90a..907f7e11e273e55a559af20f7f9762de0498846f 100644 (file)
@@ -93,6 +93,7 @@ async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelMode
     channelId: videoChannel.id,
     duration: parseInt(duration, 10),
     createdAt: new Date(videoObject.published),
+    publishedAt: new Date(videoObject.published),
     // FIXME: updatedAt does not seems to be considered by Sequelize
     updatedAt: new Date(videoObject.updated),
     views: videoObject.views,
index 94d627e263d53b92ab3eb76adfcbc8d0fe22db61..fc7c0cb21c8be23480368a202083190fbdcb988b 100644 (file)
@@ -105,6 +105,7 @@ describe('Test multiple servers', function () {
       await wait(10000)
 
       // All servers should have this video
+      let publishedAt: string = null
       for (const server of servers) {
         const isLocal = server.url === 'http://localhost:9001'
         const checkAttributes = {
@@ -120,6 +121,7 @@ describe('Test multiple servers', function () {
             host: 'localhost:9001'
           },
           isLocal,
+          publishedAt,
           duration: 10,
           tags: [ 'tag1p1', 'tag2p1' ],
           privacy: VideoPrivacy.PUBLIC,
@@ -145,6 +147,7 @@ describe('Test multiple servers', function () {
         const video = videos[0]
 
         await completeVideoCheck(server.url, video, checkAttributes)
+        publishedAt = video.publishedAt
       }
     })
 
index 46fa5f79d357217654864cdc3ee265975d6a7ac0..746b5ca6b558e69383d1f970a95baafcb27131ea 100644 (file)
@@ -447,6 +447,7 @@ async function completeVideoCheck (
     nsfw: boolean
     commentsEnabled: boolean
     description: string
+    publishedAt?: string
     support: string
     account: {
       name: string
@@ -500,6 +501,12 @@ async function completeVideoCheck (
   expect(dateIsValid(video.publishedAt)).to.be.true
   expect(dateIsValid(video.updatedAt)).to.be.true
 
+  if (attributes.publishedAt) {
+    console.log(attributes.publishedAt)
+    console.log(video.publishedAt)
+    expect(video.publishedAt).to.equal(attributes.publishedAt)
+  }
+
   const res = await getVideo(url, video.uuid)
   const videoDetails: VideoDetails = res.body