From 7d9ba5c08999c6482f0bc5e0c09c6f55b7724090 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 May 2021 11:15:29 +0200 Subject: Cleanup models directory organization --- server/models/account/user-notification-setting.ts | 221 --------------------- 1 file changed, 221 deletions(-) delete mode 100644 server/models/account/user-notification-setting.ts (limited to 'server/models/account/user-notification-setting.ts') diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts deleted file mode 100644 index 138051528..000000000 --- a/server/models/account/user-notification-setting.ts +++ /dev/null @@ -1,221 +0,0 @@ -import { - AfterDestroy, - AfterUpdate, - AllowNull, - BelongsTo, - Column, - CreatedAt, - Default, - ForeignKey, - Is, - Model, - 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' - -@Table({ - tableName: 'userNotificationSetting', - indexes: [ - { - fields: [ 'userId' ], - unique: true - } - ] -}) -export class UserNotificationSettingModel extends Model { - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewVideoFromSubscription', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'newVideoFromSubscription') - ) - @Column - newVideoFromSubscription: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewCommentOnMyVideo', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'newCommentOnMyVideo') - ) - @Column - newCommentOnMyVideo: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingAbuseAsModerator', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseAsModerator') - ) - @Column - abuseAsModerator: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingVideoAutoBlacklistAsModerator', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator') - ) - @Column - videoAutoBlacklistAsModerator: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingBlacklistOnMyVideo', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'blacklistOnMyVideo') - ) - @Column - blacklistOnMyVideo: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingMyVideoPublished', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoPublished') - ) - @Column - myVideoPublished: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingMyVideoImportFinished', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoImportFinished') - ) - @Column - myVideoImportFinished: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewUserRegistration', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'newUserRegistration') - ) - @Column - newUserRegistration: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewInstanceFollower', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'newInstanceFollower') - ) - @Column - newInstanceFollower: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewInstanceFollower', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing') - ) - @Column - autoInstanceFollowing: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingNewFollow', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'newFollow') - ) - @Column - newFollow: UserNotificationSettingValue - - @AllowNull(false) - @Default(null) - @Is( - 'UserNotificationSettingCommentMention', - value => throwIfNotValid(value, isUserNotificationSettingValid, 'commentMention') - ) - @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 - - @BelongsTo(() => UserModel, { - foreignKey: { - allowNull: false - }, - onDelete: 'cascade' - }) - User: UserModel - - @CreatedAt - createdAt: Date - - @UpdatedAt - updatedAt: Date - - @AfterUpdate - @AfterDestroy - static removeTokenCache (instance: UserNotificationSettingModel) { - return TokensCache.Instance.clearCacheByUserId(instance.userId) - } - - toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting { - return { - newCommentOnMyVideo: this.newCommentOnMyVideo, - newVideoFromSubscription: this.newVideoFromSubscription, - abuseAsModerator: this.abuseAsModerator, - videoAutoBlacklistAsModerator: this.videoAutoBlacklistAsModerator, - blacklistOnMyVideo: this.blacklistOnMyVideo, - myVideoPublished: this.myVideoPublished, - myVideoImportFinished: this.myVideoImportFinished, - newUserRegistration: this.newUserRegistration, - commentMention: this.commentMention, - newFollow: this.newFollow, - newInstanceFollower: this.newInstanceFollower, - autoInstanceFollowing: this.autoInstanceFollowing, - abuseNewMessage: this.abuseNewMessage, - abuseStateChange: this.abuseStateChange, - newPeerTubeVersion: this.newPeerTubeVersion, - newPluginVersion: this.newPluginVersion - } - } -} -- cgit v1.2.3