From f0a3988066f72a28bb44520af072f18d91d77dde Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Mar 2019 17:06:00 +0100 Subject: Add to playlist dropdown --- server/models/video/video-playlist.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'server/models/video') diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 4d2ea0a66..aa42687cd 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts @@ -317,6 +317,29 @@ export class VideoPlaylistModel extends Model { }) } + static listPlaylistIdsOf (accountId: number, videoIds: number[]) { + const query = { + attributes: [ 'id' ], + where: { + ownerAccountId: accountId + }, + include: [ + { + attributes: [ 'videoId', 'startTimestamp', 'stopTimestamp' ], + model: VideoPlaylistElementModel.unscoped(), + where: { + videoId: { + [Sequelize.Op.any]: videoIds + } + }, + required: true + } + ] + } + + return VideoPlaylistModel.findAll(query) + } + static doesPlaylistExist (url: string) { const query = { attributes: [], -- cgit v1.2.3