diff options
Diffstat (limited to 'server/models/user/user-notification.ts')
-rw-r--r-- | server/models/user/user-notification.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server/models/user/user-notification.ts b/server/models/user/user-notification.ts index 6e134158f..667ee7f5f 100644 --- a/server/models/user/user-notification.ts +++ b/server/models/user/user-notification.ts | |||
@@ -20,6 +20,7 @@ import { VideoCommentModel } from '../video/video-comment' | |||
20 | import { VideoImportModel } from '../video/video-import' | 20 | import { VideoImportModel } from '../video/video-import' |
21 | import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder' | 21 | import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder' |
22 | import { UserModel } from './user' | 22 | import { UserModel } from './user' |
23 | import { UserRegistrationModel } from './user-registration' | ||
23 | 24 | ||
24 | @Table({ | 25 | @Table({ |
25 | tableName: 'userNotification', | 26 | tableName: 'userNotification', |
@@ -98,6 +99,14 @@ import { UserModel } from './user' | |||
98 | [Op.ne]: null | 99 | [Op.ne]: null |
99 | } | 100 | } |
100 | } | 101 | } |
102 | }, | ||
103 | { | ||
104 | fields: [ 'userRegistrationId' ], | ||
105 | where: { | ||
106 | userRegistrationId: { | ||
107 | [Op.ne]: null | ||
108 | } | ||
109 | } | ||
101 | } | 110 | } |
102 | ] as (ModelIndexesOptions & { where?: WhereOptions })[] | 111 | ] as (ModelIndexesOptions & { where?: WhereOptions })[] |
103 | }) | 112 | }) |
@@ -241,6 +250,18 @@ export class UserNotificationModel extends Model<Partial<AttributesOnly<UserNoti | |||
241 | }) | 250 | }) |
242 | Application: ApplicationModel | 251 | Application: ApplicationModel |
243 | 252 | ||
253 | @ForeignKey(() => UserRegistrationModel) | ||
254 | @Column | ||
255 | userRegistrationId: number | ||
256 | |||
257 | @BelongsTo(() => UserRegistrationModel, { | ||
258 | foreignKey: { | ||
259 | allowNull: true | ||
260 | }, | ||
261 | onDelete: 'cascade' | ||
262 | }) | ||
263 | UserRegistration: UserRegistrationModel | ||
264 | |||
244 | static listForApi (userId: number, start: number, count: number, sort: string, unread?: boolean) { | 265 | static listForApi (userId: number, start: number, count: number, sort: string, unread?: boolean) { |
245 | const where = { userId } | 266 | const where = { userId } |
246 | 267 | ||
@@ -416,6 +437,10 @@ export class UserNotificationModel extends Model<Partial<AttributesOnly<UserNoti | |||
416 | ? { latestVersion: this.Application.latestPeerTubeVersion } | 437 | ? { latestVersion: this.Application.latestPeerTubeVersion } |
417 | : undefined | 438 | : undefined |
418 | 439 | ||
440 | const registration = this.UserRegistration | ||
441 | ? { id: this.UserRegistration.id, username: this.UserRegistration.username } | ||
442 | : undefined | ||
443 | |||
419 | return { | 444 | return { |
420 | id: this.id, | 445 | id: this.id, |
421 | type: this.type, | 446 | type: this.type, |
@@ -429,6 +454,7 @@ export class UserNotificationModel extends Model<Partial<AttributesOnly<UserNoti | |||
429 | actorFollow, | 454 | actorFollow, |
430 | plugin, | 455 | plugin, |
431 | peertube, | 456 | peertube, |
457 | registration, | ||
432 | createdAt: this.createdAt.toISOString(), | 458 | createdAt: this.createdAt.toISOString(), |
433 | updatedAt: this.updatedAt.toISOString() | 459 | updatedAt: this.updatedAt.toISOString() |
434 | } | 460 | } |