diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-28 14:40:06 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-09-05 10:17:02 +0200 |
commit | 43d0ea7f4b88d52097172cc0c1831edd7e492503 (patch) | |
tree | d950f0a365bc1d7086992a686a06c335e14a9be9 /server/models/account/user.ts | |
parent | bc20aaed463b1fc6727a2a90a7d7c4a00b95142a (diff) | |
download | PeerTube-43d0ea7f4b88d52097172cc0c1831edd7e492503.tar.gz PeerTube-43d0ea7f4b88d52097172cc0c1831edd7e492503.tar.zst PeerTube-43d0ea7f4b88d52097172cc0c1831edd7e492503.zip |
Add welcome modal
Diffstat (limited to 'server/models/account/user.ts')
-rw-r--r-- | server/models/account/user.ts | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 616dd603c..451e1fd6b 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -22,6 +22,7 @@ import { | |||
22 | import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' | 22 | import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' |
23 | import { User, UserRole } from '../../../shared/models/users' | 23 | import { User, UserRole } from '../../../shared/models/users' |
24 | import { | 24 | import { |
25 | isNoInstanceConfigWarningModal, | ||
25 | isUserAdminFlagsValid, | 26 | isUserAdminFlagsValid, |
26 | isUserAutoPlayVideoValid, | 27 | isUserAutoPlayVideoValid, |
27 | isUserBlockedReasonValid, | 28 | isUserBlockedReasonValid, |
@@ -35,7 +36,8 @@ import { | |||
35 | isUserVideoQuotaDailyValid, | 36 | isUserVideoQuotaDailyValid, |
36 | isUserVideoQuotaValid, | 37 | isUserVideoQuotaValid, |
37 | isUserVideosHistoryEnabledValid, | 38 | isUserVideosHistoryEnabledValid, |
38 | isUserWebTorrentEnabledValid | 39 | isUserWebTorrentEnabledValid, |
40 | isNoWelcomeModal | ||
39 | } from '../../helpers/custom-validators/users' | 41 | } from '../../helpers/custom-validators/users' |
40 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' | 42 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' |
41 | import { OAuthTokenModel } from '../oauth/oauth-token' | 43 | import { OAuthTokenModel } from '../oauth/oauth-token' |
@@ -203,6 +205,24 @@ export class UserModel extends Model<UserModel> { | |||
203 | @Column | 205 | @Column |
204 | theme: string | 206 | theme: string |
205 | 207 | ||
208 | @AllowNull(false) | ||
209 | @Default(false) | ||
210 | @Is( | ||
211 | 'UserNoInstanceConfigWarningModal', | ||
212 | value => throwIfNotValid(value, isNoInstanceConfigWarningModal, 'no instance config warning modal') | ||
213 | ) | ||
214 | @Column | ||
215 | noInstanceConfigWarningModal: boolean | ||
216 | |||
217 | @AllowNull(false) | ||
218 | @Default(false) | ||
219 | @Is( | ||
220 | 'UserNoInstanceConfigWarningModal', | ||
221 | value => throwIfNotValid(value, isNoWelcomeModal, 'no welcome modal') | ||
222 | ) | ||
223 | @Column | ||
224 | noWelcomeModal: boolean | ||
225 | |||
206 | @CreatedAt | 226 | @CreatedAt |
207 | createdAt: Date | 227 | createdAt: Date |
208 | 228 | ||
@@ -560,40 +580,52 @@ export class UserModel extends Model<UserModel> { | |||
560 | return comparePassword(password, this.password) | 580 | return comparePassword(password, this.password) |
561 | } | 581 | } |
562 | 582 | ||
563 | toSummaryJSON | ||
564 | |||
565 | toFormattedJSON (this: MUserFormattable, parameters: { withAdminFlags?: boolean } = {}): User { | 583 | toFormattedJSON (this: MUserFormattable, parameters: { withAdminFlags?: boolean } = {}): User { |
566 | const videoQuotaUsed = this.get('videoQuotaUsed') | 584 | const videoQuotaUsed = this.get('videoQuotaUsed') |
567 | const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily') | 585 | const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily') |
568 | 586 | ||
569 | const json = { | 587 | const json: User = { |
570 | id: this.id, | 588 | id: this.id, |
571 | username: this.username, | 589 | username: this.username, |
572 | email: this.email, | 590 | email: this.email, |
591 | theme: getThemeOrDefault(this.theme, DEFAULT_USER_THEME_NAME), | ||
592 | |||
573 | pendingEmail: this.pendingEmail, | 593 | pendingEmail: this.pendingEmail, |
574 | emailVerified: this.emailVerified, | 594 | emailVerified: this.emailVerified, |
595 | |||
575 | nsfwPolicy: this.nsfwPolicy, | 596 | nsfwPolicy: this.nsfwPolicy, |
576 | webTorrentEnabled: this.webTorrentEnabled, | 597 | webTorrentEnabled: this.webTorrentEnabled, |
577 | videosHistoryEnabled: this.videosHistoryEnabled, | 598 | videosHistoryEnabled: this.videosHistoryEnabled, |
578 | autoPlayVideo: this.autoPlayVideo, | 599 | autoPlayVideo: this.autoPlayVideo, |
579 | videoLanguages: this.videoLanguages, | 600 | videoLanguages: this.videoLanguages, |
601 | |||
580 | role: this.role, | 602 | role: this.role, |
581 | theme: getThemeOrDefault(this.theme, DEFAULT_USER_THEME_NAME), | ||
582 | roleLabel: USER_ROLE_LABELS[ this.role ], | 603 | roleLabel: USER_ROLE_LABELS[ this.role ], |
604 | |||
583 | videoQuota: this.videoQuota, | 605 | videoQuota: this.videoQuota, |
584 | videoQuotaDaily: this.videoQuotaDaily, | 606 | videoQuotaDaily: this.videoQuotaDaily, |
585 | createdAt: this.createdAt, | 607 | videoQuotaUsed: videoQuotaUsed !== undefined |
608 | ? parseInt(videoQuotaUsed + '', 10) | ||
609 | : undefined, | ||
610 | videoQuotaUsedDaily: videoQuotaUsedDaily !== undefined | ||
611 | ? parseInt(videoQuotaUsedDaily + '', 10) | ||
612 | : undefined, | ||
613 | |||
614 | noInstanceConfigWarningModal: this.noInstanceConfigWarningModal, | ||
615 | noWelcomeModal: this.noWelcomeModal, | ||
616 | |||
586 | blocked: this.blocked, | 617 | blocked: this.blocked, |
587 | blockedReason: this.blockedReason, | 618 | blockedReason: this.blockedReason, |
619 | |||
588 | account: this.Account.toFormattedJSON(), | 620 | account: this.Account.toFormattedJSON(), |
589 | notificationSettings: this.NotificationSetting ? this.NotificationSetting.toFormattedJSON() : undefined, | 621 | |
622 | notificationSettings: this.NotificationSetting | ||
623 | ? this.NotificationSetting.toFormattedJSON() | ||
624 | : undefined, | ||
625 | |||
590 | videoChannels: [], | 626 | videoChannels: [], |
591 | videoQuotaUsed: videoQuotaUsed !== undefined | 627 | |
592 | ? parseInt(videoQuotaUsed + '', 10) | 628 | createdAt: this.createdAt |
593 | : undefined, | ||
594 | videoQuotaUsedDaily: videoQuotaUsedDaily !== undefined | ||
595 | ? parseInt(videoQuotaUsedDaily + '', 10) | ||
596 | : undefined | ||
597 | } | 629 | } |
598 | 630 | ||
599 | if (parameters.withAdminFlags) { | 631 | if (parameters.withAdminFlags) { |