X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fusers%2Fmy-video-playlists.ts;h=d0bd9946323b16066006c87f1f91f7d69099674d;hb=0fee09d878c576e6cbb2dd6cc733021717acc644;hp=1ec175f6496f4f2b0f83cc7a50b5fff9735d299c;hpb=f0a3988066f72a28bb44520af072f18d91d77dde;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts index 1ec175f64..d0bd99463 100644 --- a/server/controllers/api/users/my-video-playlists.ts +++ b/server/controllers/api/users/my-video-playlists.ts @@ -1,9 +1,8 @@ import * as express from 'express' import { asyncMiddleware, authenticate } from '../../../middlewares' -import { UserModel } from '../../../models/account/user' import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' +import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' const myVideoPlaylistsRouter = express.Router() @@ -22,12 +21,12 @@ export { // --------------------------------------------------------------------------- async function doVideosInPlaylistExist (req: express.Request, res: express.Response) { - const videoIds = req.query.videoIds as number[] - const user = res.locals.oauth.token.User as UserModel + const videoIds = req.query.videoIds.map(i => parseInt(i + '', 10)) + const user = res.locals.oauth.token.User const results = await VideoPlaylistModel.listPlaylistIdsOf(user.Account.id, videoIds) - const existObject: VideoExistInPlaylist = {} + const existObject: VideosExistInPlaylists = {} for (const videoId of videoIds) { existObject[videoId] = [] @@ -36,6 +35,7 @@ async function doVideosInPlaylistExist (req: express.Request, res: express.Respo for (const result of results) { for (const element of result.VideoPlaylistElements) { existObject[element.videoId].push({ + playlistElementId: element.id, playlistId: result.id, startTimestamp: element.startTimestamp, stopTimestamp: element.stopTimestamp