Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix channel activities tests

Chocobozzz0f4dbf95137c
diff --git a/packages/tests/src/api/videos/channel-activities.ts b/packages/tests/src/api/videos/channel-activities.ts
index 322ab1ae31..7a8b81f037 100644
--- a/packages/tests/src/api/videos/channel-activities.ts
+++ b/packages/tests/src/api/videos/channel-activities.ts
@@ -406,88 +406,6 @@ describe('Test channel activities', function () {
})
})
- describe('Ownership changes', function () {
- let video: VideoCreateResult
- let receiverToken: string
-
- before(async function () {
- video = await server.videos.quickUpload({ name: 'video for ownership change', channelId })
- receiverToken = await server.users.generateUserAndToken('receiver')
- })
-
- it('Should send an ownership change request', async function () {
- const a = await getActivityAfterAction(() => {
- return server.changeOwnership.create({ username: 'receiver', videoId: video.id })
- })
-
- expect(a.action.id).to.equal(VideoChannelActivityAction.SEND_OWNERSHIP_REQUEST)
- expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)
-
- expect(a.account.name).to.equal('root')
-
- expect(a.video.name).to.equal('video for ownership change')
-
- expect(a.targetAccount.username).to.equal('receiver')
- expect(a.targetAccount.url).to.equal(server.url + '/accounts/receiver')
- expect(a.targetAccount.displayName).to.equal('receiver')
- })
-
- it('Should refuse an ownership change request', async function () {
- const { data } = await server.changeOwnership.list({ token: receiverToken })
-
- const a = await getActivityAfterAction(() => {
- return server.changeOwnership.refuse({ ownershipId: data[0].id, token: receiverToken })
- })
-
- expect(a.action.id).to.equal(VideoChannelActivityAction.REFUSE_OWNERSHIP_REQUEST)
- expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)
-
- expect(a.account.name).to.equal('receiver')
-
- expect(a.video.name).to.equal('video for ownership change')
-
- expect(a.targetAccount.username).to.equal('receiver')
- expect(a.targetAccount.url).to.equal(server.url + '/accounts/receiver')
- expect(a.targetAccount.displayName).to.equal('receiver')
- })
-
- it('Should accept an ownership change request', async function () {
- await server.changeOwnership.create({ username: 'receiver', videoId: video.id })
- const { data } = await server.changeOwnership.list({ token: receiverToken })
-
- const a = await getActivityAfterAction(async () => {
- return server.changeOwnership.accept({
- ownershipId: data[0].id,
- channelId: await server.channels.getDefaultId({ token: receiverToken }),
- token: receiverToken
- })
- })
-
- {
- expect(a.action.id).to.equal(VideoChannelActivityAction.ACCEPT_OWNERSHIP_REQUEST)
- expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)
-
- expect(a.account.name).to.equal('receiver')
-
- expect(a.video.name).to.equal('video for ownership change')
-
- expect(a.targetAccount.username).to.equal('receiver')
- expect(a.targetAccount.url).to.equal(server.url + '/accounts/receiver')
- expect(a.targetAccount.displayName).to.equal('receiver')
- }
-
- {
- const { data } = await server.channels.listActivities({ channelName: 'receiver_channel', sort: '-createdAt' })
- const a = data[0]
-
- expect(a.action.id).to.equal(VideoChannelActivityAction.ACCEPT_OWNERSHIP_REQUEST)
- expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)
-
- expect(a.video.name).to.equal('video for ownership change')
- }
- })
- })
-
describe('Lives', async function () {
let liveVideo: VideoCreateResult
@@ -836,6 +754,8 @@ describe('Test channel activities', function () {
})
it('Should delete an ownership request', async function () {
+ video = await server.videos.quickUpload({ name: 'video 2 for ownership change', channelId })
+
await server.changeOwnership.create({ videoId: video.id, username: 'user_ownership_change' })
const { data } = await server.changeOwnership.listOfVideo({ videoId: video.id })
const changeOwnershipId = data[0].id
@@ -847,7 +767,7 @@ describe('Test channel activities', function () {
expect(a.action.id).to.equal(VideoChannelActivityAction.DELETE_OWNERSHIP_REQUEST)
expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)
expect(a.account.name).to.equal('root')
- expect(a.video.name).to.equal('video for ownership change')
+ expect(a.video.name).to.equal('video 2 for ownership change')
expect(a.targetAccount.username).to.equal('user_ownership_change')
})
})
diff --git a/server/core/lib/job-queue/handlers/video-import.ts b/server/core/lib/job-queue/handlers/video-import.ts
index 7270f3d8d6..1ee5bb9d0b 100644
--- a/server/core/lib/job-queue/handlers/video-import.ts
+++ b/server/core/lib/job-queue/handlers/video-import.ts
@@ -154,6 +154,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid
// Get information about this video
const stats = await stat(tmpVideoPath)
const user = await UserModel.loadByVideoId(videoImport.videoId)
+ if (!user) throw new Error('Video does not exist anymore')
const isAble = await isUserQuotaValid({ channelUserId: user.id, uploadSize: stats.size })
if (isAble === false) {