diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/user-notification-setting.ts | 30 | ||||
-rw-r--r-- | server/models/account/user-notification.ts | 3 |
2 files changed, 27 insertions, 6 deletions
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 { | |||
12 | Table, | 12 | Table, |
13 | UpdatedAt | 13 | UpdatedAt |
14 | } from 'sequelize-typescript' | 14 | } from 'sequelize-typescript' |
15 | import { throwIfNotValid } from '../utils' | 15 | import { MNotificationSettingFormattable } from '@server/types/models' |
16 | import { UserModel } from './user' | ||
17 | import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' | ||
18 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' | 16 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' |
17 | import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' | ||
19 | import { clearCacheByUserId } from '../../lib/oauth-model' | 18 | import { clearCacheByUserId } from '../../lib/oauth-model' |
20 | import { MNotificationSettingFormattable } from '@server/types/models' | 19 | import { throwIfNotValid } from '../utils' |
20 | import { UserModel } from './user' | ||
21 | 21 | ||
22 | @Table({ | 22 | @Table({ |
23 | tableName: 'userNotificationSetting', | 23 | tableName: 'userNotificationSetting', |
@@ -138,6 +138,24 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM | |||
138 | @Column | 138 | @Column |
139 | commentMention: UserNotificationSettingValue | 139 | commentMention: UserNotificationSettingValue |
140 | 140 | ||
141 | @AllowNull(false) | ||
142 | @Default(null) | ||
143 | @Is( | ||
144 | 'UserNotificationSettingAbuseStateChange', | ||
145 | value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseStateChange') | ||
146 | ) | ||
147 | @Column | ||
148 | abuseStateChange: UserNotificationSettingValue | ||
149 | |||
150 | @AllowNull(false) | ||
151 | @Default(null) | ||
152 | @Is( | ||
153 | 'UserNotificationSettingAbuseNewMessage', | ||
154 | value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseNewMessage') | ||
155 | ) | ||
156 | @Column | ||
157 | abuseNewMessage: UserNotificationSettingValue | ||
158 | |||
141 | @ForeignKey(() => UserModel) | 159 | @ForeignKey(() => UserModel) |
142 | @Column | 160 | @Column |
143 | userId: number | 161 | userId: number |
@@ -175,7 +193,9 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM | |||
175 | commentMention: this.commentMention, | 193 | commentMention: this.commentMention, |
176 | newFollow: this.newFollow, | 194 | newFollow: this.newFollow, |
177 | newInstanceFollower: this.newInstanceFollower, | 195 | newInstanceFollower: this.newInstanceFollower, |
178 | autoInstanceFollowing: this.autoInstanceFollowing | 196 | autoInstanceFollowing: this.autoInstanceFollowing, |
197 | abuseNewMessage: this.abuseNewMessage, | ||
198 | abuseStateChange: this.abuseStateChange | ||
179 | } | 199 | } |
180 | } | 200 | } |
181 | } | 201 | } |
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts index 2945bf709..bd89b8973 100644 --- a/server/models/account/user-notification.ts +++ b/server/models/account/user-notification.ts | |||
@@ -88,7 +88,7 @@ function buildAccountInclude (required: boolean, withActor = false) { | |||
88 | }, | 88 | }, |
89 | 89 | ||
90 | { | 90 | { |
91 | attributes: [ 'id' ], | 91 | attributes: [ 'id', 'state' ], |
92 | model: AbuseModel.unscoped(), | 92 | model: AbuseModel.unscoped(), |
93 | required: false, | 93 | required: false, |
94 | include: [ | 94 | include: [ |
@@ -504,6 +504,7 @@ export class UserNotificationModel extends Model<UserNotificationModel> { | |||
504 | 504 | ||
505 | return { | 505 | return { |
506 | id: abuse.id, | 506 | id: abuse.id, |
507 | state: abuse.state, | ||
507 | video: videoAbuse, | 508 | video: videoAbuse, |
508 | comment: commentAbuse, | 509 | comment: commentAbuse, |
509 | account: accountAbuse | 510 | account: accountAbuse |