]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/moderation/abuse.ts
Add abuse messages management in my account
[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, MAccount } 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 export type MAbuseReporter =
22 MAbuse &
23 Use<'ReporterAccount', MAccountDefault>
24
25 // ############################################################################
26
27 export type MVideoAbuseVideo =
28 MVideoAbuse &
29 UseVideoAbuse<'Video', MVideo>
30
31 export type MVideoAbuseVideoUrl =
32 MVideoAbuse &
33 UseVideoAbuse<'Video', MVideoUrl>
34
35 export type MVideoAbuseVideoFull =
36 MVideoAbuse &
37 UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles>
38
39 export type MVideoAbuseFormattable =
40 MVideoAbuse &
41 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
42 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
43
44 // ############################################################################
45
46 export type MCommentAbuseAccount =
47 MCommentAbuse &
48 UseCommentAbuse<'VideoComment', MCommentOwner>
49
50 export type MCommentAbuseAccountVideo =
51 MCommentAbuse &
52 UseCommentAbuse<'VideoComment', MCommentOwnerVideo>
53
54 export type MCommentAbuseUrl =
55 MCommentAbuse &
56 UseCommentAbuse<'VideoComment', MCommentUrl>
57
58 export type MCommentAbuseFormattable =
59 MCommentAbuse &
60 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
61
62 // ############################################################################
63
64 export type MAbuseId = Pick<AbuseModel, 'id'>
65
66 export type MAbuseVideo =
67 MAbuse &
68 Pick<AbuseModel, 'toActivityPubObject'> &
69 Use<'VideoAbuse', MVideoAbuseVideo>
70
71 export type MAbuseUrl =
72 MAbuse &
73 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
74 Use<'VideoCommentAbuse', MCommentAbuseUrl>
75
76 export type MAbuseAccountVideo =
77 MAbuse &
78 Pick<AbuseModel, 'toActivityPubObject'> &
79 Use<'VideoAbuse', MVideoAbuseVideoFull> &
80 Use<'ReporterAccount', MAccountDefault>
81
82 export type MAbuseAP =
83 MAbuse &
84 Pick<AbuseModel, 'toActivityPubObject'> &
85 Use<'ReporterAccount', MAccountUrl> &
86 Use<'FlaggedAccount', MAccountUrl> &
87 Use<'VideoAbuse', MVideoAbuseVideo> &
88 Use<'VideoCommentAbuse', MCommentAbuseAccount>
89
90 export type MAbuseFull =
91 MAbuse &
92 Pick<AbuseModel, 'toActivityPubObject'> &
93 Use<'ReporterAccount', MAccountLight> &
94 Use<'FlaggedAccount', MAccountLight> &
95 Use<'VideoAbuse', MVideoAbuseVideoFull> &
96 Use<'VideoCommentAbuse', MCommentAbuseAccountVideo>
97
98 // ############################################################################
99
100 // Format for API or AP object
101
102 export type MAbuseAdminFormattable =
103 MAbuse &
104 Use<'ReporterAccount', MAccountFormattable> &
105 Use<'FlaggedAccount', MAccountFormattable> &
106 Use<'VideoAbuse', MVideoAbuseFormattable> &
107 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
108
109 export type MAbuseUserFormattable =
110 MAbuse &
111 Use<'FlaggedAccount', MAccountFormattable> &
112 Use<'VideoAbuse', MVideoAbuseFormattable> &
113 Use<'VideoCommentAbuse', MCommentAbuseFormattable>