diff options
author | Josh Morel <morel.josh@hotmail.com> | 2019-04-02 05:26:47 -0400 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-04-02 11:26:47 +0200 |
commit | 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 (patch) | |
tree | e75dc991369c1768804fefa114eb2a832881087f /shared/utils | |
parent | 12fed49ebab0c414713d57ea316b6488ae6bef99 (diff) | |
download | PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.gz PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.zst PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.zip |
add quarantine videos feature (#1637)
* add quarantine videos feature
* increase Notification settings test timeout
to 20000ms. was completing 7000 locally but timing out
after 10000 on travis
* fix quarantine video test issues
-propagate misspelling
-remove skip from server/tests/client.ts
* WIP use blacklist for moderator video approval
instead of video.quarantine boolean
* finish auto-blacklist feature
Diffstat (limited to 'shared/utils')
-rw-r--r-- | shared/utils/server/config.ts | 7 | ||||
-rw-r--r-- | shared/utils/users/user-notifications.ts | 35 | ||||
-rw-r--r-- | shared/utils/videos/video-blacklist.ts | 13 | ||||
-rw-r--r-- | shared/utils/videos/video-change-ownership.ts | 4 |
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 | ||
21 | function getUserNotifications ( | 21 | async 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 | ||
393 | async 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 | |||
390 | async function checkNewBlacklistOnMyVideo ( | 418 | async 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 | ||
54 | function 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 | |||
54 | function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { | 66 | function 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 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | 2 | ||
3 | function changeVideoOwnership (url: string, token: string, videoId: number | string, username) { | 3 | function 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 | ||
14 | function getVideoChangeOwnershipList (url: string, token: string) { | 14 | function getVideoChangeOwnershipList (url: string, token: string) { |