aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-07 14:58:24 +0200
committerChocobozzz <me@florianbigard.com>2020-05-07 15:07:01 +0200
commit80fdaf064562aff968f4c9cea1cf220bc12a70da (patch)
treea0ec49f433b828660f741b394dfd87056cd2c6ef /server/lib
parent3cc665f48fd233d09f778d7e887488dde6f03ef6 (diff)
downloadPeerTube-80fdaf064562aff968f4c9cea1cf220bc12a70da.tar.gz
PeerTube-80fdaf064562aff968f4c9cea1cf220bc12a70da.tar.zst
PeerTube-80fdaf064562aff968f4c9cea1cf220bc12a70da.zip
Add moderation helpers to plugins
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-announce.ts2
-rw-r--r--server/lib/activitypub/process/process-create.ts2
-rw-r--r--server/lib/activitypub/process/process-delete.ts2
-rw-r--r--server/lib/activitypub/process/process-dislike.ts2
-rw-r--r--server/lib/activitypub/process/process-flag.ts2
-rw-r--r--server/lib/activitypub/process/process-follow.ts2
-rw-r--r--server/lib/activitypub/process/process-like.ts2
-rw-r--r--server/lib/activitypub/process/process-reject.ts2
-rw-r--r--server/lib/activitypub/process/process-undo.ts2
-rw-r--r--server/lib/activitypub/process/process-update.ts2
-rw-r--r--server/lib/blocklist.ts4
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts2
-rw-r--r--server/lib/plugins/plugin-helpers.ts78
-rw-r--r--server/lib/video-blacklist.ts80
14 files changed, 159 insertions, 25 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index 7e22125d5..26427aaa1 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -1,6 +1,6 @@
1import { ActivityAnnounce } from '../../../../shared/models/activitypub' 1import { ActivityAnnounce } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { sequelizeTypescript } from '../../../initializers' 3import { sequelizeTypescript } from '../../../initializers/database'
4import { VideoShareModel } from '../../../models/video/video-share' 4import { VideoShareModel } from '../../../models/video/video-share'
5import { forwardVideoRelatedActivity } from '../send/utils' 5import { forwardVideoRelatedActivity } from '../send/utils'
6import { getOrCreateVideoAndAccountAndChannel } from '../videos' 6import { getOrCreateVideoAndAccountAndChannel } from '../videos'
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index d375e29e3..566bf6992 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -2,7 +2,7 @@ import { ActivityCreate, CacheFileObject, VideoTorrentObject } from '../../../..
2import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object' 2import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers/database'
6import { resolveThread } from '../video-comments' 6import { resolveThread } from '../video-comments'
7import { getOrCreateVideoAndAccountAndChannel } from '../videos' 7import { getOrCreateVideoAndAccountAndChannel } from '../videos'
8import { forwardVideoRelatedActivity } from '../send/utils' 8import { forwardVideoRelatedActivity } from '../send/utils'
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index e76132f91..7c8dc83e8 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -1,7 +1,7 @@
1import { ActivityDelete } from '../../../../shared/models/activitypub' 1import { ActivityDelete } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers/database'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
7import { VideoCommentModel } from '../../../models/video/video-comment' 7import { VideoCommentModel } from '../../../models/video/video-comment'
diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/lib/activitypub/process/process-dislike.ts
index debd8a67c..fcdd0b86e 100644
--- a/server/lib/activitypub/process/process-dislike.ts
+++ b/server/lib/activitypub/process/process-dislike.ts
@@ -1,7 +1,7 @@
1import { ActivityCreate, ActivityDislike } from '../../../../shared' 1import { ActivityCreate, ActivityDislike } from '../../../../shared'
2import { DislikeObject } from '../../../../shared/models/activitypub/objects' 2import { DislikeObject } from '../../../../shared/models/activitypub/objects'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers/database'
5import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 5import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
6import { getOrCreateVideoAndAccountAndChannel } from '../videos' 6import { getOrCreateVideoAndAccountAndChannel } from '../videos'
7import { forwardVideoRelatedActivity } from '../send/utils' 7import { forwardVideoRelatedActivity } from '../send/utils'
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts
index e6e9084de..9a488a473 100644
--- a/server/lib/activitypub/process/process-flag.ts
+++ b/server/lib/activitypub/process/process-flag.ts
@@ -2,7 +2,7 @@ import { ActivityCreate, ActivityFlag, VideoAbuseState } from '../../../../share
2import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects' 2import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers/database'
6import { VideoAbuseModel } from '../../../models/video/video-abuse' 6import { VideoAbuseModel } from '../../../models/video/video-abuse'
7import { getOrCreateVideoAndAccountAndChannel } from '../videos' 7import { getOrCreateVideoAndAccountAndChannel } from '../videos'
8import { Notifier } from '../../notifier' 8import { Notifier } from '../../notifier'
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index 8f7828e41..950d421dd 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -1,7 +1,7 @@
1import { ActivityFollow } from '../../../../shared/models/activitypub' 1import { ActivityFollow } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers/database'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
7import { sendAccept, sendReject } from '../send' 7import { sendAccept, sendReject } from '../send'
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index 62be0de42..fba3c76a4 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -1,6 +1,6 @@
1import { ActivityLike } from '../../../../shared/models/activitypub' 1import { ActivityLike } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { sequelizeTypescript } from '../../../initializers' 3import { sequelizeTypescript } from '../../../initializers/database'
4import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 4import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
5import { forwardVideoRelatedActivity } from '../send/utils' 5import { forwardVideoRelatedActivity } from '../send/utils'
6import { getOrCreateVideoAndAccountAndChannel } from '../videos' 6import { getOrCreateVideoAndAccountAndChannel } from '../videos'
diff --git a/server/lib/activitypub/process/process-reject.ts b/server/lib/activitypub/process/process-reject.ts
index 00e9afa10..9804436a2 100644
--- a/server/lib/activitypub/process/process-reject.ts
+++ b/server/lib/activitypub/process/process-reject.ts
@@ -1,5 +1,5 @@
1import { ActivityReject } from '../../../../shared/models/activitypub/activity' 1import { ActivityReject } from '../../../../shared/models/activitypub/activity'
2import { sequelizeTypescript } from '../../../initializers' 2import { sequelizeTypescript } from '../../../initializers/database'
3import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
4import { APProcessorOptions } from '../../../typings/activitypub-processor.model' 4import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
5import { MActor } from '../../../typings/models' 5import { MActor } from '../../../typings/models'
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index 10643b2e9..9ef6a8a97 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -2,7 +2,7 @@ import { ActivityAnnounce, ActivityFollow, ActivityLike, ActivityUndo, CacheFile
2import { DislikeObject } from '../../../../shared/models/activitypub/objects' 2import { DislikeObject } from '../../../../shared/models/activitypub/objects'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers/database'
6import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 6import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
7import { ActorModel } from '../../../models/activitypub/actor' 7import { ActorModel } from '../../../models/activitypub/actor'
8import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 8import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 9579512b7..98ab0f83d 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -2,7 +2,7 @@ import { ActivityUpdate, CacheFileObject, VideoTorrentObject } from '../../../..
2import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' 2import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor'
3import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils' 3import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers/database'
6import { AccountModel } from '../../../models/account/account' 6import { AccountModel } from '../../../models/account/account'
7import { ActorModel } from '../../../models/activitypub/actor' 7import { ActorModel } from '../../../models/activitypub/actor'
8import { VideoChannelModel } from '../../../models/video/video-channel' 8import { VideoChannelModel } from '../../../models/video/video-channel'
diff --git a/server/lib/blocklist.ts b/server/lib/blocklist.ts
index 28c69b46e..842eecb5b 100644
--- a/server/lib/blocklist.ts
+++ b/server/lib/blocklist.ts
@@ -1,7 +1,7 @@
1import { sequelizeTypescript } from '../initializers' 1import { sequelizeTypescript } from '@server/initializers/database'
2import { MAccountBlocklist, MServerBlocklist } from '@server/typings/models'
2import { AccountBlocklistModel } from '../models/account/account-blocklist' 3import { AccountBlocklistModel } from '../models/account/account-blocklist'
3import { ServerBlocklistModel } from '../models/server/server-blocklist' 4import { ServerBlocklistModel } from '../models/server/server-blocklist'
4import { MAccountBlocklist, MServerBlocklist } from '@server/typings/models'
5 5
6function addAccountInBlocklist (byAccountId: number, targetAccountId: number) { 6function addAccountInBlocklist (byAccountId: number, targetAccountId: number) {
7 return sequelizeTypescript.transaction(async t => { 7 return sequelizeTypescript.transaction(async t => {
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 04aac515f..46d52e1cf 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -10,7 +10,7 @@ import { VideoModel } from '../../../models/video/video'
10import { JobQueue } from '../job-queue' 10import { JobQueue } from '../job-queue'
11import { federateVideoIfNeeded } from '../../activitypub/videos' 11import { federateVideoIfNeeded } from '../../activitypub/videos'
12import { retryTransactionWrapper } from '../../../helpers/database-utils' 12import { retryTransactionWrapper } from '../../../helpers/database-utils'
13import { sequelizeTypescript } from '../../../initializers' 13import { sequelizeTypescript } from '../../../initializers/database'
14import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' 14import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
15import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding' 15import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding'
16import { Notifier } from '../../notifier' 16import { Notifier } from '../../notifier'
diff --git a/server/lib/plugins/plugin-helpers.ts b/server/lib/plugins/plugin-helpers.ts
index 608207e05..de82b4918 100644
--- a/server/lib/plugins/plugin-helpers.ts
+++ b/server/lib/plugins/plugin-helpers.ts
@@ -3,6 +3,15 @@ import { sequelizeTypescript } from '@server/initializers/database'
3import { buildLogger } from '@server/helpers/logger' 3import { buildLogger } from '@server/helpers/logger'
4import { VideoModel } from '@server/models/video/video' 4import { VideoModel } from '@server/models/video/video'
5import { WEBSERVER } from '@server/initializers/constants' 5import { WEBSERVER } from '@server/initializers/constants'
6import { ServerModel } from '@server/models/server/server'
7import { getServerActor } from '@server/models/application/application'
8import { addServerInBlocklist, removeServerFromBlocklist, addAccountInBlocklist, removeAccountFromBlocklist } from '../blocklist'
9import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
10import { AccountModel } from '@server/models/account/account'
11import { VideoBlacklistCreate } from '@shared/models'
12import { blacklistVideo, unblacklistVideo } from '../video-blacklist'
13import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
14import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
6 15
7function buildPluginHelpers (npmName: string): PeerTubeHelpers { 16function buildPluginHelpers (npmName: string): PeerTubeHelpers {
8 const logger = buildPluginLogger(npmName) 17 const logger = buildPluginLogger(npmName)
@@ -12,11 +21,17 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers {
12 21
13 const config = buildConfigHelpers() 22 const config = buildConfigHelpers()
14 23
24 const server = buildServerHelpers()
25
26 const moderation = buildModerationHelpers()
27
15 return { 28 return {
16 logger, 29 logger,
17 database, 30 database,
18 videos, 31 videos,
19 config 32 config,
33 moderation,
34 server
20 } 35 }
21} 36}
22 37
@@ -36,8 +51,18 @@ function buildDatabaseHelpers () {
36 } 51 }
37} 52}
38 53
54function buildServerHelpers () {
55 return {
56 getServerActor: () => getServerActor()
57 }
58}
59
39function buildVideosHelpers () { 60function buildVideosHelpers () {
40 return { 61 return {
62 loadByUrl: (url: string) => {
63 return VideoModel.loadByUrl(url)
64 },
65
41 removeVideo: (id: number) => { 66 removeVideo: (id: number) => {
42 return sequelizeTypescript.transaction(async t => { 67 return sequelizeTypescript.transaction(async t => {
43 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) 68 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t)
@@ -48,6 +73,57 @@ function buildVideosHelpers () {
48 } 73 }
49} 74}
50 75
76function buildModerationHelpers () {
77 return {
78 blockServer: async (options: { byAccountId: number, hostToBlock: string }) => {
79 const serverToBlock = await ServerModel.loadOrCreateByHost(options.hostToBlock)
80
81 await addServerInBlocklist(options.byAccountId, serverToBlock.id)
82 },
83
84 unblockServer: async (options: { byAccountId: number, hostToUnblock: string }) => {
85 const serverBlock = await ServerBlocklistModel.loadByAccountAndHost(options.byAccountId, options.hostToUnblock)
86 if (!serverBlock) return
87
88 await removeServerFromBlocklist(serverBlock)
89 },
90
91 blockAccount: async (options: { byAccountId: number, handleToBlock: string }) => {
92 const accountToBlock = await AccountModel.loadByNameWithHost(options.handleToBlock)
93 if (!accountToBlock) return
94
95 await addAccountInBlocklist(options.byAccountId, accountToBlock.id)
96 },
97
98 unblockAccount: async (options: { byAccountId: number, handleToUnblock: string }) => {
99 const targetAccount = await AccountModel.loadByNameWithHost(options.handleToUnblock)
100 if (!targetAccount) return
101
102 const accountBlock = await AccountBlocklistModel.loadByAccountAndTarget(options.byAccountId, targetAccount.id)
103 if (!accountBlock) return
104
105 await removeAccountFromBlocklist(accountBlock)
106 },
107
108 blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => {
109 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
110 if (!video) return
111
112 await blacklistVideo(video, options.createOptions)
113 },
114
115 unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => {
116 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
117 if (!video) return
118
119 const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id)
120 if (!videoBlacklist) return
121
122 await unblacklistVideo(videoBlacklist, video)
123 }
124 }
125}
126
51function buildConfigHelpers () { 127function buildConfigHelpers () {
52 return { 128 return {
53 getWebserverUrl () { 129 getWebserverUrl () {
diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts
index 3b90b1b94..bd60c6201 100644
--- a/server/lib/video-blacklist.ts
+++ b/server/lib/video-blacklist.ts
@@ -1,12 +1,22 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { sequelizeTypescript } from '@server/initializers/database'
3import {
4 MUser,
5 MVideoAccountLight,
6 MVideoBlacklist,
7 MVideoBlacklistVideo,
8 MVideoFullLight,
9 MVideoWithBlacklistLight
10} from '@server/typings/models'
11import { UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models'
12import { UserAdminFlag } from '../../shared/models/users/user-flag.model'
13import { logger } from '../helpers/logger'
2import { CONFIG } from '../initializers/config' 14import { CONFIG } from '../initializers/config'
3import { UserRight, VideoBlacklistType } from '../../shared/models'
4import { VideoBlacklistModel } from '../models/video/video-blacklist' 15import { VideoBlacklistModel } from '../models/video/video-blacklist'
5import { logger } from '../helpers/logger' 16import { sendDeleteVideo } from './activitypub/send'
6import { UserAdminFlag } from '../../shared/models/users/user-flag.model' 17import { federateVideoIfNeeded } from './activitypub/videos'
7import { Hooks } from './plugins/hooks'
8import { Notifier } from './notifier' 18import { Notifier } from './notifier'
9import { MUser, MVideoBlacklistVideo, MVideoWithBlacklistLight } from '@server/typings/models' 19import { Hooks } from './plugins/hooks'
10 20
11async function autoBlacklistVideoIfNeeded (parameters: { 21async function autoBlacklistVideoIfNeeded (parameters: {
12 video: MVideoWithBlacklistLight 22 video: MVideoWithBlacklistLight
@@ -49,6 +59,60 @@ async function autoBlacklistVideoIfNeeded (parameters: {
49 return true 59 return true
50} 60}
51 61
62async function blacklistVideo (videoInstance: MVideoAccountLight, options: VideoBlacklistCreate) {
63 const blacklist: MVideoBlacklistVideo = await VideoBlacklistModel.create({
64 videoId: videoInstance.id,
65 unfederated: options.unfederate === true,
66 reason: options.reason,
67 type: VideoBlacklistType.MANUAL
68 }
69 )
70 blacklist.Video = videoInstance
71
72 if (options.unfederate === true) {
73 await sendDeleteVideo(videoInstance, undefined)
74 }
75
76 Notifier.Instance.notifyOnVideoBlacklist(blacklist)
77}
78
79async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoFullLight) {
80 const videoBlacklistType = await sequelizeTypescript.transaction(async t => {
81 const unfederated = videoBlacklist.unfederated
82 const videoBlacklistType = videoBlacklist.type
83
84 await videoBlacklist.destroy({ transaction: t })
85 video.VideoBlacklist = undefined
86
87 // Re federate the video
88 if (unfederated === true) {
89 await federateVideoIfNeeded(video, true, t)
90 }
91
92 return videoBlacklistType
93 })
94
95 Notifier.Instance.notifyOnVideoUnblacklist(video)
96
97 if (videoBlacklistType === VideoBlacklistType.AUTO_BEFORE_PUBLISHED) {
98 Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(video)
99
100 // Delete on object so new video notifications will send
101 delete video.VideoBlacklist
102 Notifier.Instance.notifyOnNewVideoIfNeeded(video)
103 }
104}
105
106// ---------------------------------------------------------------------------
107
108export {
109 autoBlacklistVideoIfNeeded,
110 blacklistVideo,
111 unblacklistVideo
112}
113
114// ---------------------------------------------------------------------------
115
52function autoBlacklistNeeded (parameters: { 116function autoBlacklistNeeded (parameters: {
53 video: MVideoWithBlacklistLight 117 video: MVideoWithBlacklistLight
54 isRemote: boolean 118 isRemote: boolean
@@ -66,9 +130,3 @@ function autoBlacklistNeeded (parameters: {
66 130
67 return true 131 return true
68} 132}
69
70// ---------------------------------------------------------------------------
71
72export {
73 autoBlacklistVideoIfNeeded
74}