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