]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/user/user-notification.ts
Add version comment
[github/Chocobozzz/PeerTube.git] / server / types / models / user / user-notification.ts
CommitLineData
d95d1559
C
1import { VideoAbuseModel } from '@server/models/abuse/video-abuse'
2import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse'
32a18cbf
C
3import { ApplicationModel } from '@server/models/application/application'
4import { PluginModel } from '@server/models/server/plugin'
7d9ba5c0 5import { UserNotificationModel } from '@server/models/user/user-notification'
e364e31e 6import { UserRegistrationModel } from '@server/models/user/user-registration'
6b5f72be 7import { PickWith, PickWithOpt } from '@shared/typescript-utils'
d95d1559
C
8import { AbuseModel } from '../../../models/abuse/abuse'
9import { AccountModel } from '../../../models/account/account'
7d9ba5c0
C
10import { ActorModel } from '../../../models/actor/actor'
11import { ActorFollowModel } from '../../../models/actor/actor-follow'
12import { ActorImageModel } from '../../../models/actor/actor-image'
d95d1559
C
13import { ServerModel } from '../../../models/server/server'
14import { VideoModel } from '../../../models/video/video'
15import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
453e83ea 16import { VideoChannelModel } from '../../../models/video/video-channel'
453e83ea 17import { VideoCommentModel } from '../../../models/video/video-comment'
453e83ea 18import { VideoImportModel } from '../../../models/video/video-import'
453e83ea 19
0283eaac
C
20type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
21
22// ############################################################################
23
a1587156 24export module UserNotificationIncludes {
d0800f76 25 export type ActorImageInclude = Pick<ActorImageModel, 'createdAt' | 'filename' | 'getStaticPath' | 'width' | 'updatedAt'>
a1587156 26
453e83ea 27 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
a1587156
C
28 export type VideoIncludeChannel =
29 VideoInclude &
453e83ea
C
30 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
31
a1587156
C
32 export type ActorInclude =
33 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
d0800f76 34 PickWith<ActorModel, 'Avatars', ActorImageInclude[]> &
453e83ea
C
35 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
36
37 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
a1587156
C
38 export type VideoChannelIncludeActor =
39 VideoChannelInclude &
453e83ea
C
40 PickWith<VideoChannelModel, 'Actor', ActorInclude>
41
42 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
a1587156
C
43 export type AccountIncludeActor =
44 AccountInclude &
453e83ea
C
45 PickWith<AccountModel, 'Actor', ActorInclude>
46
a1587156
C
47 export type VideoCommentInclude =
48 Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
453e83ea
C
49 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
50 PickWith<VideoCommentModel, 'Video', VideoInclude>
51
a1587156
C
52 export type VideoAbuseInclude =
53 Pick<VideoAbuseModel, 'id'> &
453e83ea
C
54 PickWith<VideoAbuseModel, 'Video', VideoInclude>
55
d95d1559
C
56 export type VideoCommentAbuseInclude =
57 Pick<VideoCommentAbuseModel, 'id'> &
58 PickWith<VideoCommentAbuseModel, 'VideoComment',
59 Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
310b5219 60 PickWith<VideoCommentModel, 'Video', Pick<VideoModel, 'id' | 'name' | 'uuid'>>>
d95d1559
C
61
62 export type AbuseInclude =
594d3e48 63 Pick<AbuseModel, 'id' | 'state'> &
d95d1559
C
64 PickWith<AbuseModel, 'VideoAbuse', VideoAbuseInclude> &
65 PickWith<AbuseModel, 'VideoCommentAbuse', VideoCommentAbuseInclude> &
66 PickWith<AbuseModel, 'FlaggedAccount', AccountIncludeActor>
67
a1587156
C
68 export type VideoBlacklistInclude =
69 Pick<VideoBlacklistModel, 'id'> &
453e83ea
C
70 PickWith<VideoAbuseModel, 'Video', VideoInclude>
71
a1587156
C
72 export type VideoImportInclude =
73 Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
453e83ea
C
74 PickWith<VideoImportModel, 'Video', VideoInclude>
75
a1587156
C
76 export type ActorFollower =
77 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
453e83ea 78 PickWith<ActorModel, 'Account', AccountInclude> &
8424c402 79 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
d0800f76 80 PickWithOpt<ActorModel, 'Avatars', ActorImageInclude[]>
453e83ea 81
a1587156
C
82 export type ActorFollowing =
83 Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
453e83ea 84 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
8424c402
C
85 PickWith<ActorModel, 'Account', AccountInclude> &
86 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
453e83ea 87
a1587156
C
88 export type ActorFollowInclude =
89 Pick<ActorFollowModel, 'id' | 'state'> &
453e83ea
C
90 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
91 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
32a18cbf
C
92
93 export type PluginInclude =
94 Pick<PluginModel, 'id' | 'name' | 'type' | 'latestVersion'>
95
96 export type ApplicationInclude =
97 Pick<ApplicationModel, 'latestPeerTubeVersion'>
e364e31e
C
98
99 export type UserRegistrationInclude =
100 Pick<UserRegistrationModel, 'id' | 'username'>
453e83ea
C
101}
102
0283eaac
C
103// ############################################################################
104
a1587156 105export type MUserNotification =
d0800f76 106 Omit<UserNotificationModel, 'User' | 'Video' | 'VideoComment' | 'Abuse' | 'VideoBlacklist' |
e364e31e 107 'VideoImport' | 'Account' | 'ActorFollow' | 'Plugin' | 'Application' | 'UserRegistration'>
453e83ea 108
0283eaac
C
109// ############################################################################
110
a1587156
C
111export type UserNotificationModelForApi =
112 MUserNotification &
0283eaac 113 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
d0800f76 114 Use<'VideoComment', UserNotificationIncludes.VideoCommentInclude> &
d95d1559 115 Use<'Abuse', UserNotificationIncludes.AbuseInclude> &
0283eaac
C
116 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
117 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
118 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
32a18cbf
C
119 Use<'Plugin', UserNotificationIncludes.PluginInclude> &
120 Use<'Application', UserNotificationIncludes.ApplicationInclude> &
e364e31e
C
121 Use<'Account', UserNotificationIncludes.AccountIncludeActor> &
122 Use<'UserRegistration', UserNotificationIncludes.UserRegistrationInclude>