diff options
Diffstat (limited to 'server/controllers/api/users/my-video-playlists.ts')
-rw-r--r-- | server/controllers/api/users/my-video-playlists.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts deleted file mode 100644 index fbdbb7e50..000000000 --- a/server/controllers/api/users/my-video-playlists.ts +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { forceNumber } from '@shared/core-utils' | ||
3 | import { uuidToShort } from '@shared/extra-utils' | ||
4 | import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' | ||
5 | import { asyncMiddleware, authenticate } from '../../../middlewares' | ||
6 | import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' | ||
7 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
8 | |||
9 | const myVideoPlaylistsRouter = express.Router() | ||
10 | |||
11 | myVideoPlaylistsRouter.get('/me/video-playlists/videos-exist', | ||
12 | authenticate, | ||
13 | doVideosInPlaylistExistValidator, | ||
14 | asyncMiddleware(doVideosInPlaylistExist) | ||
15 | ) | ||
16 | |||
17 | // --------------------------------------------------------------------------- | ||
18 | |||
19 | export { | ||
20 | myVideoPlaylistsRouter | ||
21 | } | ||
22 | |||
23 | // --------------------------------------------------------------------------- | ||
24 | |||
25 | async function doVideosInPlaylistExist (req: express.Request, res: express.Response) { | ||
26 | const videoIds = req.query.videoIds.map(i => forceNumber(i)) | ||
27 | const user = res.locals.oauth.token.User | ||
28 | |||
29 | const results = await VideoPlaylistModel.listPlaylistSummariesOf(user.Account.id, videoIds) | ||
30 | |||
31 | const existObject: VideosExistInPlaylists = {} | ||
32 | |||
33 | for (const videoId of videoIds) { | ||
34 | existObject[videoId] = [] | ||
35 | } | ||
36 | |||
37 | for (const result of results) { | ||
38 | for (const element of result.VideoPlaylistElements) { | ||
39 | existObject[element.videoId].push({ | ||
40 | playlistElementId: element.id, | ||
41 | playlistId: result.id, | ||
42 | playlistDisplayName: result.name, | ||
43 | playlistShortUUID: uuidToShort(result.uuid), | ||
44 | startTimestamp: element.startTimestamp, | ||
45 | stopTimestamp: element.stopTimestamp | ||
46 | }) | ||
47 | } | ||
48 | } | ||
49 | |||
50 | return res.json(existObject) | ||
51 | } | ||