aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/video-playlist.ts8
-rw-r--r--server/tests/api/videos/video-playlists.ts31
2 files changed, 35 insertions, 4 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 0a7ff92df..c7dfc583b 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -292,7 +292,7 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
292 videoId: video.id 292 videoId: video.id
293 }, { transaction: t }) 293 }, { transaction: t })
294 294
295 videoPlaylist.updatedAt = new Date() 295 videoPlaylist.changed('updatedAt', true)
296 await videoPlaylist.save({ transaction: t }) 296 await videoPlaylist.save({ transaction: t })
297 297
298 await sendUpdateVideoPlaylist(videoPlaylist, t) 298 await sendUpdateVideoPlaylist(videoPlaylist, t)
@@ -332,7 +332,7 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re
332 332
333 const element = await videoPlaylistElement.save({ transaction: t }) 333 const element = await videoPlaylistElement.save({ transaction: t })
334 334
335 videoPlaylist.updatedAt = new Date() 335 videoPlaylist.changed('updatedAt', true)
336 await videoPlaylist.save({ transaction: t }) 336 await videoPlaylist.save({ transaction: t })
337 337
338 await sendUpdateVideoPlaylist(videoPlaylist, t) 338 await sendUpdateVideoPlaylist(videoPlaylist, t)
@@ -356,7 +356,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
356 // Decrease position of the next elements 356 // Decrease position of the next elements
357 await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t) 357 await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t)
358 358
359 videoPlaylist.updatedAt = new Date() 359 videoPlaylist.changed('updatedAt', true)
360 await videoPlaylist.save({ transaction: t }) 360 await videoPlaylist.save({ transaction: t })
361 361
362 await sendUpdateVideoPlaylist(videoPlaylist, t) 362 await sendUpdateVideoPlaylist(videoPlaylist, t)
@@ -401,7 +401,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
401 // Decrease positions of elements after the old position of our ordered elements (decrease) 401 // Decrease positions of elements after the old position of our ordered elements (decrease)
402 await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t) 402 await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t)
403 403
404 videoPlaylist.updatedAt = new Date() 404 videoPlaylist.changed('updatedAt', true)
405 await videoPlaylist.save({ transaction: t }) 405 await videoPlaylist.save({ transaction: t })
406 406
407 await sendUpdateVideoPlaylist(videoPlaylist, t) 407 await sendUpdateVideoPlaylist(videoPlaylist, t)
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 931491406..358a064ff 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -664,6 +664,37 @@ describe('Test video playlists', function () {
664 expect(obj[43000]).to.have.lengthOf(0) 664 expect(obj[43000]).to.have.lengthOf(0)
665 }) 665 })
666 666
667 it('Should automatically update updatedAt field of playlists', async function () {
668 const server = servers[1]
669 const videoId = servers[1].videos[5].id
670
671 async function getPlaylistNames () {
672 const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, undefined, '-updatedAt')
673
674 return (res.body.data as VideoPlaylist[]).map(p => p.displayName)
675 }
676
677 const elementAttrs = { videoId }
678 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, elementAttrs })
679 await addVideoInPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, elementAttrs })
680
681 const names1 = await getPlaylistNames()
682 expect(names1[0]).to.equal('playlist 3 updated')
683 expect(names1[1]).to.equal('playlist 2')
684
685 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id1, videoId })
686
687 const names2 = await getPlaylistNames()
688 expect(names2[0]).to.equal('playlist 2')
689 expect(names2[1]).to.equal('playlist 3 updated')
690
691 await removeVideoFromPlaylist({ url: server.url, token: server.accessToken, playlistId: playlistServer2Id2, videoId })
692
693 const names3 = await getPlaylistNames()
694 expect(names3[0]).to.equal('playlist 3 updated')
695 expect(names3[1]).to.equal('playlist 2')
696 })
697
667 it('Should delete some elements', async function () { 698 it('Should delete some elements', async function () {
668 this.timeout(30000) 699 this.timeout(30000)
669 700