add quarantine videos feature (#1637)
[oweals/peertube.git] / shared / utils / videos / video-change-ownership.ts
1 import * as request from 'supertest'
2
3 function changeVideoOwnership (url: string, token: string, videoId: number | string, username, expectedStatus = 204) {
4   const path = '/api/v1/videos/' + videoId + '/give-ownership'
5
6   return request(url)
7     .post(path)
8     .set('Accept', 'application/json')
9     .set('Authorization', 'Bearer ' + token)
10     .send({ username })
11     .expect(expectedStatus)
12 }
13
14 function getVideoChangeOwnershipList (url: string, token: string) {
15   const path = '/api/v1/videos/ownership'
16
17   return request(url)
18     .get(path)
19     .query({ sort: '-createdAt' })
20     .set('Accept', 'application/json')
21     .set('Authorization', 'Bearer ' + token)
22     .expect(200)
23     .expect('Content-Type', /json/)
24 }
25
26 function acceptChangeOwnership (url: string, token: string, ownershipId: string, channelId: number, expectedStatus = 204) {
27   const path = '/api/v1/videos/ownership/' + ownershipId + '/accept'
28
29   return request(url)
30     .post(path)
31     .set('Accept', 'application/json')
32     .set('Authorization', 'Bearer ' + token)
33     .send({ channelId })
34     .expect(expectedStatus)
35 }
36
37 function refuseChangeOwnership (url: string, token: string, ownershipId: string, expectedStatus = 204) {
38   const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse'
39
40   return request(url)
41     .post(path)
42     .set('Accept', 'application/json')
43     .set('Authorization', 'Bearer ' + token)
44     .expect(expectedStatus)
45 }
46
47 // ---------------------------------------------------------------------------
48
49 export {
50   changeVideoOwnership,
51   getVideoChangeOwnershipList,
52   acceptChangeOwnership,
53   refuseChangeOwnership
54 }