diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-01 16:05:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | d95d15598847c7f020aa056e7e6e0c02d2bbf732 (patch) | |
tree | a8a593f1269688caf9e5f99559996f346290fec5 /server/types/models/moderation | |
parent | 72493e44e9b455a04c4f093ed6c6ffa300b98d8b (diff) | |
download | PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.gz PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.zst PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.zip |
Use 3 tables to represent abuses
Diffstat (limited to 'server/types/models/moderation')
-rw-r--r-- | server/types/models/moderation/abuse.ts | 97 | ||||
-rw-r--r-- | server/types/models/moderation/index.ts | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/server/types/models/moderation/abuse.ts b/server/types/models/moderation/abuse.ts new file mode 100644 index 000000000..abbc93d6f --- /dev/null +++ b/server/types/models/moderation/abuse.ts | |||
@@ -0,0 +1,97 @@ | |||
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 } from '../video' | ||
7 | import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video' | ||
8 | |||
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> | ||
12 | |||
13 | // ############################################################################ | ||
14 | |||
15 | export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'> | ||
16 | |||
17 | export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'> | ||
18 | |||
19 | export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'> | ||
20 | |||
21 | // ############################################################################ | ||
22 | |||
23 | export type MVideoAbuseVideo = | ||
24 | MVideoAbuse & | ||
25 | UseVideoAbuse<'Video', MVideo> | ||
26 | |||
27 | export type MVideoAbuseVideoUrl = | ||
28 | MVideoAbuse & | ||
29 | UseVideoAbuse<'Video', MVideoUrl> | ||
30 | |||
31 | export type MVideoAbuseVideoFull = | ||
32 | MVideoAbuse & | ||
33 | UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles> | ||
34 | |||
35 | export type MVideoAbuseFormattable = | ||
36 | MVideoAbuse & | ||
37 | UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles, | ||
38 | 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>> | ||
39 | |||
40 | // ############################################################################ | ||
41 | |||
42 | export type MCommentAbuseAccount = | ||
43 | MCommentAbuse & | ||
44 | UseCommentAbuse<'VideoComment', MCommentOwner> | ||
45 | |||
46 | export type MCommentAbuseAccountVideo = | ||
47 | MCommentAbuse & | ||
48 | UseCommentAbuse<'VideoComment', MCommentOwnerVideo> | ||
49 | |||
50 | export type MCommentAbuseUrl = | ||
51 | MCommentAbuse & | ||
52 | UseCommentAbuse<'VideoComment', MCommentUrl> | ||
53 | |||
54 | // ############################################################################ | ||
55 | |||
56 | export type MAbuseId = Pick<AbuseModel, 'id'> | ||
57 | |||
58 | export type MAbuseVideo = | ||
59 | MAbuse & | ||
60 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
61 | Use<'VideoAbuse', MVideoAbuseVideo> | ||
62 | |||
63 | export type MAbuseUrl = | ||
64 | MAbuse & | ||
65 | Use<'VideoAbuse', MVideoAbuseVideoUrl> & | ||
66 | Use<'VideoCommentAbuse', MCommentAbuseUrl> | ||
67 | |||
68 | export type MAbuseAccountVideo = | ||
69 | MAbuse & | ||
70 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
71 | Use<'VideoAbuse', MVideoAbuseVideoFull> & | ||
72 | Use<'ReporterAccount', MAccountDefault> | ||
73 | |||
74 | export type MAbuseAP = | ||
75 | MAbuse & | ||
76 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
77 | Use<'ReporterAccount', MAccountUrl> & | ||
78 | Use<'FlaggedAccount', MAccountUrl> & | ||
79 | Use<'VideoAbuse', MVideoAbuseVideo> & | ||
80 | Use<'VideoCommentAbuse', MCommentAbuseAccount> | ||
81 | |||
82 | export type MAbuseFull = | ||
83 | MAbuse & | ||
84 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
85 | Use<'ReporterAccount', MAccountLight> & | ||
86 | Use<'FlaggedAccount', MAccountLight> & | ||
87 | Use<'VideoAbuse', MVideoAbuseVideoFull> & | ||
88 | Use<'VideoCommentAbuse', MCommentAbuseAccountVideo> | ||
89 | |||
90 | // ############################################################################ | ||
91 | |||
92 | // Format for API or AP object | ||
93 | |||
94 | export type MAbuseFormattable = | ||
95 | MAbuse & | ||
96 | Use<'ReporterAccount', MAccountFormattable> & | ||
97 | Use<'VideoAbuse', MVideoAbuseFormattable> | ||
diff --git a/server/types/models/moderation/index.ts b/server/types/models/moderation/index.ts new file mode 100644 index 000000000..8bea1708f --- /dev/null +++ b/server/types/models/moderation/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './abuse' | |||