From 6def7d34e6be805751b3f505b4e1436cc92fba35 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Dec 2021 14:20:43 +0100 Subject: [PATCH] Fix migrations --- server/initializers/migrator.ts | 2 +- server/tests/api/users/user-subscriptions.ts | 55 ++++++++++++++++---- server/tools/peertube-import-videos.ts | 3 +- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts index 7d7c9f8cb..7ac20127e 100644 --- a/server/initializers/migrator.ts +++ b/server/initializers/migrator.ts @@ -65,7 +65,7 @@ async function getMigrationScripts () { }[] = [] files - .filter(file => file.endsWith('.js.map') === false) + .filter(file => file.endsWith('.js')) .forEach(file => { // Filename is something like 'version-blabla.js' const version = file.split('-')[0] diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 190a19c38..57cca6ad4 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -2,6 +2,7 @@ import 'mocha' import * as chai from 'chai' +import { VideoPrivacy } from '@shared/models' import { cleanupTests, createMultipleServers, @@ -32,20 +33,18 @@ describe('Test users subscriptions', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - { - for (const server of servers) { - const user = { username: 'user' + server.serverNumber, password: 'password' } - await server.users.create({ username: user.username, password: user.password }) + for (const server of servers) { + const user = { username: 'user' + server.serverNumber, password: 'password' } + await server.users.create({ username: user.username, password: user.password }) - const accessToken = await server.login.getAccessToken(user) - users.push({ accessToken }) + const accessToken = await server.login.getAccessToken(user) + users.push({ accessToken }) - const videoName1 = 'video 1-' + server.serverNumber - await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) + const videoName1 = 'video 1-' + server.serverNumber + await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) - const videoName2 = 'video 2-' + server.serverNumber - await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) - } + const videoName2 = 'video 2-' + server.serverNumber + await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) } await waitJobs(servers) @@ -540,6 +539,40 @@ describe('Test users subscriptions', function () { } }) + it('Should update video as internal and not see from remote server', async function () { + this.timeout(30000) + + await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) + await waitJobs(servers) + + { + const { data } = await command.listVideos({ token: users[0].accessToken }) + expect(data.find(v => v.name === 'internal')).to.not.exist + } + }) + + it('Should see internal from local user', async function () { + const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) + expect(data.find(v => v.name === 'internal')).to.exist + }) + + it('Should update video as private and not see from anyone server', async function () { + this.timeout(30000) + + await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) + await waitJobs(servers) + + { + const { data } = await command.listVideos({ token: users[0].accessToken }) + expect(data.find(v => v.name === 'private')).to.not.exist + } + + { + const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) + expect(data.find(v => v.name === 'private')).to.not.exist + } + }) + after(async function () { await cleanupTests(servers) }) diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 44c42bad6..87aec60ef 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -5,7 +5,8 @@ import { program } from 'commander' import { accessSync, constants } from 'fs' import { remove } from 'fs-extra' import { join } from 'path' -import { sha256, wait } from '@shared/core-utils' +import { sha256 } from '@shared/extra-utils' +import { wait } from '@shared/core-utils' import { doRequestAndSaveToFile } from '../helpers/requests' import { assignToken, -- 2.41.0