]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { UserNotificationModel } from '../../../models/account/user-notification' |
8424c402 | 2 | import { PickWith, PickWithOpt } from '../../utils' |
453e83ea C |
3 | import { VideoModel } from '../../../models/video/video' |
4 | import { ActorModel } from '../../../models/activitypub/actor' | |
5 | import { ServerModel } from '../../../models/server/server' | |
6 | import { AvatarModel } from '../../../models/avatar/avatar' | |
7 | import { VideoChannelModel } from '../../../models/video/video-channel' | |
8 | import { AccountModel } from '../../../models/account/account' | |
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | |
10 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | |
11 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | |
12 | import { VideoImportModel } from '../../../models/video/video-import' | |
13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |
14 | ||
0283eaac C |
15 | type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M> |
16 | ||
17 | // ############################################################################ | |
18 | ||
453e83ea C |
19 | export namespace UserNotificationIncludes { |
20 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | |
21 | export type VideoIncludeChannel = VideoInclude & | |
22 | PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor> | |
23 | ||
24 | export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | |
25 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | |
26 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | |
27 | ||
28 | export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'> | |
29 | export type VideoChannelIncludeActor = VideoChannelInclude & | |
30 | PickWith<VideoChannelModel, 'Actor', ActorInclude> | |
31 | ||
32 | export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'> | |
33 | export type AccountIncludeActor = AccountInclude & | |
34 | PickWith<AccountModel, 'Actor', ActorInclude> | |
35 | ||
36 | export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> & | |
37 | PickWith<VideoCommentModel, 'Account', AccountIncludeActor> & | |
38 | PickWith<VideoCommentModel, 'Video', VideoInclude> | |
39 | ||
40 | export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> & | |
41 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | |
42 | ||
43 | export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> & | |
44 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | |
45 | ||
46 | export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> & | |
47 | PickWith<VideoImportModel, 'Video', VideoInclude> | |
48 | ||
49 | export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | |
50 | PickWith<ActorModel, 'Account', AccountInclude> & | |
8424c402 C |
51 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> & |
52 | PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> | |
453e83ea | 53 | |
8424c402 | 54 | export type ActorFollowing = Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> & |
453e83ea | 55 | PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> & |
8424c402 C |
56 | PickWith<ActorModel, 'Account', AccountInclude> & |
57 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | |
453e83ea C |
58 | |
59 | export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> & | |
60 | PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> & | |
61 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | |
62 | } | |
63 | ||
0283eaac C |
64 | // ############################################################################ |
65 | ||
66 | export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | |
453e83ea C |
67 | 'VideoImport' | 'Account' | 'ActorFollow'> |
68 | ||
0283eaac C |
69 | // ############################################################################ |
70 | ||
71 | export type UserNotificationModelForApi = MUserNotification & | |
72 | Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & | |
73 | Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & | |
74 | Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | |
75 | Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | |
76 | Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & | |
77 | Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | |
78 | Use<'Account', UserNotificationIncludes.AccountIncludeActor> |