aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-18 11:28:17 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:20 +0200
commit1735c825726edaa0af5035cb6cbb0cc0db502c6d (patch)
tree7bbb442f2cb4d7be58a4e08d87f5974403a3047c /server/models/account/user.ts
parente8bafea35bc930cb8ac5b2d521a188642a1adffe (diff)
downloadPeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip
Update sequelize
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r--server/models/account/user.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index b66458351..8bd0397dd 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -80,7 +80,7 @@ enum ScopeNames {
80 model: () => UserNotificationSettingModel, 80 model: () => UserNotificationSettingModel,
81 required: true 81 required: true
82 } 82 }
83 ] 83 ] as any // FIXME: sequelize typings
84 } 84 }
85}) 85})
86@Table({ 86@Table({
@@ -115,13 +115,13 @@ export class UserModel extends Model<UserModel> {
115 115
116 @AllowNull(true) 116 @AllowNull(true)
117 @Default(null) 117 @Default(null)
118 @Is('UserEmailVerified', value => throwIfNotValid(value, isUserEmailVerifiedValid, 'email verified boolean')) 118 @Is('UserEmailVerified', value => throwIfNotValid(value, isUserEmailVerifiedValid, 'email verified boolean', true))
119 @Column 119 @Column
120 emailVerified: boolean 120 emailVerified: boolean
121 121
122 @AllowNull(false) 122 @AllowNull(false)
123 @Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy')) 123 @Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy'))
124 @Column(DataType.ENUM(values(NSFW_POLICY_TYPES))) 124 @Column(DataType.ENUM(...values(NSFW_POLICY_TYPES)))
125 nsfwPolicy: NSFWPolicyType 125 nsfwPolicy: NSFWPolicyType
126 126
127 @AllowNull(false) 127 @AllowNull(false)
@@ -156,7 +156,7 @@ export class UserModel extends Model<UserModel> {
156 156
157 @AllowNull(true) 157 @AllowNull(true)
158 @Default(null) 158 @Default(null)
159 @Is('UserBlockedReason', value => throwIfNotValid(value, isUserBlockedReasonValid, 'blocked reason')) 159 @Is('UserBlockedReason', value => throwIfNotValid(value, isUserBlockedReasonValid, 'blocked reason', true))
160 @Column 160 @Column
161 blockedReason: string 161 blockedReason: string
162 162
@@ -556,10 +556,10 @@ export class UserModel extends Model<UserModel> {
556 notificationSettings: this.NotificationSetting ? this.NotificationSetting.toFormattedJSON() : undefined, 556 notificationSettings: this.NotificationSetting ? this.NotificationSetting.toFormattedJSON() : undefined,
557 videoChannels: [], 557 videoChannels: [],
558 videoQuotaUsed: videoQuotaUsed !== undefined 558 videoQuotaUsed: videoQuotaUsed !== undefined
559 ? parseInt(videoQuotaUsed, 10) 559 ? parseInt(videoQuotaUsed + '', 10)
560 : undefined, 560 : undefined,
561 videoQuotaUsedDaily: videoQuotaUsedDaily !== undefined 561 videoQuotaUsedDaily: videoQuotaUsedDaily !== undefined
562 ? parseInt(videoQuotaUsedDaily, 10) 562 ? parseInt(videoQuotaUsedDaily + '', 10)
563 : undefined 563 : undefined
564 } 564 }
565 565
@@ -619,14 +619,14 @@ export class UserModel extends Model<UserModel> {
619 private static getTotalRawQuery (query: string, userId: number) { 619 private static getTotalRawQuery (query: string, userId: number) {
620 const options = { 620 const options = {
621 bind: { userId }, 621 bind: { userId },
622 type: Sequelize.QueryTypes.SELECT 622 type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT
623 } 623 }
624 624
625 return UserModel.sequelize.query(query, options) 625 return UserModel.sequelize.query<{ total: number }>(query, options)
626 .then(([ { total } ]) => { 626 .then(([ { total } ]) => {
627 if (total === null) return 0 627 if (total === null) return 0
628 628
629 return parseInt(total, 10) 629 return parseInt(total + '', 10)
630 }) 630 })
631 } 631 }
632} 632}