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