diff options
Diffstat (limited to 'server/models/video/video-playlist.ts')
-rw-r--r-- | server/models/video/video-playlist.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index c8e97c491..9f1d03ac5 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -43,6 +43,14 @@ import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video- | |||
43 | import { ThumbnailModel } from './thumbnail' | 43 | import { ThumbnailModel } from './thumbnail' |
44 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 44 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
45 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' | 45 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' |
46 | import * as Bluebird from 'bluebird' | ||
47 | import { | ||
48 | MVideoPlaylistAccountThumbnail, | ||
49 | MVideoPlaylistFull, | ||
50 | MVideoPlaylistFullSummary, | ||
51 | MVideoPlaylistIdWithElements | ||
52 | } from '../../typings/models/video/video-playlist' | ||
53 | import { MThumbnail } from '../../typings/models/video/thumbnail' | ||
46 | 54 | ||
47 | enum ScopeNames { | 55 | enum ScopeNames { |
48 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', | 56 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', |
@@ -332,7 +340,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
332 | }) | 340 | }) |
333 | } | 341 | } |
334 | 342 | ||
335 | static listPlaylistIdsOf (accountId: number, videoIds: number[]) { | 343 | static listPlaylistIdsOf (accountId: number, videoIds: number[]): Bluebird<MVideoPlaylistIdWithElements[]> { |
336 | const query = { | 344 | const query = { |
337 | attributes: [ 'id' ], | 345 | attributes: [ 'id' ], |
338 | where: { | 346 | where: { |
@@ -368,7 +376,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
368 | .then(e => !!e) | 376 | .then(e => !!e) |
369 | } | 377 | } |
370 | 378 | ||
371 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction) { | 379 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFullSummary> { |
372 | const where = buildWhereIdOrUUID(id) | 380 | const where = buildWhereIdOrUUID(id) |
373 | 381 | ||
374 | const query = { | 382 | const query = { |
@@ -381,7 +389,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
381 | .findOne(query) | 389 | .findOne(query) |
382 | } | 390 | } |
383 | 391 | ||
384 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction) { | 392 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFull> { |
385 | const where = buildWhereIdOrUUID(id) | 393 | const where = buildWhereIdOrUUID(id) |
386 | 394 | ||
387 | const query = { | 395 | const query = { |
@@ -394,7 +402,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
394 | .findOne(query) | 402 | .findOne(query) |
395 | } | 403 | } |
396 | 404 | ||
397 | static loadByUrlAndPopulateAccount (url: string) { | 405 | static loadByUrlAndPopulateAccount (url: string): Bluebird<MVideoPlaylistAccountThumbnail> { |
398 | const query = { | 406 | const query = { |
399 | where: { | 407 | where: { |
400 | url | 408 | url |
@@ -423,7 +431,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
423 | return VideoPlaylistModel.update({ privacy: VideoPlaylistPrivacy.PRIVATE, videoChannelId: null }, query) | 431 | return VideoPlaylistModel.update({ privacy: VideoPlaylistPrivacy.PRIVATE, videoChannelId: null }, query) |
424 | } | 432 | } |
425 | 433 | ||
426 | async setAndSaveThumbnail (thumbnail: ThumbnailModel, t: Transaction) { | 434 | async setAndSaveThumbnail (thumbnail: MThumbnail, t: Transaction) { |
427 | thumbnail.videoPlaylistId = this.id | 435 | thumbnail.videoPlaylistId = this.id |
428 | 436 | ||
429 | this.Thumbnail = await thumbnail.save({ transaction: t }) | 437 | this.Thumbnail = await thumbnail.save({ transaction: t }) |