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 { throwIfNotValid } from '../utils'
import { UserModel } from './user'
-import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
-import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
-import { clearCacheByUserId } from '../../lib/oauth-model'
-import { MNotificationSettingFormattable } from '@server/types/models'
@Table({
tableName: 'userNotificationSetting',
}
]
})
-export class UserNotificationSettingModel extends Model<UserNotificationSettingModel> {
+export class UserNotificationSettingModel extends Model {
@AllowNull(false)
@Default(null)
@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
@AfterUpdate
@AfterDestroy
static removeTokenCache (instance: UserNotificationSettingModel) {
- return clearCacheByUserId(instance.userId)
+ return TokensCache.Instance.clearCacheByUserId(instance.userId)
}
toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting {
commentMention: this.commentMention,
newFollow: this.newFollow,
newInstanceFollower: this.newInstanceFollower,
- autoInstanceFollowing: this.autoInstanceFollowing
+ autoInstanceFollowing: this.autoInstanceFollowing,
+ abuseNewMessage: this.abuseNewMessage,
+ abuseStateChange: this.abuseStateChange,
+ newPeerTubeVersion: this.newPeerTubeVersion,
+ newPluginVersion: this.newPluginVersion
}
}
}