mirror of https://github.com/Chocobozzz/PeerTube
Introduce change ownership command
parent
44364d06d7
commit
72cbfc5695
|
@ -4,8 +4,7 @@ import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
acceptChangeOwnership,
|
ChangeOwnershipCommand,
|
||||||
changeVideoOwnership,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
|
@ -13,9 +12,7 @@ import {
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoChangeOwnershipList,
|
|
||||||
getVideosList,
|
getVideosList,
|
||||||
refuseChangeOwnership,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
setDefaultVideoChannel,
|
setDefaultVideoChannel,
|
||||||
|
@ -39,16 +36,18 @@ describe('Test video change ownership - nominal', function () {
|
||||||
password: 'My other password'
|
password: 'My other password'
|
||||||
}
|
}
|
||||||
|
|
||||||
let firstUserAccessToken = ''
|
let firstUserToken = ''
|
||||||
let firstUserChannelId: number
|
let firstUserChannelId: number
|
||||||
|
|
||||||
let secondUserAccessToken = ''
|
let secondUserToken = ''
|
||||||
let secondUserChannelId: number
|
let secondUserChannelId: number
|
||||||
|
|
||||||
let lastRequestChangeOwnershipId = ''
|
let lastRequestId: number
|
||||||
|
|
||||||
let liveId: number
|
let liveId: number
|
||||||
|
|
||||||
|
let command: ChangeOwnershipCommand
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(50000)
|
this.timeout(50000)
|
||||||
|
|
||||||
|
@ -83,17 +82,17 @@ describe('Test video change ownership - nominal', function () {
|
||||||
videoQuota: videoQuota
|
videoQuota: videoQuota
|
||||||
})
|
})
|
||||||
|
|
||||||
firstUserAccessToken = await userLogin(servers[0], firstUser)
|
firstUserToken = await userLogin(servers[0], firstUser)
|
||||||
secondUserAccessToken = await userLogin(servers[0], secondUser)
|
secondUserToken = await userLogin(servers[0], secondUser)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(servers[0].url, firstUserAccessToken)
|
const res = await getMyUserInformation(servers[0].url, firstUserToken)
|
||||||
const firstUserInformation: User = res.body
|
const firstUserInformation: User = res.body
|
||||||
firstUserChannelId = firstUserInformation.videoChannels[0].id
|
firstUserChannelId = firstUserInformation.videoChannels[0].id
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getMyUserInformation(servers[0].url, secondUserAccessToken)
|
const res = await getMyUserInformation(servers[0].url, secondUserToken)
|
||||||
const secondUserInformation: User = res.body
|
const secondUserInformation: User = res.body
|
||||||
secondUserChannelId = secondUserInformation.videoChannels[0].id
|
secondUserChannelId = secondUserInformation.videoChannels[0].id
|
||||||
}
|
}
|
||||||
|
@ -103,7 +102,7 @@ describe('Test video change ownership - nominal', function () {
|
||||||
name: 'my super name',
|
name: 'my super name',
|
||||||
description: 'my super description'
|
description: 'my super description'
|
||||||
}
|
}
|
||||||
const res = await uploadVideo(servers[0].url, firstUserAccessToken, videoAttributes)
|
const res = await uploadVideo(servers[0].url, firstUserToken, videoAttributes)
|
||||||
|
|
||||||
const resVideo = await getVideo(servers[0].url, res.body.video.id)
|
const resVideo = await getVideo(servers[0].url, res.body.video.id)
|
||||||
servers[0].video = resVideo.body
|
servers[0].video = resVideo.body
|
||||||
|
@ -111,116 +110,129 @@ describe('Test video change ownership - nominal', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC }
|
const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC }
|
||||||
const video = await servers[0].liveCommand.create({ token: firstUserAccessToken, fields: attributes })
|
const video = await servers[0].liveCommand.create({ token: firstUserToken, fields: attributes })
|
||||||
|
|
||||||
liveId = video.id
|
liveId = video.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command = servers[0].changeOwnershipCommand
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have video change ownership', async function () {
|
it('Should not have video change ownership', async function () {
|
||||||
const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: firstUserToken })
|
||||||
|
|
||||||
expect(resFirstUser.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(resFirstUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resFirstUser.body.data.length).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
|
}
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(resSecondUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resSecondUser.body.data.length).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send a request to change ownership of a video', async function () {
|
it('Should send a request to change ownership of a video', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
|
await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should only return a request to change ownership for the second user', async function () {
|
it('Should only return a request to change ownership for the second user', async function () {
|
||||||
const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: firstUserToken })
|
||||||
|
|
||||||
expect(resFirstUser.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(resFirstUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resFirstUser.body.data.length).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
|
}
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(resSecondUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resSecondUser.body.data.length).to.equal(1)
|
expect(body.data.length).to.equal(1)
|
||||||
|
|
||||||
lastRequestChangeOwnershipId = resSecondUser.body.data[0].id
|
lastRequestId = body.data[0].id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should accept the same change ownership request without crashing', async function () {
|
it('Should accept the same change ownership request without crashing', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
|
await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not create multiple change ownership requests while one is waiting', async function () {
|
it('Should not create multiple change ownership requests while one is waiting', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
|
const body = await command.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(resSecondUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resSecondUser.body.data.length).to.equal(1)
|
expect(body.data.length).to.equal(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be possible to refuse the change of ownership from first user', async function () {
|
it('Should not be possible to refuse the change of ownership from first user', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, HttpStatusCode.FORBIDDEN_403)
|
await command.refuse({ token: firstUserToken, ownershipId: lastRequestId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be possible to refuse the change of ownership from second user', async function () {
|
it('Should be possible to refuse the change of ownership from second user', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await refuseChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId)
|
await command.refuse({ token: secondUserToken, ownershipId: lastRequestId })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send a new request to change ownership of a video', async function () {
|
it('Should send a new request to change ownership of a video', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
await changeVideoOwnership(servers[0].url, firstUserAccessToken, servers[0].video.id, secondUser.username)
|
await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser.username })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return two requests to change ownership for the second user', async function () {
|
it('Should return two requests to change ownership for the second user', async function () {
|
||||||
const resFirstUser = await getVideoChangeOwnershipList(servers[0].url, firstUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: firstUserToken })
|
||||||
|
|
||||||
expect(resFirstUser.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(resFirstUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resFirstUser.body.data.length).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
|
}
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
|
{
|
||||||
|
const body = await command.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(2)
|
expect(body.total).to.equal(2)
|
||||||
expect(resSecondUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resSecondUser.body.data.length).to.equal(2)
|
expect(body.data.length).to.equal(2)
|
||||||
|
|
||||||
lastRequestChangeOwnershipId = resSecondUser.body.data[0].id
|
lastRequestId = body.data[0].id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be possible to accept the change of ownership from first user', async function () {
|
it('Should not be possible to accept the change of ownership from first user', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await acceptChangeOwnership(
|
await command.accept({
|
||||||
servers[0].url,
|
token: firstUserToken,
|
||||||
firstUserAccessToken,
|
ownershipId: lastRequestId,
|
||||||
lastRequestChangeOwnershipId,
|
channelId: secondUserChannelId,
|
||||||
secondUserChannelId,
|
expectedStatus: HttpStatusCode.FORBIDDEN_403
|
||||||
HttpStatusCode.FORBIDDEN_403
|
})
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should be possible to accept the change of ownership from second user', async function () {
|
it('Should be possible to accept the change of ownership from second user', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, secondUserChannelId)
|
await command.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId: secondUserChannelId })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -240,20 +252,20 @@ describe('Test video change ownership - nominal', function () {
|
||||||
it('Should send a request to change ownership of a live', async function () {
|
it('Should send a request to change ownership of a live', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
await changeVideoOwnership(servers[0].url, firstUserAccessToken, liveId, secondUser.username)
|
await command.create({ token: firstUserToken, videoId: liveId, username: secondUser.username })
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(servers[0].url, secondUserAccessToken)
|
const body = await command.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(3)
|
expect(body.total).to.equal(3)
|
||||||
expect(resSecondUser.body.data.length).to.equal(3)
|
expect(body.data.length).to.equal(3)
|
||||||
|
|
||||||
lastRequestChangeOwnershipId = resSecondUser.body.data[0].id
|
lastRequestId = body.data[0].id
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should accept a live ownership change', async function () {
|
it('Should accept a live ownership change', async function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
await acceptChangeOwnership(servers[0].url, secondUserAccessToken, lastRequestChangeOwnershipId, secondUserChannelId)
|
await command.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId: secondUserChannelId })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -283,9 +295,9 @@ describe('Test video change ownership - quota too small', function () {
|
||||||
username: 'second',
|
username: 'second',
|
||||||
password: 'My other password'
|
password: 'My other password'
|
||||||
}
|
}
|
||||||
let firstUserAccessToken = ''
|
let firstUserToken = ''
|
||||||
let secondUserAccessToken = ''
|
let secondUserToken = ''
|
||||||
let lastRequestChangeOwnershipId = ''
|
let lastRequestId: number
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(50000)
|
this.timeout(50000)
|
||||||
|
@ -311,15 +323,15 @@ describe('Test video change ownership - quota too small', function () {
|
||||||
videoQuota: limitedVideoQuota
|
videoQuota: limitedVideoQuota
|
||||||
})
|
})
|
||||||
|
|
||||||
firstUserAccessToken = await userLogin(server, firstUser)
|
firstUserToken = await userLogin(server, firstUser)
|
||||||
secondUserAccessToken = await userLogin(server, secondUser)
|
secondUserToken = await userLogin(server, secondUser)
|
||||||
|
|
||||||
// Upload some videos on the server
|
// Upload some videos on the server
|
||||||
const video1Attributes = {
|
const video1Attributes = {
|
||||||
name: 'my super name',
|
name: 'my super name',
|
||||||
description: 'my super description'
|
description: 'my super description'
|
||||||
}
|
}
|
||||||
await uploadVideo(server.url, firstUserAccessToken, video1Attributes)
|
await uploadVideo(server.url, firstUserToken, video1Attributes)
|
||||||
|
|
||||||
await waitJobs(server)
|
await waitJobs(server)
|
||||||
|
|
||||||
|
@ -334,39 +346,42 @@ describe('Test video change ownership - quota too small', function () {
|
||||||
it('Should send a request to change ownership of a video', async function () {
|
it('Should send a request to change ownership of a video', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
await changeVideoOwnership(server.url, firstUserAccessToken, server.video.id, secondUser.username)
|
await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser.username })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should only return a request to change ownership for the second user', async function () {
|
it('Should only return a request to change ownership for the second user', async function () {
|
||||||
const resFirstUser = await getVideoChangeOwnershipList(server.url, firstUserAccessToken)
|
{
|
||||||
|
const body = await server.changeOwnershipCommand.list({ token: firstUserToken })
|
||||||
|
|
||||||
expect(resFirstUser.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(resFirstUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resFirstUser.body.data.length).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
|
}
|
||||||
|
|
||||||
const resSecondUser = await getVideoChangeOwnershipList(server.url, secondUserAccessToken)
|
{
|
||||||
|
const body = await server.changeOwnershipCommand.list({ token: secondUserToken })
|
||||||
|
|
||||||
expect(resSecondUser.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(resSecondUser.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(resSecondUser.body.data.length).to.equal(1)
|
expect(body.data.length).to.equal(1)
|
||||||
|
|
||||||
lastRequestChangeOwnershipId = resSecondUser.body.data[0].id
|
lastRequestId = body.data[0].id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () {
|
it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken)
|
const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserToken)
|
||||||
const secondUserInformation: User = secondUserInformationResponse.body
|
const secondUserInformation: User = secondUserInformationResponse.body
|
||||||
const channelId = secondUserInformation.videoChannels[0].id
|
const channelId = secondUserInformation.videoChannels[0].id
|
||||||
|
|
||||||
await acceptChangeOwnership(
|
await server.changeOwnershipCommand.accept({
|
||||||
server.url,
|
token: secondUserToken,
|
||||||
secondUserAccessToken,
|
ownershipId: lastRequestId,
|
||||||
lastRequestChangeOwnershipId,
|
|
||||||
channelId,
|
channelId,
|
||||||
HttpStatusCode.PAYLOAD_TOO_LARGE_413
|
expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413
|
||||||
)
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { makeGetRequest } from '../requests/requests'
|
||||||
import { SearchCommand } from '../search'
|
import { SearchCommand } from '../search'
|
||||||
import { SocketIOCommand } from '../socket'
|
import { SocketIOCommand } from '../socket'
|
||||||
import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
|
import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
|
||||||
import { LiveCommand, ServicesCommand, BlacklistCommand, CaptionsCommand } from '../videos'
|
import { BlacklistCommand, CaptionsCommand, ChangeOwnershipCommand, LiveCommand, ServicesCommand } from '../videos'
|
||||||
import { ConfigCommand } from './config-command'
|
import { ConfigCommand } from './config-command'
|
||||||
import { ContactFormCommand } from './contact-form-command'
|
import { ContactFormCommand } from './contact-form-command'
|
||||||
import { DebugCommand } from './debug-command'
|
import { DebugCommand } from './debug-command'
|
||||||
|
@ -104,6 +104,7 @@ interface ServerInfo {
|
||||||
servicesCommand?: ServicesCommand
|
servicesCommand?: ServicesCommand
|
||||||
blacklistCommand?: BlacklistCommand
|
blacklistCommand?: BlacklistCommand
|
||||||
captionsCommand?: CaptionsCommand
|
captionsCommand?: CaptionsCommand
|
||||||
|
changeOwnershipCommand?: ChangeOwnershipCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
function parallelTests () {
|
function parallelTests () {
|
||||||
|
@ -333,6 +334,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
|
||||||
server.servicesCommand = new ServicesCommand(server)
|
server.servicesCommand = new ServicesCommand(server)
|
||||||
server.blacklistCommand = new BlacklistCommand(server)
|
server.blacklistCommand = new BlacklistCommand(server)
|
||||||
server.captionsCommand = new CaptionsCommand(server)
|
server.captionsCommand = new CaptionsCommand(server)
|
||||||
|
server.changeOwnershipCommand = new ChangeOwnershipCommand(server)
|
||||||
|
|
||||||
res(server)
|
res(server)
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
import { ResultList, VideoChangeOwnership } from '@shared/models'
|
||||||
|
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||||
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
|
export class ChangeOwnershipCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
create (options: OverrideCommandOptions & {
|
||||||
|
videoId: number | string
|
||||||
|
username: string
|
||||||
|
}) {
|
||||||
|
const { videoId, username } = options
|
||||||
|
const path = '/api/v1/videos/' + videoId + '/give-ownership'
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
fields: { username },
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
list (options: OverrideCommandOptions = {}) {
|
||||||
|
const path = '/api/v1/videos/ownership'
|
||||||
|
|
||||||
|
return this.getRequestBody<ResultList<VideoChangeOwnership>>({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
query: { sort: '-createdAt' },
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
accept (options: OverrideCommandOptions & {
|
||||||
|
ownershipId: number
|
||||||
|
channelId: number
|
||||||
|
}) {
|
||||||
|
const { ownershipId, channelId } = options
|
||||||
|
const path = '/api/v1/videos/ownership/' + ownershipId + '/accept'
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
fields: { channelId },
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
refuse (options: OverrideCommandOptions & {
|
||||||
|
ownershipId: number
|
||||||
|
}) {
|
||||||
|
const { ownershipId } = options
|
||||||
|
const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse'
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
export * from './blacklist-command'
|
export * from './blacklist-command'
|
||||||
export * from './captions'
|
export * from './captions'
|
||||||
export * from './captions-command'
|
export * from './captions-command'
|
||||||
|
export * from './change-ownership-command'
|
||||||
export * from './live-command'
|
export * from './live-command'
|
||||||
export * from './live'
|
export * from './live'
|
||||||
export * from './services-command'
|
export * from './services-command'
|
||||||
export * from './video-change-ownership'
|
|
||||||
export * from './video-channels'
|
export * from './video-channels'
|
||||||
export * from './video-comments'
|
export * from './video-comments'
|
||||||
export * from './video-history'
|
export * from './video-history'
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
import * as request from 'supertest'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
function changeVideoOwnership (
|
|
||||||
url: string,
|
|
||||||
token: string,
|
|
||||||
videoId: number | string,
|
|
||||||
username,
|
|
||||||
expectedStatus = HttpStatusCode.NO_CONTENT_204
|
|
||||||
) {
|
|
||||||
const path = '/api/v1/videos/' + videoId + '/give-ownership'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.post(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + token)
|
|
||||||
.send({ username })
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVideoChangeOwnershipList (url: string, token: string) {
|
|
||||||
const path = '/api/v1/videos/ownership'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.get(path)
|
|
||||||
.query({ sort: '-createdAt' })
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + token)
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
}
|
|
||||||
|
|
||||||
function acceptChangeOwnership (
|
|
||||||
url: string,
|
|
||||||
token: string,
|
|
||||||
ownershipId: string,
|
|
||||||
channelId: number,
|
|
||||||
expectedStatus = HttpStatusCode.NO_CONTENT_204
|
|
||||||
) {
|
|
||||||
const path = '/api/v1/videos/ownership/' + ownershipId + '/accept'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.post(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + token)
|
|
||||||
.send({ channelId })
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
function refuseChangeOwnership (
|
|
||||||
url: string,
|
|
||||||
token: string,
|
|
||||||
ownershipId: string,
|
|
||||||
expectedStatus = HttpStatusCode.NO_CONTENT_204
|
|
||||||
) {
|
|
||||||
const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse'
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.post(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + token)
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
changeVideoOwnership,
|
|
||||||
getVideoChangeOwnershipList,
|
|
||||||
acceptChangeOwnership,
|
|
||||||
refuseChangeOwnership
|
|
||||||
}
|
|
Loading…
Reference in New Issue