]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/moderation/abuse.ts
a0bf4b08f9fde2534821c02c20ece8e81c680fb9
[github/Chocobozzz/PeerTube.git] / server / types / models / moderation / abuse.ts
1 import { VideoAbuseModel } from '@server/models/abuse/video-abuse'
2 import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse'
3 import { PickWith } from '@shared/core-utils'
4 import { AbuseModel } from '../../../models/abuse/abuse'
5 import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account'
6 import { MCommentOwner, MCommentUrl, MVideoUrl, MCommentOwnerVideo, MComment, MCommentVideo } from '../video'
7 import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video'
8
9 type Use<K extends keyof AbuseModel, M> = PickWith<AbuseModel, K, M>
10 type UseVideoAbuse<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
11 type UseCommentAbuse<K extends keyof VideoCommentAbuseModel, M> = PickWith<VideoCommentAbuseModel, K, M>
12
13 // ############################################################################
14
15 export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'>
16
17 export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'>
18
19 export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'>
20
21 // ############################################################################
22
23 export type MVideoAbuseVideo =
24 MVideoAbuse &
25 UseVideoAbuse<'Video', MVideo>
26
27 export type MVideoAbuseVideoUrl =
28 MVideoAbuse &
29 UseVideoAbuse<'Video', MVideoUrl>
30
31 export type MVideoAbuseVideoFull =
32 MVideoAbuse &
33 UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles>
34
35 export type MVideoAbuseFormattable =
36 MVideoAbuse &
37 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
38 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
39
40 // ############################################################################
41
42 export type MCommentAbuseAccount =
43 MCommentAbuse &
44 UseCommentAbuse<'VideoComment', MCommentOwner>
45
46 export type MCommentAbuseAccountVideo =
47 MCommentAbuse &
48 UseCommentAbuse<'VideoComment', MCommentOwnerVideo>
49
50 export type MCommentAbuseUrl =
51 MCommentAbuse &
52 UseCommentAbuse<'VideoComment', MCommentUrl>
53
54 export type MCommentAbuseFormattable =
55 MCommentAbuse &
56 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
57
58 // ############################################################################
59
60 export type MAbuseId = Pick<AbuseModel, 'id'>
61
62 export type MAbuseVideo =
63 MAbuse &
64 Pick<AbuseModel, 'toActivityPubObject'> &
65 Use<'VideoAbuse', MVideoAbuseVideo>
66
67 export type MAbuseUrl =
68 MAbuse &
69 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
70 Use<'VideoCommentAbuse', MCommentAbuseUrl>
71
72 export type MAbuseAccountVideo =
73 MAbuse &
74 Pick<AbuseModel, 'toActivityPubObject'> &
75 Use<'VideoAbuse', MVideoAbuseVideoFull> &
76 Use<'ReporterAccount', MAccountDefault>
77
78 export type MAbuseAP =
79 MAbuse &
80 Pick<AbuseModel, 'toActivityPubObject'> &
81 Use<'ReporterAccount', MAccountUrl> &
82 Use<'FlaggedAccount', MAccountUrl> &
83 Use<'VideoAbuse', MVideoAbuseVideo> &
84 Use<'VideoCommentAbuse', MCommentAbuseAccount>
85
86 export type MAbuseFull =
87 MAbuse &
88 Pick<AbuseModel, 'toActivityPubObject'> &
89 Use<'ReporterAccount', MAccountLight> &
90 Use<'FlaggedAccount', MAccountLight> &
91 Use<'VideoAbuse', MVideoAbuseVideoFull> &
92 Use<'VideoCommentAbuse', MCommentAbuseAccountVideo>
93
94 // ############################################################################
95
96 // Format for API or AP object
97
98 export type MAbuseFormattable =
99 MAbuse &
100 Use<'ReporterAccount', MAccountFormattable> &
101 Use<'FlaggedAccount', MAccountFormattable> &
102 Use<'VideoAbuse', MVideoAbuseFormattable> &
103 Use<'VideoCommentAbuse', MCommentAbuseFormattable>