]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user-notification-setting.ts
Add abuse messages/states notifications
[github/Chocobozzz/PeerTube.git] / server / models / account / user-notification-setting.ts
index d8f3f13da1219116598d8bc1e67961fad026c814..acc192d53f861df34f2d2e6dd17ec5e34ca559e7 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/types/models'
+import { throwIfNotValid } from '../utils'
+import { UserModel } from './user'
 
 @Table({
   tableName: 'userNotificationSetting',
@@ -138,6 +138,24 @@ 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
+
   @ForeignKey(() => UserModel)
   @Column
   userId: number
@@ -175,7 +193,9 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
       commentMention: this.commentMention,
       newFollow: this.newFollow,
       newInstanceFollower: this.newInstanceFollower,
-      autoInstanceFollowing: this.autoInstanceFollowing
+      autoInstanceFollowing: this.autoInstanceFollowing,
+      abuseNewMessage: this.abuseNewMessage,
+      abuseStateChange: this.abuseStateChange
     }
   }
 }