]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/types/models/abuse/abuse.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / types / models / abuse / abuse.ts
... / ...
CommitLineData
1import { VideoAbuseModel } from '@server/models/abuse/video-abuse'
2import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse'
3import { VideoCommentModel } from '@server/models/video/video-comment'
4import { PickWith } from '@shared/core-utils'
5import { AbuseModel } from '../../../models/abuse/abuse'
6import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account'
7import { MComment, MCommentOwner, MCommentUrl, MCommentVideo, MVideoUrl } from '../video'
8import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video'
9
10type Use<K extends keyof AbuseModel, M> = PickWith<AbuseModel, K, M>
11type UseVideoAbuse<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
12type UseCommentAbuse<K extends keyof VideoCommentAbuseModel, M> = PickWith<VideoCommentAbuseModel, K, M>
13
14// ############################################################################
15
16export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'>
17
18export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'>
19
20export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'>
21
22export type MAbuseReporter =
23 MAbuse &
24 Use<'ReporterAccount', MAccountDefault>
25
26// ############################################################################
27
28export type MVideoAbuseVideo =
29 MVideoAbuse &
30 UseVideoAbuse<'Video', MVideo>
31
32export type MVideoAbuseVideoUrl =
33 MVideoAbuse &
34 UseVideoAbuse<'Video', MVideoUrl>
35
36export type MVideoAbuseVideoFull =
37 MVideoAbuse &
38 UseVideoAbuse<'Video', Omit<MVideoAccountLightBlacklistAllFiles, 'VideoFiles' | 'VideoStreamingPlaylists'>>
39
40export type MVideoAbuseFormattable =
41 MVideoAbuse &
42 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
43 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
44
45// ############################################################################
46
47export type MCommentAbuseAccount =
48 MCommentAbuse &
49 UseCommentAbuse<'VideoComment', MCommentOwner>
50
51export type MCommentAbuseAccountVideo =
52 MCommentAbuse &
53 UseCommentAbuse<'VideoComment', MCommentOwner & PickWith<VideoCommentModel, 'Video', MVideo>>
54
55export type MCommentAbuseUrl =
56 MCommentAbuse &
57 UseCommentAbuse<'VideoComment', MCommentUrl>
58
59export type MCommentAbuseFormattable =
60 MCommentAbuse &
61 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
62
63// ############################################################################
64
65export type MAbuseId = Pick<AbuseModel, 'id'>
66
67export type MAbuseVideo =
68 MAbuse &
69 Pick<AbuseModel, 'toActivityPubObject'> &
70 Use<'VideoAbuse', MVideoAbuseVideo>
71
72export type MAbuseUrl =
73 MAbuse &
74 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
75 Use<'VideoCommentAbuse', MCommentAbuseUrl>
76
77export type MAbuseAccountVideo =
78 MAbuse &
79 Pick<AbuseModel, 'toActivityPubObject'> &
80 Use<'VideoAbuse', MVideoAbuseVideoFull> &
81 Use<'ReporterAccount', MAccountDefault>
82
83export 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
95export type MAbuseAdminFormattable =
96 MAbuse &
97 Use<'ReporterAccount', MAccountFormattable> &
98 Use<'FlaggedAccount', MAccountFormattable> &
99 Use<'VideoAbuse', MVideoAbuseFormattable> &
100 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
101
102export type MAbuseUserFormattable =
103 MAbuse &
104 Use<'FlaggedAccount', MAccountFormattable> &
105 Use<'VideoAbuse', MVideoAbuseFormattable> &
106 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
107
108export type MAbuseAP =
109 MAbuse &
110 Pick<AbuseModel, 'toActivityPubObject'> &
111 Use<'ReporterAccount', MAccountUrl> &
112 Use<'FlaggedAccount', MAccountUrl> &
113 Use<'VideoAbuse', MVideoAbuseVideo> &
114 Use<'VideoCommentAbuse', MCommentAbuseAccount>