]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user-notification-setting.ts
Add new plugin/peertube version notifs
[github/Chocobozzz/PeerTube.git] / server / models / account / user-notification-setting.ts
index 1506295cf7f7183ad9e6b2c29fac9bb32e86fd9d..de150129922ca57e0dced2524d2a9c222030d331 100644 (file)
@@ -12,12 +12,12 @@ import {
   Table,
   UpdatedAt
 } from 'sequelize-typescript'
-import { throwIfNotValid } from '../utils'
-import { UserModel } from './user'
-import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
+import { MNotificationSettingFormattable } from '@server/types/models'
 import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
+import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
 import { clearCacheByUserId } from '../../lib/oauth-model'
-import { MNotificationSettingFormattable } from '@server/typings/models'
+import { throwIfNotValid } from '../utils'
+import { UserModel } from './user'
 
 @Table({
   tableName: 'userNotificationSetting',
@@ -28,7 +28,7 @@ import { MNotificationSettingFormattable } from '@server/typings/models'
     }
   ]
 })
-export class UserNotificationSettingModel extends Model<UserNotificationSettingModel> {
+export class UserNotificationSettingModel extends Model {
 
   @AllowNull(false)
   @Default(null)
@@ -51,11 +51,11 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
   @AllowNull(false)
   @Default(null)
   @Is(
-    'UserNotificationSettingVideoAbuseAsModerator',
-    value => throwIfNotValid(value, isUserNotificationSettingValid, 'videoAbuseAsModerator')
+    'UserNotificationSettingAbuseAsModerator',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseAsModerator')
   )
   @Column
-  videoAbuseAsModerator: UserNotificationSettingValue
+  abuseAsModerator: UserNotificationSettingValue
 
   @AllowNull(false)
   @Default(null)
@@ -111,6 +111,15 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
   @Column
   newInstanceFollower: UserNotificationSettingValue
 
+  @AllowNull(false)
+  @Default(null)
+  @Is(
+    'UserNotificationSettingNewInstanceFollower',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing')
+  )
+  @Column
+  autoInstanceFollowing: UserNotificationSettingValue
+
   @AllowNull(false)
   @Default(null)
   @Is(
@@ -129,6 +138,42 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
   @Column
   commentMention: UserNotificationSettingValue
 
+  @AllowNull(false)
+  @Default(null)
+  @Is(
+    'UserNotificationSettingAbuseStateChange',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseStateChange')
+  )
+  @Column
+  abuseStateChange: UserNotificationSettingValue
+
+  @AllowNull(false)
+  @Default(null)
+  @Is(
+    'UserNotificationSettingAbuseNewMessage',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseNewMessage')
+  )
+  @Column
+  abuseNewMessage: UserNotificationSettingValue
+
+  @AllowNull(false)
+  @Default(null)
+  @Is(
+    'UserNotificationSettingNewPeerTubeVersion',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'newPeerTubeVersion')
+  )
+  @Column
+  newPeerTubeVersion: UserNotificationSettingValue
+
+  @AllowNull(false)
+  @Default(null)
+  @Is(
+    'UserNotificationSettingNewPeerPluginVersion',
+    value => throwIfNotValid(value, isUserNotificationSettingValid, 'newPluginVersion')
+  )
+  @Column
+  newPluginVersion: UserNotificationSettingValue
+
   @ForeignKey(() => UserModel)
   @Column
   userId: number
@@ -157,7 +202,7 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
     return {
       newCommentOnMyVideo: this.newCommentOnMyVideo,
       newVideoFromSubscription: this.newVideoFromSubscription,
-      videoAbuseAsModerator: this.videoAbuseAsModerator,
+      abuseAsModerator: this.abuseAsModerator,
       videoAutoBlacklistAsModerator: this.videoAutoBlacklistAsModerator,
       blacklistOnMyVideo: this.blacklistOnMyVideo,
       myVideoPublished: this.myVideoPublished,
@@ -165,7 +210,12 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
       newUserRegistration: this.newUserRegistration,
       commentMention: this.commentMention,
       newFollow: this.newFollow,
-      newInstanceFollower: this.newInstanceFollower
+      newInstanceFollower: this.newInstanceFollower,
+      autoInstanceFollowing: this.autoInstanceFollowing,
+      abuseNewMessage: this.abuseNewMessage,
+      abuseStateChange: this.abuseStateChange,
+      newPeerTubeVersion: this.newPeerTubeVersion,
+      newPluginVersion: this.newPluginVersion
     }
   }
 }