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