]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/user/user.ts
Add banners support
[github/Chocobozzz/PeerTube.git] / server / types / models / user / user.ts
CommitLineData
2cb03dc1
C
1import { AccountModel } from '@server/models/account/account'
2import { MVideoPlaylist } from '@server/types/models'
67ed6552 3import { PickWith, PickWithOpt } from '@shared/core-utils'
2cb03dc1 4import { UserModel } from '../../../models/account/user'
1ca9f7c3
C
5import {
6 MAccount,
7 MAccountDefault,
8 MAccountDefaultChannelDefault,
9 MAccountFormattable,
10 MAccountId,
11 MAccountIdActorId,
12 MAccountUrl
13} from '../account'
d7a25329 14import { MChannelFormattable } from '../video/video-channels'
2cb03dc1 15import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
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
a1587156
C
32export type MUserAccountId =
33 MUser &
0283eaac
C
34 Use<'Account', MAccountId>
35
a1587156
C
36export type MUserAccountUrl =
37 MUser &
0283eaac 38 Use<'Account', MAccountUrl & MAccountIdActorId>
453e83ea 39
a1587156
C
40export type MUserAccount =
41 MUser &
0283eaac 42 Use<'Account', MAccount>
453e83ea 43
a1587156
C
44export type MUserAccountDefault =
45 MUser &
0283eaac 46 Use<'Account', MAccountDefault>
453e83ea 47
0283eaac 48// With channel
453e83ea 49
a1587156
C
50export type MUserNotifSettingChannelDefault =
51 MUser &
0283eaac
C
52 Use<'NotificationSetting', MNotificationSetting> &
53 Use<'Account', MAccountDefaultChannelDefault>
453e83ea 54
0283eaac 55// With notification settings
453e83ea 56
a1587156
C
57export type MUserWithNotificationSetting =
58 MUser &
0283eaac
C
59 Use<'NotificationSetting', MNotificationSetting>
60
a1587156
C
61export type MUserNotifSettingAccount =
62 MUser &
0283eaac
C
63 Use<'NotificationSetting', MNotificationSetting> &
64 Use<'Account', MAccount>
65
66// Default scope
67
a1587156
C
68export type MUserDefault =
69 MUser &
0283eaac
C
70 Use<'NotificationSetting', MNotificationSetting> &
71 Use<'Account', MAccountDefault>
1ca9f7c3
C
72
73// ############################################################################
74
75// Format for API or AP object
76
ac0868bc 77type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
a1587156
C
78type MAccountWithChannelsAndSpecialPlaylists =
79 MAccountWithChannels &
ac0868bc
C
80 PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
81
a1587156
C
82export type MUserFormattable =
83 MUserQuotaUsed &
ac0868bc 84 Use<'Account', MAccountWithChannels> &
1ca9f7c3 85 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
ac0868bc 86
a1587156
C
87export type MMyUserFormattable =
88 MUserFormattable &
ac0868bc 89 Use<'Account', MAccountWithChannelsAndSpecialPlaylists>