diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-31 15:57:32 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-08-01 09:11:04 +0200 |
commit | bfbd912886eba17b4aa9a40dcef2fddc685d85bf (patch) | |
tree | 85e0f22980210a8ccd0888eb5e1790b152074677 /server/controllers | |
parent | 85394ba22a07bde1dfccebf3f591a5d6dbe9df56 (diff) | |
download | PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.tar.gz PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.tar.zst PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.zip |
Fix broken playlist api
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/users/my-video-playlists.ts | 1 | ||||
-rw-r--r-- | server/controllers/api/video-playlist.ts | 35 |
2 files changed, 14 insertions, 22 deletions
diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts index 15e92f4f3..735a3cbee 100644 --- a/server/controllers/api/users/my-video-playlists.ts +++ b/server/controllers/api/users/my-video-playlists.ts | |||
@@ -35,6 +35,7 @@ async function doVideosInPlaylistExist (req: express.Request, res: express.Respo | |||
35 | for (const result of results) { | 35 | for (const result of results) { |
36 | for (const element of result.VideoPlaylistElements) { | 36 | for (const element of result.VideoPlaylistElements) { |
37 | existObject[element.videoId].push({ | 37 | existObject[element.videoId].push({ |
38 | playlistElementId: element.id, | ||
38 | playlistId: result.id, | 39 | playlistId: result.id, |
39 | startTimestamp: element.startTimestamp, | 40 | startTimestamp: element.startTimestamp, |
40 | stopTimestamp: element.stopTimestamp | 41 | stopTimestamp: element.stopTimestamp |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 62490e63b..540120cca 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -4,14 +4,13 @@ import { | |||
4 | asyncMiddleware, | 4 | asyncMiddleware, |
5 | asyncRetryTransactionMiddleware, | 5 | asyncRetryTransactionMiddleware, |
6 | authenticate, | 6 | authenticate, |
7 | commonVideosFiltersValidator, | ||
8 | optionalAuthenticate, | 7 | optionalAuthenticate, |
9 | paginationValidator, | 8 | paginationValidator, |
10 | setDefaultPagination, | 9 | setDefaultPagination, |
11 | setDefaultSort | 10 | setDefaultSort |
12 | } from '../../middlewares' | 11 | } from '../../middlewares' |
13 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' | 12 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' |
14 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 13 | import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' |
15 | import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' | 14 | import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' |
16 | import { logger } from '../../helpers/logger' | 15 | import { logger } from '../../helpers/logger' |
17 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 16 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
@@ -32,7 +31,6 @@ import { join } from 'path' | |||
32 | import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' | 31 | import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' |
33 | import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' | 32 | import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' |
34 | import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' | 33 | import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' |
35 | import { VideoModel } from '../../models/video/video' | ||
36 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | 34 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' |
37 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' | 35 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' |
38 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | 36 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' |
@@ -88,7 +86,6 @@ videoPlaylistRouter.get('/:playlistId/videos', | |||
88 | paginationValidator, | 86 | paginationValidator, |
89 | setDefaultPagination, | 87 | setDefaultPagination, |
90 | optionalAuthenticate, | 88 | optionalAuthenticate, |
91 | commonVideosFiltersValidator, | ||
92 | asyncMiddleware(getVideoPlaylistVideos) | 89 | asyncMiddleware(getVideoPlaylistVideos) |
93 | ) | 90 | ) |
94 | 91 | ||
@@ -104,13 +101,13 @@ videoPlaylistRouter.post('/:playlistId/videos/reorder', | |||
104 | asyncRetryTransactionMiddleware(reorderVideosPlaylist) | 101 | asyncRetryTransactionMiddleware(reorderVideosPlaylist) |
105 | ) | 102 | ) |
106 | 103 | ||
107 | videoPlaylistRouter.put('/:playlistId/videos/:videoId', | 104 | videoPlaylistRouter.put('/:playlistId/videos/:playlistElementId', |
108 | authenticate, | 105 | authenticate, |
109 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), | 106 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), |
110 | asyncRetryTransactionMiddleware(updateVideoPlaylistElement) | 107 | asyncRetryTransactionMiddleware(updateVideoPlaylistElement) |
111 | ) | 108 | ) |
112 | 109 | ||
113 | videoPlaylistRouter.delete('/:playlistId/videos/:videoId', | 110 | videoPlaylistRouter.delete('/:playlistId/videos/:playlistElementId', |
114 | authenticate, | 111 | authenticate, |
115 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), | 112 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), |
116 | asyncRetryTransactionMiddleware(removeVideoFromPlaylist) | 113 | asyncRetryTransactionMiddleware(removeVideoFromPlaylist) |
@@ -426,26 +423,20 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons | |||
426 | 423 | ||
427 | async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { | 424 | async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { |
428 | const videoPlaylistInstance = res.locals.videoPlaylist | 425 | const videoPlaylistInstance = res.locals.videoPlaylist |
429 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined | 426 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
427 | const server = await getServerActor() | ||
430 | 428 | ||
431 | const resultList = await VideoModel.listForApi({ | 429 | const resultList = await VideoPlaylistElementModel.listForApi({ |
432 | followerActorId, | ||
433 | start: req.query.start, | 430 | start: req.query.start, |
434 | count: req.query.count, | 431 | count: req.query.count, |
435 | sort: 'VideoPlaylistElements.position', | ||
436 | includeLocalVideos: true, | ||
437 | categoryOneOf: req.query.categoryOneOf, | ||
438 | licenceOneOf: req.query.licenceOneOf, | ||
439 | languageOneOf: req.query.languageOneOf, | ||
440 | tagsOneOf: req.query.tagsOneOf, | ||
441 | tagsAllOf: req.query.tagsAllOf, | ||
442 | filter: req.query.filter, | ||
443 | nsfw: buildNSFWFilter(res, req.query.nsfw), | ||
444 | withFiles: false, | ||
445 | videoPlaylistId: videoPlaylistInstance.id, | 432 | videoPlaylistId: videoPlaylistInstance.id, |
446 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined | 433 | serverAccount: server.Account, |
434 | user | ||
447 | }) | 435 | }) |
448 | 436 | ||
449 | const additionalAttributes = { playlistInfo: true } | 437 | const options = { |
450 | return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) | 438 | displayNSFW: buildNSFWFilter(res, req.query.nsfw), |
439 | accountId: user ? user.Account.id : undefined | ||
440 | } | ||
441 | return res.json(getFormattedObjects(resultList.data, resultList.total, options)) | ||
451 | } | 442 | } |