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'
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>
13 // ############################################################################
15 export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'>
17 export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'>
19 export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'>
21 export type MAbuseReporter =
23 Use<'ReporterAccount', MAccountDefault>
25 // ############################################################################
27 export type MVideoAbuseVideo =
29 UseVideoAbuse<'Video', MVideo>
31 export type MVideoAbuseVideoUrl =
33 UseVideoAbuse<'Video', MVideoUrl>
35 export type MVideoAbuseVideoFull =
37 UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles>
39 export type MVideoAbuseFormattable =
41 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
42 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
44 // ############################################################################
46 export type MCommentAbuseAccount =
48 UseCommentAbuse<'VideoComment', MCommentOwner>
50 export type MCommentAbuseAccountVideo =
52 UseCommentAbuse<'VideoComment', MCommentOwnerVideo>
54 export type MCommentAbuseUrl =
56 UseCommentAbuse<'VideoComment', MCommentUrl>
58 export type MCommentAbuseFormattable =
60 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
62 // ############################################################################
64 export type MAbuseId = Pick<AbuseModel, 'id'>
66 export type MAbuseVideo =
68 Pick<AbuseModel, 'toActivityPubObject'> &
69 Use<'VideoAbuse', MVideoAbuseVideo>
71 export type MAbuseUrl =
73 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
74 Use<'VideoCommentAbuse', MCommentAbuseUrl>
76 export type MAbuseAccountVideo =
78 Pick<AbuseModel, 'toActivityPubObject'> &
79 Use<'VideoAbuse', MVideoAbuseVideoFull> &
80 Use<'ReporterAccount', MAccountDefault>
82 export type MAbuseAP =
84 Pick<AbuseModel, 'toActivityPubObject'> &
85 Use<'ReporterAccount', MAccountUrl> &
86 Use<'FlaggedAccount', MAccountUrl> &
87 Use<'VideoAbuse', MVideoAbuseVideo> &
88 Use<'VideoCommentAbuse', MCommentAbuseAccount>
90 export type MAbuseFull =
92 Pick<AbuseModel, 'toActivityPubObject'> &
93 Use<'ReporterAccount', MAccountLight> &
94 Use<'FlaggedAccount', MAccountLight> &
95 Use<'VideoAbuse', MVideoAbuseVideoFull> &
96 Use<'VideoCommentAbuse', MCommentAbuseAccountVideo>
98 // ############################################################################
100 // Format for API or AP object
102 export type MAbuseAdminFormattable =
104 Use<'ReporterAccount', MAccountFormattable> &
105 Use<'FlaggedAccount', MAccountFormattable> &
106 Use<'VideoAbuse', MVideoAbuseFormattable> &
107 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
109 export type MAbuseUserFormattable =
111 Use<'FlaggedAccount', MAccountFormattable> &
112 Use<'VideoAbuse', MVideoAbuseFormattable> &
113 Use<'VideoCommentAbuse', MCommentAbuseFormattable>