From 594d3e48d8a887bbf48ce4cc594c1c36c9640fb1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Jul 2020 16:26:25 +0200 Subject: Add abuse messages/states notifications --- server/models/account/user-notification-setting.ts | 30 ++++++++++++++++++---- server/models/account/user-notification.ts | 3 ++- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts index d8f3f13da..acc192d53 100644 --- a/server/models/account/user-notification-setting.ts +++ b/server/models/account/user-notification-setting.ts @@ -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 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 { return { id: abuse.id, + state: abuse.state, video: videoAbuse, comment: commentAbuse, account: accountAbuse -- cgit v1.2.3