2017-09-04 21:21:47 +02:00
|
|
|
import * as request from 'supertest'
|
2020-07-01 16:05:30 +02:00
|
|
|
import { AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models'
|
|
|
|
import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
|
|
|
|
|
|
|
|
// FIXME: deprecated in 2.3. Remove this file
|
2017-09-04 21:21:47 +02:00
|
|
|
|
2020-06-22 13:00:39 +02:00
|
|
|
function reportVideoAbuse (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
videoId: number | string,
|
|
|
|
reason: string,
|
2020-07-01 16:05:30 +02:00
|
|
|
predefinedReasons?: AbusePredefinedReasonsString[],
|
2020-06-22 13:00:39 +02:00
|
|
|
startAt?: number,
|
|
|
|
endAt?: number,
|
|
|
|
specialStatus = 200
|
|
|
|
) {
|
2017-09-04 21:21:47 +02:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/abuse'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.post(path)
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
2020-06-22 13:00:39 +02:00
|
|
|
.send({ reason, predefinedReasons, startAt, endAt })
|
2017-09-04 21:21:47 +02:00
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
2020-05-06 17:39:07 +02:00
|
|
|
function getVideoAbusesList (options: {
|
|
|
|
url: string
|
|
|
|
token: string
|
|
|
|
id?: number
|
2020-07-01 16:05:30 +02:00
|
|
|
predefinedReason?: AbusePredefinedReasonsString
|
2020-05-06 17:39:07 +02:00
|
|
|
search?: string
|
2020-07-01 16:05:30 +02:00
|
|
|
state?: AbuseState
|
|
|
|
videoIs?: AbuseVideoIs
|
2020-05-06 17:39:07 +02:00
|
|
|
searchReporter?: string
|
|
|
|
searchReportee?: string
|
|
|
|
searchVideo?: string
|
|
|
|
searchVideoChannel?: string
|
|
|
|
}) {
|
|
|
|
const {
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
id,
|
2020-06-22 13:00:39 +02:00
|
|
|
predefinedReason,
|
2020-05-06 17:39:07 +02:00
|
|
|
search,
|
|
|
|
state,
|
|
|
|
videoIs,
|
|
|
|
searchReporter,
|
|
|
|
searchReportee,
|
|
|
|
searchVideo,
|
|
|
|
searchVideoChannel
|
|
|
|
} = options
|
2017-09-04 21:21:47 +02:00
|
|
|
const path = '/api/v1/videos/abuse'
|
|
|
|
|
2020-05-06 17:39:07 +02:00
|
|
|
const query = {
|
|
|
|
sort: 'createdAt',
|
|
|
|
id,
|
2020-06-22 13:00:39 +02:00
|
|
|
predefinedReason,
|
2020-05-06 17:39:07 +02:00
|
|
|
search,
|
|
|
|
state,
|
|
|
|
videoIs,
|
|
|
|
searchReporter,
|
|
|
|
searchReportee,
|
|
|
|
searchVideo,
|
|
|
|
searchVideoChannel
|
|
|
|
}
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
query,
|
|
|
|
statusCodeExpected: 200
|
|
|
|
})
|
2017-09-04 21:21:47 +02:00
|
|
|
}
|
|
|
|
|
2018-08-10 16:54:01 +02:00
|
|
|
function updateVideoAbuse (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
videoId: string | number,
|
|
|
|
videoAbuseId: number,
|
2020-07-01 16:05:30 +02:00
|
|
|
body: AbuseUpdate,
|
2018-08-10 16:54:01 +02:00
|
|
|
statusCodeExpected = 204
|
|
|
|
) {
|
|
|
|
const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId
|
|
|
|
|
|
|
|
return makePutBodyRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
path,
|
|
|
|
fields: body,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteVideoAbuse (url: string, token: string, videoId: string | number, videoAbuseId: number, statusCodeExpected = 204) {
|
|
|
|
const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId
|
|
|
|
|
|
|
|
return makeDeleteRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
path,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-09-04 21:21:47 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
reportVideoAbuse,
|
2018-08-10 16:54:01 +02:00
|
|
|
getVideoAbusesList,
|
|
|
|
updateVideoAbuse,
|
|
|
|
deleteVideoAbuse
|
2017-09-04 21:21:47 +02:00
|
|
|
}
|