From 1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Apr 2019 10:49:46 +0200 Subject: Add user adminFlags --- shared/utils/videos/video-blacklist.ts | 51 ++++++++++++---------------------- 1 file changed, 18 insertions(+), 33 deletions(-) (limited to 'shared/utils/videos') 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 @@ import * as request from 'supertest' +import { VideoBlacklistType } from '../../models/videos' +import { makeGetRequest } from '..' function addVideoToBlacklist ( url: string, @@ -39,40 +41,25 @@ function removeVideoFromBlacklist (url: string, token: string, videoId: number | .expect(specialStatus) } -function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) { +function getBlacklistedVideosList (parameters: { + url: string, + token: string, + sort?: string, + type?: VideoBlacklistType, + specialStatus?: number +}) { + let { url, token, sort, type, specialStatus = 200 } = parameters const path = '/api/v1/videos/blacklist/' - return request(url) - .get(path) - .query({ sort: 'createdAt' }) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + token) - .expect(specialStatus) - .expect('Content-Type', /json/) -} - -function getBlacklistedVideosListWithTypeFilter (url: string, token: string, type: number, specialStatus = 200) { - const path = '/api/v1/videos/blacklist/' + const query = { sort, type } - return request(url) - .get(path) - .query({ sort: 'createdAt', type }) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + token) - .expect(specialStatus) - .expect('Content-Type', /json/) -} - -function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { - const path = '/api/v1/videos/blacklist/' - - return request(url) - .get(path) - .query({ sort: sort }) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + token) - .expect(specialStatus) - .expect('Content-Type', /json/) + return makeGetRequest({ + url, + path, + query, + token, + statusCodeExpected: specialStatus + }) } // --------------------------------------------------------------------------- @@ -81,7 +68,5 @@ export { addVideoToBlacklist, removeVideoFromBlacklist, getBlacklistedVideosList, - getBlacklistedVideosListWithTypeFilter, - getSortedBlacklistedVideosList, updateVideoBlacklist } -- cgit v1.2.3