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