]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/typings/models/user/user.ts
Type toFormattedJSON
[github/Chocobozzz/PeerTube.git] / server / typings / models / user / user.ts
index 466cde33b890bf41525eeffe67190bf3fe37f4f1..52d6d4a057f191ffde59366cb95c2fbc6813c0ec 100644 (file)
@@ -1,7 +1,17 @@
 import { UserModel } from '../../../models/account/user'
-import { PickWith } from '../../utils'
-import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
-import { MNotificationSetting } from './user-notification-setting'
+import { PickWith, PickWithOpt } from '../../utils'
+import {
+  MAccount,
+  MAccountDefault,
+  MAccountDefaultChannelDefault,
+  MAccountFormattable,
+  MAccountId,
+  MAccountIdActorId,
+  MAccountUrl
+} from '../account'
+import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
+import { AccountModel } from '@server/models/account/account'
+import { MChannelFormattable } from '@server/typings/models'
 
 type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
 
@@ -11,6 +21,7 @@ export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoIm
 
 // ############################################################################
 
+export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
 export type MUserId = Pick<UserModel, 'id'>
 
 // ############################################################################
@@ -49,3 +60,11 @@ export type MUserNotifSettingAccount = MUser &
 export type MUserDefault = MUser &
   Use<'NotificationSetting', MNotificationSetting> &
   Use<'Account', MAccountDefault>
+
+// ############################################################################
+
+// Format for API or AP object
+
+export type MUserFormattable = MUserQuotaUsed &
+  Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> &
+  PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>