aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/utils')
-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
4 files changed, 54 insertions, 5 deletions
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) {