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