aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/user
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/models/user')
-rw-r--r--server/typings/models/user/index.d.ts4
-rw-r--r--server/typings/models/user/user-notification-setting.ts9
-rw-r--r--server/typings/models/user/user-notification.ts78
-rw-r--r--server/typings/models/user/user-video-history.ts5
-rw-r--r--server/typings/models/user/user.ts70
5 files changed, 166 insertions, 0 deletions
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts
new file mode 100644
index 000000000..6657b2128
--- /dev/null
+++ b/server/typings/models/user/index.d.ts
@@ -0,0 +1,4 @@
1export * from './user'
2export * from './user-notification'
3export * from './user-notification-setting'
4export * from './user-video-history'
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts
new file mode 100644
index 000000000..c674add1b
--- /dev/null
+++ b/server/typings/models/user/user-notification-setting.ts
@@ -0,0 +1,9 @@
1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'
2
3export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'>
4
5// ############################################################################
6
7// Format for API or AP object
8
9export type MNotificationSettingFormattable = MNotificationSetting
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts
new file mode 100644
index 000000000..1cdc691b0
--- /dev/null
+++ b/server/typings/models/user/user-notification.ts
@@ -0,0 +1,78 @@
1import { UserNotificationModel } from '../../../models/account/user-notification'
2import { PickWith, PickWithOpt } from '../../utils'
3import { VideoModel } from '../../../models/video/video'
4import { ActorModel } from '../../../models/activitypub/actor'
5import { ServerModel } from '../../../models/server/server'
6import { AvatarModel } from '../../../models/avatar/avatar'
7import { VideoChannelModel } from '../../../models/video/video-channel'
8import { AccountModel } from '../../../models/account/account'
9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { VideoAbuseModel } from '../../../models/video/video-abuse'
11import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
12import { VideoImportModel } from '../../../models/video/video-import'
13import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
14
15type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
16
17// ############################################################################
18
19export namespace UserNotificationIncludes {
20 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
21 export type VideoIncludeChannel = VideoInclude &
22 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
23
24 export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
25 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
26 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
27
28 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
29 export type VideoChannelIncludeActor = VideoChannelInclude &
30 PickWith<VideoChannelModel, 'Actor', ActorInclude>
31
32 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
33 export type AccountIncludeActor = AccountInclude &
34 PickWith<AccountModel, 'Actor', ActorInclude>
35
36 export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
37 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
38 PickWith<VideoCommentModel, 'Video', VideoInclude>
39
40 export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> &
41 PickWith<VideoAbuseModel, 'Video', VideoInclude>
42
43 export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> &
44 PickWith<VideoAbuseModel, 'Video', VideoInclude>
45
46 export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
47 PickWith<VideoImportModel, 'Video', VideoInclude>
48
49 export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
50 PickWith<ActorModel, 'Account', AccountInclude> &
51 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
52 PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
53
54 export type ActorFollowing = Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
55 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
56 PickWith<ActorModel, 'Account', AccountInclude> &
57 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
58
59 export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> &
60 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
61 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
62}
63
64// ############################################################################
65
66export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
67 'VideoImport' | 'Account' | 'ActorFollow'>
68
69// ############################################################################
70
71export type UserNotificationModelForApi = MUserNotification &
72 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
73 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
74 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
75 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
76 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
77 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
78 Use<'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts
new file mode 100644
index 000000000..62673ab1b
--- /dev/null
+++ b/server/typings/models/user/user-video-history.ts
@@ -0,0 +1,5 @@
1import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
2
3export type MUserVideoHistory = Omit<UserVideoHistoryModel, 'Video' | 'User'>
4
5export type MUserVideoHistoryTime = Pick<MUserVideoHistory, 'currentTime'>
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts
new file mode 100644
index 000000000..52d6d4a05
--- /dev/null
+++ b/server/typings/models/user/user.ts
@@ -0,0 +1,70 @@
1import { UserModel } from '../../../models/account/user'
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'
14import { MChannelFormattable } from '@server/typings/models'
15
16type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
17
18// ############################################################################
19
20export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
21
22// ############################################################################
23
24export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
25export type MUserId = Pick<UserModel, 'id'>
26
27// ############################################################################
28
29// With account
30
31export type MUserAccountId = MUser &
32 Use<'Account', MAccountId>
33
34export type MUserAccountUrl = MUser &
35 Use<'Account', MAccountUrl & MAccountIdActorId>
36
37export type MUserAccount = MUser &
38 Use<'Account', MAccount>
39
40export type MUserAccountDefault = MUser &
41 Use<'Account', MAccountDefault>
42
43// With channel
44
45export type MUserNotifSettingChannelDefault = MUser &
46 Use<'NotificationSetting', MNotificationSetting> &
47 Use<'Account', MAccountDefaultChannelDefault>
48
49// With notification settings
50
51export type MUserWithNotificationSetting = MUser &
52 Use<'NotificationSetting', MNotificationSetting>
53
54export type MUserNotifSettingAccount = MUser &
55 Use<'NotificationSetting', MNotificationSetting> &
56 Use<'Account', MAccount>
57
58// Default scope
59
60export type MUserDefault = MUser &
61 Use<'NotificationSetting', MNotificationSetting> &
62 Use<'Account', MAccountDefault>
63
64// ############################################################################
65
66// Format for API or AP object
67
68export type MUserFormattable = MUserQuotaUsed &
69 Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> &
70 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>