aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/models/server/custom-config.model.ts9
-rw-r--r--shared/models/server/server-config.model.ts8
-rw-r--r--shared/models/users/user-notification-setting.model.ts1
-rw-r--r--shared/models/users/user-notification.model.ts4
-rw-r--r--shared/models/videos/blacklist/video-blacklist.model.ts20
-rw-r--r--shared/utils/server/config.ts7
-rw-r--r--shared/utils/users/user-notifications.ts35
-rw-r--r--shared/utils/videos/video-blacklist.ts13
-rw-r--r--shared/utils/videos/video-change-ownership.ts4
9 files changed, 84 insertions, 17 deletions
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts
index 20b261426..1607b40a8 100644
--- a/shared/models/server/custom-config.model.ts
+++ b/shared/models/server/custom-config.model.ts
@@ -77,4 +77,13 @@ export interface CustomConfig {
77 } 77 }
78 } 78 }
79 } 79 }
80
81 autoBlacklist: {
82 videos: {
83 ofUsers: {
84 enabled: boolean
85 }
86 }
87 }
88
80} 89}
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 0200d88ca..dcc45be8a 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -49,6 +49,14 @@ export interface ServerConfig {
49 } 49 }
50 } 50 }
51 51
52 autoBlacklist: {
53 videos: {
54 ofUsers: {
55 enabled: boolean
56 }
57 }
58 }
59
52 avatar: { 60 avatar: {
53 file: { 61 file: {
54 size: { 62 size: {
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts
index 531e12bba..57b33e4b8 100644
--- a/shared/models/users/user-notification-setting.model.ts
+++ b/shared/models/users/user-notification-setting.model.ts
@@ -8,6 +8,7 @@ export interface UserNotificationSetting {
8 newVideoFromSubscription: UserNotificationSettingValue 8 newVideoFromSubscription: UserNotificationSettingValue
9 newCommentOnMyVideo: UserNotificationSettingValue 9 newCommentOnMyVideo: UserNotificationSettingValue
10 videoAbuseAsModerator: UserNotificationSettingValue 10 videoAbuseAsModerator: UserNotificationSettingValue
11 videoAutoBlacklistAsModerator: UserNotificationSettingValue
11 blacklistOnMyVideo: UserNotificationSettingValue 12 blacklistOnMyVideo: UserNotificationSettingValue
12 myVideoPublished: UserNotificationSettingValue 13 myVideoPublished: UserNotificationSettingValue
13 myVideoImportFinished: UserNotificationSettingValue 14 myVideoImportFinished: UserNotificationSettingValue
diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts
index 186b62612..19892b61a 100644
--- a/shared/models/users/user-notification.model.ts
+++ b/shared/models/users/user-notification.model.ts
@@ -13,7 +13,9 @@ export enum UserNotificationType {
13 13
14 NEW_USER_REGISTRATION = 9, 14 NEW_USER_REGISTRATION = 9,
15 NEW_FOLLOW = 10, 15 NEW_FOLLOW = 10,
16 COMMENT_MENTION = 11 16 COMMENT_MENTION = 11,
17
18 VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12
17} 19}
18 20
19export interface VideoInfo { 21export interface VideoInfo {
diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts
index 4bd976190..68d59e489 100644
--- a/shared/models/videos/blacklist/video-blacklist.model.ts
+++ b/shared/models/videos/blacklist/video-blacklist.model.ts
@@ -1,19 +1,17 @@
1import { Video } from '../video.model'
2
3export enum VideoBlacklistType {
4 MANUAL = 1,
5 AUTO_BEFORE_PUBLISHED = 2
6}
7
1export interface VideoBlacklist { 8export interface VideoBlacklist {
2 id: number 9 id: number
3 createdAt: Date 10 createdAt: Date
4 updatedAt: Date 11 updatedAt: Date
5 unfederated: boolean 12 unfederated: boolean
6 reason?: string 13 reason?: string
14 type: VideoBlacklistType
7 15
8 video: { 16 video: Video
9 id: number
10 name: string
11 uuid: string
12 description: string
13 duration: number
14 views: number
15 likes: number
16 dislikes: number
17 nsfw: boolean
18 }
19} 17}
diff --git a/shared/utils/server/config.ts b/shared/utils/server/config.ts
index 0e16af0f2..eaa493a93 100644
--- a/shared/utils/server/config.ts
+++ b/shared/utils/server/config.ts
@@ -112,6 +112,13 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) {
112 enabled: false 112 enabled: false
113 } 113 }
114 } 114 }
115 },
116 autoBlacklist: {
117 videos: {
118 ofUsers: {
119 enabled: false
120 }
121 }
115 } 122 }
116 } 123 }
117 124
diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts
index c8ed7df30..e3a79f523 100644
--- a/shared/utils/users/user-notifications.ts
+++ b/shared/utils/users/user-notifications.ts
@@ -18,7 +18,7 @@ function updateMyNotificationSettings (url: string, token: string, settings: Use
18 }) 18 })
19} 19}
20 20
21function getUserNotifications ( 21async function getUserNotifications (
22 url: string, 22 url: string,
23 token: string, 23 token: string,
24 start: number, 24 start: number,
@@ -165,12 +165,15 @@ async function checkNewVideoFromSubscription (base: CheckerBaseParams, videoName
165 checkVideo(notification.video, videoName, videoUUID) 165 checkVideo(notification.video, videoName, videoUUID)
166 checkActor(notification.video.channel) 166 checkActor(notification.video.channel)
167 } else { 167 } else {
168 expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName) 168 expect(notification).to.satisfy((n: UserNotification) => {
169 return n === undefined || n.type !== UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION || n.video.name !== videoName
170 })
169 } 171 }
170 } 172 }
171 173
172 function emailFinder (email: object) { 174 function emailFinder (email: object) {
173 return email[ 'text' ].indexOf(videoUUID) !== -1 175 const text = email[ 'text' ]
176 return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1
174 } 177 }
175 178
176 await checkNotification(base, notificationChecker, emailFinder, type) 179 await checkNotification(base, notificationChecker, emailFinder, type)
@@ -387,6 +390,31 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU
387 await checkNotification(base, notificationChecker, emailFinder, type) 390 await checkNotification(base, notificationChecker, emailFinder, type)
388} 391}
389 392
393async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
394 const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
395
396 function notificationChecker (notification: UserNotification, type: CheckerType) {
397 if (type === 'presence') {
398 expect(notification).to.not.be.undefined
399 expect(notification.type).to.equal(notificationType)
400
401 expect(notification.video.id).to.be.a('number')
402 checkVideo(notification.video, videoName, videoUUID)
403 } else {
404 expect(notification).to.satisfy((n: UserNotification) => {
405 return n === undefined || n.video === undefined || n.video.uuid !== videoUUID
406 })
407 }
408 }
409
410 function emailFinder (email: object) {
411 const text = email[ 'text' ]
412 return text.indexOf(videoUUID) !== -1 && email[ 'text' ].indexOf('video-auto-blacklist/list') !== -1
413 }
414
415 await checkNotification(base, notificationChecker, emailFinder, type)
416}
417
390async function checkNewBlacklistOnMyVideo ( 418async function checkNewBlacklistOnMyVideo (
391 base: CheckerBaseParams, 419 base: CheckerBaseParams,
392 videoUUID: string, 420 videoUUID: string,
@@ -431,6 +459,7 @@ export {
431 checkCommentMention, 459 checkCommentMention,
432 updateMyNotificationSettings, 460 updateMyNotificationSettings,
433 checkNewVideoAbuseForModerators, 461 checkNewVideoAbuseForModerators,
462 checkVideoAutoBlacklistForModerators,
434 getUserNotifications, 463 getUserNotifications,
435 markAsReadNotifications, 464 markAsReadNotifications,
436 getLastNotification 465 getLastNotification
diff --git a/shared/utils/videos/video-blacklist.ts b/shared/utils/videos/video-blacklist.ts
index f2ae0ed26..82d5b7e31 100644
--- a/shared/utils/videos/video-blacklist.ts
+++ b/shared/utils/videos/video-blacklist.ts
@@ -51,6 +51,18 @@ function getBlacklistedVideosList (url: string, token: string, specialStatus = 2
51 .expect('Content-Type', /json/) 51 .expect('Content-Type', /json/)
52} 52}
53 53
54function getBlacklistedVideosListWithTypeFilter (url: string, token: string, type: number, specialStatus = 200) {
55 const path = '/api/v1/videos/blacklist/'
56
57 return request(url)
58 .get(path)
59 .query({ sort: 'createdAt', type })
60 .set('Accept', 'application/json')
61 .set('Authorization', 'Bearer ' + token)
62 .expect(specialStatus)
63 .expect('Content-Type', /json/)
64}
65
54function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { 66function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
55 const path = '/api/v1/videos/blacklist/' 67 const path = '/api/v1/videos/blacklist/'
56 68
@@ -69,6 +81,7 @@ export {
69 addVideoToBlacklist, 81 addVideoToBlacklist,
70 removeVideoFromBlacklist, 82 removeVideoFromBlacklist,
71 getBlacklistedVideosList, 83 getBlacklistedVideosList,
84 getBlacklistedVideosListWithTypeFilter,
72 getSortedBlacklistedVideosList, 85 getSortedBlacklistedVideosList,
73 updateVideoBlacklist 86 updateVideoBlacklist
74} 87}
diff --git a/shared/utils/videos/video-change-ownership.ts b/shared/utils/videos/video-change-ownership.ts
index f288692ea..371d02000 100644
--- a/shared/utils/videos/video-change-ownership.ts
+++ b/shared/utils/videos/video-change-ownership.ts
@@ -1,6 +1,6 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2 2
3function changeVideoOwnership (url: string, token: string, videoId: number | string, username) { 3function changeVideoOwnership (url: string, token: string, videoId: number | string, username, expectedStatus = 204) {
4 const path = '/api/v1/videos/' + videoId + '/give-ownership' 4 const path = '/api/v1/videos/' + videoId + '/give-ownership'
5 5
6 return request(url) 6 return request(url)
@@ -8,7 +8,7 @@ function changeVideoOwnership (url: string, token: string, videoId: number | str
8 .set('Accept', 'application/json') 8 .set('Accept', 'application/json')
9 .set('Authorization', 'Bearer ' + token) 9 .set('Authorization', 'Bearer ' + token)
10 .send({ username }) 10 .send({ username })
11 .expect(204) 11 .expect(expectedStatus)
12} 12}
13 13
14function getVideoChangeOwnershipList (url: string, token: string) { 14function getVideoChangeOwnershipList (url: string, token: string) {