]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user-notification-setting.ts
Merge branch 'release/3.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / account / user-notification-setting.ts
index acc192d53f861df34f2d2e6dd17ec5e34ca559e7..138051528d6f493da896a79773d37294f56c2093 100644 (file)
@@ -12,10 +12,10 @@ import {
   Table,
   UpdatedAt
 } from 'sequelize-typescript'
+import { TokensCache } from '@server/lib/auth/tokens-cache'
 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 { throwIfNotValid } from '../utils'
 import { UserModel } from './user'
 
@@ -28,7 +28,7 @@ import { UserModel } from './user'
     }
   ]
 })
-export class UserNotificationSettingModel extends Model<UserNotificationSettingModel> {
+export class UserNotificationSettingModel extends Model {
 
   @AllowNull(false)
   @Default(null)
@@ -156,6 +156,24 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
   @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
@@ -177,7 +195,7 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
   @AfterUpdate
   @AfterDestroy
   static removeTokenCache (instance: UserNotificationSettingModel) {
-    return clearCacheByUserId(instance.userId)
+    return TokensCache.Instance.clearCacheByUserId(instance.userId)
   }
 
   toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting {
@@ -195,7 +213,9 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
       newInstanceFollower: this.newInstanceFollower,
       autoInstanceFollowing: this.autoInstanceFollowing,
       abuseNewMessage: this.abuseNewMessage,
-      abuseStateChange: this.abuseStateChange
+      abuseStateChange: this.abuseStateChange,
+      newPeerTubeVersion: this.newPeerTubeVersion,
+      newPluginVersion: this.newPluginVersion
     }
   }
 }