diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-15 10:49:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-15 14:39:52 +0200 |
commit | 1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a (patch) | |
tree | 91a10310cdf924779527525d39f8eb7e09e4ba49 /shared/utils/videos | |
parent | 31b48aad478506d4214586f02792816efa968e4b (diff) | |
download | PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.gz PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.zst PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.zip |
Add user adminFlags
Diffstat (limited to 'shared/utils/videos')
-rw-r--r-- | shared/utils/videos/video-blacklist.ts | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/shared/utils/videos/video-blacklist.ts b/shared/utils/videos/video-blacklist.ts index 82d5b7e31..e25a292fc 100644 --- a/shared/utils/videos/video-blacklist.ts +++ b/shared/utils/videos/video-blacklist.ts | |||
@@ -1,4 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoBlacklistType } from '../../models/videos' | ||
3 | import { makeGetRequest } from '..' | ||
2 | 4 | ||
3 | function addVideoToBlacklist ( | 5 | function addVideoToBlacklist ( |
4 | url: string, | 6 | url: string, |
@@ -39,40 +41,25 @@ function removeVideoFromBlacklist (url: string, token: string, videoId: number | | |||
39 | .expect(specialStatus) | 41 | .expect(specialStatus) |
40 | } | 42 | } |
41 | 43 | ||
42 | function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) { | 44 | function getBlacklistedVideosList (parameters: { |
45 | url: string, | ||
46 | token: string, | ||
47 | sort?: string, | ||
48 | type?: VideoBlacklistType, | ||
49 | specialStatus?: number | ||
50 | }) { | ||
51 | let { url, token, sort, type, specialStatus = 200 } = parameters | ||
43 | const path = '/api/v1/videos/blacklist/' | 52 | const path = '/api/v1/videos/blacklist/' |
44 | 53 | ||
45 | return request(url) | 54 | const query = { sort, type } |
46 | .get(path) | ||
47 | .query({ sort: 'createdAt' }) | ||
48 | .set('Accept', 'application/json') | ||
49 | .set('Authorization', 'Bearer ' + token) | ||
50 | .expect(specialStatus) | ||
51 | .expect('Content-Type', /json/) | ||
52 | } | ||
53 | |||
54 | function getBlacklistedVideosListWithTypeFilter (url: string, token: string, type: number, specialStatus = 200) { | ||
55 | const path = '/api/v1/videos/blacklist/' | ||
56 | 55 | ||
57 | return request(url) | 56 | return makeGetRequest({ |
58 | .get(path) | 57 | url, |
59 | .query({ sort: 'createdAt', type }) | 58 | path, |
60 | .set('Accept', 'application/json') | 59 | query, |
61 | .set('Authorization', 'Bearer ' + token) | 60 | token, |
62 | .expect(specialStatus) | 61 | statusCodeExpected: specialStatus |
63 | .expect('Content-Type', /json/) | 62 | }) |
64 | } | ||
65 | |||
66 | function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { | ||
67 | const path = '/api/v1/videos/blacklist/' | ||
68 | |||
69 | return request(url) | ||
70 | .get(path) | ||
71 | .query({ sort: sort }) | ||
72 | .set('Accept', 'application/json') | ||
73 | .set('Authorization', 'Bearer ' + token) | ||
74 | .expect(specialStatus) | ||
75 | .expect('Content-Type', /json/) | ||
76 | } | 63 | } |
77 | 64 | ||
78 | // --------------------------------------------------------------------------- | 65 | // --------------------------------------------------------------------------- |
@@ -81,7 +68,5 @@ export { | |||
81 | addVideoToBlacklist, | 68 | addVideoToBlacklist, |
82 | removeVideoFromBlacklist, | 69 | removeVideoFromBlacklist, |
83 | getBlacklistedVideosList, | 70 | getBlacklistedVideosList, |
84 | getBlacklistedVideosListWithTypeFilter, | ||
85 | getSortedBlacklistedVideosList, | ||
86 | updateVideoBlacklist | 71 | updateVideoBlacklist |
87 | } | 72 | } |