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