]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/moderation.ts
Add server plugin filter hooks for import with torrent and url (#2621)
[github/Chocobozzz/PeerTube.git] / server / lib / moderation.ts
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, VideoImportCreate } 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 import { VideoFileModel } from '@server/models/video/video-file'
11 import { PathLike } from 'fs-extra'
12 import { MUser } from '@server/typings/models'
13
14 export type AcceptResult = {
15 accepted: boolean
16 errorMessage?: string
17 }
18
19 // Can be filtered by plugins
20 function isLocalVideoAccepted (object: {
21 videoBody: VideoCreate
22 videoFile: Express.Multer.File & { duration?: number }
23 user: UserModel
24 }): AcceptResult {
25 return { accepted: true }
26 }
27
28 function isLocalVideoThreadAccepted (_object: {
29 commentBody: VideoCommentCreate
30 video: VideoModel
31 user: UserModel
32 }): AcceptResult {
33 return { accepted: true }
34 }
35
36 function isLocalVideoCommentReplyAccepted (_object: {
37 commentBody: VideoCommentCreate
38 parentComment: VideoCommentModel
39 video: VideoModel
40 user: UserModel
41 }): AcceptResult {
42 return { accepted: true }
43 }
44
45 function isRemoteVideoAccepted (_object: {
46 activity: ActivityCreate
47 videoAP: VideoTorrentObject
48 byActor: ActorModel
49 }): AcceptResult {
50 return { accepted: true }
51 }
52
53 function isRemoteVideoCommentAccepted (_object: {
54 activity: ActivityCreate
55 commentAP: VideoCommentObject
56 byActor: ActorModel
57 }): AcceptResult {
58 return { accepted: true }
59 }
60
61 function isPreImportVideoAccepted (object: {
62 videoImportBody: VideoImportCreate
63 user: MUser
64 }): AcceptResult {
65 return { accepted: true }
66 }
67
68 function isPostImportVideoAccepted (object: {
69 videoFilePath: PathLike
70 videoFile: VideoFileModel
71 user: MUser
72 }): AcceptResult {
73 return { accepted: true }
74 }
75
76 export {
77 isLocalVideoAccepted,
78 isLocalVideoThreadAccepted,
79 isRemoteVideoAccepted,
80 isRemoteVideoCommentAccepted,
81 isLocalVideoCommentReplyAccepted,
82 isPreImportVideoAccepted,
83 isPostImportVideoAccepted
84 }