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'
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>
14 // ############################################################################
16 export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'>
18 export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'>
20 export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'>
22 export type MAbuseReporter =
24 Use<'ReporterAccount', MAccountDefault>
26 // ############################################################################
28 export type MVideoAbuseVideo =
30 UseVideoAbuse<'Video', MVideo>
32 export type MVideoAbuseVideoUrl =
34 UseVideoAbuse<'Video', MVideoUrl>
36 export type MVideoAbuseVideoFull =
38 UseVideoAbuse<'Video', Omit<MVideoAccountLightBlacklistAllFiles, 'VideoFiles' | 'VideoStreamingPlaylists'>>
40 export type MVideoAbuseFormattable =
42 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
43 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
45 // ############################################################################
47 export type MCommentAbuseAccount =
49 UseCommentAbuse<'VideoComment', MCommentOwner>
51 export type MCommentAbuseAccountVideo =
53 UseCommentAbuse<'VideoComment', MCommentOwner & PickWith<VideoCommentModel, 'Video', MVideo>>
55 export type MCommentAbuseUrl =
57 UseCommentAbuse<'VideoComment', MCommentUrl>
59 export type MCommentAbuseFormattable =
61 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
63 // ############################################################################
65 export type MAbuseId = Pick<AbuseModel, 'id'>
67 export type MAbuseVideo =
69 Pick<AbuseModel, 'toActivityPubObject'> &
70 Use<'VideoAbuse', MVideoAbuseVideo>
72 export type MAbuseUrl =
74 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
75 Use<'VideoCommentAbuse', MCommentAbuseUrl>
77 export type MAbuseAccountVideo =
79 Pick<AbuseModel, 'toActivityPubObject'> &
80 Use<'VideoAbuse', MVideoAbuseVideoFull> &
81 Use<'ReporterAccount', MAccountDefault>
83 export type MAbuseFull =
85 Pick<AbuseModel, 'toActivityPubObject'> &
86 Use<'ReporterAccount', MAccountLight> &
87 Use<'FlaggedAccount', MAccountLight> &
88 Use<'VideoAbuse', MVideoAbuseVideoFull> &
89 Use<'VideoCommentAbuse', MCommentAbuseAccountVideo>
91 // ############################################################################
93 // Format for API or AP object
95 export type MAbuseAdminFormattable =
97 Use<'ReporterAccount', MAccountFormattable> &
98 Use<'FlaggedAccount', MAccountFormattable> &
99 Use<'VideoAbuse', MVideoAbuseFormattable> &
100 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
102 export type MAbuseUserFormattable =
104 Use<'FlaggedAccount', MAccountFormattable> &
105 Use<'VideoAbuse', MVideoAbuseFormattable> &
106 Use<'VideoCommentAbuse', MCommentAbuseFormattable>
108 export type MAbuseAP =
110 Pick<AbuseModel, 'toActivityPubObject'> &
111 Use<'ReporterAccount', MAccountUrl> &
112 Use<'FlaggedAccount', MAccountUrl> &
113 Use<'VideoAbuse', MVideoAbuseVideo> &
114 Use<'VideoCommentAbuse', MCommentAbuseAccount>