2019-08-15 11:53:26 +02:00
|
|
|
import { UserModel } from '../../../models/account/user'
|
2019-08-20 19:05:31 +02:00
|
|
|
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'
|
2019-11-15 15:06:03 +01:00
|
|
|
import { MChannelFormattable } from '../video/video-channels'
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
|
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
|
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
// ############################################################################
|
|
|
|
|
2019-08-20 19:05:31 +02:00
|
|
|
export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
|
2019-08-15 11:53:26 +02:00
|
|
|
export type MUserId = Pick<UserModel, 'id'>
|
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
// ############################################################################
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
// With account
|
|
|
|
|
|
|
|
export type MUserAccountId = MUser &
|
|
|
|
Use<'Account', MAccountId>
|
|
|
|
|
|
|
|
export type MUserAccountUrl = MUser &
|
|
|
|
Use<'Account', MAccountUrl & MAccountIdActorId>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
|
|
|
export type MUserAccount = MUser &
|
2019-08-20 13:52:49 +02:00
|
|
|
Use<'Account', MAccount>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
export type MUserAccountDefault = MUser &
|
|
|
|
Use<'Account', MAccountDefault>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
// With channel
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
export type MUserNotifSettingChannelDefault = MUser &
|
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccountDefaultChannelDefault>
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
// With notification settings
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2019-08-20 13:52:49 +02:00
|
|
|
export type MUserWithNotificationSetting = MUser &
|
|
|
|
Use<'NotificationSetting', MNotificationSetting>
|
|
|
|
|
|
|
|
export type MUserNotifSettingAccount = MUser &
|
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccount>
|
|
|
|
|
|
|
|
// Default scope
|
|
|
|
|
|
|
|
export type MUserDefault = MUser &
|
|
|
|
Use<'NotificationSetting', MNotificationSetting> &
|
|
|
|
Use<'Account', MAccountDefault>
|
2019-08-20 19:05:31 +02:00
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
// Format for API or AP object
|
|
|
|
|
|
|
|
export type MUserFormattable = MUserQuotaUsed &
|
|
|
|
Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> &
|
|
|
|
PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
|