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