diff options
Diffstat (limited to 'server/typings/models/user')
-rw-r--r-- | server/typings/models/user/index.d.ts | 1 | ||||
-rw-r--r-- | server/typings/models/user/user-notification.ts | 26 | ||||
-rw-r--r-- | server/typings/models/user/user.ts | 49 |
3 files changed, 52 insertions, 24 deletions
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts index e3353d0b1..6657b2128 100644 --- a/server/typings/models/user/index.d.ts +++ b/server/typings/models/user/index.d.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './user' | 1 | export * from './user' |
2 | export * from './user-notification' | 2 | export * from './user-notification' |
3 | export * from './user-notification-setting' | ||
3 | export * from './user-video-history' | 4 | export * from './user-video-history' |
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts index b872c5dc5..f9daf5eb2 100644 --- a/server/typings/models/user/user-notification.ts +++ b/server/typings/models/user/user-notification.ts | |||
@@ -12,6 +12,10 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | |||
12 | import { VideoImportModel } from '../../../models/video/video-import' | 12 | import { VideoImportModel } from '../../../models/video/video-import' |
13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
14 | 14 | ||
15 | type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
15 | export namespace UserNotificationIncludes { | 19 | export namespace UserNotificationIncludes { |
16 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | 20 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> |
17 | export type VideoIncludeChannel = VideoInclude & | 21 | export type VideoIncludeChannel = VideoInclude & |
@@ -56,14 +60,18 @@ export namespace UserNotificationIncludes { | |||
56 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | 60 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> |
57 | } | 61 | } |
58 | 62 | ||
59 | export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | 63 | // ############################################################################ |
64 | |||
65 | export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
60 | 'VideoImport' | 'Account' | 'ActorFollow'> | 66 | 'VideoImport' | 'Account' | 'ActorFollow'> |
61 | 67 | ||
62 | export type UserNotificationModelForApi = UserNotificationModelOnly & | 68 | // ############################################################################ |
63 | PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> & | 69 | |
64 | PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> & | 70 | export type UserNotificationModelForApi = MUserNotification & |
65 | PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | 71 | Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & |
66 | PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | 72 | Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & |
67 | PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> & | 73 | Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & |
68 | PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | 74 | Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & |
69 | PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor> | 75 | Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & |
76 | Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | ||
77 | Use<'Account', UserNotificationIncludes.AccountIncludeActor> | ||
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts index b91eed8d9..466cde33b 100644 --- a/server/typings/models/user/user.ts +++ b/server/typings/models/user/user.ts | |||
@@ -3,30 +3,49 @@ import { PickWith } from '../../utils' | |||
3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' | 3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' |
4 | import { MNotificationSetting } from './user-notification-setting' | 4 | import { MNotificationSetting } from './user-notification-setting' |
5 | 5 | ||
6 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
6 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | 10 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> |
7 | 11 | ||
12 | // ############################################################################ | ||
13 | |||
8 | export type MUserId = Pick<UserModel, 'id'> | 14 | export type MUserId = Pick<UserModel, 'id'> |
9 | 15 | ||
10 | export type MUserWithNotificationSetting = MUser & | 16 | // ############################################################################ |
11 | PickWith<UserModel, 'NotificationSetting', MNotificationSetting> | ||
12 | 17 | ||
13 | export type MUserAccountDefault = MUser & | 18 | // With account |
14 | PickWith<UserModel, 'Account', MAccountDefault> | 19 | |
20 | export type MUserAccountId = MUser & | ||
21 | Use<'Account', MAccountId> | ||
22 | |||
23 | export type MUserAccountUrl = MUser & | ||
24 | Use<'Account', MAccountUrl & MAccountIdActorId> | ||
15 | 25 | ||
16 | export type MUserAccount = MUser & | 26 | export type MUserAccount = MUser & |
17 | PickWith<UserModel, 'Account', MAccount> | 27 | Use<'Account', MAccount> |
18 | 28 | ||
19 | export type MUserAccountId = MUser & | 29 | export type MUserAccountDefault = MUser & |
20 | PickWith<UserModel, 'Account', MAccountId> | 30 | Use<'Account', MAccountDefault> |
21 | 31 | ||
22 | export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount | 32 | // With channel |
23 | 33 | ||
24 | export type MUserDefault = MUser & | 34 | export type MUserNotifSettingChannelDefault = MUser & |
25 | MUserWithNotificationSetting & | 35 | Use<'NotificationSetting', MNotificationSetting> & |
26 | MUserAccountDefault | 36 | Use<'Account', MAccountDefaultChannelDefault> |
27 | 37 | ||
28 | export type MUserChannel = MUserWithNotificationSetting & | 38 | // With notification settings |
29 | PickWith<UserModel, 'Account', MAccountDefaultChannelDefault> | ||
30 | 39 | ||
31 | export type MUserAccountUrl = MUser & | 40 | export type MUserWithNotificationSetting = MUser & |
32 | PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId> | 41 | Use<'NotificationSetting', MNotificationSetting> |
42 | |||
43 | export type MUserNotifSettingAccount = MUser & | ||
44 | Use<'NotificationSetting', MNotificationSetting> & | ||
45 | Use<'Account', MAccount> | ||
46 | |||
47 | // Default scope | ||
48 | |||
49 | export type MUserDefault = MUser & | ||
50 | Use<'NotificationSetting', MNotificationSetting> & | ||
51 | Use<'Account', MAccountDefault> | ||