diff options
Diffstat (limited to 'server/lib/moderation.ts')
-rw-r--r-- | server/lib/moderation.ts | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts index c23f5b6a6..3cc92ca30 100644 --- a/server/lib/moderation.ts +++ b/server/lib/moderation.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { VideoUploadFile } from 'express' | 1 | import express, { VideoUploadFile } from 'express' |
2 | import { PathLike } from 'fs-extra' | 2 | import { PathLike } from 'fs-extra' |
3 | import { Transaction } from 'sequelize/types' | 3 | import { Transaction } from 'sequelize/types' |
4 | import { AbuseAuditView, auditLoggerFactory } from '@server/helpers/audit-logger' | 4 | import { AbuseAuditView, auditLoggerFactory } from '@server/helpers/audit-logger' |
@@ -13,18 +13,15 @@ import { | |||
13 | MAbuseFull, | 13 | MAbuseFull, |
14 | MAccountDefault, | 14 | MAccountDefault, |
15 | MAccountLight, | 15 | MAccountLight, |
16 | MComment, | ||
16 | MCommentAbuseAccountVideo, | 17 | MCommentAbuseAccountVideo, |
17 | MCommentOwnerVideo, | 18 | MCommentOwnerVideo, |
18 | MUser, | 19 | MUser, |
19 | MVideoAbuseVideoFull, | 20 | MVideoAbuseVideoFull, |
20 | MVideoAccountLightBlacklistAllFiles | 21 | MVideoAccountLightBlacklistAllFiles |
21 | } from '@server/types/models' | 22 | } from '@server/types/models' |
22 | import { ActivityCreate } from '../../shared/models/activitypub' | ||
23 | import { VideoObject } from '../../shared/models/activitypub/objects' | ||
24 | import { VideoCommentObject } from '../../shared/models/activitypub/objects/video-comment-object' | ||
25 | import { LiveVideoCreate, VideoCreate, VideoImportCreate } from '../../shared/models/videos' | 23 | import { LiveVideoCreate, VideoCreate, VideoImportCreate } from '../../shared/models/videos' |
26 | import { VideoCommentCreate } from '../../shared/models/videos/comment' | 24 | import { VideoCommentCreate } from '../../shared/models/videos/comment' |
27 | import { ActorModel } from '../models/actor/actor' | ||
28 | import { UserModel } from '../models/user/user' | 25 | import { UserModel } from '../models/user/user' |
29 | import { VideoModel } from '../models/video/video' | 26 | import { VideoModel } from '../models/video/video' |
30 | import { VideoCommentModel } from '../models/video/video-comment' | 27 | import { VideoCommentModel } from '../models/video/video-comment' |
@@ -36,7 +33,9 @@ export type AcceptResult = { | |||
36 | errorMessage?: string | 33 | errorMessage?: string |
37 | } | 34 | } |
38 | 35 | ||
39 | // Can be filtered by plugins | 36 | // --------------------------------------------------------------------------- |
37 | |||
38 | // Stub function that can be filtered by plugins | ||
40 | function isLocalVideoAccepted (object: { | 39 | function isLocalVideoAccepted (object: { |
41 | videoBody: VideoCreate | 40 | videoBody: VideoCreate |
42 | videoFile: VideoUploadFile | 41 | videoFile: VideoUploadFile |
@@ -45,6 +44,9 @@ function isLocalVideoAccepted (object: { | |||
45 | return { accepted: true } | 44 | return { accepted: true } |
46 | } | 45 | } |
47 | 46 | ||
47 | // --------------------------------------------------------------------------- | ||
48 | |||
49 | // Stub function that can be filtered by plugins | ||
48 | function isLocalLiveVideoAccepted (object: { | 50 | function isLocalLiveVideoAccepted (object: { |
49 | liveVideoBody: LiveVideoCreate | 51 | liveVideoBody: LiveVideoCreate |
50 | user: UserModel | 52 | user: UserModel |
@@ -52,7 +54,11 @@ function isLocalLiveVideoAccepted (object: { | |||
52 | return { accepted: true } | 54 | return { accepted: true } |
53 | } | 55 | } |
54 | 56 | ||
57 | // --------------------------------------------------------------------------- | ||
58 | |||
59 | // Stub function that can be filtered by plugins | ||
55 | function isLocalVideoThreadAccepted (_object: { | 60 | function isLocalVideoThreadAccepted (_object: { |
61 | req: express.Request | ||
56 | commentBody: VideoCommentCreate | 62 | commentBody: VideoCommentCreate |
57 | video: VideoModel | 63 | video: VideoModel |
58 | user: UserModel | 64 | user: UserModel |
@@ -60,7 +66,9 @@ function isLocalVideoThreadAccepted (_object: { | |||
60 | return { accepted: true } | 66 | return { accepted: true } |
61 | } | 67 | } |
62 | 68 | ||
69 | // Stub function that can be filtered by plugins | ||
63 | function isLocalVideoCommentReplyAccepted (_object: { | 70 | function isLocalVideoCommentReplyAccepted (_object: { |
71 | req: express.Request | ||
64 | commentBody: VideoCommentCreate | 72 | commentBody: VideoCommentCreate |
65 | parentComment: VideoCommentModel | 73 | parentComment: VideoCommentModel |
66 | video: VideoModel | 74 | video: VideoModel |
@@ -69,22 +77,18 @@ function isLocalVideoCommentReplyAccepted (_object: { | |||
69 | return { accepted: true } | 77 | return { accepted: true } |
70 | } | 78 | } |
71 | 79 | ||
72 | function isRemoteVideoAccepted (_object: { | 80 | // --------------------------------------------------------------------------- |
73 | activity: ActivityCreate | ||
74 | videoAP: VideoObject | ||
75 | byActor: ActorModel | ||
76 | }): AcceptResult { | ||
77 | return { accepted: true } | ||
78 | } | ||
79 | 81 | ||
82 | // Stub function that can be filtered by plugins | ||
80 | function isRemoteVideoCommentAccepted (_object: { | 83 | function isRemoteVideoCommentAccepted (_object: { |
81 | activity: ActivityCreate | 84 | comment: MComment |
82 | commentAP: VideoCommentObject | ||
83 | byActor: ActorModel | ||
84 | }): AcceptResult { | 85 | }): AcceptResult { |
85 | return { accepted: true } | 86 | return { accepted: true } |
86 | } | 87 | } |
87 | 88 | ||
89 | // --------------------------------------------------------------------------- | ||
90 | |||
91 | // Stub function that can be filtered by plugins | ||
88 | function isPreImportVideoAccepted (object: { | 92 | function isPreImportVideoAccepted (object: { |
89 | videoImportBody: VideoImportCreate | 93 | videoImportBody: VideoImportCreate |
90 | user: MUser | 94 | user: MUser |
@@ -92,6 +96,7 @@ function isPreImportVideoAccepted (object: { | |||
92 | return { accepted: true } | 96 | return { accepted: true } |
93 | } | 97 | } |
94 | 98 | ||
99 | // Stub function that can be filtered by plugins | ||
95 | function isPostImportVideoAccepted (object: { | 100 | function isPostImportVideoAccepted (object: { |
96 | videoFilePath: PathLike | 101 | videoFilePath: PathLike |
97 | videoFile: VideoFileModel | 102 | videoFile: VideoFileModel |
@@ -100,6 +105,8 @@ function isPostImportVideoAccepted (object: { | |||
100 | return { accepted: true } | 105 | return { accepted: true } |
101 | } | 106 | } |
102 | 107 | ||
108 | // --------------------------------------------------------------------------- | ||
109 | |||
103 | async function createVideoAbuse (options: { | 110 | async function createVideoAbuse (options: { |
104 | baseAbuse: FilteredModelAttributes<AbuseModel> | 111 | baseAbuse: FilteredModelAttributes<AbuseModel> |
105 | videoInstance: MVideoAccountLightBlacklistAllFiles | 112 | videoInstance: MVideoAccountLightBlacklistAllFiles |
@@ -189,12 +196,13 @@ function createAccountAbuse (options: { | |||
189 | }) | 196 | }) |
190 | } | 197 | } |
191 | 198 | ||
199 | // --------------------------------------------------------------------------- | ||
200 | |||
192 | export { | 201 | export { |
193 | isLocalLiveVideoAccepted, | 202 | isLocalLiveVideoAccepted, |
194 | 203 | ||
195 | isLocalVideoAccepted, | 204 | isLocalVideoAccepted, |
196 | isLocalVideoThreadAccepted, | 205 | isLocalVideoThreadAccepted, |
197 | isRemoteVideoAccepted, | ||
198 | isRemoteVideoCommentAccepted, | 206 | isRemoteVideoCommentAccepted, |
199 | isLocalVideoCommentReplyAccepted, | 207 | isLocalVideoCommentReplyAccepted, |
200 | isPreImportVideoAccepted, | 208 | isPreImportVideoAccepted, |