aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-28 11:14:26 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commit07b1a18aa678d260009a93e36606c5c5f585723d (patch)
tree27a399fa0f7a29a7ac1d7d7cf077a24ea6ee39de /server/controllers/api
parent418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (diff)
downloadPeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.gz
PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.zst
PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.zip
Add playlist check param tests
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/video-playlist.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 709c58beb..e026b4d16 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -4,7 +4,7 @@ import {
4 asyncMiddleware, 4 asyncMiddleware,
5 asyncRetryTransactionMiddleware, 5 asyncRetryTransactionMiddleware,
6 authenticate, 6 authenticate,
7 commonVideosFiltersValidator, 7 commonVideosFiltersValidator, optionalAuthenticate,
8 paginationValidator, 8 paginationValidator,
9 setDefaultPagination, 9 setDefaultPagination,
10 setDefaultSort 10 setDefaultSort
@@ -31,12 +31,14 @@ import { processImage } from '../../helpers/image-utils'
31import { join } from 'path' 31import { join } from 'path'
32import { UserModel } from '../../models/account/user' 32import { UserModel } from '../../models/account/user'
33import { 33import {
34 getVideoPlaylistActivityPubUrl,
35 getVideoPlaylistElementActivityPubUrl,
36 sendCreateVideoPlaylist, 34 sendCreateVideoPlaylist,
37 sendDeleteVideoPlaylist, 35 sendDeleteVideoPlaylist,
38 sendUpdateVideoPlaylist 36 sendUpdateVideoPlaylist
39} from '../../lib/activitypub' 37} from '../../lib/activitypub/send'
38import {
39 getVideoPlaylistActivityPubUrl,
40 getVideoPlaylistElementActivityPubUrl
41} from '../../lib/activitypub/url'
40import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' 42import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model'
41import { VideoModel } from '../../models/video/video' 43import { VideoModel } from '../../models/video/video'
42import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' 44import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
@@ -85,6 +87,7 @@ videoPlaylistRouter.get('/:playlistId/videos',
85 asyncMiddleware(videoPlaylistsGetValidator), 87 asyncMiddleware(videoPlaylistsGetValidator),
86 paginationValidator, 88 paginationValidator,
87 setDefaultPagination, 89 setDefaultPagination,
90 optionalAuthenticate,
88 commonVideosFiltersValidator, 91 commonVideosFiltersValidator,
89 asyncMiddleware(getVideoPlaylistVideos) 92 asyncMiddleware(getVideoPlaylistVideos)
90) 93)
@@ -95,7 +98,7 @@ videoPlaylistRouter.post('/:playlistId/videos',
95 asyncRetryTransactionMiddleware(addVideoInPlaylist) 98 asyncRetryTransactionMiddleware(addVideoInPlaylist)
96) 99)
97 100
98videoPlaylistRouter.put('/:playlistId/videos', 101videoPlaylistRouter.post('/:playlistId/videos/reorder',
99 authenticate, 102 authenticate,
100 asyncMiddleware(videoPlaylistsReorderVideosValidator), 103 asyncMiddleware(videoPlaylistsReorderVideosValidator),
101 asyncRetryTransactionMiddleware(reorderVideosPlaylist) 104 asyncRetryTransactionMiddleware(reorderVideosPlaylist)
@@ -168,6 +171,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
168 const videoPlaylistCreated: VideoPlaylistModel = await sequelizeTypescript.transaction(async t => { 171 const videoPlaylistCreated: VideoPlaylistModel = await sequelizeTypescript.transaction(async t => {
169 const videoPlaylistCreated = await videoPlaylist.save({ transaction: t }) 172 const videoPlaylistCreated = await videoPlaylist.save({ transaction: t })
170 173
174 videoPlaylistCreated.OwnerAccount = user.Account
171 await sendCreateVideoPlaylist(videoPlaylistCreated, t) 175 await sendCreateVideoPlaylist(videoPlaylistCreated, t)
172 176
173 return videoPlaylistCreated 177 return videoPlaylistCreated
@@ -349,7 +353,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
349 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist 353 const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
350 354
351 const start: number = req.body.startPosition 355 const start: number = req.body.startPosition
352 const insertAfter: number = req.body.insertAfter 356 const insertAfter: number = req.body.insertAfterPosition
353 const reorderLength: number = req.body.reorderLength || 1 357 const reorderLength: number = req.body.reorderLength || 1
354 358
355 if (start === insertAfter) { 359 if (start === insertAfter) {