2017-09-22 03:13:43 -04:00
|
|
|
import * as request from 'supertest'
|
2019-04-15 04:49:46 -04:00
|
|
|
import { VideoBlacklistType } from '../../models/videos'
|
|
|
|
import { makeGetRequest } from '..'
|
2017-09-22 03:13:43 -04:00
|
|
|
|
2019-01-10 09:39:51 -05:00
|
|
|
function addVideoToBlacklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
videoId: number | string,
|
|
|
|
reason?: string,
|
|
|
|
unfederate?: boolean,
|
|
|
|
specialStatus = 204
|
|
|
|
) {
|
2017-09-22 03:13:43 -04:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.post(path)
|
2019-01-10 09:39:51 -05:00
|
|
|
.send({ reason, unfederate })
|
2017-09-22 03:13:43 -04:00
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
2018-08-13 10:57:13 -04:00
|
|
|
function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) {
|
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.put(path)
|
|
|
|
.send({ reason })
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
2018-08-14 03:08:47 -04:00
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
2018-08-13 10:57:13 -04:00
|
|
|
|
2017-12-28 10:26:28 -05:00
|
|
|
function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
|
2017-10-10 04:02:18 -04:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
2017-09-22 03:13:43 -04:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.delete(path)
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
2019-04-15 04:49:46 -04:00
|
|
|
function getBlacklistedVideosList (parameters: {
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
sort?: string,
|
|
|
|
type?: VideoBlacklistType,
|
|
|
|
specialStatus?: number
|
|
|
|
}) {
|
|
|
|
let { url, token, sort, type, specialStatus = 200 } = parameters
|
2017-10-10 04:02:18 -04:00
|
|
|
const path = '/api/v1/videos/blacklist/'
|
2017-09-22 03:13:43 -04:00
|
|
|
|
2019-04-15 04:49:46 -04:00
|
|
|
const query = { sort, type }
|
2019-04-02 05:26:47 -04:00
|
|
|
|
2019-04-15 04:49:46 -04:00
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
query,
|
|
|
|
token,
|
|
|
|
statusCodeExpected: specialStatus
|
|
|
|
})
|
2017-09-22 03:13:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
addVideoToBlacklist,
|
|
|
|
removeVideoFromBlacklist,
|
|
|
|
getBlacklistedVideosList,
|
2018-08-13 10:57:13 -04:00
|
|
|
updateVideoBlacklist
|
2017-09-22 03:13:43 -04:00
|
|
|
}
|