]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/moderation/abuse.ts
Add abuse messages/states notifications
[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'
94148c90 5import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl, MAccount } from '../account'
57f6896f 6import { MCommentOwner, MCommentUrl, MVideoUrl, MCommentOwnerVideo, MComment, MCommentVideo } from '../video'
d95d1559 7import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video'
594d3e48 8import { VideoCommentModel } from '@server/models/video/video-comment'
d95d1559
C
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
94148c90
C
22export type MAbuseReporter =
23 MAbuse &
24 Use<'ReporterAccount', MAccountDefault>
25
d95d1559
C
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 &
594d3e48 38 UseVideoAbuse<'Video', Omit<MVideoAccountLightBlacklistAllFiles, 'VideoFiles' | 'VideoStreamingPlaylists'>>
d95d1559
C
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 &
594d3e48 53 UseCommentAbuse<'VideoComment', MCommentOwner & PickWith<VideoCommentModel, 'Video', MVideo>>
d95d1559
C
54
55export type MCommentAbuseUrl =
56 MCommentAbuse &
57 UseCommentAbuse<'VideoComment', MCommentUrl>
58
57f6896f
C
59export type MCommentAbuseFormattable =
60 MCommentAbuse &
61 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
62
d95d1559
C
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
d95d1559
C
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
edbc9325 95export type MAbuseAdminFormattable =
d95d1559
C
96 MAbuse &
97 Use<'ReporterAccount', MAccountFormattable> &
4f32032f 98 Use<'FlaggedAccount', MAccountFormattable> &
57f6896f
C
99 Use<'VideoAbuse', MVideoAbuseFormattable> &
100 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
edbc9325
C
101
102export type MAbuseUserFormattable =
103 MAbuse &
104 Use<'FlaggedAccount', MAccountFormattable> &
105 Use<'VideoAbuse', MVideoAbuseFormattable> &
106 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
594d3e48
C
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>