aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user/user-notification.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-19 09:27:16 +0100
committerChocobozzz <chocobozzz@cpy.re>2023-01-19 13:53:40 +0100
commite364e31e25bd1d4b8d801c845a96d6be708f0a18 (patch)
tree220785a42af361706eb8243960c5da9cddf4d2be /server/models/user/user-notification.ts
parentbc48e33b80f357767b98c1d310b04bdda24c6d46 (diff)
downloadPeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.gz
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.zst
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.zip
Implement signup approval in server
Diffstat (limited to 'server/models/user/user-notification.ts')
-rw-r--r--server/models/user/user-notification.ts26
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'
20import { VideoImportModel } from '../video/video-import' 20import { VideoImportModel } from '../video/video-import'
21import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder' 21import { UserNotificationListQueryBuilder } from './sql/user-notitication-list-query-builder'
22import { UserModel } from './user' 22import { UserModel } from './user'
23import { 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 }