diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-08 14:30:29 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-09 11:41:22 +0100 |
commit | b49f22d8f9a52ab75fd38db2d377249eb58fa678 (patch) | |
tree | a2825877d7b3b53454804a79c9d2a14c5d37385c /server/models/video | |
parent | 6c8c15f914cd375da1db5d0cd4d924a86c53d4c1 (diff) | |
download | PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.gz PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.zst PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.zip |
Upgrade sequelize to v6
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/schedule-video-update.ts | 2 | ||||
-rw-r--r-- | server/models/video/tag.ts | 13 | ||||
-rw-r--r-- | server/models/video/thumbnail.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 17 | ||||
-rw-r--r-- | server/models/video/video-caption.ts | 23 | ||||
-rw-r--r-- | server/models/video/video-change-ownership.ts | 11 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 78 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 13 | ||||
-rw-r--r-- | server/models/video/video-file.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-import.ts | 15 | ||||
-rw-r--r-- | server/models/video/video-live.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-playlist-element.ts | 33 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 22 | ||||
-rw-r--r-- | server/models/video/video-share.ts | 19 | ||||
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-tag.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-view.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 85 |
18 files changed, 167 insertions, 176 deletions
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts index 1ce6bbfe5..22b08e91a 100644 --- a/server/models/video/schedule-video-update.ts +++ b/server/models/video/schedule-video-update.ts | |||
@@ -16,7 +16,7 @@ import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdateVideoAll } from '@ | |||
16 | } | 16 | } |
17 | ] | 17 | ] |
18 | }) | 18 | }) |
19 | export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | 19 | export class ScheduleVideoUpdateModel extends Model { |
20 | 20 | ||
21 | @AllowNull(false) | 21 | @AllowNull(false) |
22 | @Default(null) | 22 | @Default(null) |
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts index adbc4fb7d..d04205703 100644 --- a/server/models/video/tag.ts +++ b/server/models/video/tag.ts | |||
@@ -1,12 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { col, fn, QueryTypes, Transaction } from 'sequelize' |
2 | import { fn, QueryTypes, Transaction, col } from 'sequelize' | ||
3 | import { AllowNull, BelongsToMany, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsToMany, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { MTag } from '@server/types/models' | ||
4 | import { VideoPrivacy, VideoState } from '../../../shared/models/videos' | ||
4 | import { isVideoTagValid } from '../../helpers/custom-validators/videos' | 5 | import { isVideoTagValid } from '../../helpers/custom-validators/videos' |
5 | import { throwIfNotValid } from '../utils' | 6 | import { throwIfNotValid } from '../utils' |
6 | import { VideoModel } from './video' | 7 | import { VideoModel } from './video' |
7 | import { VideoTagModel } from './video-tag' | 8 | import { VideoTagModel } from './video-tag' |
8 | import { VideoPrivacy, VideoState } from '../../../shared/models/videos' | ||
9 | import { MTag } from '@server/types/models' | ||
10 | 9 | ||
11 | @Table({ | 10 | @Table({ |
12 | tableName: 'tag', | 11 | tableName: 'tag', |
@@ -22,7 +21,7 @@ import { MTag } from '@server/types/models' | |||
22 | } | 21 | } |
23 | ] | 22 | ] |
24 | }) | 23 | }) |
25 | export class TagModel extends Model<TagModel> { | 24 | export class TagModel extends Model { |
26 | 25 | ||
27 | @AllowNull(false) | 26 | @AllowNull(false) |
28 | @Is('VideoTag', value => throwIfNotValid(value, isVideoTagValid, 'tag')) | 27 | @Is('VideoTag', value => throwIfNotValid(value, isVideoTagValid, 'tag')) |
@@ -45,7 +44,7 @@ export class TagModel extends Model<TagModel> { | |||
45 | static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> { | 44 | static findOrCreateTags (tags: string[], transaction: Transaction): Promise<MTag[]> { |
46 | if (tags === null) return Promise.resolve([]) | 45 | if (tags === null) return Promise.resolve([]) |
47 | 46 | ||
48 | const tasks: Bluebird<MTag>[] = [] | 47 | const tasks: Promise<MTag>[] = [] |
49 | tags.forEach(tag => { | 48 | tags.forEach(tag => { |
50 | const query = { | 49 | const query = { |
51 | where: { | 50 | where: { |
@@ -66,7 +65,7 @@ export class TagModel extends Model<TagModel> { | |||
66 | } | 65 | } |
67 | 66 | ||
68 | // threshold corresponds to how many video the field should have to be returned | 67 | // threshold corresponds to how many video the field should have to be returned |
69 | static getRandomSamples (threshold: number, count: number): Bluebird<string[]> { | 68 | static getRandomSamples (threshold: number, count: number): Promise<string[]> { |
70 | const query = 'SELECT tag.name FROM tag ' + | 69 | const query = 'SELECT tag.name FROM tag ' + |
71 | 'INNER JOIN "videoTag" ON "videoTag"."tagId" = tag.id ' + | 70 | 'INNER JOIN "videoTag" ON "videoTag"."tagId" = tag.id ' + |
72 | 'INNER JOIN video ON video.id = "videoTag"."videoId" ' + | 71 | 'INNER JOIN video ON video.id = "videoTag"."videoId" ' + |
diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts index 20c1e5858..6878a3155 100644 --- a/server/models/video/thumbnail.ts +++ b/server/models/video/thumbnail.ts | |||
@@ -34,7 +34,7 @@ import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' | |||
34 | } | 34 | } |
35 | ] | 35 | ] |
36 | }) | 36 | }) |
37 | export class ThumbnailModel extends Model<ThumbnailModel> { | 37 | export class ThumbnailModel extends Model { |
38 | 38 | ||
39 | @AllowNull(false) | 39 | @AllowNull(false) |
40 | @Column | 40 | @Column |
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 36d2a30fa..aa18896da 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -1,14 +1,13 @@ | |||
1 | import { FindOptions } from 'sequelize' | ||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' |
2 | import { getBlacklistSort, SortType, throwIfNotValid, searchAttribute } from '../utils' | 3 | import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models' |
3 | import { VideoModel } from './video' | ||
4 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' | ||
5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' | ||
6 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' | 4 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' |
5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' | ||
7 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 6 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
8 | import { FindOptions } from 'sequelize' | 7 | import { getBlacklistSort, searchAttribute, SortType, throwIfNotValid } from '../utils' |
9 | import { ThumbnailModel } from './thumbnail' | 8 | import { ThumbnailModel } from './thumbnail' |
10 | import * as Bluebird from 'bluebird' | 9 | import { VideoModel } from './video' |
11 | import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models' | 10 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' |
12 | 11 | ||
13 | @Table({ | 12 | @Table({ |
14 | tableName: 'videoBlacklist', | 13 | tableName: 'videoBlacklist', |
@@ -19,7 +18,7 @@ import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/model | |||
19 | } | 18 | } |
20 | ] | 19 | ] |
21 | }) | 20 | }) |
22 | export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | 21 | export class VideoBlacklistModel extends Model { |
23 | 22 | ||
24 | @AllowNull(true) | 23 | @AllowNull(true) |
25 | @Is('VideoBlacklistReason', value => throwIfNotValid(value, isVideoBlacklistReasonValid, 'reason', true)) | 24 | @Is('VideoBlacklistReason', value => throwIfNotValid(value, isVideoBlacklistReasonValid, 'reason', true)) |
@@ -109,7 +108,7 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | |||
109 | }) | 108 | }) |
110 | } | 109 | } |
111 | 110 | ||
112 | static loadByVideoId (id: number): Bluebird<MVideoBlacklist> { | 111 | static loadByVideoId (id: number): Promise<MVideoBlacklist> { |
113 | const query = { | 112 | const query = { |
114 | where: { | 113 | where: { |
115 | videoId: id | 114 | videoId: id |
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index b68a6e99f..e8e883dd0 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { remove } from 'fs-extra' | ||
2 | import { join } from 'path' | ||
1 | import { OrderItem, Transaction } from 'sequelize' | 3 | import { OrderItem, Transaction } from 'sequelize' |
2 | import { | 4 | import { |
3 | AllowNull, | 5 | AllowNull, |
@@ -13,18 +15,15 @@ import { | |||
13 | Table, | 15 | Table, |
14 | UpdatedAt | 16 | UpdatedAt |
15 | } from 'sequelize-typescript' | 17 | } from 'sequelize-typescript' |
16 | import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' | 18 | import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' |
17 | import { VideoModel } from './video' | 19 | import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' |
18 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | ||
19 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 20 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
20 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' | 21 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
21 | import { join } from 'path' | ||
22 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
23 | import { remove } from 'fs-extra' | ||
24 | import { CONFIG } from '../../initializers/config' | 23 | import { CONFIG } from '../../initializers/config' |
25 | import * as Bluebird from 'bluebird' | 24 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' |
26 | import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' | 25 | import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' |
27 | import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' | 26 | import { VideoModel } from './video' |
28 | 27 | ||
29 | export enum ScopeNames { | 28 | export enum ScopeNames { |
30 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' | 29 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' |
@@ -54,7 +53,7 @@ export enum ScopeNames { | |||
54 | } | 53 | } |
55 | ] | 54 | ] |
56 | }) | 55 | }) |
57 | export class VideoCaptionModel extends Model<VideoCaptionModel> { | 56 | export class VideoCaptionModel extends Model { |
58 | @CreatedAt | 57 | @CreatedAt |
59 | createdAt: Date | 58 | createdAt: Date |
60 | 59 | ||
@@ -101,7 +100,7 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> { | |||
101 | return undefined | 100 | return undefined |
102 | } | 101 | } |
103 | 102 | ||
104 | static loadByVideoIdAndLanguage (videoId: string | number, language: string): Bluebird<MVideoCaptionVideo> { | 103 | static loadByVideoIdAndLanguage (videoId: string | number, language: string): Promise<MVideoCaptionVideo> { |
105 | const videoInclude = { | 104 | const videoInclude = { |
106 | model: VideoModel.unscoped(), | 105 | model: VideoModel.unscoped(), |
107 | attributes: [ 'id', 'remote', 'uuid' ], | 106 | attributes: [ 'id', 'remote', 'uuid' ], |
@@ -131,7 +130,7 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> { | |||
131 | .then(([ caption ]) => caption) | 130 | .then(([ caption ]) => caption) |
132 | } | 131 | } |
133 | 132 | ||
134 | static listVideoCaptions (videoId: number): Bluebird<MVideoCaptionVideo[]> { | 133 | static listVideoCaptions (videoId: number): Promise<MVideoCaptionVideo[]> { |
135 | const query = { | 134 | const query = { |
136 | order: [ [ 'language', 'ASC' ] ] as OrderItem[], | 135 | order: [ [ 'language', 'ASC' ] ] as OrderItem[], |
137 | where: { | 136 | where: { |
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index ac0ab7e8b..298e8bfe2 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
2 | import { AccountModel } from '../account/account' | 2 | import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' |
3 | import { ScopeNames as VideoScopeNames, VideoModel } from './video' | ||
4 | import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' | 3 | import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' |
4 | import { AccountModel } from '../account/account' | ||
5 | import { getSort } from '../utils' | 5 | import { getSort } from '../utils' |
6 | import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' | 6 | import { ScopeNames as VideoScopeNames, VideoModel } from './video' |
7 | import * as Bluebird from 'bluebird' | ||
8 | 7 | ||
9 | enum ScopeNames { | 8 | enum ScopeNames { |
10 | WITH_ACCOUNTS = 'WITH_ACCOUNTS', | 9 | WITH_ACCOUNTS = 'WITH_ACCOUNTS', |
@@ -54,7 +53,7 @@ enum ScopeNames { | |||
54 | ] | 53 | ] |
55 | } | 54 | } |
56 | })) | 55 | })) |
57 | export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel> { | 56 | export class VideoChangeOwnershipModel extends Model { |
58 | @CreatedAt | 57 | @CreatedAt |
59 | createdAt: Date | 58 | createdAt: Date |
60 | 59 | ||
@@ -119,7 +118,7 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel> | |||
119 | ]).then(([ count, rows ]) => ({ total: count, data: rows })) | 118 | ]).then(([ count, rows ]) => ({ total: count, data: rows })) |
120 | } | 119 | } |
121 | 120 | ||
122 | static load (id: number): Bluebird<MVideoChangeOwnershipFull> { | 121 | static load (id: number): Promise<MVideoChangeOwnershipFull> { |
123 | return VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]) | 122 | return VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]) |
124 | .findByPk(id) | 123 | .findByPk(id) |
125 | } | 124 | } |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 0c8aef18f..178878c55 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { FindOptions, Includeable, literal, Op, ScopeOptions } from 'sequelize' |
2 | import { FindOptions, literal, Op, ScopeOptions } from 'sequelize' | ||
3 | import { | 2 | import { |
4 | AllowNull, | 3 | AllowNull, |
5 | BeforeDestroy, | 4 | BeforeDestroy, |
@@ -119,30 +118,31 @@ export type SummaryOptions = { | |||
119 | } | 118 | } |
120 | }, | 119 | }, |
121 | [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => { | 120 | [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => { |
121 | const include: Includeable[] = [ | ||
122 | { | ||
123 | attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], | ||
124 | model: ActorModel.unscoped(), | ||
125 | required: options.actorRequired ?? true, | ||
126 | include: [ | ||
127 | { | ||
128 | attributes: [ 'host' ], | ||
129 | model: ServerModel.unscoped(), | ||
130 | required: false | ||
131 | }, | ||
132 | { | ||
133 | model: AvatarModel.unscoped(), | ||
134 | required: false | ||
135 | } | ||
136 | ] | ||
137 | } | ||
138 | ] | ||
139 | |||
122 | const base: FindOptions = { | 140 | const base: FindOptions = { |
123 | attributes: [ 'id', 'name', 'description', 'actorId' ], | 141 | attributes: [ 'id', 'name', 'description', 'actorId' ] |
124 | include: [ | ||
125 | { | ||
126 | attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], | ||
127 | model: ActorModel.unscoped(), | ||
128 | required: options.actorRequired ?? true, | ||
129 | include: [ | ||
130 | { | ||
131 | attributes: [ 'host' ], | ||
132 | model: ServerModel.unscoped(), | ||
133 | required: false | ||
134 | }, | ||
135 | { | ||
136 | model: AvatarModel.unscoped(), | ||
137 | required: false | ||
138 | } | ||
139 | ] | ||
140 | } | ||
141 | ] | ||
142 | } | 142 | } |
143 | 143 | ||
144 | if (options.withAccount === true) { | 144 | if (options.withAccount === true) { |
145 | base.include.push({ | 145 | include.push({ |
146 | model: AccountModel.scope({ | 146 | model: AccountModel.scope({ |
147 | method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ] | 147 | method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ] |
148 | }), | 148 | }), |
@@ -150,6 +150,8 @@ export type SummaryOptions = { | |||
150 | }) | 150 | }) |
151 | } | 151 | } |
152 | 152 | ||
153 | base.include = include | ||
154 | |||
153 | return base | 155 | return base |
154 | }, | 156 | }, |
155 | [ScopeNames.WITH_ACCOUNT]: { | 157 | [ScopeNames.WITH_ACCOUNT]: { |
@@ -221,7 +223,7 @@ export type SummaryOptions = { | |||
221 | } | 223 | } |
222 | ] | 224 | ] |
223 | }) | 225 | }) |
224 | export class VideoChannelModel extends Model<VideoChannelModel> { | 226 | export class VideoChannelModel extends Model { |
225 | 227 | ||
226 | @AllowNull(false) | 228 | @AllowNull(false) |
227 | @Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelNameValid, 'name')) | 229 | @Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelNameValid, 'name')) |
@@ -328,18 +330,17 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
328 | order: getSort(parameters.sort) | 330 | order: getSort(parameters.sort) |
329 | } | 331 | } |
330 | 332 | ||
331 | const scopes = { | ||
332 | method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ] | ||
333 | } | ||
334 | return VideoChannelModel | 333 | return VideoChannelModel |
335 | .scope(scopes) | 334 | .scope({ |
335 | method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ] | ||
336 | }) | ||
336 | .findAndCountAll(query) | 337 | .findAndCountAll(query) |
337 | .then(({ rows, count }) => { | 338 | .then(({ rows, count }) => { |
338 | return { total: count, data: rows } | 339 | return { total: count, data: rows } |
339 | }) | 340 | }) |
340 | } | 341 | } |
341 | 342 | ||
342 | static listLocalsForSitemap (sort: string): Bluebird<MChannelActor[]> { | 343 | static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> { |
343 | const query = { | 344 | const query = { |
344 | attributes: [ ], | 345 | attributes: [ ], |
345 | offset: 0, | 346 | offset: 0, |
@@ -391,11 +392,10 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
391 | } | 392 | } |
392 | } | 393 | } |
393 | 394 | ||
394 | const scopes = { | ||
395 | method: [ ScopeNames.FOR_API, { actorId: options.actorId } as AvailableForListOptions ] | ||
396 | } | ||
397 | return VideoChannelModel | 395 | return VideoChannelModel |
398 | .scope(scopes) | 396 | .scope({ |
397 | method: [ ScopeNames.FOR_API, { actorId: options.actorId } as AvailableForListOptions ] | ||
398 | }) | ||
399 | .findAndCountAll(query) | 399 | .findAndCountAll(query) |
400 | .then(({ rows, count }) => { | 400 | .then(({ rows, count }) => { |
401 | return { total: count, data: rows } | 401 | return { total: count, data: rows } |
@@ -457,13 +457,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
457 | }) | 457 | }) |
458 | } | 458 | } |
459 | 459 | ||
460 | static loadByIdAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> { | 460 | static loadByIdAndPopulateAccount (id: number): Promise<MChannelAccountDefault> { |
461 | return VideoChannelModel.unscoped() | 461 | return VideoChannelModel.unscoped() |
462 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) | 462 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) |
463 | .findByPk(id) | 463 | .findByPk(id) |
464 | } | 464 | } |
465 | 465 | ||
466 | static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelAccountDefault> { | 466 | static loadByIdAndAccount (id: number, accountId: number): Promise<MChannelAccountDefault> { |
467 | const query = { | 467 | const query = { |
468 | where: { | 468 | where: { |
469 | id, | 469 | id, |
@@ -476,13 +476,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
476 | .findOne(query) | 476 | .findOne(query) |
477 | } | 477 | } |
478 | 478 | ||
479 | static loadAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> { | 479 | static loadAndPopulateAccount (id: number): Promise<MChannelAccountDefault> { |
480 | return VideoChannelModel.unscoped() | 480 | return VideoChannelModel.unscoped() |
481 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) | 481 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) |
482 | .findByPk(id) | 482 | .findByPk(id) |
483 | } | 483 | } |
484 | 484 | ||
485 | static loadByUrlAndPopulateAccount (url: string): Bluebird<MChannelAccountDefault> { | 485 | static loadByUrlAndPopulateAccount (url: string): Promise<MChannelAccountDefault> { |
486 | const query = { | 486 | const query = { |
487 | include: [ | 487 | include: [ |
488 | { | 488 | { |
@@ -508,7 +508,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
508 | return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) | 508 | return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) |
509 | } | 509 | } |
510 | 510 | ||
511 | static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelAccountDefault> { | 511 | static loadLocalByNameAndPopulateAccount (name: string): Promise<MChannelAccountDefault> { |
512 | const query = { | 512 | const query = { |
513 | include: [ | 513 | include: [ |
514 | { | 514 | { |
@@ -527,7 +527,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
527 | .findOne(query) | 527 | .findOne(query) |
528 | } | 528 | } |
529 | 529 | ||
530 | static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelAccountDefault> { | 530 | static loadByNameAndHostAndPopulateAccount (name: string, host: string): Promise<MChannelAccountDefault> { |
531 | const query = { | 531 | const query = { |
532 | include: [ | 532 | include: [ |
533 | { | 533 | { |
@@ -552,7 +552,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
552 | .findOne(query) | 552 | .findOne(query) |
553 | } | 553 | } |
554 | 554 | ||
555 | static loadAndPopulateAccountAndVideos (id: number): Bluebird<MChannelActorAccountDefaultVideos> { | 555 | static loadAndPopulateAccountAndVideos (id: number): Promise<MChannelActorAccountDefaultVideos> { |
556 | const options = { | 556 | const options = { |
557 | include: [ | 557 | include: [ |
558 | VideoModel | 558 | VideoModel |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index ed4a345eb..8d1c38826 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { uniq } from 'lodash' | 1 | import { uniq } from 'lodash' |
3 | import { FindAndCountOptions, FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' | 2 | import { FindAndCountOptions, FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' |
4 | import { | 3 | import { |
@@ -174,7 +173,7 @@ export enum ScopeNames { | |||
174 | } | 173 | } |
175 | ] | 174 | ] |
176 | }) | 175 | }) |
177 | export class VideoCommentModel extends Model<VideoCommentModel> { | 176 | export class VideoCommentModel extends Model { |
178 | @CreatedAt | 177 | @CreatedAt |
179 | createdAt: Date | 178 | createdAt: Date |
180 | 179 | ||
@@ -255,7 +254,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
255 | }) | 254 | }) |
256 | CommentAbuses: VideoCommentAbuseModel[] | 255 | CommentAbuses: VideoCommentAbuseModel[] |
257 | 256 | ||
258 | static loadById (id: number, t?: Transaction): Bluebird<MComment> { | 257 | static loadById (id: number, t?: Transaction): Promise<MComment> { |
259 | const query: FindOptions = { | 258 | const query: FindOptions = { |
260 | where: { | 259 | where: { |
261 | id | 260 | id |
@@ -267,7 +266,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
267 | return VideoCommentModel.findOne(query) | 266 | return VideoCommentModel.findOne(query) |
268 | } | 267 | } |
269 | 268 | ||
270 | static loadByIdAndPopulateVideoAndAccountAndReply (id: number, t?: Transaction): Bluebird<MCommentOwnerVideoReply> { | 269 | static loadByIdAndPopulateVideoAndAccountAndReply (id: number, t?: Transaction): Promise<MCommentOwnerVideoReply> { |
271 | const query: FindOptions = { | 270 | const query: FindOptions = { |
272 | where: { | 271 | where: { |
273 | id | 272 | id |
@@ -281,7 +280,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
281 | .findOne(query) | 280 | .findOne(query) |
282 | } | 281 | } |
283 | 282 | ||
284 | static loadByUrlAndPopulateAccountAndVideo (url: string, t?: Transaction): Bluebird<MCommentOwnerVideo> { | 283 | static loadByUrlAndPopulateAccountAndVideo (url: string, t?: Transaction): Promise<MCommentOwnerVideo> { |
285 | const query: FindOptions = { | 284 | const query: FindOptions = { |
286 | where: { | 285 | where: { |
287 | url | 286 | url |
@@ -293,7 +292,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
293 | return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEO ]).findOne(query) | 292 | return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEO ]).findOne(query) |
294 | } | 293 | } |
295 | 294 | ||
296 | static loadByUrlAndPopulateReplyAndVideoUrlAndAccount (url: string, t?: Transaction): Bluebird<MCommentOwnerReplyVideoLight> { | 295 | static loadByUrlAndPopulateReplyAndVideoUrlAndAccount (url: string, t?: Transaction): Promise<MCommentOwnerReplyVideoLight> { |
297 | const query: FindOptions = { | 296 | const query: FindOptions = { |
298 | where: { | 297 | where: { |
299 | url | 298 | url |
@@ -501,7 +500,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
501 | }) | 500 | }) |
502 | } | 501 | } |
503 | 502 | ||
504 | static listThreadParentComments (comment: MCommentId, t: Transaction, order: 'ASC' | 'DESC' = 'ASC'): Bluebird<MCommentOwner[]> { | 503 | static listThreadParentComments (comment: MCommentId, t: Transaction, order: 'ASC' | 'DESC' = 'ASC'): Promise<MCommentOwner[]> { |
505 | const query = { | 504 | const query = { |
506 | order: [ [ 'createdAt', order ] ] as Order, | 505 | order: [ [ 'createdAt', order ] ] as Order, |
507 | where: { | 506 | where: { |
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index d48c9f5d4..48b337c68 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -101,7 +101,7 @@ export enum ScopeNames { | |||
101 | } | 101 | } |
102 | ] | 102 | ] |
103 | }) | 103 | }) |
104 | export class VideoFileModel extends Model<VideoFileModel> { | 104 | export class VideoFileModel extends Model { |
105 | @CreatedAt | 105 | @CreatedAt |
106 | createdAt: Date | 106 | createdAt: Date |
107 | 107 | ||
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index ea1e085af..f3ed651b2 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts | |||
@@ -13,15 +13,14 @@ import { | |||
13 | Table, | 13 | Table, |
14 | UpdatedAt | 14 | UpdatedAt |
15 | } from 'sequelize-typescript' | 15 | } from 'sequelize-typescript' |
16 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' | 16 | import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import' |
17 | import { getSort, throwIfNotValid } from '../utils' | ||
18 | import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' | ||
19 | import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' | ||
20 | import { VideoImport, VideoImportState } from '../../../shared' | 17 | import { VideoImport, VideoImportState } from '../../../shared' |
18 | import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' | ||
21 | import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' | 19 | import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' |
20 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' | ||
22 | import { UserModel } from '../account/user' | 21 | import { UserModel } from '../account/user' |
23 | import * as Bluebird from 'bluebird' | 22 | import { getSort, throwIfNotValid } from '../utils' |
24 | import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import' | 23 | import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' |
25 | 24 | ||
26 | @DefaultScope(() => ({ | 25 | @DefaultScope(() => ({ |
27 | include: [ | 26 | include: [ |
@@ -52,7 +51,7 @@ import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/mode | |||
52 | } | 51 | } |
53 | ] | 52 | ] |
54 | }) | 53 | }) |
55 | export class VideoImportModel extends Model<VideoImportModel> { | 54 | export class VideoImportModel extends Model { |
56 | @CreatedAt | 55 | @CreatedAt |
57 | createdAt: Date | 56 | createdAt: Date |
58 | 57 | ||
@@ -120,7 +119,7 @@ export class VideoImportModel extends Model<VideoImportModel> { | |||
120 | return undefined | 119 | return undefined |
121 | } | 120 | } |
122 | 121 | ||
123 | static loadAndPopulateVideo (id: number): Bluebird<MVideoImportDefault> { | 122 | static loadAndPopulateVideo (id: number): Promise<MVideoImportDefault> { |
124 | return VideoImportModel.findByPk(id) | 123 | return VideoImportModel.findByPk(id) |
125 | } | 124 | } |
126 | 125 | ||
diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts index 875ba9b31..cb4a9b896 100644 --- a/server/models/video/video-live.ts +++ b/server/models/video/video-live.ts | |||
@@ -28,7 +28,7 @@ import { VideoBlacklistModel } from './video-blacklist' | |||
28 | } | 28 | } |
29 | ] | 29 | ] |
30 | }) | 30 | }) |
31 | export class VideoLiveModel extends Model<VideoLiveModel> { | 31 | export class VideoLiveModel extends Model { |
32 | 32 | ||
33 | @AllowNull(true) | 33 | @AllowNull(true) |
34 | @Column(DataType.STRING) | 34 | @Column(DataType.STRING) |
diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.ts index d357766e9..d2d7e2740 100644 --- a/server/models/video/video-playlist-element.ts +++ b/server/models/video/video-playlist-element.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { AggregateOptions, Op, ScopeOptions, Sequelize, Transaction } from 'sequelize' | ||
1 | import { | 2 | import { |
2 | AllowNull, | 3 | AllowNull, |
3 | BelongsTo, | 4 | BelongsTo, |
@@ -13,18 +14,8 @@ import { | |||
13 | Table, | 14 | Table, |
14 | UpdatedAt | 15 | UpdatedAt |
15 | } from 'sequelize-typescript' | 16 | } from 'sequelize-typescript' |
16 | import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video' | ||
17 | import { VideoPlaylistModel } from './video-playlist' | ||
18 | import { getSort, throwIfNotValid } from '../utils' | ||
19 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | ||
20 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | ||
21 | import { PlaylistElementObject } from '../../../shared/models/activitypub/objects/playlist-element-object' | ||
22 | import validator from 'validator' | 17 | import validator from 'validator' |
23 | import { AggregateOptions, Op, ScopeOptions, Sequelize, Transaction } from 'sequelize' | 18 | import { MUserAccountId } from '@server/types/models' |
24 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../shared/models/videos/playlist/video-playlist-element.model' | ||
25 | import { AccountModel } from '../account/account' | ||
26 | import { VideoPrivacy } from '../../../shared/models/videos' | ||
27 | import * as Bluebird from 'bluebird' | ||
28 | import { | 19 | import { |
29 | MVideoPlaylistElement, | 20 | MVideoPlaylistElement, |
30 | MVideoPlaylistElementAP, | 21 | MVideoPlaylistElementAP, |
@@ -32,7 +23,15 @@ import { | |||
32 | MVideoPlaylistElementVideoUrlPlaylistPrivacy, | 23 | MVideoPlaylistElementVideoUrlPlaylistPrivacy, |
33 | MVideoPlaylistVideoThumbnail | 24 | MVideoPlaylistVideoThumbnail |
34 | } from '@server/types/models/video/video-playlist-element' | 25 | } from '@server/types/models/video/video-playlist-element' |
35 | import { MUserAccountId } from '@server/types/models' | 26 | import { PlaylistElementObject } from '../../../shared/models/activitypub/objects/playlist-element-object' |
27 | import { VideoPrivacy } from '../../../shared/models/videos' | ||
28 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../shared/models/videos/playlist/video-playlist-element.model' | ||
29 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | ||
30 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | ||
31 | import { AccountModel } from '../account/account' | ||
32 | import { getSort, throwIfNotValid } from '../utils' | ||
33 | import { ForAPIOptions, ScopeNames as VideoScopeNames, VideoModel } from './video' | ||
34 | import { VideoPlaylistModel } from './video-playlist' | ||
36 | 35 | ||
37 | @Table({ | 36 | @Table({ |
38 | tableName: 'videoPlaylistElement', | 37 | tableName: 'videoPlaylistElement', |
@@ -49,7 +48,7 @@ import { MUserAccountId } from '@server/types/models' | |||
49 | } | 48 | } |
50 | ] | 49 | ] |
51 | }) | 50 | }) |
52 | export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel> { | 51 | export class VideoPlaylistElementModel extends Model { |
53 | @CreatedAt | 52 | @CreatedAt |
54 | createdAt: Date | 53 | createdAt: Date |
55 | 54 | ||
@@ -166,7 +165,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel> | |||
166 | ]).then(([ total, data ]) => ({ total, data })) | 165 | ]).then(([ total, data ]) => ({ total, data })) |
167 | } | 166 | } |
168 | 167 | ||
169 | static loadByPlaylistAndVideo (videoPlaylistId: number, videoId: number): Bluebird<MVideoPlaylistElement> { | 168 | static loadByPlaylistAndVideo (videoPlaylistId: number, videoId: number): Promise<MVideoPlaylistElement> { |
170 | const query = { | 169 | const query = { |
171 | where: { | 170 | where: { |
172 | videoPlaylistId, | 171 | videoPlaylistId, |
@@ -177,14 +176,14 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel> | |||
177 | return VideoPlaylistElementModel.findOne(query) | 176 | return VideoPlaylistElementModel.findOne(query) |
178 | } | 177 | } |
179 | 178 | ||
180 | static loadById (playlistElementId: number | string): Bluebird<MVideoPlaylistElement> { | 179 | static loadById (playlistElementId: number | string): Promise<MVideoPlaylistElement> { |
181 | return VideoPlaylistElementModel.findByPk(playlistElementId) | 180 | return VideoPlaylistElementModel.findByPk(playlistElementId) |
182 | } | 181 | } |
183 | 182 | ||
184 | static loadByPlaylistAndElementIdForAP ( | 183 | static loadByPlaylistAndElementIdForAP ( |
185 | playlistId: number | string, | 184 | playlistId: number | string, |
186 | playlistElementId: number | 185 | playlistElementId: number |
187 | ): Bluebird<MVideoPlaylistElementVideoUrlPlaylistPrivacy> { | 186 | ): Promise<MVideoPlaylistElementVideoUrlPlaylistPrivacy> { |
188 | const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId } | 187 | const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId } |
189 | 188 | ||
190 | const query = { | 189 | const query = { |
@@ -226,7 +225,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel> | |||
226 | }) | 225 | }) |
227 | } | 226 | } |
228 | 227 | ||
229 | static loadFirstElementWithVideoThumbnail (videoPlaylistId: number): Bluebird<MVideoPlaylistVideoThumbnail> { | 228 | static loadFirstElementWithVideoThumbnail (videoPlaylistId: number): Promise<MVideoPlaylistVideoThumbnail> { |
230 | const query = { | 229 | const query = { |
231 | order: getSort('position'), | 230 | order: getSort('position'), |
232 | where: { | 231 | where: { |
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 9f9e0b069..93ecf8cea 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { join } from 'path' | 1 | import { join } from 'path' |
3 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' | 2 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' |
4 | import { | 3 | import { |
@@ -125,7 +124,6 @@ type AvailableForListOptions = { | |||
125 | ] | 124 | ] |
126 | }, | 125 | }, |
127 | [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => { | 126 | [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => { |
128 | |||
129 | let whereActor: WhereOptions = {} | 127 | let whereActor: WhereOptions = {} |
130 | 128 | ||
131 | const whereAnd: WhereOptions[] = [] | 129 | const whereAnd: WhereOptions[] = [] |
@@ -182,15 +180,13 @@ type AvailableForListOptions = { | |||
182 | [Op.and]: whereAnd | 180 | [Op.and]: whereAnd |
183 | } | 181 | } |
184 | 182 | ||
185 | const accountScope = { | ||
186 | method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ] | ||
187 | } | ||
188 | |||
189 | return { | 183 | return { |
190 | where, | 184 | where, |
191 | include: [ | 185 | include: [ |
192 | { | 186 | { |
193 | model: AccountModel.scope(accountScope), | 187 | model: AccountModel.scope({ |
188 | method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ] | ||
189 | }), | ||
194 | required: true | 190 | required: true |
195 | }, | 191 | }, |
196 | { | 192 | { |
@@ -217,7 +213,7 @@ type AvailableForListOptions = { | |||
217 | } | 213 | } |
218 | ] | 214 | ] |
219 | }) | 215 | }) |
220 | export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | 216 | export class VideoPlaylistModel extends Model { |
221 | @CreatedAt | 217 | @CreatedAt |
222 | createdAt: Date | 218 | createdAt: Date |
223 | 219 | ||
@@ -367,7 +363,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
367 | }) | 363 | }) |
368 | } | 364 | } |
369 | 365 | ||
370 | static listPlaylistIdsOf (accountId: number, videoIds: number[]): Bluebird<MVideoPlaylistIdWithElements[]> { | 366 | static listPlaylistIdsOf (accountId: number, videoIds: number[]): Promise<MVideoPlaylistIdWithElements[]> { |
371 | const query = { | 367 | const query = { |
372 | attributes: [ 'id' ], | 368 | attributes: [ 'id' ], |
373 | where: { | 369 | where: { |
@@ -392,7 +388,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
392 | 388 | ||
393 | static doesPlaylistExist (url: string) { | 389 | static doesPlaylistExist (url: string) { |
394 | const query = { | 390 | const query = { |
395 | attributes: [], | 391 | attributes: [ 'id' ], |
396 | where: { | 392 | where: { |
397 | url | 393 | url |
398 | } | 394 | } |
@@ -403,7 +399,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
403 | .then(e => !!e) | 399 | .then(e => !!e) |
404 | } | 400 | } |
405 | 401 | ||
406 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFullSummary> { | 402 | static loadWithAccountAndChannelSummary (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFullSummary> { |
407 | const where = buildWhereIdOrUUID(id) | 403 | const where = buildWhereIdOrUUID(id) |
408 | 404 | ||
409 | const query = { | 405 | const query = { |
@@ -416,7 +412,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
416 | .findOne(query) | 412 | .findOne(query) |
417 | } | 413 | } |
418 | 414 | ||
419 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Bluebird<MVideoPlaylistFull> { | 415 | static loadWithAccountAndChannel (id: number | string, transaction: Transaction): Promise<MVideoPlaylistFull> { |
420 | const where = buildWhereIdOrUUID(id) | 416 | const where = buildWhereIdOrUUID(id) |
421 | 417 | ||
422 | const query = { | 418 | const query = { |
@@ -429,7 +425,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
429 | .findOne(query) | 425 | .findOne(query) |
430 | } | 426 | } |
431 | 427 | ||
432 | static loadByUrlAndPopulateAccount (url: string): Bluebird<MVideoPlaylistAccountThumbnail> { | 428 | static loadByUrlAndPopulateAccount (url: string): Promise<MVideoPlaylistAccountThumbnail> { |
433 | const query = { | 429 | const query = { |
434 | where: { | 430 | where: { |
435 | url | 431 | url |
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index f9ee94589..b7f5f3fa3 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -1,13 +1,12 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { literal, Op, Transaction } from 'sequelize' |
2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
5 | import { MActorDefault } from '../../types/models' | ||
6 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' | ||
5 | import { ActorModel } from '../activitypub/actor' | 7 | import { ActorModel } from '../activitypub/actor' |
6 | import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' | 8 | import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' |
7 | import { VideoModel } from './video' | 9 | import { VideoModel } from './video' |
8 | import { literal, Op, Transaction } from 'sequelize' | ||
9 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' | ||
10 | import { MActorDefault } from '../../types/models' | ||
11 | 10 | ||
12 | enum ScopeNames { | 11 | enum ScopeNames { |
13 | FULL = 'FULL', | 12 | FULL = 'FULL', |
@@ -51,7 +50,7 @@ enum ScopeNames { | |||
51 | } | 50 | } |
52 | ] | 51 | ] |
53 | }) | 52 | }) |
54 | export class VideoShareModel extends Model<VideoShareModel> { | 53 | export class VideoShareModel extends Model { |
55 | 54 | ||
56 | @AllowNull(false) | 55 | @AllowNull(false) |
57 | @Is('VideoShareUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url')) | 56 | @Is('VideoShareUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url')) |
@@ -88,7 +87,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
88 | }) | 87 | }) |
89 | Video: VideoModel | 88 | Video: VideoModel |
90 | 89 | ||
91 | static load (actorId: number | string, videoId: number | string, t?: Transaction): Bluebird<MVideoShareActor> { | 90 | static load (actorId: number | string, videoId: number | string, t?: Transaction): Promise<MVideoShareActor> { |
92 | return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ | 91 | return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ |
93 | where: { | 92 | where: { |
94 | actorId, | 93 | actorId, |
@@ -98,7 +97,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
98 | }) | 97 | }) |
99 | } | 98 | } |
100 | 99 | ||
101 | static loadByUrl (url: string, t: Transaction): Bluebird<MVideoShareFull> { | 100 | static loadByUrl (url: string, t: Transaction): Promise<MVideoShareFull> { |
102 | return VideoShareModel.scope(ScopeNames.FULL).findOne({ | 101 | return VideoShareModel.scope(ScopeNames.FULL).findOne({ |
103 | where: { | 102 | where: { |
104 | url | 103 | url |
@@ -107,7 +106,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
107 | }) | 106 | }) |
108 | } | 107 | } |
109 | 108 | ||
110 | static loadActorsByShare (videoId: number, t: Transaction): Bluebird<MActorDefault[]> { | 109 | static loadActorsByShare (videoId: number, t: Transaction): Promise<MActorDefault[]> { |
111 | const query = { | 110 | const query = { |
112 | where: { | 111 | where: { |
113 | videoId | 112 | videoId |
@@ -125,7 +124,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
125 | .then((res: MVideoShareFull[]) => res.map(r => r.Actor)) | 124 | .then((res: MVideoShareFull[]) => res.map(r => r.Actor)) |
126 | } | 125 | } |
127 | 126 | ||
128 | static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Bluebird<MActorDefault[]> { | 127 | static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Promise<MActorDefault[]> { |
129 | const safeOwnerId = parseInt(actorOwnerId + '', 10) | 128 | const safeOwnerId = parseInt(actorOwnerId + '', 10) |
130 | 129 | ||
131 | // /!\ On actor model | 130 | // /!\ On actor model |
@@ -150,7 +149,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
150 | return ActorModel.findAll(query) | 149 | return ActorModel.findAll(query) |
151 | } | 150 | } |
152 | 151 | ||
153 | static loadActorsByVideoChannel (videoChannelId: number, t: Transaction): Bluebird<MActorDefault[]> { | 152 | static loadActorsByVideoChannel (videoChannelId: number, t: Transaction): Promise<MActorDefault[]> { |
154 | const safeChannelId = parseInt(videoChannelId + '', 10) | 153 | const safeChannelId = parseInt(videoChannelId + '', 10) |
155 | 154 | ||
156 | // /!\ On actor model | 155 | // /!\ On actor model |
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index 73bd89844..148768c21 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -40,7 +40,7 @@ import { logger } from '@server/helpers/logger' | |||
40 | } | 40 | } |
41 | ] | 41 | ] |
42 | }) | 42 | }) |
43 | export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistModel> { | 43 | export class VideoStreamingPlaylistModel extends Model { |
44 | @CreatedAt | 44 | @CreatedAt |
45 | createdAt: Date | 45 | createdAt: Date |
46 | 46 | ||
diff --git a/server/models/video/video-tag.ts b/server/models/video/video-tag.ts index ca15e3426..5052b8c4d 100644 --- a/server/models/video/video-tag.ts +++ b/server/models/video/video-tag.ts | |||
@@ -13,7 +13,7 @@ import { VideoModel } from './video' | |||
13 | } | 13 | } |
14 | ] | 14 | ] |
15 | }) | 15 | }) |
16 | export class VideoTagModel extends Model<VideoTagModel> { | 16 | export class VideoTagModel extends Model { |
17 | @CreatedAt | 17 | @CreatedAt |
18 | createdAt: Date | 18 | createdAt: Date |
19 | 19 | ||
diff --git a/server/models/video/video-view.ts b/server/models/video/video-view.ts index 40db5effd..992cf258a 100644 --- a/server/models/video/video-view.ts +++ b/server/models/video/video-view.ts | |||
@@ -14,7 +14,7 @@ import * as Sequelize from 'sequelize' | |||
14 | } | 14 | } |
15 | ] | 15 | ] |
16 | }) | 16 | }) |
17 | export class VideoViewModel extends Model<VideoViewModel> { | 17 | export class VideoViewModel extends Model { |
18 | @CreatedAt | 18 | @CreatedAt |
19 | createdAt: Date | 19 | createdAt: Date |
20 | 20 | ||
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index a43abbc09..d3fed338a 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -2,7 +2,7 @@ import * as Bluebird from 'bluebird' | |||
2 | import { remove } from 'fs-extra' | 2 | import { remove } from 'fs-extra' |
3 | import { maxBy, minBy, pick } from 'lodash' | 3 | import { maxBy, minBy, pick } from 'lodash' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { FindOptions, IncludeOptions, Op, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' | 5 | import { FindOptions, Includeable, IncludeOptions, Op, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' |
6 | import { | 6 | import { |
7 | AllowNull, | 7 | AllowNull, |
8 | BeforeDestroy, | 8 | BeforeDestroy, |
@@ -190,26 +190,26 @@ export type AvailableForListIDsOptions = { | |||
190 | attributes: [ 'id', 'url', 'uuid', 'remote' ] | 190 | attributes: [ 'id', 'url', 'uuid', 'remote' ] |
191 | }, | 191 | }, |
192 | [ScopeNames.FOR_API]: (options: ForAPIOptions) => { | 192 | [ScopeNames.FOR_API]: (options: ForAPIOptions) => { |
193 | const query: FindOptions = { | 193 | const include: Includeable[] = [ |
194 | include: [ | 194 | { |
195 | { | 195 | model: VideoChannelModel.scope({ |
196 | model: VideoChannelModel.scope({ | 196 | method: [ |
197 | method: [ | 197 | VideoChannelScopeNames.SUMMARY, { |
198 | VideoChannelScopeNames.SUMMARY, { | 198 | withAccount: true, |
199 | withAccount: true, | 199 | withAccountBlockerIds: options.withAccountBlockerIds |
200 | withAccountBlockerIds: options.withAccountBlockerIds | 200 | } as SummaryOptions |
201 | } as SummaryOptions | 201 | ] |
202 | ] | 202 | }), |
203 | }), | 203 | required: true |
204 | required: true | 204 | }, |
205 | }, | 205 | { |
206 | { | 206 | attributes: [ 'type', 'filename' ], |
207 | attributes: [ 'type', 'filename' ], | 207 | model: ThumbnailModel, |
208 | model: ThumbnailModel, | 208 | required: false |
209 | required: false | 209 | } |
210 | } | 210 | ] |
211 | ] | 211 | |
212 | } | 212 | const query: FindOptions = {} |
213 | 213 | ||
214 | if (options.ids) { | 214 | if (options.ids) { |
215 | query.where = { | 215 | query.where = { |
@@ -220,14 +220,14 @@ export type AvailableForListIDsOptions = { | |||
220 | } | 220 | } |
221 | 221 | ||
222 | if (options.withFiles === true) { | 222 | if (options.withFiles === true) { |
223 | query.include.push({ | 223 | include.push({ |
224 | model: VideoFileModel, | 224 | model: VideoFileModel, |
225 | required: true | 225 | required: true |
226 | }) | 226 | }) |
227 | } | 227 | } |
228 | 228 | ||
229 | if (options.videoPlaylistId) { | 229 | if (options.videoPlaylistId) { |
230 | query.include.push({ | 230 | include.push({ |
231 | model: VideoPlaylistElementModel.unscoped(), | 231 | model: VideoPlaylistElementModel.unscoped(), |
232 | required: true, | 232 | required: true, |
233 | where: { | 233 | where: { |
@@ -236,6 +236,8 @@ export type AvailableForListIDsOptions = { | |||
236 | }) | 236 | }) |
237 | } | 237 | } |
238 | 238 | ||
239 | query.include = include | ||
240 | |||
239 | return query | 241 | return query |
240 | }, | 242 | }, |
241 | [ScopeNames.WITH_THUMBNAILS]: { | 243 | [ScopeNames.WITH_THUMBNAILS]: { |
@@ -477,7 +479,7 @@ export type AvailableForListIDsOptions = { | |||
477 | } | 479 | } |
478 | ] | 480 | ] |
479 | }) | 481 | }) |
480 | export class VideoModel extends Model<VideoModel> { | 482 | export class VideoModel extends Model { |
481 | 483 | ||
482 | @AllowNull(false) | 484 | @AllowNull(false) |
483 | @Default(DataType.UUIDV4) | 485 | @Default(DataType.UUIDV4) |
@@ -860,7 +862,7 @@ export class VideoModel extends Model<VideoModel> { | |||
860 | return undefined | 862 | return undefined |
861 | } | 863 | } |
862 | 864 | ||
863 | static listLocal (): Bluebird<MVideoWithAllFiles[]> { | 865 | static listLocal (): Promise<MVideoWithAllFiles[]> { |
864 | const query = { | 866 | const query = { |
865 | where: { | 867 | where: { |
866 | remote: false | 868 | remote: false |
@@ -988,7 +990,7 @@ export class VideoModel extends Model<VideoModel> { | |||
988 | }) | 990 | }) |
989 | } | 991 | } |
990 | 992 | ||
991 | static listPublishedLiveIds () { | 993 | static async listPublishedLiveIds () { |
992 | const options = { | 994 | const options = { |
993 | attributes: [ 'id' ], | 995 | attributes: [ 'id' ], |
994 | where: { | 996 | where: { |
@@ -997,8 +999,9 @@ export class VideoModel extends Model<VideoModel> { | |||
997 | } | 999 | } |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | return VideoModel.findAll(options) | 1002 | const result = await VideoModel.findAll(options) |
1001 | .map(v => v.id) | 1003 | |
1004 | return result.map(v => v.id) | ||
1002 | } | 1005 | } |
1003 | 1006 | ||
1004 | static listUserVideosForApi ( | 1007 | static listUserVideosForApi ( |
@@ -1214,7 +1217,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1214 | return VideoModel.count(options) | 1217 | return VideoModel.count(options) |
1215 | } | 1218 | } |
1216 | 1219 | ||
1217 | static load (id: number | string, t?: Transaction): Bluebird<MVideoThumbnail> { | 1220 | static load (id: number | string, t?: Transaction): Promise<MVideoThumbnail> { |
1218 | const where = buildWhereIdOrUUID(id) | 1221 | const where = buildWhereIdOrUUID(id) |
1219 | const options = { | 1222 | const options = { |
1220 | where, | 1223 | where, |
@@ -1224,7 +1227,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1224 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) | 1227 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) |
1225 | } | 1228 | } |
1226 | 1229 | ||
1227 | static loadWithBlacklist (id: number | string, t?: Transaction): Bluebird<MVideoThumbnailBlacklist> { | 1230 | static loadWithBlacklist (id: number | string, t?: Transaction): Promise<MVideoThumbnailBlacklist> { |
1228 | const where = buildWhereIdOrUUID(id) | 1231 | const where = buildWhereIdOrUUID(id) |
1229 | const options = { | 1232 | const options = { |
1230 | where, | 1233 | where, |
@@ -1237,7 +1240,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1237 | ]).findOne(options) | 1240 | ]).findOne(options) |
1238 | } | 1241 | } |
1239 | 1242 | ||
1240 | static loadImmutableAttributes (id: number | string, t?: Transaction): Bluebird<MVideoImmutable> { | 1243 | static loadImmutableAttributes (id: number | string, t?: Transaction): Promise<MVideoImmutable> { |
1241 | const fun = () => { | 1244 | const fun = () => { |
1242 | const query = { | 1245 | const query = { |
1243 | where: buildWhereIdOrUUID(id), | 1246 | where: buildWhereIdOrUUID(id), |
@@ -1255,7 +1258,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1255 | }) | 1258 | }) |
1256 | } | 1259 | } |
1257 | 1260 | ||
1258 | static loadWithRights (id: number | string, t?: Transaction): Bluebird<MVideoWithRights> { | 1261 | static loadWithRights (id: number | string, t?: Transaction): Promise<MVideoWithRights> { |
1259 | const where = buildWhereIdOrUUID(id) | 1262 | const where = buildWhereIdOrUUID(id) |
1260 | const options = { | 1263 | const options = { |
1261 | where, | 1264 | where, |
@@ -1269,7 +1272,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1269 | ]).findOne(options) | 1272 | ]).findOne(options) |
1270 | } | 1273 | } |
1271 | 1274 | ||
1272 | static loadOnlyId (id: number | string, t?: Transaction): Bluebird<MVideoIdThumbnail> { | 1275 | static loadOnlyId (id: number | string, t?: Transaction): Promise<MVideoIdThumbnail> { |
1273 | const where = buildWhereIdOrUUID(id) | 1276 | const where = buildWhereIdOrUUID(id) |
1274 | 1277 | ||
1275 | const options = { | 1278 | const options = { |
@@ -1281,7 +1284,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1281 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) | 1284 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) |
1282 | } | 1285 | } |
1283 | 1286 | ||
1284 | static loadWithFiles (id: number | string, t?: Transaction, logging?: boolean): Bluebird<MVideoWithAllFiles> { | 1287 | static loadWithFiles (id: number | string, t?: Transaction, logging?: boolean): Promise<MVideoWithAllFiles> { |
1285 | const where = buildWhereIdOrUUID(id) | 1288 | const where = buildWhereIdOrUUID(id) |
1286 | 1289 | ||
1287 | const query = { | 1290 | const query = { |
@@ -1297,7 +1300,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1297 | ]).findOne(query) | 1300 | ]).findOne(query) |
1298 | } | 1301 | } |
1299 | 1302 | ||
1300 | static loadByUUID (uuid: string): Bluebird<MVideoThumbnail> { | 1303 | static loadByUUID (uuid: string): Promise<MVideoThumbnail> { |
1301 | const options = { | 1304 | const options = { |
1302 | where: { | 1305 | where: { |
1303 | uuid | 1306 | uuid |
@@ -1307,7 +1310,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1307 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) | 1310 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) |
1308 | } | 1311 | } |
1309 | 1312 | ||
1310 | static loadByUrl (url: string, transaction?: Transaction): Bluebird<MVideoThumbnail> { | 1313 | static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> { |
1311 | const query: FindOptions = { | 1314 | const query: FindOptions = { |
1312 | where: { | 1315 | where: { |
1313 | url | 1316 | url |
@@ -1318,7 +1321,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1318 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query) | 1321 | return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query) |
1319 | } | 1322 | } |
1320 | 1323 | ||
1321 | static loadByUrlImmutableAttributes (url: string, transaction?: Transaction): Bluebird<MVideoImmutable> { | 1324 | static loadByUrlImmutableAttributes (url: string, transaction?: Transaction): Promise<MVideoImmutable> { |
1322 | const fun = () => { | 1325 | const fun = () => { |
1323 | const query: FindOptions = { | 1326 | const query: FindOptions = { |
1324 | where: { | 1327 | where: { |
@@ -1338,7 +1341,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1338 | }) | 1341 | }) |
1339 | } | 1342 | } |
1340 | 1343 | ||
1341 | static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Bluebird<MVideoAccountLightBlacklistAllFiles> { | 1344 | static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> { |
1342 | const query: FindOptions = { | 1345 | const query: FindOptions = { |
1343 | where: { | 1346 | where: { |
1344 | url | 1347 | url |
@@ -1355,7 +1358,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1355 | ]).findOne(query) | 1358 | ]).findOne(query) |
1356 | } | 1359 | } |
1357 | 1360 | ||
1358 | static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Bluebird<MVideoFullLight> { | 1361 | static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> { |
1359 | const where = buildWhereIdOrUUID(id) | 1362 | const where = buildWhereIdOrUUID(id) |
1360 | 1363 | ||
1361 | const options = { | 1364 | const options = { |
@@ -1388,7 +1391,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1388 | id: number | string | 1391 | id: number | string |
1389 | t?: Transaction | 1392 | t?: Transaction |
1390 | userId?: number | 1393 | userId?: number |
1391 | }): Bluebird<MVideoDetails> { | 1394 | }): Promise<MVideoDetails> { |
1392 | const { id, t, userId } = parameters | 1395 | const { id, t, userId } = parameters |
1393 | const where = buildWhereIdOrUUID(id) | 1396 | const where = buildWhereIdOrUUID(id) |
1394 | 1397 | ||
@@ -1487,7 +1490,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1487 | return VideoModel.update({ support: videoChannel.support }, options) | 1490 | return VideoModel.update({ support: videoChannel.support }, options) |
1488 | } | 1491 | } |
1489 | 1492 | ||
1490 | static getAllIdsFromChannel (videoChannel: MChannelId): Bluebird<number[]> { | 1493 | static getAllIdsFromChannel (videoChannel: MChannelId): Promise<number[]> { |
1491 | const query = { | 1494 | const query = { |
1492 | attributes: [ 'id' ], | 1495 | attributes: [ 'id' ], |
1493 | where: { | 1496 | where: { |