aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-blacklist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-blacklist.ts')
-rw-r--r--server/lib/video-blacklist.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts
new file mode 100644
index 000000000..dc4e0aed9
--- /dev/null
+++ b/server/lib/video-blacklist.ts
@@ -0,0 +1,31 @@
1import * as sequelize from 'sequelize'
2import { CONFIG } from '../initializers/constants'
3import { VideoBlacklistType, UserRight } from '../../shared/models'
4import { VideoBlacklistModel } from '../models/video/video-blacklist'
5import { UserModel } from '../models/account/user'
6import { VideoModel } from '../models/video/video'
7import { logger } from '../helpers/logger'
8
9async function autoBlacklistVideoIfNeeded (video: VideoModel, user: UserModel, transaction: sequelize.Transaction) {
10 if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED) return false
11
12 if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) return false
13
14 const sequelizeOptions = { transaction }
15 const videoBlacklistToCreate = {
16 videoId: video.id,
17 unfederated: true,
18 reason: 'Auto-blacklisted. Moderator review required.',
19 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
20 }
21 await VideoBlacklistModel.create(videoBlacklistToCreate, sequelizeOptions)
22 logger.info('Video %s auto-blacklisted.', video.uuid)
23
24 return true
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 autoBlacklistVideoIfNeeded
31}