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