diff options
Diffstat (limited to 'server/types/models/abuse/abuse.ts')
-rw-r--r-- | server/types/models/abuse/abuse.ts | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/server/types/models/abuse/abuse.ts b/server/types/models/abuse/abuse.ts new file mode 100644 index 000000000..6fd83684c --- /dev/null +++ b/server/types/models/abuse/abuse.ts | |||
@@ -0,0 +1,114 @@ | |||
1 | import { VideoAbuseModel } from '@server/models/abuse/video-abuse' | ||
2 | import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' | ||
3 | import { VideoCommentModel } from '@server/models/video/video-comment' | ||
4 | import { PickWith } from '@shared/core-utils' | ||
5 | import { AbuseModel } from '../../../models/abuse/abuse' | ||
6 | import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account' | ||
7 | import { MComment, MCommentOwner, MCommentUrl, MCommentVideo, MVideoUrl } from '../video' | ||
8 | import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video' | ||
9 | |||
10 | type Use<K extends keyof AbuseModel, M> = PickWith<AbuseModel, K, M> | ||
11 | type UseVideoAbuse<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> | ||
12 | type UseCommentAbuse<K extends keyof VideoCommentAbuseModel, M> = PickWith<VideoCommentAbuseModel, K, M> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'> | ||
17 | |||
18 | export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'> | ||
19 | |||
20 | export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'> | ||
21 | |||
22 | export type MAbuseReporter = | ||
23 | MAbuse & | ||
24 | Use<'ReporterAccount', MAccountDefault> | ||
25 | |||
26 | // ############################################################################ | ||
27 | |||
28 | export type MVideoAbuseVideo = | ||
29 | MVideoAbuse & | ||
30 | UseVideoAbuse<'Video', MVideo> | ||
31 | |||
32 | export type MVideoAbuseVideoUrl = | ||
33 | MVideoAbuse & | ||
34 | UseVideoAbuse<'Video', MVideoUrl> | ||
35 | |||
36 | export type MVideoAbuseVideoFull = | ||
37 | MVideoAbuse & | ||
38 | UseVideoAbuse<'Video', Omit<MVideoAccountLightBlacklistAllFiles, 'VideoFiles' | 'VideoStreamingPlaylists'>> | ||
39 | |||
40 | export type MVideoAbuseFormattable = | ||
41 | MVideoAbuse & | ||
42 | UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles, | ||
43 | 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>> | ||
44 | |||
45 | // ############################################################################ | ||
46 | |||
47 | export type MCommentAbuseAccount = | ||
48 | MCommentAbuse & | ||
49 | UseCommentAbuse<'VideoComment', MCommentOwner> | ||
50 | |||
51 | export type MCommentAbuseAccountVideo = | ||
52 | MCommentAbuse & | ||
53 | UseCommentAbuse<'VideoComment', MCommentOwner & PickWith<VideoCommentModel, 'Video', MVideo>> | ||
54 | |||
55 | export type MCommentAbuseUrl = | ||
56 | MCommentAbuse & | ||
57 | UseCommentAbuse<'VideoComment', MCommentUrl> | ||
58 | |||
59 | export type MCommentAbuseFormattable = | ||
60 | MCommentAbuse & | ||
61 | UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>> | ||
62 | |||
63 | // ############################################################################ | ||
64 | |||
65 | export type MAbuseId = Pick<AbuseModel, 'id'> | ||
66 | |||
67 | export type MAbuseVideo = | ||
68 | MAbuse & | ||
69 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
70 | Use<'VideoAbuse', MVideoAbuseVideo> | ||
71 | |||
72 | export type MAbuseUrl = | ||
73 | MAbuse & | ||
74 | Use<'VideoAbuse', MVideoAbuseVideoUrl> & | ||
75 | Use<'VideoCommentAbuse', MCommentAbuseUrl> | ||
76 | |||
77 | export type MAbuseAccountVideo = | ||
78 | MAbuse & | ||
79 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
80 | Use<'VideoAbuse', MVideoAbuseVideoFull> & | ||
81 | Use<'ReporterAccount', MAccountDefault> | ||
82 | |||
83 | export type MAbuseFull = | ||
84 | MAbuse & | ||
85 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
86 | Use<'ReporterAccount', MAccountLight> & | ||
87 | Use<'FlaggedAccount', MAccountLight> & | ||
88 | Use<'VideoAbuse', MVideoAbuseVideoFull> & | ||
89 | Use<'VideoCommentAbuse', MCommentAbuseAccountVideo> | ||
90 | |||
91 | // ############################################################################ | ||
92 | |||
93 | // Format for API or AP object | ||
94 | |||
95 | export type MAbuseAdminFormattable = | ||
96 | MAbuse & | ||
97 | Use<'ReporterAccount', MAccountFormattable> & | ||
98 | Use<'FlaggedAccount', MAccountFormattable> & | ||
99 | Use<'VideoAbuse', MVideoAbuseFormattable> & | ||
100 | Use<'VideoCommentAbuse', MCommentAbuseFormattable> | ||
101 | |||
102 | export type MAbuseUserFormattable = | ||
103 | MAbuse & | ||
104 | Use<'FlaggedAccount', MAccountFormattable> & | ||
105 | Use<'VideoAbuse', MVideoAbuseFormattable> & | ||
106 | Use<'VideoCommentAbuse', MCommentAbuseFormattable> | ||
107 | |||
108 | export type MAbuseAP = | ||
109 | MAbuse & | ||
110 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
111 | Use<'ReporterAccount', MAccountUrl> & | ||
112 | Use<'FlaggedAccount', MAccountUrl> & | ||
113 | Use<'VideoAbuse', MVideoAbuseVideo> & | ||
114 | Use<'VideoCommentAbuse', MCommentAbuseAccount> | ||