aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r--server/models/account/user.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 55ec14d05..33f56f641 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -48,6 +48,7 @@ import { UserNotificationSettingModel } from './user-notification-setting'
48import { VideoModel } from '../video/video' 48import { VideoModel } from '../video/video'
49import { ActorModel } from '../activitypub/actor' 49import { ActorModel } from '../activitypub/actor'
50import { ActorFollowModel } from '../activitypub/actor-follow' 50import { ActorFollowModel } from '../activitypub/actor-follow'
51import { VideoImportModel } from '../video/video-import'
51 52
52enum ScopeNames { 53enum ScopeNames {
53 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' 54 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@@ -186,6 +187,12 @@ export class UserModel extends Model<UserModel> {
186 }) 187 })
187 NotificationSetting: UserNotificationSettingModel 188 NotificationSetting: UserNotificationSettingModel
188 189
190 @HasMany(() => VideoImportModel, {
191 foreignKey: 'userId',
192 onDelete: 'cascade'
193 })
194 VideoImports: VideoImportModel[]
195
189 @HasMany(() => OAuthTokenModel, { 196 @HasMany(() => OAuthTokenModel, {
190 foreignKey: 'userId', 197 foreignKey: 'userId',
191 onDelete: 'cascade' 198 onDelete: 'cascade'
@@ -400,6 +407,23 @@ export class UserModel extends Model<UserModel> {
400 return UserModel.findOne(query) 407 return UserModel.findOne(query)
401 } 408 }
402 409
410 static loadByVideoImportId (videoImportId: number) {
411 const query = {
412 include: [
413 {
414 required: true,
415 attributes: [ 'id' ],
416 model: VideoImportModel.unscoped(),
417 where: {
418 id: videoImportId
419 }
420 }
421 ]
422 }
423
424 return UserModel.findOne(query)
425 }
426
403 static getOriginalVideoFileTotalFromUser (user: UserModel) { 427 static getOriginalVideoFileTotalFromUser (user: UserModel) {
404 // Don't use sequelize because we need to use a sub query 428 // Don't use sequelize because we need to use a sub query
405 const query = UserModel.generateUserQuotaBaseSQL() 429 const query = UserModel.generateUserQuotaBaseSQL()