]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/typings/models/user/user.ts
Correctly fix octet stream fallback for video ext
[github/Chocobozzz/PeerTube.git] / server / typings / models / user / user.ts
CommitLineData
453e83ea 1import { UserModel } from '../../../models/account/user'
1ca9f7c3
C
2import { PickWith, PickWithOpt } from '../../utils'
3import {
4 MAccount,
5 MAccountDefault,
6 MAccountDefaultChannelDefault,
7 MAccountFormattable,
8 MAccountId,
9 MAccountIdActorId,
10 MAccountUrl
11} from '../account'
12import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
13import { AccountModel } from '@server/models/account/account'
d7a25329 14import { MChannelFormattable } from '../video/video-channels'
ac0868bc 15import { MVideoPlaylist } from '@server/typings/models'
453e83ea 16
0283eaac
C
17type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
18
19// ############################################################################
20
453e83ea
C
21export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
22
0283eaac
C
23// ############################################################################
24
1ca9f7c3 25export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
453e83ea
C
26export type MUserId = Pick<UserModel, 'id'>
27
0283eaac 28// ############################################################################
453e83ea 29
0283eaac
C
30// With account
31
32export type MUserAccountId = MUser &
33 Use<'Account', MAccountId>
34
35export type MUserAccountUrl = MUser &
36 Use<'Account', MAccountUrl & MAccountIdActorId>
453e83ea
C
37
38export type MUserAccount = MUser &
0283eaac 39 Use<'Account', MAccount>
453e83ea 40
0283eaac
C
41export type MUserAccountDefault = MUser &
42 Use<'Account', MAccountDefault>
453e83ea 43
0283eaac 44// With channel
453e83ea 45
0283eaac
C
46export type MUserNotifSettingChannelDefault = MUser &
47 Use<'NotificationSetting', MNotificationSetting> &
48 Use<'Account', MAccountDefaultChannelDefault>
453e83ea 49
0283eaac 50// With notification settings
453e83ea 51
0283eaac
C
52export type MUserWithNotificationSetting = MUser &
53 Use<'NotificationSetting', MNotificationSetting>
54
55export type MUserNotifSettingAccount = MUser &
56 Use<'NotificationSetting', MNotificationSetting> &
57 Use<'Account', MAccount>
58
59// Default scope
60
61export type MUserDefault = MUser &
62 Use<'NotificationSetting', MNotificationSetting> &
63 Use<'Account', MAccountDefault>
1ca9f7c3
C
64
65// ############################################################################
66
67// Format for API or AP object
68
ac0868bc
C
69type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
70type MAccountWithChannelsAndSpecialPlaylists = MAccountWithChannels &
71 PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
72
1ca9f7c3 73export type MUserFormattable = MUserQuotaUsed &
ac0868bc 74 Use<'Account', MAccountWithChannels> &
1ca9f7c3 75 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
ac0868bc
C
76
77export type MMyUserFormattable = MUserFormattable &
78 Use<'Account', MAccountWithChannelsAndSpecialPlaylists>