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 } 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 // ############################################################################
23 export type MVideoAbuseVideo =
25 UseVideoAbuse<'Video', MVideo>
27 export type MVideoAbuseVideoUrl =
29 UseVideoAbuse<'Video', MVideoUrl>
31 export type MVideoAbuseVideoFull =
33 UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles>
35 export type MVideoAbuseFormattable =
37 UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
38 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
40 // ############################################################################
42 export type MCommentAbuseAccount =
44 UseCommentAbuse<'VideoComment', MCommentOwner>
46 export type MCommentAbuseAccountVideo =
48 UseCommentAbuse<'VideoComment', MCommentOwnerVideo>
50 export type MCommentAbuseUrl =
52 UseCommentAbuse<'VideoComment', MCommentUrl>
54 export type MCommentAbuseFormattable =
56 UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>>
58 // ############################################################################
60 export type MAbuseId = Pick<AbuseModel, 'id'>
62 export type MAbuseVideo =
64 Pick<AbuseModel, 'toActivityPubObject'> &
65 Use<'VideoAbuse', MVideoAbuseVideo>
67 export type MAbuseUrl =
69 Use<'VideoAbuse', MVideoAbuseVideoUrl> &
70 Use<'VideoCommentAbuse', MCommentAbuseUrl>
72 export type MAbuseAccountVideo =
74 Pick<AbuseModel, 'toActivityPubObject'> &
75 Use<'VideoAbuse', MVideoAbuseVideoFull> &
76 Use<'ReporterAccount', MAccountDefault>
78 export type MAbuseAP =
80 Pick<AbuseModel, 'toActivityPubObject'> &
81 Use<'ReporterAccount', MAccountUrl> &
82 Use<'FlaggedAccount', MAccountUrl> &
83 Use<'VideoAbuse', MVideoAbuseVideo> &
84 Use<'VideoCommentAbuse', MCommentAbuseAccount>
86 export type MAbuseFull =
88 Pick<AbuseModel, 'toActivityPubObject'> &
89 Use<'ReporterAccount', MAccountLight> &
90 Use<'FlaggedAccount', MAccountLight> &
91 Use<'VideoAbuse', MVideoAbuseVideoFull> &
92 Use<'VideoCommentAbuse', MCommentAbuseAccountVideo>
94 // ############################################################################
96 // Format for API or AP object
98 export type MAbuseFormattable =
100 Use<'ReporterAccount', MAccountFormattable> &
101 Use<'FlaggedAccount', MAccountFormattable> &
102 Use<'VideoAbuse', MVideoAbuseFormattable> &
103 Use<'VideoCommentAbuse', MCommentAbuseFormattable>