diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-11 11:15:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-11 11:32:31 +0200 |
commit | 7d9ba5c08999c6482f0bc5e0c09c6f55b7724090 (patch) | |
tree | 5f4ea1f06dcb781c9e61062522b53a28a401111f /server/types/models/abuse | |
parent | c07902b9083ab5756436cd020bed5bdfa51028bf (diff) | |
download | PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.gz PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.zst PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.zip |
Cleanup models directory organization
Diffstat (limited to 'server/types/models/abuse')
-rw-r--r-- | server/types/models/abuse/abuse-message.ts | 20 | ||||
-rw-r--r-- | server/types/models/abuse/abuse.ts | 114 | ||||
-rw-r--r-- | server/types/models/abuse/index.ts | 2 |
3 files changed, 136 insertions, 0 deletions
diff --git a/server/types/models/abuse/abuse-message.ts b/server/types/models/abuse/abuse-message.ts new file mode 100644 index 000000000..565eca706 --- /dev/null +++ b/server/types/models/abuse/abuse-message.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' | ||
2 | import { PickWith } from '@shared/core-utils' | ||
3 | import { AbuseModel } from '../../../models/abuse/abuse' | ||
4 | import { MAccountFormattable } from '../account' | ||
5 | |||
6 | type Use<K extends keyof AbuseMessageModel, M> = PickWith<AbuseMessageModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MAbuseMessage = Omit<AbuseMessageModel, 'Account' | 'Abuse' | 'toFormattedJSON'> | ||
11 | |||
12 | export type MAbuseMessageId = Pick<AbuseModel, 'id'> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | // Format for API | ||
17 | |||
18 | export type MAbuseMessageFormattable = | ||
19 | MAbuseMessage & | ||
20 | Use<'Account', MAccountFormattable> | ||
diff --git a/server/types/models/abuse/abuse.ts b/server/types/models/abuse/abuse.ts new file mode 100644 index 000000000..6fd83684c --- /dev/null +++ b/server/types/models/abuse/abuse.ts | |||
@@ -0,0 +1,114 @@ | |||
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' | ||
9 | |||
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> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MAbuse = Omit<AbuseModel, 'VideoCommentAbuse' | 'VideoAbuse' | 'ReporterAccount' | 'FlaggedAccount' | 'toActivityPubObject'> | ||
17 | |||
18 | export type MVideoAbuse = Omit<VideoAbuseModel, 'Abuse' | 'Video'> | ||
19 | |||
20 | export type MCommentAbuse = Omit<VideoCommentAbuseModel, 'Abuse' | 'VideoComment'> | ||
21 | |||
22 | export type MAbuseReporter = | ||
23 | MAbuse & | ||
24 | Use<'ReporterAccount', MAccountDefault> | ||
25 | |||
26 | // ############################################################################ | ||
27 | |||
28 | export type MVideoAbuseVideo = | ||
29 | MVideoAbuse & | ||
30 | UseVideoAbuse<'Video', MVideo> | ||
31 | |||
32 | export type MVideoAbuseVideoUrl = | ||
33 | MVideoAbuse & | ||
34 | UseVideoAbuse<'Video', MVideoUrl> | ||
35 | |||
36 | export type MVideoAbuseVideoFull = | ||
37 | MVideoAbuse & | ||
38 | UseVideoAbuse<'Video', Omit<MVideoAccountLightBlacklistAllFiles, 'VideoFiles' | 'VideoStreamingPlaylists'>> | ||
39 | |||
40 | export type MVideoAbuseFormattable = | ||
41 | MVideoAbuse & | ||
42 | UseVideoAbuse<'Video', Pick<MVideoAccountLightBlacklistAllFiles, | ||
43 | 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>> | ||
44 | |||
45 | // ############################################################################ | ||
46 | |||
47 | export type MCommentAbuseAccount = | ||
48 | MCommentAbuse & | ||
49 | UseCommentAbuse<'VideoComment', MCommentOwner> | ||
50 | |||
51 | export type MCommentAbuseAccountVideo = | ||
52 | MCommentAbuse & | ||
53 | UseCommentAbuse<'VideoComment', MCommentOwner & PickWith<VideoCommentModel, 'Video', MVideo>> | ||
54 | |||
55 | export type MCommentAbuseUrl = | ||
56 | MCommentAbuse & | ||
57 | UseCommentAbuse<'VideoComment', MCommentUrl> | ||
58 | |||
59 | export type MCommentAbuseFormattable = | ||
60 | MCommentAbuse & | ||
61 | UseCommentAbuse<'VideoComment', MComment & PickWith<MCommentVideo, 'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>> | ||
62 | |||
63 | // ############################################################################ | ||
64 | |||
65 | export type MAbuseId = Pick<AbuseModel, 'id'> | ||
66 | |||
67 | export type MAbuseVideo = | ||
68 | MAbuse & | ||
69 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
70 | Use<'VideoAbuse', MVideoAbuseVideo> | ||
71 | |||
72 | export type MAbuseUrl = | ||
73 | MAbuse & | ||
74 | Use<'VideoAbuse', MVideoAbuseVideoUrl> & | ||
75 | Use<'VideoCommentAbuse', MCommentAbuseUrl> | ||
76 | |||
77 | export type MAbuseAccountVideo = | ||
78 | MAbuse & | ||
79 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
80 | Use<'VideoAbuse', MVideoAbuseVideoFull> & | ||
81 | Use<'ReporterAccount', MAccountDefault> | ||
82 | |||
83 | export 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 | |||
95 | export type MAbuseAdminFormattable = | ||
96 | MAbuse & | ||
97 | Use<'ReporterAccount', MAccountFormattable> & | ||
98 | Use<'FlaggedAccount', MAccountFormattable> & | ||
99 | Use<'VideoAbuse', MVideoAbuseFormattable> & | ||
100 | Use<'VideoCommentAbuse', MCommentAbuseFormattable> | ||
101 | |||
102 | export type MAbuseUserFormattable = | ||
103 | MAbuse & | ||
104 | Use<'FlaggedAccount', MAccountFormattable> & | ||
105 | Use<'VideoAbuse', MVideoAbuseFormattable> & | ||
106 | Use<'VideoCommentAbuse', MCommentAbuseFormattable> | ||
107 | |||
108 | export type MAbuseAP = | ||
109 | MAbuse & | ||
110 | Pick<AbuseModel, 'toActivityPubObject'> & | ||
111 | Use<'ReporterAccount', MAccountUrl> & | ||
112 | Use<'FlaggedAccount', MAccountUrl> & | ||
113 | Use<'VideoAbuse', MVideoAbuseVideo> & | ||
114 | Use<'VideoCommentAbuse', MCommentAbuseAccount> | ||
diff --git a/server/types/models/abuse/index.ts b/server/types/models/abuse/index.ts new file mode 100644 index 000000000..1ed91b249 --- /dev/null +++ b/server/types/models/abuse/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './abuse' | ||
2 | export * from './abuse-message' | ||