diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-18 14:28:37 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | b4055e1c23eeefb0c8a85a77f312b2827d98f483 (patch) | |
tree | 51b6b04c1ad10897047817d2eaaa037d1331fa6a /server/lib/moderation.ts | |
parent | 66e001c848c009412c65cbce41be344d8985fd83 (diff) | |
download | PeerTube-b4055e1c23eeefb0c8a85a77f312b2827d98f483.tar.gz PeerTube-b4055e1c23eeefb0c8a85a77f312b2827d98f483.tar.zst PeerTube-b4055e1c23eeefb0c8a85a77f312b2827d98f483.zip |
Add server hooks
Diffstat (limited to 'server/lib/moderation.ts')
-rw-r--r-- | server/lib/moderation.ts | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts new file mode 100644 index 000000000..b609f4585 --- /dev/null +++ b/server/lib/moderation.ts | |||
@@ -0,0 +1,64 @@ | |||
1 | import { VideoModel } from '../models/video/video' | ||
2 | import { VideoCommentModel } from '../models/video/video-comment' | ||
3 | import { VideoCommentCreate } from '../../shared/models/videos/video-comment.model' | ||
4 | import { VideoCreate } from '../../shared/models/videos' | ||
5 | import { UserModel } from '../models/account/user' | ||
6 | import { VideoTorrentObject } from '../../shared/models/activitypub/objects' | ||
7 | import { ActivityCreate } from '../../shared/models/activitypub' | ||
8 | import { ActorModel } from '../models/activitypub/actor' | ||
9 | import { VideoCommentObject } from '../../shared/models/activitypub/objects/video-comment-object' | ||
10 | |||
11 | export type AcceptResult = { | ||
12 | accepted: boolean | ||
13 | errorMessage?: string | ||
14 | } | ||
15 | |||
16 | // Can be filtered by plugins | ||
17 | function isLocalVideoAccepted (object: { | ||
18 | videoBody: VideoCreate, | ||
19 | videoFile: Express.Multer.File & { duration?: number }, | ||
20 | user: UserModel | ||
21 | }): AcceptResult { | ||
22 | return { accepted: true } | ||
23 | } | ||
24 | |||
25 | function isLocalVideoThreadAccepted (_object: { | ||
26 | commentBody: VideoCommentCreate, | ||
27 | video: VideoModel, | ||
28 | user: UserModel | ||
29 | }): AcceptResult { | ||
30 | return { accepted: true } | ||
31 | } | ||
32 | |||
33 | function isLocalVideoCommentReplyAccepted (_object: { | ||
34 | commentBody: VideoCommentCreate, | ||
35 | parentComment: VideoCommentModel, | ||
36 | video: VideoModel, | ||
37 | user: UserModel | ||
38 | }): AcceptResult { | ||
39 | return { accepted: true } | ||
40 | } | ||
41 | |||
42 | function isRemoteVideoAccepted (_object: { | ||
43 | activity: ActivityCreate, | ||
44 | videoAP: VideoTorrentObject, | ||
45 | byActor: ActorModel | ||
46 | }): AcceptResult { | ||
47 | return { accepted: true } | ||
48 | } | ||
49 | |||
50 | function isRemoteVideoCommentAccepted (_object: { | ||
51 | activity: ActivityCreate, | ||
52 | commentAP: VideoCommentObject, | ||
53 | byActor: ActorModel | ||
54 | }): AcceptResult { | ||
55 | return { accepted: true } | ||
56 | } | ||
57 | |||
58 | export { | ||
59 | isLocalVideoAccepted, | ||
60 | isLocalVideoThreadAccepted, | ||
61 | isRemoteVideoAccepted, | ||
62 | isRemoteVideoCommentAccepted, | ||
63 | isLocalVideoCommentReplyAccepted | ||
64 | } | ||