diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-02 16:37:43 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | dc13348070d808d0ba3feb56a435b835c2e7e791 (patch) | |
tree | 887202a33f1aa680fd8ece6ee465381f3931c64e /server/models/account/user.ts | |
parent | 6e7e63b83f08ba68edc2bb9f72ff03d1802e45df (diff) | |
download | PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.gz PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.zst PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.zip |
Add import finished and video published notifs
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r-- | server/models/account/user.ts | 24 |
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' | |||
48 | import { VideoModel } from '../video/video' | 48 | import { VideoModel } from '../video/video' |
49 | import { ActorModel } from '../activitypub/actor' | 49 | import { ActorModel } from '../activitypub/actor' |
50 | import { ActorFollowModel } from '../activitypub/actor-follow' | 50 | import { ActorFollowModel } from '../activitypub/actor-follow' |
51 | import { VideoImportModel } from '../video/video-import' | ||
51 | 52 | ||
52 | enum ScopeNames { | 53 | enum 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() |