aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/user
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-18 10:45:25 +0200
committerChocobozzz <me@florianbigard.com>2020-06-18 10:46:27 +0200
commit26d6bf6533023326fa017812cf31bbe20c752d36 (patch)
tree9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/typings/models/user
parentd6d951ddc0c492f3261065b5dcb4df0534d252fc (diff)
downloadPeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip
Split types and typings
Diffstat (limited to 'server/typings/models/user')
-rw-r--r--server/typings/models/user/index.ts4
-rw-r--r--server/typings/models/user/user-notification-setting.ts9
-rw-r--r--server/typings/models/user/user-notification.ts92
-rw-r--r--server/typings/models/user/user-video-history.ts5
-rw-r--r--server/typings/models/user/user.ts89
5 files changed, 0 insertions, 199 deletions
diff --git a/server/typings/models/user/index.ts b/server/typings/models/user/index.ts
deleted file mode 100644
index 6657b2128..000000000
--- a/server/typings/models/user/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
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
deleted file mode 100644
index c674add1b..000000000
--- a/server/typings/models/user/user-notification-setting.ts
+++ /dev/null
@@ -1,9 +0,0 @@
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
deleted file mode 100644
index 2080360e1..000000000
--- a/server/typings/models/user/user-notification.ts
+++ /dev/null
@@ -1,92 +0,0 @@
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 module UserNotificationIncludes {
20
21 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
22 export type VideoIncludeChannel =
23 VideoInclude &
24 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
25
26 export type ActorInclude =
27 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
28 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
29 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
30
31 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
32 export type VideoChannelIncludeActor =
33 VideoChannelInclude &
34 PickWith<VideoChannelModel, 'Actor', ActorInclude>
35
36 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
37 export type AccountIncludeActor =
38 AccountInclude &
39 PickWith<AccountModel, 'Actor', ActorInclude>
40
41 export type VideoCommentInclude =
42 Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
43 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
44 PickWith<VideoCommentModel, 'Video', VideoInclude>
45
46 export type VideoAbuseInclude =
47 Pick<VideoAbuseModel, 'id'> &
48 PickWith<VideoAbuseModel, 'Video', VideoInclude>
49
50 export type VideoBlacklistInclude =
51 Pick<VideoBlacklistModel, 'id'> &
52 PickWith<VideoAbuseModel, 'Video', VideoInclude>
53
54 export type VideoImportInclude =
55 Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
56 PickWith<VideoImportModel, 'Video', VideoInclude>
57
58 export type ActorFollower =
59 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
60 PickWith<ActorModel, 'Account', AccountInclude> &
61 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
62 PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
63
64 export type ActorFollowing =
65 Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
66 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
67 PickWith<ActorModel, 'Account', AccountInclude> &
68 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
69
70 export type ActorFollowInclude =
71 Pick<ActorFollowModel, 'id' | 'state'> &
72 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
73 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
74}
75
76// ############################################################################
77
78export type MUserNotification =
79 Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
80 'VideoImport' | 'Account' | 'ActorFollow'>
81
82// ############################################################################
83
84export type UserNotificationModelForApi =
85 MUserNotification &
86 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
87 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
88 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
89 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
90 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
91 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
92 Use<'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts
deleted file mode 100644
index 62673ab1b..000000000
--- a/server/typings/models/user/user-video-history.ts
+++ /dev/null
@@ -1,5 +0,0 @@
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
deleted file mode 100644
index 31cf075ef..000000000
--- a/server/typings/models/user/user.ts
+++ /dev/null
@@ -1,89 +0,0 @@
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 '../video/video-channels'
15import { MVideoPlaylist } from '@server/typings/models'
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>