]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/user/user.ts
Add ability to filter by file type
[github/Chocobozzz/PeerTube.git] / server / models / user / user.ts
index 8d2564e54626b9fed988ab3f774a81046a566f07..b56f37e558eea81a3bfa19e0950266d246d8d149 100644 (file)
@@ -31,6 +31,7 @@ import {
   MUserWithNotificationSetting,
   MVideoWithRights
 } from '@server/types/models'
+import { AttributesOnly } from '@shared/core-utils'
 import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users'
 import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models'
 import { User, UserRole } from '../../../shared/models/users'
@@ -38,8 +39,6 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
 import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
 import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
 import {
-  isNoInstanceConfigWarningModal,
-  isNoWelcomeModal,
   isUserAdminFlagsValid,
   isUserAutoPlayNextVideoPlaylistValid,
   isUserAutoPlayNextVideoValid,
@@ -47,6 +46,7 @@ import {
   isUserBlockedReasonValid,
   isUserBlockedValid,
   isUserEmailVerifiedValid,
+  isUserNoModal,
   isUserNSFWPolicyValid,
   isUserPasswordValid,
   isUserRoleValid,
@@ -233,7 +233,7 @@ enum ScopeNames {
     }
   ]
 })
-export class UserModel extends Model {
+export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> {
 
   @AllowNull(true)
   @Is('UserPassword', value => throwIfNotValid(value, isUserPasswordValid, 'user password', true))
@@ -348,7 +348,7 @@ export class UserModel extends Model {
   @Default(false)
   @Is(
     'UserNoInstanceConfigWarningModal',
-    value => throwIfNotValid(value, isNoInstanceConfigWarningModal, 'no instance config warning modal')
+    value => throwIfNotValid(value, isUserNoModal, 'no instance config warning modal')
   )
   @Column
   noInstanceConfigWarningModal: boolean
@@ -356,12 +356,21 @@ export class UserModel extends Model {
   @AllowNull(false)
   @Default(false)
   @Is(
-    'UserNoInstanceConfigWarningModal',
-    value => throwIfNotValid(value, isNoWelcomeModal, 'no welcome modal')
+    'UserNoWelcomeModal',
+    value => throwIfNotValid(value, isUserNoModal, 'no welcome modal')
   )
   @Column
   noWelcomeModal: boolean
 
+  @AllowNull(false)
+  @Default(false)
+  @Is(
+    'UserNoAccountSetupWarningModal',
+    value => throwIfNotValid(value, isUserNoModal, 'no account setup warning modal')
+  )
+  @Column
+  noAccountSetupWarningModal: boolean
+
   @AllowNull(true)
   @Default(null)
   @Column
@@ -478,7 +487,7 @@ export class UserModel extends Model {
               ')'
             ),
             'videoQuotaUsed'
-          ] as any // FIXME: typings
+          ]
         ]
       },
       offset: start,
@@ -919,6 +928,7 @@ export class UserModel extends Model {
 
       noInstanceConfigWarningModal: this.noInstanceConfigWarningModal,
       noWelcomeModal: this.noWelcomeModal,
+      noAccountSetupWarningModal: this.noAccountSetupWarningModal,
 
       blocked: this.blocked,
       blockedReason: this.blockedReason,
@@ -957,7 +967,7 @@ export class UserModel extends Model {
   }
 
   toMeFormattedJSON (this: MMyUserFormattable): MyUser {
-    const formatted = this.toFormattedJSON()
+    const formatted = this.toFormattedJSON({ withAdminFlags: true })
 
     const specialPlaylists = this.Account.VideoPlaylists
                                  .map(p => ({ id: p.id, name: p.name, type: p.type }))