diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-playlist.ts | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index ce49f77ec..4d2ea0a66 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -47,7 +47,8 @@ enum ScopeNames { | |||
47 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', | 47 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', |
48 | WITH_VIDEOS_LENGTH = 'WITH_VIDEOS_LENGTH', | 48 | WITH_VIDEOS_LENGTH = 'WITH_VIDEOS_LENGTH', |
49 | WITH_ACCOUNT_AND_CHANNEL_SUMMARY = 'WITH_ACCOUNT_AND_CHANNEL_SUMMARY', | 49 | WITH_ACCOUNT_AND_CHANNEL_SUMMARY = 'WITH_ACCOUNT_AND_CHANNEL_SUMMARY', |
50 | WITH_ACCOUNT = 'WITH_ACCOUNT' | 50 | WITH_ACCOUNT = 'WITH_ACCOUNT', |
51 | WITH_ACCOUNT_AND_CHANNEL = 'WITH_ACCOUNT_AND_CHANNEL' | ||
51 | } | 52 | } |
52 | 53 | ||
53 | type AvailableForListOptions = { | 54 | type AvailableForListOptions = { |
@@ -89,6 +90,18 @@ type AvailableForListOptions = { | |||
89 | } | 90 | } |
90 | ] | 91 | ] |
91 | }, | 92 | }, |
93 | [ ScopeNames.WITH_ACCOUNT_AND_CHANNEL ]: { | ||
94 | include: [ | ||
95 | { | ||
96 | model: () => AccountModel, | ||
97 | required: true | ||
98 | }, | ||
99 | { | ||
100 | model: () => VideoChannelModel, | ||
101 | required: false | ||
102 | } | ||
103 | ] | ||
104 | }, | ||
92 | [ ScopeNames.AVAILABLE_FOR_LIST ]: (options: AvailableForListOptions) => { | 105 | [ ScopeNames.AVAILABLE_FOR_LIST ]: (options: AvailableForListOptions) => { |
93 | // Only list local playlists OR playlists that are on an instance followed by actorId | 106 | // Only list local playlists OR playlists that are on an instance followed by actorId |
94 | const inQueryInstanceFollow = buildServerIdsFollowedBy(options.followerActorId) | 107 | const inQueryInstanceFollow = buildServerIdsFollowedBy(options.followerActorId) |
@@ -317,7 +330,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
317 | .then(e => !!e) | 330 | .then(e => !!e) |
318 | } | 331 | } |
319 | 332 | ||
320 | static loadWithAccountAndChannel (id: number | string, transaction: Sequelize.Transaction) { | 333 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Sequelize.Transaction) { |
321 | const where = buildWhereIdOrUUID(id) | 334 | const where = buildWhereIdOrUUID(id) |
322 | 335 | ||
323 | const query = { | 336 | const query = { |
@@ -330,6 +343,19 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
330 | .findOne(query) | 343 | .findOne(query) |
331 | } | 344 | } |
332 | 345 | ||
346 | static loadWithAccountAndChannel (id: number | string, transaction: Sequelize.Transaction) { | ||
347 | const where = buildWhereIdOrUUID(id) | ||
348 | |||
349 | const query = { | ||
350 | where, | ||
351 | transaction | ||
352 | } | ||
353 | |||
354 | return VideoPlaylistModel | ||
355 | .scope([ ScopeNames.WITH_ACCOUNT_AND_CHANNEL, ScopeNames.WITH_VIDEOS_LENGTH ]) | ||
356 | .findOne(query) | ||
357 | } | ||
358 | |||
333 | static loadByUrlAndPopulateAccount (url: string) { | 359 | static loadByUrlAndPopulateAccount (url: string) { |
334 | const query = { | 360 | const query = { |
335 | where: { | 361 | where: { |