diff --git a/config/default.yaml b/config/default.yaml index 3865ab5c..783a78e6 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -80,6 +80,7 @@ storage: tmp: 'storage/tmp/' # Use to download data (imports etc), store uploaded files before and during processing... avatars: 'storage/avatars/' videos: 'storage/videos/' + images: 'storage/images/' streaming_playlists: 'storage/streaming-playlists/' redundancy: 'storage/redundancy/' logs: 'storage/logs/' @@ -172,6 +173,9 @@ redundancy: # min_lifetime: '48 hours' # strategy: 'recently-added' # Cache recently added videos # min_views: 10 # Having at least x views + images: + check_interval: 120000 # How often you want to check new images to cache (in ms) + nb_images_per_req: 10 # Other instances that duplicate your content remote_redundancy: diff --git a/config/production.yaml.example b/config/production.yaml.example index 94238fad..3d1dbe80 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -78,6 +78,7 @@ storage: tmp: '/var/www/peertube/storage/tmp/' # Use to download data (imports etc), store uploaded files before and during processing... avatars: '/var/www/peertube/storage/avatars/' videos: '/var/www/peertube/storage/videos/' + images: '/var/www/peertube/storage/images/' streaming_playlists: '/var/www/peertube/storage/streaming-playlists/' redundancy: '/var/www/peertube/storage/redundancy/' logs: '/var/www/peertube/storage/logs/' @@ -170,6 +171,9 @@ redundancy: # min_lifetime: '48 hours' # strategy: 'recently-added' # Cache recently added videos # min_views: 10 # Having at least x views + images: + check_interval: 120000 # How often you want to check new images to cache (in ms) + nb_images_per_req: 10 # Other instances that duplicate your content remote_redundancy: diff --git a/config/test-1.yaml b/config/test-1.yaml index fe5b3cf4..3ed4ae28 100644 --- a/config/test-1.yaml +++ b/config/test-1.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test1/tmp/' avatars: 'test1/avatars/' videos: 'test1/videos/' + images: 'test1/images/' streaming_playlists: 'test1/streaming-playlists/' redundancy: 'test1/redundancy/' logs: 'test1/logs/' diff --git a/config/test-2.yaml b/config/test-2.yaml index b559769c..dd5fce38 100644 --- a/config/test-2.yaml +++ b/config/test-2.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test2/tmp/' avatars: 'test2/avatars/' videos: 'test2/videos/' + images: 'test2/images/' streaming_playlists: 'test2/streaming-playlists/' redundancy: 'test2/redundancy/' logs: 'test2/logs/' diff --git a/config/test-3.yaml b/config/test-3.yaml index 9a7a944e..3e363ce4 100644 --- a/config/test-3.yaml +++ b/config/test-3.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test3/tmp/' avatars: 'test3/avatars/' videos: 'test3/videos/' + images: 'test3/images/' streaming_playlists: 'test3/streaming-playlists/' redundancy: 'test3/redundancy/' logs: 'test3/logs/' diff --git a/config/test-4.yaml b/config/test-4.yaml index 1e4bee97..cb1cd7a9 100644 --- a/config/test-4.yaml +++ b/config/test-4.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test4/tmp/' avatars: 'test4/avatars/' videos: 'test4/videos/' + images: 'test4/images/' streaming_playlists: 'test4/streaming-playlists/' redundancy: 'test4/redundancy/' logs: 'test4/logs/' diff --git a/config/test-5.yaml b/config/test-5.yaml index 9725e84f..a8e2ada7 100644 --- a/config/test-5.yaml +++ b/config/test-5.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test5/tmp/' avatars: 'test5/avatars/' videos: 'test5/videos/' + images: 'test5/images/' streaming_playlists: 'test5/streaming-playlists/' redundancy: 'test5/redundancy/' logs: 'test5/logs/' diff --git a/config/test-6.yaml b/config/test-6.yaml index a04c8a6a..9a82c4f4 100644 --- a/config/test-6.yaml +++ b/config/test-6.yaml @@ -13,6 +13,7 @@ storage: tmp: 'test6/tmp/' avatars: 'test6/avatars/' videos: 'test6/videos/' + images: 'test6/images/' streaming_playlists: 'test6/streaming-playlists/' redundancy: 'test6/redundancy/' logs: 'test6/logs/' diff --git a/dist/scripts/benchmark.js b/dist/scripts/benchmark.js index b5bf8fca..55ec5f5f 100644 --- a/dist/scripts/benchmark.js +++ b/dist/scripts/benchmark.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); -const autocannon_1 = tslib_1.__importStar(require("autocannon")); +(0, register_ts_paths_1.registerTSPaths)(); +const autocannon_1 = (0, tslib_1.__importStar)(require("autocannon")); const fs_extra_1 = require("fs-extra"); const extra_utils_1 = require("@shared/extra-utils"); let server; @@ -14,7 +14,7 @@ run() .catch(err => console.error(err)) .finally(() => { if (server) - return extra_utils_1.killallServers([server]); + return (0, extra_utils_1.killallServers)([server]); }); function buildAuthorizationHeader() { return { @@ -27,7 +27,7 @@ function buildAPHeader() { }; } function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { console.log('Preparing server...'); yield prepare(); const tests = [ @@ -140,16 +140,16 @@ function run() { const testResult = yield runBenchmark(test); Object.assign(testResult, { title: test.title, path: test.path }); finalResult.push(testResult); - console.log(autocannon_1.printResult(testResult)); + console.log((0, autocannon_1.printResult)(testResult)); } if (outfile) - yield fs_extra_1.writeJson(outfile, finalResult); + yield (0, fs_extra_1.writeJson)(outfile, finalResult); }); } function runBenchmark(options) { const { path, expecter, headers } = options; return new Promise((res, rej) => { - autocannon_1.default({ + (0, autocannon_1.default)({ url: server.url + path, connections: 20, headers, @@ -173,15 +173,15 @@ function runBenchmark(options) { }); } function prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - server = yield extra_utils_1.createSingleServer(1, { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + server = yield (0, extra_utils_1.createSingleServer)(1, { rates_limit: { api: { max: 5000000 } } }); - yield extra_utils_1.setAccessTokensToServers([server]); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const attributes = { name: 'my super video', category: 2, diff --git a/dist/scripts/client-build-stats.js b/dist/scripts/client-build-stats.js index 5e951627..5f554266 100644 --- a/dist/scripts/client-build-stats.js +++ b/dist/scripts/client-build-stats.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const core_utils_1 = require("@server/helpers/core-utils"); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = { - app: yield buildResult(path_1.join(core_utils_1.root(), 'client', 'dist', 'en-US')), - embed: yield buildResult(path_1.join(core_utils_1.root(), 'client', 'dist', 'standalone', 'videos')) + app: yield buildResult((0, path_1.join)((0, core_utils_1.root)(), 'client', 'dist', 'en-US')), + embed: yield buildResult((0, path_1.join)((0, core_utils_1.root)(), 'client', 'dist', 'standalone', 'videos')) }; console.log(JSON.stringify(result)); }); @@ -18,12 +18,12 @@ function run() { run() .catch(err => console.error(err)); function buildResult(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const distFiles = yield fs_extra_1.readdir(path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const distFiles = yield (0, fs_extra_1.readdir)(path); const files = []; for (const file of distFiles) { - const filePath = path_1.join(path, file); - const statsResult = yield fs_extra_1.stat(filePath); + const filePath = (0, path_1.join)(path, file); + const statsResult = yield (0, fs_extra_1.stat)(filePath); files.push({ name: file, size: statsResult.size diff --git a/dist/scripts/create-import-video-file-job.js b/dist/scripts/create-import-video-file-job.js index 2c176a43..bfaf0a57 100644 --- a/dist/scripts/create-import-video-file-job.js +++ b/dist/scripts/create-import-video-file-job.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const commander_1 = require("commander"); const path_1 = require("path"); const video_1 = require("../server/models/video/video"); @@ -26,10 +26,10 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); - const uuid = misc_1.toCompleteUUID(options.video); - if (misc_1.isUUIDValid(uuid) === false) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); + const uuid = (0, misc_1.toCompleteUUID)(options.video); + if ((0, misc_1.isUUIDValid)(uuid) === false) { console.error('%s is not a valid video UUID.', options.video); return; } @@ -40,7 +40,7 @@ function run() { throw new Error('Cannot import files of a non owned video.'); const dataInput = { videoUUID: video.uuid, - filePath: path_1.resolve(options.import) + filePath: (0, path_1.resolve)(options.import) }; job_queue_1.JobQueue.Instance.init(); yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'video-file-import', payload: dataInput }); diff --git a/dist/scripts/create-transcoding-job.js b/dist/scripts/create-transcoding-job.js index ce12de02..7903ec60 100644 --- a/dist/scripts/create-transcoding-job.js +++ b/dist/scripts/create-transcoding-job.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const commander_1 = require("commander"); const video_1 = require("../server/models/video/video"); const database_1 = require("../server/initializers/database"); @@ -32,10 +32,10 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); - const uuid = misc_1.toCompleteUUID(options.video); - if (misc_1.isUUIDValid(uuid) === false) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); + const uuid = (0, misc_1.toCompleteUUID)(options.video); + if ((0, misc_1.isUUIDValid)(uuid) === false) { console.error('%s is not a valid video UUID.', options.video); return; } @@ -47,7 +47,7 @@ function run() { if (options.generateHls || config_1.CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { const resolutionsEnabled = options.resolution ? [options.resolution] - : ffprobe_utils_1.computeResolutionsToTranscode(resolution, 'vod').concat([resolution]); + : (0, ffprobe_utils_1.computeResolutionsToTranscode)(resolution, 'vod').concat([resolution]); for (const resolution of resolutionsEnabled) { dataInput.push({ type: 'new-resolution-to-hls', @@ -85,7 +85,7 @@ function run() { video.state = 2; yield video.save(); for (const d of dataInput) { - yield video_2.addTranscodingJob(d, {}); + yield (0, video_2.addTranscodingJob)(d, {}); console.log('Transcoding job for video %s created.', video.uuid); } }); diff --git a/dist/scripts/generate-code-contributors.js b/dist/scripts/generate-code-contributors.js index 512763ee..011aab4e 100644 --- a/dist/scripts/generate-code-contributors.js +++ b/dist/scripts/generate-code-contributors.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const extra_utils_1 = require("@shared/extra-utils"); run() .then(() => process.exit(0)) @@ -11,7 +11,7 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const blacklist = getContributorsBlacklist(); { let contributors = yield getGitContributors(); @@ -50,7 +50,7 @@ function run() { }); } function getGitContributors() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const output = yield extra_utils_1.CLICommand.exec(`git --no-pager shortlog -sn < /dev/tty | sed 's/^\\s\\+[0-9]\\+\\s\\+//g'`); return output.split('\n') .filter(l => !!l) diff --git a/dist/scripts/i18n/create-custom-files.js b/dist/scripts/i18n/create-custom-files.js index bf14ae73..4efe0e4c 100644 --- a/dist/scripts/i18n/create-custom-files.js +++ b/dist/scripts/i18n/create-custom-files.js @@ -7,8 +7,8 @@ const path_1 = require("path"); const register_ts_paths_1 = require("../../server/helpers/register-ts-paths"); const constants_1 = require("../../server/initializers/constants"); const i18n_1 = require("../../shared/core-utils/i18n"); -register_ts_paths_1.registerTSPaths(); -const videojs = require(path_1.join(__dirname, '../../../client/src/locale/videojs.en-US.json')); +(0, register_ts_paths_1.registerTSPaths)(); +const videojs = require((0, path_1.join)(__dirname, '../../../client/src/locale/videojs.en-US.json')); const playerKeys = { 'Quality': 'Quality', 'Auto': 'Auto', @@ -47,13 +47,13 @@ const playerKeys = { }; Object.assign(playerKeys, videojs); const serverKeys = {}; -lodash_1.values(constants_1.VIDEO_CATEGORIES) - .concat(lodash_1.values(constants_1.VIDEO_LICENCES)) - .concat(lodash_1.values(constants_1.VIDEO_PRIVACIES)) - .concat(lodash_1.values(constants_1.VIDEO_STATES)) - .concat(lodash_1.values(constants_1.VIDEO_IMPORT_STATES)) - .concat(lodash_1.values(constants_1.VIDEO_PLAYLIST_PRIVACIES)) - .concat(lodash_1.values(constants_1.VIDEO_PLAYLIST_TYPES)) +(0, lodash_1.values)(constants_1.VIDEO_CATEGORIES) + .concat((0, lodash_1.values)(constants_1.VIDEO_LICENCES)) + .concat((0, lodash_1.values)(constants_1.VIDEO_PRIVACIES)) + .concat((0, lodash_1.values)(constants_1.VIDEO_STATES)) + .concat((0, lodash_1.values)(constants_1.VIDEO_IMPORT_STATES)) + .concat((0, lodash_1.values)(constants_1.VIDEO_PLAYLIST_PRIVACIES)) + .concat((0, lodash_1.values)(constants_1.VIDEO_PLAYLIST_TYPES)) .concat([ 'This video does not exist.', 'We cannot fetch the video. Please try again later.', @@ -71,7 +71,7 @@ Object.assign(serverKeys, { Unknown: 'Unknown' }); const languageKeys = {}; -const languages = constants_1.buildLanguages(); +const languages = (0, constants_1.buildLanguages)(); Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k]; }); Object.assign(serverKeys, languageKeys); writeAll().catch(err => { @@ -79,19 +79,19 @@ writeAll().catch(err => { process.exit(-1); }); function writeAll() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const localePath = path_1.join(__dirname, '../../../client/src/locale'); - yield fs_extra_1.writeJSON(path_1.join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 }); - yield fs_extra_1.writeJSON(path_1.join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const localePath = (0, path_1.join)(__dirname, '../../../client/src/locale'); + yield (0, fs_extra_1.writeJSON)((0, path_1.join)(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 }); + yield (0, fs_extra_1.writeJSON)((0, path_1.join)(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 }); for (const key of Object.keys(i18n_1.I18N_LOCALES)) { - const playerJsonPath = path_1.join(localePath, `player.${key}.json`); + const playerJsonPath = (0, path_1.join)(localePath, `player.${key}.json`); const translatedPlayer = require(playerJsonPath); const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer); - yield fs_extra_1.writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 }); - const serverJsonPath = path_1.join(localePath, `server.${key}.json`); + yield (0, fs_extra_1.writeJSON)(playerJsonPath, newTranslatedPlayer, { spaces: 4 }); + const serverJsonPath = (0, path_1.join)(localePath, `server.${key}.json`); const translatedServer = require(serverJsonPath); const newTranslatedServer = Object.assign({}, serverKeys, translatedServer); - yield fs_extra_1.writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 }); + yield (0, fs_extra_1.writeJSON)(serverJsonPath, newTranslatedServer, { spaces: 4 }); } }); } diff --git a/dist/scripts/migrations/peertube-2.1.js b/dist/scripts/migrations/peertube-2.1.js index bed00327..fc6d3424 100644 --- a/dist/scripts/migrations/peertube-2.1.js +++ b/dist/scripts/migrations/peertube-2.1.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const database_1 = require("../../server/initializers/database"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const path_1 = require("path"); const constants_1 = require("@server/initializers/constants"); const fs_extra_1 = require("fs-extra"); const webtorrent_1 = require("@server/helpers/webtorrent"); const config_1 = require("@server/initializers/config"); -const parse_torrent_1 = tslib_1.__importDefault(require("parse-torrent")); +const parse_torrent_1 = (0, tslib_1.__importDefault)(require("parse-torrent")); const logger_1 = require("@server/helpers/logger"); run() .then(() => process.exit(0)) @@ -19,9 +19,9 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating torrents and updating database for HSL files.'); - yield database_1.initDatabaseModels(true); + yield (0, database_1.initDatabaseModels)(true); const query = 'select "videoFile".id as id, "videoFile".resolution as resolution, "video".uuid as uuid from "videoFile" ' + 'inner join "videoStreamingPlaylist" ON "videoStreamingPlaylist".id = "videoFile"."videoStreamingPlaylistId" ' + 'inner join video ON video.id = "videoStreamingPlaylist"."videoId" ' + @@ -32,9 +32,9 @@ function run() { const res = yield database_1.sequelizeTypescript.query(query, options); for (const row of res) { const videoFilename = `${row['uuid']}-${row['resolution']}-fragmented.mp4`; - const videoFilePath = path_1.join(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, row['uuid'], videoFilename); + const videoFilePath = (0, path_1.join)(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, row['uuid'], videoFilename); logger_1.logger.info('Processing %s.', videoFilePath); - if (!(yield fs_extra_1.pathExists(videoFilePath))) { + if (!(yield (0, fs_extra_1.pathExists)(videoFilePath))) { console.warn('Cannot generate torrent of %s: file does not exist.', videoFilePath); continue; } @@ -45,15 +45,15 @@ function run() { [constants_1.WEBSERVER.WS + '://' + constants_1.WEBSERVER.HOSTNAME + ':' + constants_1.WEBSERVER.PORT + '/tracker/socket'], [constants_1.WEBSERVER.URL + '/tracker/announce'] ], - urlList: [constants_1.WEBSERVER.URL + path_1.join(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, row['uuid'], videoFilename)] + urlList: [constants_1.WEBSERVER.URL + (0, path_1.join)(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, row['uuid'], videoFilename)] }; - const torrent = yield webtorrent_1.createTorrentPromise(videoFilePath, createTorrentOptions); + const torrent = yield (0, webtorrent_1.createTorrentPromise)(videoFilePath, createTorrentOptions); const torrentName = `${row['uuid']}-${row['resolution']}-hls.torrent`; - const filePath = path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, torrentName); - yield fs_extra_1.writeFile(filePath, torrent); - const parsedTorrent = parse_torrent_1.default(torrent); + const filePath = (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, torrentName); + yield (0, fs_extra_1.writeFile)(filePath, torrent); + const parsedTorrent = (0, parse_torrent_1.default)(torrent); const infoHash = parsedTorrent.infoHash; - const stats = yield fs_extra_1.stat(videoFilePath); + const stats = yield (0, fs_extra_1.stat)(videoFilePath); const size = stats.size; const queryUpdate = 'UPDATE "videoFile" SET "infoHash" = ?, "size" = ? WHERE id = ?'; const options = { diff --git a/dist/scripts/parse-log.js b/dist/scripts/parse-log.js index 19712869..8cf2770a 100644 --- a/dist/scripts/parse-log.js +++ b/dist/scripts/parse-log.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const commander_1 = require("commander"); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const readline_1 = require("readline"); -const winston = tslib_1.__importStar(require("winston")); +const winston = (0, tslib_1.__importStar)(require("winston")); const logger_1 = require("../server/helpers/logger"); const config_1 = require("../server/initializers/config"); const util_1 = require("util"); @@ -39,7 +39,7 @@ const loggerFormat = winston.format.printf((info) => { additionalInfos = ' ' + additionalInfos; if (info.sql) { if (config_1.CONFIG.LOG.PRETTIFY_SQL) { - additionalInfos += '\n' + sql_formatter_1.format(info.sql, { + additionalInfos += '\n' + (0, sql_formatter_1.format)(info.sql, { language: 'sql', indent: ' ' }); @@ -55,7 +55,7 @@ const logger = winston.createLogger({ new winston.transports.Console({ level: options.level || 'debug', stderrLevels: [], - format: winston.format.combine(winston.format.splat(), logger_1.labelFormatter(), winston.format.colorize(), loggerFormat) + format: winston.format.combine(winston.format.splat(), (0, logger_1.labelFormatter)(), winston.format.colorize(), loggerFormat) }) ], exitOnError: true @@ -70,14 +70,14 @@ run() .then(() => process.exit(0)) .catch(err => console.error(err)); function run() { - return new Promise((res) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return new Promise((res) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const files = yield getFiles(); for (const file of files) { if (file === 'peertube-audit.log') continue; console.log('Opening %s.', file); - const stream = fs_extra_1.createReadStream(file); - const rl = readline_1.createInterface({ + const stream = (0, fs_extra_1.createReadStream)(file); + const rl = (0, readline_1.createInterface)({ input: stream }); rl.on('line', line => { @@ -93,7 +93,7 @@ function run() { logLevels[log.level](log); } catch (err) { - console.error('Cannot parse line.', util_1.inspect(line)); + console.error('Cannot parse line.', (0, util_1.inspect)(line)); throw err; } }); @@ -102,18 +102,18 @@ function run() { })); } function getNewestFile(files, basePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const sorted = yield logger_1.mtimeSortFilesDesc(files, basePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const sorted = yield (0, logger_1.mtimeSortFilesDesc)(files, basePath); return (sorted.length > 0) ? sorted[0].file : ''; }); } function getFiles() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (options.files) return options.files; - const logFiles = yield fs_extra_1.readdir(config_1.CONFIG.STORAGE.LOG_DIR); + const logFiles = yield (0, fs_extra_1.readdir)(config_1.CONFIG.STORAGE.LOG_DIR); const filename = yield getNewestFile(logFiles, config_1.CONFIG.STORAGE.LOG_DIR); - return [path_1.join(config_1.CONFIG.STORAGE.LOG_DIR, filename)]; + return [(0, path_1.join)(config_1.CONFIG.STORAGE.LOG_DIR, filename)]; }); } function toTimeFormat(time) { diff --git a/dist/scripts/plugin/install.js b/dist/scripts/plugin/install.js index d1bd0454..8b110b2d 100644 --- a/dist/scripts/plugin/install.js +++ b/dist/scripts/plugin/install.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const database_1 = require("../../server/initializers/database"); const commander_1 = require("commander"); const plugin_manager_1 = require("../../server/lib/plugins/plugin-manager"); @@ -17,7 +17,7 @@ if (!options.npmName && !options.pluginPath) { console.error('You need to specify a plugin name with the desired version, or a plugin path.'); process.exit(-1); } -if (options.pluginPath && !path_1.isAbsolute(options.pluginPath)) { +if (options.pluginPath && !(0, path_1.isAbsolute)(options.pluginPath)) { console.error('Plugin path should be absolute.'); process.exit(-1); } @@ -28,8 +28,8 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); const toInstall = options.npmName || options.pluginPath; yield plugin_manager_1.PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath); }); diff --git a/dist/scripts/plugin/uninstall.js b/dist/scripts/plugin/uninstall.js index fe319e39..646864c8 100644 --- a/dist/scripts/plugin/uninstall.js +++ b/dist/scripts/plugin/uninstall.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const database_1 = require("../../server/initializers/database"); const commander_1 = require("commander"); const plugin_manager_1 = require("../../server/lib/plugins/plugin-manager"); @@ -21,8 +21,8 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); const toUninstall = options.npmName; yield plugin_manager_1.PluginManager.Instance.uninstall(toUninstall); }); diff --git a/dist/scripts/print-transcode-command.js b/dist/scripts/print-transcode-command.js index f4779f54..fa2fc464 100644 --- a/dist/scripts/print-transcode-command.js +++ b/dist/scripts/print-transcode-command.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const commander_1 = require("commander"); -const fluent_ffmpeg_1 = tslib_1.__importDefault(require("fluent-ffmpeg")); +const fluent_ffmpeg_1 = (0, tslib_1.__importDefault)(require("fluent-ffmpeg")); const ffmpeg_utils_1 = require("@server/helpers/ffmpeg-utils"); const process_1 = require("process"); const video_transcoding_profiles_1 = require("@server/lib/transcoding/video-transcoding-profiles"); @@ -25,7 +25,7 @@ commander_1.program }) .parse(process.argv); function run(path, cmd) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { type: 'video', inputPath: path, @@ -35,13 +35,13 @@ function run(path, cmd) { resolution: +cmd.resolution, isPortraitMode: false }; - let command = fluent_ffmpeg_1.default(options.inputPath) + let command = (0, fluent_ffmpeg_1.default)(options.inputPath) .output(options.outputPath); - command = yield ffmpeg_utils_1.buildx264VODCommand(command, options); + command = yield (0, ffmpeg_utils_1.buildx264VODCommand)(command, options); command.on('start', (cmdline) => { console.log(cmdline); - process_1.exit(); + (0, process_1.exit)(); }); - yield ffmpeg_utils_1.runCommand({ command }); + yield (0, ffmpeg_utils_1.runCommand)({ command }); }); } diff --git a/dist/scripts/prune-storage.js b/dist/scripts/prune-storage.js index 996f71b0..343c2d17 100644 --- a/dist/scripts/prune-storage.js +++ b/dist/scripts/prune-storage.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const prompt_1 = require("prompt"); const path_1 = require("path"); const config_1 = require("../server/initializers/config"); @@ -24,18 +24,18 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const dirs = lodash_1.values(config_1.CONFIG.STORAGE); - if (lodash_1.uniq(dirs).length !== dirs.length) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const dirs = (0, lodash_1.values)(config_1.CONFIG.STORAGE); + if ((0, lodash_1.uniq)(dirs).length !== dirs.length) { console.error('Cannot prune storage because you put multiple storage keys in the same directory.'); process.exit(0); } - yield database_1.initDatabaseModels(true); + yield (0, database_1.initDatabaseModels)(true); let toDelete = []; console.log('Detecting files to remove, it could take a while...'); toDelete = toDelete.concat(yield pruneDirectory(config_1.CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()), yield pruneDirectory(config_1.CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()), yield pruneDirectory(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), yield pruneDirectory(config_1.CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, 2)), yield pruneDirectory(config_1.CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, 1)), yield pruneDirectory(config_1.CONFIG.STORAGE.ACTOR_IMAGES, doesActorImageExist)); - const tmpFiles = yield fs_extra_1.readdir(config_1.CONFIG.STORAGE.TMP_DIR); - toDelete = toDelete.concat(tmpFiles.map(t => path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, t))); + const tmpFiles = yield (0, fs_extra_1.readdir)(config_1.CONFIG.STORAGE.TMP_DIR); + toDelete = toDelete.concat(tmpFiles.map(t => (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, t))); if (toDelete.length === 0) { console.log('No files to delete.'); return; @@ -45,7 +45,7 @@ function run() { if (res === true) { console.log('Processing delete...\n'); for (const path of toDelete) { - yield fs_extra_1.remove(path); + yield (0, fs_extra_1.remove)(path); } console.log('Done!'); } @@ -55,11 +55,11 @@ function run() { }); } function pruneDirectory(directory, existFun) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const files = yield fs_extra_1.readdir(directory); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const files = yield (0, fs_extra_1.readdir)(directory); const toDelete = []; - yield bluebird_1.map(files, (file) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const filePath = path_1.join(directory, file); + yield (0, bluebird_1.map)(files, (file) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const filePath = (0, path_1.join)(directory, file); if ((yield existFun(filePath)) !== true) { toDelete.push(filePath); } @@ -68,14 +68,14 @@ function pruneDirectory(directory, existFun) { }); } function doesWebTorrentFileExist() { - return (filePath) => video_file_1.VideoFileModel.doesOwnedWebTorrentVideoFileExist(path_1.basename(filePath)); + return (filePath) => video_file_1.VideoFileModel.doesOwnedWebTorrentVideoFileExist((0, path_1.basename)(filePath)); } function doesTorrentFileExist() { - return (filePath) => video_file_1.VideoFileModel.doesOwnedTorrentFileExist(path_1.basename(filePath)); + return (filePath) => video_file_1.VideoFileModel.doesOwnedTorrentFileExist((0, path_1.basename)(filePath)); } function doesThumbnailExist(keepOnlyOwned, type) { - return (filePath) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const thumbnail = yield thumbnail_1.ThumbnailModel.loadByFilename(path_1.basename(filePath), type); + return (filePath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const thumbnail = yield thumbnail_1.ThumbnailModel.loadByFilename((0, path_1.basename)(filePath), type); if (!thumbnail) return false; if (keepOnlyOwned) { @@ -87,18 +87,18 @@ function doesThumbnailExist(keepOnlyOwned, type) { }); } function doesActorImageExist(filePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const image = yield actor_image_1.ActorImageModel.loadByName(path_1.basename(filePath)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const image = yield actor_image_1.ActorImageModel.loadByName((0, path_1.basename)(filePath)); return !!image; }); } function doesRedundancyExist(filePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const isPlaylist = (yield fs_extra_1.stat(filePath)).isDirectory(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const isPlaylist = (yield (0, fs_extra_1.stat)(filePath)).isDirectory(); if (isPlaylist) { if (filePath === constants_1.HLS_REDUNDANCY_DIRECTORY) return true; - const uuid = utils_1.getUUIDFromFilename(filePath); + const uuid = (0, utils_1.getUUIDFromFilename)(filePath); const video = yield video_1.VideoModel.loadWithFiles(uuid); if (!video) return false; @@ -108,7 +108,7 @@ function doesRedundancyExist(filePath) { const redundancy = yield video_redundancy_1.VideoRedundancyModel.loadLocalByStreamingPlaylistId(p.id); return !!redundancy; } - const file = yield video_file_1.VideoFileModel.loadByFilename(path_1.basename(filePath)); + const file = yield video_file_1.VideoFileModel.loadByFilename((0, path_1.basename)(filePath)); if (!file) return false; const redundancy = yield video_redundancy_1.VideoRedundancyModel.loadLocalByFileId(file.id); @@ -116,9 +116,9 @@ function doesRedundancyExist(filePath) { }); } function askConfirmation() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return new Promise((res, rej) => { - prompt_1.start(); + (0, prompt_1.start)(); const schema = { properties: { confirm: { @@ -131,7 +131,7 @@ function askConfirmation() { } } }; - prompt_1.get(schema, function (err, result) { + (0, prompt_1.get)(schema, function (err, result) { var _a; if (err) return rej(err); diff --git a/dist/scripts/regenerate-thumbnails.js b/dist/scripts/regenerate-thumbnails.js index eaeadf24..e229d74c 100644 --- a/dist/scripts/regenerate-thumbnails.js +++ b/dist/scripts/regenerate-thumbnails.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const bluebird_1 = require("bluebird"); const commander_1 = require("commander"); const fs_extra_1 = require("fs-extra"); @@ -17,23 +17,23 @@ run() .then(() => process.exit(0)) .catch(err => console.error(err)); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); const videos = yield video_1.VideoModel.listLocal(); - yield bluebird_1.map(videos, v => { + yield (0, bluebird_1.map)(videos, v => { return processVideo(v) .catch(err => console.error('Cannot process video %s.', v.url, err)); }, { concurrency: 20 }); }); } function processVideo(videoArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadWithFiles(videoArg.id); console.log('Processing video %s.', video.name); const thumbnail = video.getMiniature(); const preview = video.getPreview(); const previewPath = preview.getPath(); - if (!(yield fs_extra_1.pathExists(previewPath))) { + if (!(yield (0, fs_extra_1.pathExists)(previewPath))) { throw new Error(`Preview ${previewPath} does not exist on disk`); } const size = { @@ -41,12 +41,12 @@ function processVideo(videoArg) { height: constants_1.THUMBNAILS_SIZE.height }; const oldPath = thumbnail.getPath(); - thumbnail.filename = image_utils_1.generateImageFilename(); + thumbnail.filename = (0, image_utils_1.generateImageFilename)(); thumbnail.width = size.width; thumbnail.height = size.height; const thumbnailPath = thumbnail.getPath(); - yield image_utils_1.processImage(previewPath, thumbnailPath, size, true); + yield (0, image_utils_1.processImage)(previewPath, thumbnailPath, size, true); yield thumbnail.save(); - yield fs_extra_1.remove(oldPath); + yield (0, fs_extra_1.remove)(oldPath); }); } diff --git a/dist/scripts/reset-password.js b/dist/scripts/reset-password.js index 8ed0d29a..3c93a6c7 100644 --- a/dist/scripts/reset-password.js +++ b/dist/scripts/reset-password.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const commander_1 = require("commander"); const database_1 = require("../server/initializers/database"); const user_1 = require("../server/models/user/user"); @@ -14,7 +14,7 @@ if (options.user === undefined) { console.error('All parameters are mandatory.'); process.exit(-1); } -database_1.initDatabaseModels(true) +(0, database_1.initDatabaseModels)(true) .then(() => { return user_1.UserModel.loadByUsername(options.user); }) @@ -37,7 +37,7 @@ database_1.initDatabaseModels(true) }); console.log('New password?'); rl.on('line', function (password) { - if (!users_1.isUserPasswordValid(password)) { + if (!(0, users_1.isUserPasswordValid)(password)) { console.error('New password is invalid.'); process.exit(-1); } diff --git a/dist/scripts/update-host.js b/dist/scripts/update-host.js index 22228fad..0bf9b90c 100644 --- a/dist/scripts/update-host.js +++ b/dist/scripts/update-host.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("../server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const constants_1 = require("../server/initializers/constants"); const actor_follow_1 = require("../server/models/actor/actor-follow"); const video_1 = require("../server/models/video/video"); @@ -22,9 +22,9 @@ run() process.exit(-1); }); function run() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield database_1.initDatabaseModels(true); - const serverAccount = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, database_1.initDatabaseModels)(true); + const serverAccount = yield (0, application_1.getServerActor)(); { const res = yield actor_follow_1.ActorFollowModel.listAcceptedFollowingUrlsForApi([serverAccount.id], undefined); const hasFollowing = res.total > 0; @@ -50,8 +50,8 @@ function run() { continue; console.log('Updating actor ' + actor.url); const newUrl = actor.Account - ? url_1.getLocalAccountActivityPubUrl(actor.preferredUsername) - : url_1.getLocalVideoChannelActivityPubUrl(actor.preferredUsername); + ? (0, url_1.getLocalAccountActivityPubUrl)(actor.preferredUsername) + : (0, url_1.getLocalVideoChannelActivityPubUrl)(actor.preferredUsername); actor.url = newUrl; actor.inboxUrl = newUrl + '/inbox'; actor.outboxUrl = newUrl + '/outbox'; @@ -68,7 +68,7 @@ function run() { if (videoShare.Video.isOwned() === false) continue; console.log('Updating video share ' + videoShare.url); - videoShare.url = url_1.getLocalVideoAnnounceActivityPubUrl(videoShare.Actor, videoShare.Video); + videoShare.url = (0, url_1.getLocalVideoAnnounceActivityPubUrl)(videoShare.Actor, videoShare.Video); yield videoShare.save(); } console.log('Updating video comments.'); @@ -91,7 +91,7 @@ function run() { if (comment.isOwned() === false) continue; console.log('Updating comment ' + comment.url); - comment.url = url_1.getLocalVideoCommentActivityPubUrl(comment.Video, comment); + comment.url = (0, url_1.getLocalVideoCommentActivityPubUrl)(comment.Video, comment); yield comment.save(); } console.log('Updating video and torrent files.'); @@ -99,17 +99,17 @@ function run() { for (const localVideo of localVideos) { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(localVideo.id); console.log('Updating video ' + video.uuid); - video.url = url_1.getLocalVideoActivityPubUrl(video); + video.url = (0, url_1.getLocalVideoActivityPubUrl)(video); yield video.save(); for (const file of video.VideoFiles) { console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid); - yield webtorrent_1.updateTorrentUrls(video, file); + yield (0, webtorrent_1.updateTorrentUrls)(video, file); yield file.save(); } const playlist = video.getHLSPlaylist(); for (const file of ((playlist === null || playlist === void 0 ? void 0 : playlist.VideoFiles) || [])) { console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid); - yield webtorrent_1.updateTorrentUrls(video, file); + yield (0, webtorrent_1.updateTorrentUrls)(video, file); yield file.save(); } } diff --git a/dist/server.js b/dist/server.js index a3823170..fd3456f6 100644 --- a/dist/server.js +++ b/dist/server.js @@ -2,38 +2,38 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const register_ts_paths_1 = require("./server/helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); const core_utils_1 = require("./server/helpers/core-utils"); -if (core_utils_1.isTestInstance()) { +if ((0, core_utils_1.isTestInstance)()) { require('source-map-support').install(); } -const express_1 = tslib_1.__importDefault(require("express")); -const morgan_1 = tslib_1.__importStar(require("morgan")); -const cors_1 = tslib_1.__importDefault(require("cors")); -const cookie_parser_1 = tslib_1.__importDefault(require("cookie-parser")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const morgan_1 = (0, tslib_1.__importStar)(require("morgan")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const cookie_parser_1 = (0, tslib_1.__importDefault)(require("cookie-parser")); const helmet_1 = require("helmet"); const useragent_1 = require("useragent"); -const ip_anonymize_1 = tslib_1.__importDefault(require("ip-anonymize")); +const ip_anonymize_1 = (0, tslib_1.__importDefault)(require("ip-anonymize")); const commander_1 = require("commander"); process.title = 'peertube'; -const app = express_1.default().disable("x-powered-by"); +const app = (0, express_1.default)().disable("x-powered-by"); const checker_before_init_1 = require("./server/initializers/checker-before-init"); const config_1 = require("./server/initializers/config"); const constants_1 = require("./server/initializers/constants"); const logger_1 = require("./server/helpers/logger"); -const missed = checker_before_init_1.checkMissedConfig(); +const missed = (0, checker_before_init_1.checkMissedConfig)(); if (missed.length !== 0) { logger_1.logger.error('Your configuration files miss keys: ' + missed); process.exit(-1); } -checker_before_init_1.checkFFmpeg(config_1.CONFIG) +(0, checker_before_init_1.checkFFmpeg)(config_1.CONFIG) .catch(err => { logger_1.logger.error('Error in ffmpeg check.', { err }); process.exit(-1); }); -checker_before_init_1.checkNodeVersion(); +(0, checker_before_init_1.checkNodeVersion)(); const checker_after_init_1 = require("./server/initializers/checker-after-init"); -const errorMessage = checker_after_init_1.checkConfig(); +const errorMessage = (0, checker_after_init_1.checkConfig)(); if (errorMessage !== null) { throw new Error(errorMessage); } @@ -43,21 +43,21 @@ if (config_1.CONFIG.CSP.ENABLED) { app.use(csp_1.baseCSP); } if (config_1.CONFIG.SECURITY.FRAMEGUARD.ENABLED) { - app.use(helmet_1.frameguard({ + app.use((0, helmet_1.frameguard)({ action: 'deny' })); } const database_1 = require("./server/initializers/database"); -database_1.checkDatabaseConnectionOrDie(); +(0, database_1.checkDatabaseConnectionOrDie)(); const migrator_1 = require("./server/initializers/migrator"); -migrator_1.migrate() - .then(() => database_1.initDatabaseModels(false)) +(0, migrator_1.migrate)() + .then(() => (0, database_1.initDatabaseModels)(false)) .then(() => startApplication()) .catch(err => { logger_1.logger.error('Cannot start application.', { err }); process.exit(-1); }); -constants_1.loadLanguages(); +(0, constants_1.loadLanguages)(); const installer_1 = require("./server/initializers/installer"); const emailer_1 = require("./server/lib/emailer"); const job_queue_1 = require("./server/lib/job-queue"); @@ -72,6 +72,7 @@ const remove_old_jobs_scheduler_1 = require("./server/lib/schedulers/remove-old- const update_videos_scheduler_1 = require("./server/lib/schedulers/update-videos-scheduler"); const youtube_dl_update_scheduler_1 = require("./server/lib/schedulers/youtube-dl-update-scheduler"); const videos_redundancy_scheduler_1 = require("./server/lib/schedulers/videos-redundancy-scheduler"); +const images_redundancy_scheduler_1 = require("./server/lib/schedulers/images-redundancy-scheduler"); const remove_old_history_scheduler_1 = require("./server/lib/schedulers/remove-old-history-scheduler"); const auto_follow_index_instances_1 = require("./server/lib/schedulers/auto-follow-index-instances"); const remove_dangling_resumable_uploads_scheduler_1 = require("./server/lib/schedulers/remove-dangling-resumable-uploads-scheduler"); @@ -90,26 +91,26 @@ commander_1.program .option('--no-client', 'Start PeerTube without client interface') .option('--no-plugins', 'Start PeerTube without plugins/themes enabled') .parse(process.argv); -if (core_utils_1.isTestInstance()) { - app.use(cors_1.default({ +if ((0, core_utils_1.isTestInstance)()) { + app.use((0, cors_1.default)({ origin: '*', exposedHeaders: 'Retry-After', credentials: true })); } -morgan_1.token('remote-addr', (req) => { +(0, morgan_1.token)('remote-addr', (req) => { if (config_1.CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { - return ip_anonymize_1.default(req.ip, 16, 16); + return (0, ip_anonymize_1.default)(req.ip, 16, 16); } return req.ip; }); -morgan_1.token('user-agent', (req) => { +(0, morgan_1.token)('user-agent', (req) => { if (req.get('DNT') === '1') { - return useragent_1.parse(req.get('user-agent')).family; + return (0, useragent_1.parse)(req.get('user-agent')).family; } return req.get('user-agent'); }); -app.use(morgan_1.default('combined', { +app.use((0, morgan_1.default)('combined', { stream: { write: (str) => logger_1.logger.info(str.trim(), { tags: ['http'] }) }, @@ -121,7 +122,7 @@ app.use(express_1.default.json({ type: ['application/json', 'application/*+json'], limit: '500kb', verify: (req, res, buf) => { - const valid = peertube_crypto_1.isHTTPSignatureDigestValid(buf, req); + const valid = (0, peertube_crypto_1.isHTTPSignatureDigestValid)(buf, req); if (valid !== true) { res.fail({ status: http_error_codes_1.HttpStatusCode.FORBIDDEN_403, @@ -130,7 +131,7 @@ app.use(express_1.default.json({ } } })); -app.use(cookie_parser_1.default()); +app.use((0, cookie_parser_1.default)()); app.use(dnt_1.advertiseDoNotTrack); const apiRoute = '/api/' + constants_1.API_VERSION; app.use(apiRoute, controllers_1.apiRouter); @@ -164,18 +165,18 @@ app.use((err, req, res, next) => { type: err.name }); }); -const server = controllers_1.createWebsocketTrackerServer(app); +const server = (0, controllers_1.createWebsocketTrackerServer)(app); function startApplication() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const port = config_1.CONFIG.LISTEN.PORT; const hostname = config_1.CONFIG.LISTEN.HOSTNAME; - yield installer_1.installApplication(); - checker_after_init_1.checkActivityPubUrls() + yield (0, installer_1.installApplication)(); + (0, checker_after_init_1.checkActivityPubUrls)() .catch(err => { logger_1.logger.error('Error in ActivityPub URLs checker.', { err }); process.exit(-1); }); - checker_after_init_1.checkFFmpegVersion() + (0, checker_after_init_1.checkFFmpegVersion)() .catch(err => logger_1.logger.error('Cannot check ffmpeg version', { err })); emailer_1.Emailer.Instance.init(); yield Promise.all([ @@ -191,6 +192,7 @@ function startApplication() { update_videos_scheduler_1.UpdateVideosScheduler.Instance.enable(); youtube_dl_update_scheduler_1.YoutubeDlUpdateScheduler.Instance.enable(); videos_redundancy_scheduler_1.VideosRedundancyScheduler.Instance.enable(); + images_redundancy_scheduler_1.ImagesRedundancyScheduler.Instance.enable(); remove_old_history_scheduler_1.RemoveOldHistoryScheduler.Instance.enable(); remove_old_views_scheduler_1.RemoveOldViewsScheduler.Instance.enable(); plugins_check_scheduler_1.PluginsCheckScheduler.Instance.enable(); @@ -199,12 +201,12 @@ function startApplication() { remove_dangling_resumable_uploads_scheduler_1.RemoveDanglingResumableUploadsScheduler.Instance.enable(); redis_1.Redis.Instance.init(); peertube_socket_1.PeerTubeSocket.Instance.init(server); - hls_1.updateStreamingPlaylistsInfohashesIfNeeded() + (0, hls_1.updateStreamingPlaylistsInfohashesIfNeeded)() .catch(err => logger_1.logger.error('Cannot update streaming playlist infohashes.', { err })); live_1.LiveManager.Instance.init(); if (config_1.CONFIG.LIVE.ENABLED) live_1.LiveManager.Instance.run(); - server.listen(port, hostname, () => tslib_1.__awaiter(this, void 0, void 0, function* () { + server.listen(port, hostname, () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (cliOptions.plugins) { try { yield plugin_manager_1.PluginManager.Instance.registerPluginsAndThemes(); diff --git a/dist/server/controllers/activitypub/client.js b/dist/server/controllers/activitypub/client.js index 535a928a..8c8259f0 100644 --- a/dist/server/controllers/activitypub/client.js +++ b/dist/server/controllers/activitypub/client.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.activityPubClientRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const application_1 = require("@server/models/application/application"); const activitypub_1 = require("../../helpers/activitypub"); const constants_1 = require("../../initializers/constants"); @@ -27,60 +27,60 @@ const video_share_1 = require("../../models/video/video-share"); const utils_1 = require("./utils"); const activityPubClientRouter = express_1.default.Router(); exports.activityPubClientRouter = activityPubClientRouter; -activityPubClientRouter.use(cors_1.default()); -activityPubClientRouter.get(['/accounts?/:name', '/accounts?/:name/video-channels', '/a/:name', '/a/:name/video-channels'], middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localAccountValidator), accountController); -activityPubClientRouter.get('/accounts?/:name/followers', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localAccountValidator), middlewares_1.asyncMiddleware(accountFollowersController)); -activityPubClientRouter.get('/accounts?/:name/following', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localAccountValidator), middlewares_1.asyncMiddleware(accountFollowingController)); -activityPubClientRouter.get('/accounts?/:name/playlists', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localAccountValidator), middlewares_1.asyncMiddleware(accountPlaylistsController)); -activityPubClientRouter.get('/accounts?/:name/likes/:videoId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(validators_1.getAccountVideoRateValidatorFactory('like')), getAccountVideoRateFactory('like')); -activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(validators_1.getAccountVideoRateValidatorFactory('dislike')), getAccountVideoRateFactory('dislike')); -activityPubClientRouter.get(['/videos/watch/:id', '/w/:id'], middlewares_1.executeIfActivityPub, cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS), middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('all')), middlewares_1.asyncMiddleware(videoController)); -activityPubClientRouter.get('/videos/watch/:id/activity', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('all')), middlewares_1.asyncMiddleware(videoController)); -activityPubClientRouter.get('/videos/watch/:id/announces', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('only-immutable-attributes')), middlewares_1.asyncMiddleware(videoAnnouncesController)); -activityPubClientRouter.get('/videos/watch/:id/announces/:actorId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosShareValidator), middlewares_1.asyncMiddleware(videoAnnounceController)); -activityPubClientRouter.get('/videos/watch/:id/likes', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('only-immutable-attributes')), middlewares_1.asyncMiddleware(videoLikesController)); -activityPubClientRouter.get('/videos/watch/:id/dislikes', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('only-immutable-attributes')), middlewares_1.asyncMiddleware(videoDislikesController)); -activityPubClientRouter.get('/videos/watch/:id/comments', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('only-immutable-attributes')), middlewares_1.asyncMiddleware(videoCommentsController)); -activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(validators_1.videoCommentGetValidator), middlewares_1.asyncMiddleware(videoCommentController)); -activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(validators_1.videoCommentGetValidator), middlewares_1.asyncMiddleware(videoCommentController)); -activityPubClientRouter.get(['/video-channels/:name', '/video-channels/:name/videos', '/c/:name', '/c/:name/videos'], middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localVideoChannelValidator), videoChannelController); -activityPubClientRouter.get('/video-channels/:name/followers', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localVideoChannelValidator), middlewares_1.asyncMiddleware(videoChannelFollowersController)); -activityPubClientRouter.get('/video-channels/:name/following', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localVideoChannelValidator), middlewares_1.asyncMiddleware(videoChannelFollowingController)); -activityPubClientRouter.get('/video-channels/:name/playlists', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(middlewares_1.localVideoChannelValidator), middlewares_1.asyncMiddleware(videoChannelPlaylistsController)); -activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(redundancy_1.videoFileRedundancyGetValidator), middlewares_1.asyncMiddleware(videoRedundancyController)); -activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(redundancy_1.videoPlaylistRedundancyGetValidator), middlewares_1.asyncMiddleware(videoRedundancyController)); -activityPubClientRouter.get(['/video-playlists/:playlistId', '/videos/watch/playlist/:playlistId', '/w/p/:playlistId'], middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsGetValidator('all')), middlewares_1.asyncMiddleware(videoPlaylistController)); -activityPubClientRouter.get('/video-playlists/:playlistId/videos/:playlistElementId', middlewares_1.executeIfActivityPub, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistElementAPGetValidator), videoPlaylistElementController); +activityPubClientRouter.use((0, cors_1.default)()); +activityPubClientRouter.get(['/accounts?/:name', '/accounts?/:name/video-channels', '/a/:name', '/a/:name/video-channels'], middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localAccountValidator), accountController); +activityPubClientRouter.get('/accounts?/:name/followers', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localAccountValidator), (0, middlewares_1.asyncMiddleware)(accountFollowersController)); +activityPubClientRouter.get('/accounts?/:name/following', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localAccountValidator), (0, middlewares_1.asyncMiddleware)(accountFollowingController)); +activityPubClientRouter.get('/accounts?/:name/playlists', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localAccountValidator), (0, middlewares_1.asyncMiddleware)(accountPlaylistsController)); +activityPubClientRouter.get('/accounts?/:name/likes/:videoId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, validators_1.getAccountVideoRateValidatorFactory)('like')), getAccountVideoRateFactory('like')); +activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, validators_1.getAccountVideoRateValidatorFactory)('dislike')), getAccountVideoRateFactory('dislike')); +activityPubClientRouter.get(['/videos/watch/:id', '/w/:id'], middlewares_1.executeIfActivityPub, (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS), (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('all')), (0, middlewares_1.asyncMiddleware)(videoController)); +activityPubClientRouter.get('/videos/watch/:id/activity', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('all')), (0, middlewares_1.asyncMiddleware)(videoController)); +activityPubClientRouter.get('/videos/watch/:id/announces', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-immutable-attributes')), (0, middlewares_1.asyncMiddleware)(videoAnnouncesController)); +activityPubClientRouter.get('/videos/watch/:id/announces/:actorId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosShareValidator), (0, middlewares_1.asyncMiddleware)(videoAnnounceController)); +activityPubClientRouter.get('/videos/watch/:id/likes', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-immutable-attributes')), (0, middlewares_1.asyncMiddleware)(videoLikesController)); +activityPubClientRouter.get('/videos/watch/:id/dislikes', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-immutable-attributes')), (0, middlewares_1.asyncMiddleware)(videoDislikesController)); +activityPubClientRouter.get('/videos/watch/:id/comments', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-immutable-attributes')), (0, middlewares_1.asyncMiddleware)(videoCommentsController)); +activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(validators_1.videoCommentGetValidator), (0, middlewares_1.asyncMiddleware)(videoCommentController)); +activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(validators_1.videoCommentGetValidator), (0, middlewares_1.asyncMiddleware)(videoCommentController)); +activityPubClientRouter.get(['/video-channels/:name', '/video-channels/:name/videos', '/c/:name', '/c/:name/videos'], middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localVideoChannelValidator), videoChannelController); +activityPubClientRouter.get('/video-channels/:name/followers', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localVideoChannelValidator), (0, middlewares_1.asyncMiddleware)(videoChannelFollowersController)); +activityPubClientRouter.get('/video-channels/:name/following', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localVideoChannelValidator), (0, middlewares_1.asyncMiddleware)(videoChannelFollowingController)); +activityPubClientRouter.get('/video-channels/:name/playlists', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(middlewares_1.localVideoChannelValidator), (0, middlewares_1.asyncMiddleware)(videoChannelPlaylistsController)); +activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(redundancy_1.videoFileRedundancyGetValidator), (0, middlewares_1.asyncMiddleware)(videoRedundancyController)); +activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(redundancy_1.videoPlaylistRedundancyGetValidator), (0, middlewares_1.asyncMiddleware)(videoRedundancyController)); +activityPubClientRouter.get(['/video-playlists/:playlistId', '/videos/watch/playlist/:playlistId', '/w/p/:playlistId'], middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)((0, video_playlists_1.videoPlaylistsGetValidator)('all')), (0, middlewares_1.asyncMiddleware)(videoPlaylistController)); +activityPubClientRouter.get('/video-playlists/:playlistId/videos/:playlistElementId', middlewares_1.executeIfActivityPub, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistElementAPGetValidator), videoPlaylistElementController); function accountController(req, res) { const account = res.locals.account; - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(account.toActivityPubObject()), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(account.toActivityPubObject()), res); } function accountFollowersController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; const activityPubResult = yield actorFollowers(req, account.Actor); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function accountFollowingController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; const activityPubResult = yield actorFollowing(req, account.Actor); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function accountPlaylistsController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; const activityPubResult = yield actorPlaylists(req, { account }); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function videoChannelPlaylistsController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const channel = res.locals.videoChannel; const activityPubResult = yield actorPlaylists(req, { channel }); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function getAccountVideoRateFactory(rateType) { @@ -88,106 +88,106 @@ function getAccountVideoRateFactory(rateType) { const accountVideoRate = res.locals.accountVideoRate; const byActor = accountVideoRate.Account.Actor; const APObject = rateType === 'like' - ? send_1.buildLikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video) - : send_dislike_1.buildDislikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(APObject), res); + ? (0, send_1.buildLikeActivity)(accountVideoRate.url, byActor, accountVideoRate.Video) + : (0, send_dislike_1.buildDislikeActivity)(accountVideoRate.url, byActor, accountVideoRate.Video); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(APObject), res); }; } function videoController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.videoAll; if (redirectIfNotOwned(video.url, res)) return; const captions = yield video_caption_1.VideoCaptionModel.listVideoCaptions(video.id); const videoWithCaptions = Object.assign(video, { VideoCaptions: captions }); - const audience = audience_1.getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === 1); - const videoObject = audience_1.audiencify(videoWithCaptions.toActivityPubObject(), audience); + const audience = (0, audience_1.getAudience)(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === 1); + const videoObject = (0, audience_1.audiencify)(videoWithCaptions.toActivityPubObject(), audience); if (req.path.endsWith('/activity')) { - const data = send_create_1.buildCreateActivity(videoWithCaptions.url, video.VideoChannel.Account.Actor, videoObject, audience); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(data), res); + const data = (0, send_create_1.buildCreateActivity)(videoWithCaptions.url, video.VideoChannel.Account.Actor, videoObject, audience); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(data), res); } - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(videoObject), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(videoObject), res); }); } function videoAnnounceController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const share = res.locals.videoShare; if (redirectIfNotOwned(share.url, res)) return; - const { activity } = yield send_1.buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activity, 'Announce'), res); + const { activity } = yield (0, send_1.buildAnnounceWithVideoAudience)(share.Actor, share, res.locals.videoAll, undefined); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activity, 'Announce'), res); }); } function videoAnnouncesController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyImmutableVideo; if (redirectIfNotOwned(video.url, res)) return; - const handler = (start, count) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const handler = (start, count) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield video_share_1.VideoShareModel.listAndCountByVideoId(video.id, start, count); return { total: result.count, data: result.rows.map(r => r.url) }; }); - const json = yield activitypub_1.activityPubCollectionPagination(url_1.getLocalVideoSharesActivityPubUrl(video), handler, req.query.page); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + const json = yield (0, activitypub_1.activityPubCollectionPagination)((0, url_1.getLocalVideoSharesActivityPubUrl)(video), handler, req.query.page); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); }); } function videoLikesController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyImmutableVideo; if (redirectIfNotOwned(video.url, res)) return; - const json = yield videoRates(req, 'like', video, url_1.getLocalVideoLikesActivityPubUrl(video)); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + const json = yield videoRates(req, 'like', video, (0, url_1.getLocalVideoLikesActivityPubUrl)(video)); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); }); } function videoDislikesController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyImmutableVideo; if (redirectIfNotOwned(video.url, res)) return; - const json = yield videoRates(req, 'dislike', video, url_1.getLocalVideoDislikesActivityPubUrl(video)); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + const json = yield videoRates(req, 'dislike', video, (0, url_1.getLocalVideoDislikesActivityPubUrl)(video)); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); }); } function videoCommentsController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyImmutableVideo; if (redirectIfNotOwned(video.url, res)) return; - const handler = (start, count) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const handler = (start, count) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield video_comment_1.VideoCommentModel.listAndCountByVideoForAP(video, start, count); return { total: result.count, data: result.rows.map(r => r.url) }; }); - const json = yield activitypub_1.activityPubCollectionPagination(url_1.getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + const json = yield (0, activitypub_1.activityPubCollectionPagination)((0, url_1.getLocalVideoCommentsActivityPubUrl)(video), handler, req.query.page); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); }); } function videoChannelController(req, res) { const videoChannel = res.locals.videoChannel; - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(videoChannel.toActivityPubObject()), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(videoChannel.toActivityPubObject()), res); } function videoChannelFollowersController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = res.locals.videoChannel; const activityPubResult = yield actorFollowers(req, videoChannel.Actor); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function videoChannelFollowingController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = res.locals.videoChannel; const activityPubResult = yield actorFollowing(req, videoChannel.Actor); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(activityPubResult), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(activityPubResult), res); }); } function videoCommentController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoComment = res.locals.videoCommentFull; if (redirectIfNotOwned(videoComment.url, res)) return; @@ -195,41 +195,41 @@ function videoCommentController(req, res) { const isPublic = true; let videoCommentObject = videoComment.toActivityPubObject(threadParentComments); if (videoComment.Account) { - const audience = audience_1.getAudience(videoComment.Account.Actor, isPublic); - videoCommentObject = audience_1.audiencify(videoCommentObject, audience); + const audience = (0, audience_1.getAudience)(videoComment.Account.Actor, isPublic); + videoCommentObject = (0, audience_1.audiencify)(videoCommentObject, audience); if (req.path.endsWith('/activity')) { - const data = send_create_1.buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(data), res); + const data = (0, send_create_1.buildCreateActivity)(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(data), res); } } - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(videoCommentObject), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(videoCommentObject), res); }); } function videoRedundancyController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoRedundancy = res.locals.videoRedundancy; if (redirectIfNotOwned(videoRedundancy.url, res)) return; - const serverActor = yield application_1.getServerActor(); - const audience = audience_1.getAudience(serverActor); - const object = audience_1.audiencify(videoRedundancy.toActivityPubObject(), audience); + const serverActor = yield (0, application_1.getServerActor)(); + const audience = (0, audience_1.getAudience)(serverActor); + const object = (0, audience_1.audiencify)(videoRedundancy.toActivityPubObject(), audience); if (req.path.endsWith('/activity')) { - const data = send_create_1.buildCreateActivity(videoRedundancy.url, serverActor, object, audience); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(data, 'CacheFile'), res); + const data = (0, send_create_1.buildCreateActivity)(videoRedundancy.url, serverActor, object, audience); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(data, 'CacheFile'), res); } - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(object, 'CacheFile'), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(object, 'CacheFile'), res); }); } function videoPlaylistController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlist = res.locals.videoPlaylistFull; if (redirectIfNotOwned(playlist.url, res)) return; playlist.OwnerAccount = yield account_1.AccountModel.load(playlist.ownerAccountId); const json = yield playlist.toActivityPubObject(req.query.page, null); - const audience = audience_1.getAudience(playlist.OwnerAccount.Actor, playlist.privacy === 1); - const object = audience_1.audiencify(json, audience); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(object), res); + const audience = (0, audience_1.getAudience)(playlist.OwnerAccount.Actor, playlist.privacy === 1); + const object = (0, audience_1.audiencify)(json, audience); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(object), res); }); } function videoPlaylistElementController(req, res) { @@ -237,41 +237,41 @@ function videoPlaylistElementController(req, res) { if (redirectIfNotOwned(videoPlaylistElement.url, res)) return; const json = videoPlaylistElement.toActivityPubObject(); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); } function actorFollowing(req, actor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handler = (start, count) => { return actor_follow_1.ActorFollowModel.listAcceptedFollowingUrlsForApi([actor.id], undefined, start, count); }; - return activitypub_1.activityPubCollectionPagination(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); + return (0, activitypub_1.activityPubCollectionPagination)(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); }); } function actorFollowers(req, actor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handler = (start, count) => { return actor_follow_1.ActorFollowModel.listAcceptedFollowerUrlsForAP([actor.id], undefined, start, count); }; - return activitypub_1.activityPubCollectionPagination(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); + return (0, activitypub_1.activityPubCollectionPagination)(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); }); } function actorPlaylists(req, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handler = (start, count) => { return video_playlist_1.VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count); }; - return activitypub_1.activityPubCollectionPagination(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); + return (0, activitypub_1.activityPubCollectionPagination)(constants_1.WEBSERVER.URL + req.path, handler, req.query.page); }); } function videoRates(req, rateType, video, url) { - const handler = (start, count) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const handler = (start, count) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield account_video_rate_1.AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count); return { total: result.count, data: result.rows.map(r => r.url) }; }); - return activitypub_1.activityPubCollectionPagination(url, handler, req.query.page); + return (0, activitypub_1.activityPubCollectionPagination)(url, handler, req.query.page); } function redirectIfNotOwned(url, res) { if (url.startsWith(constants_1.WEBSERVER.URL) === false) { diff --git a/dist/server/controllers/activitypub/inbox.js b/dist/server/controllers/activitypub/inbox.js index 7e6de83d..180cf7a4 100644 --- a/dist/server/controllers/activitypub/inbox.js +++ b/dist/server/controllers/activitypub/inbox.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.inboxRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const inbox_manager_1 = require("@server/lib/activitypub/inbox-manager"); const http_error_codes_1 = require("../../../shared/models/http/http-error-codes"); const activity_1 = require("../../helpers/custom-validators/activitypub/activity"); @@ -11,9 +11,9 @@ const middlewares_1 = require("../../middlewares"); const activity_2 = require("../../middlewares/validators/activitypub/activity"); const inboxRouter = express_1.default.Router(); exports.inboxRouter = inboxRouter; -inboxRouter.post('/inbox', middlewares_1.signatureValidator, middlewares_1.asyncMiddleware(middlewares_1.checkSignature), middlewares_1.asyncMiddleware(activity_2.activityPubValidator), inboxController); -inboxRouter.post('/accounts/:name/inbox', middlewares_1.signatureValidator, middlewares_1.asyncMiddleware(middlewares_1.checkSignature), middlewares_1.asyncMiddleware(middlewares_1.localAccountValidator), middlewares_1.asyncMiddleware(activity_2.activityPubValidator), inboxController); -inboxRouter.post('/video-channels/:name/inbox', middlewares_1.signatureValidator, middlewares_1.asyncMiddleware(middlewares_1.checkSignature), middlewares_1.asyncMiddleware(middlewares_1.localVideoChannelValidator), middlewares_1.asyncMiddleware(activity_2.activityPubValidator), inboxController); +inboxRouter.post('/inbox', middlewares_1.signatureValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.checkSignature), (0, middlewares_1.asyncMiddleware)(activity_2.activityPubValidator), inboxController); +inboxRouter.post('/accounts/:name/inbox', middlewares_1.signatureValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.checkSignature), (0, middlewares_1.asyncMiddleware)(middlewares_1.localAccountValidator), (0, middlewares_1.asyncMiddleware)(activity_2.activityPubValidator), inboxController); +inboxRouter.post('/video-channels/:name/inbox', middlewares_1.signatureValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.checkSignature), (0, middlewares_1.asyncMiddleware)(middlewares_1.localVideoChannelValidator), (0, middlewares_1.asyncMiddleware)(activity_2.activityPubValidator), inboxController); function inboxController(req, res) { const rootActivity = req.body; let activities; @@ -27,7 +27,7 @@ function inboxController(req, res) { activities = [rootActivity]; } logger_1.logger.debug('Filtering %d activities...', activities.length); - activities = activities.filter(a => activity_1.isActivityValid(a)); + activities = activities.filter(a => (0, activity_1.isActivityValid)(a)); logger_1.logger.debug('We keep %d activities.', activities.length, { activities }); const accountOrChannel = res.locals.account || res.locals.videoChannel; logger_1.logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url); diff --git a/dist/server/controllers/activitypub/index.js b/dist/server/controllers/activitypub/index.js index 55c7d8b4..812364f0 100644 --- a/dist/server/controllers/activitypub/index.js +++ b/dist/server/controllers/activitypub/index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.activityPubRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const client_1 = require("./client"); const inbox_1 = require("./inbox"); const outbox_1 = require("./outbox"); diff --git a/dist/server/controllers/activitypub/outbox.js b/dist/server/controllers/activitypub/outbox.js index 60a26842..0ed67a75 100644 --- a/dist/server/controllers/activitypub/outbox.js +++ b/dist/server/controllers/activitypub/outbox.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.outboxRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const activitypub_1 = require("../../helpers/activitypub"); const logger_1 = require("../../helpers/logger"); const send_1 = require("../../lib/activitypub/send"); @@ -13,34 +13,34 @@ const utils_1 = require("./utils"); const activitypub_2 = require("../../middlewares/validators/activitypub"); const outboxRouter = express_1.default.Router(); exports.outboxRouter = outboxRouter; -outboxRouter.get('/accounts/:name/outbox', activitypub_2.apPaginationValidator, middlewares_1.localAccountValidator, middlewares_1.asyncMiddleware(outboxController)); -outboxRouter.get('/video-channels/:name/outbox', activitypub_2.apPaginationValidator, middlewares_1.localVideoChannelValidator, middlewares_1.asyncMiddleware(outboxController)); +outboxRouter.get('/accounts/:name/outbox', activitypub_2.apPaginationValidator, middlewares_1.localAccountValidator, (0, middlewares_1.asyncMiddleware)(outboxController)); +outboxRouter.get('/video-channels/:name/outbox', activitypub_2.apPaginationValidator, middlewares_1.localVideoChannelValidator, (0, middlewares_1.asyncMiddleware)(outboxController)); function outboxController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountOrVideoChannel = res.locals.account || res.locals.videoChannel; const actor = accountOrVideoChannel.Actor; const actorOutboxUrl = actor.url + '/outbox'; logger_1.logger.info('Receiving outbox request for %s.', actorOutboxUrl); const handler = (start, count) => buildActivities(actor, start, count); - const json = yield activitypub_1.activityPubCollectionPagination(actorOutboxUrl, handler, req.query.page, req.query.size); - return utils_1.activityPubResponse(activitypub_1.activityPubContextify(json), res); + const json = yield (0, activitypub_1.activityPubCollectionPagination)(actorOutboxUrl, handler, req.query.page, req.query.size); + return (0, utils_1.activityPubResponse)((0, activitypub_1.activityPubContextify)(json), res); }); } function buildActivities(actor, start, count) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield video_1.VideoModel.listAllAndSharedByActorForOutbox(actor.id, start, count); const activities = []; for (const video of data.data) { const byActor = video.VideoChannel.Account.Actor; - const createActivityAudience = audience_1.buildAudience([byActor.followersUrl], video.privacy === 1); + const createActivityAudience = (0, audience_1.buildAudience)([byActor.followersUrl], video.privacy === 1); if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { const videoShare = video.VideoShares[0]; - const announceActivity = send_1.buildAnnounceActivity(videoShare.url, actor, video.url, createActivityAudience); + const announceActivity = (0, send_1.buildAnnounceActivity)(videoShare.url, actor, video.url, createActivityAudience); activities.push(announceActivity); } else { const videoObject = video.toActivityPubObject(); - const createActivity = send_1.buildCreateActivity(video.url, byActor, videoObject, createActivityAudience); + const createActivity = (0, send_1.buildCreateActivity)(video.url, byActor, videoObject, createActivityAudience); activities.push(createActivity); } } diff --git a/dist/server/controllers/api/abuse.js b/dist/server/controllers/api/abuse.js index ef9effc1..adb8ffed 100644 --- a/dist/server/controllers/api/abuse.js +++ b/dist/server/controllers/api/abuse.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.abuseRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const moderation_1 = require("@server/lib/moderation"); const notifier_1 = require("@server/lib/notifier"); @@ -17,17 +17,17 @@ const middlewares_1 = require("../../middlewares"); const account_1 = require("../../models/account/account"); const abuseRouter = express_1.default.Router(); exports.abuseRouter = abuseRouter; -abuseRouter.get('/', middlewares_1.openapiOperationDoc({ operationId: 'getAbuses' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(6), middlewares_1.paginationValidator, middlewares_1.abusesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.abuseListForAdminsValidator, middlewares_1.asyncMiddleware(listAbusesForAdmins)); -abuseRouter.put('/:id', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(6), middlewares_1.asyncMiddleware(middlewares_1.abuseUpdateValidator), middlewares_1.asyncRetryTransactionMiddleware(updateAbuse)); -abuseRouter.post('/', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.abuseReportValidator), middlewares_1.asyncRetryTransactionMiddleware(reportAbuse)); -abuseRouter.delete('/:id', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(6), middlewares_1.asyncMiddleware(middlewares_1.abuseGetValidator), middlewares_1.asyncRetryTransactionMiddleware(deleteAbuse)); -abuseRouter.get('/:id/messages', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, middlewares_1.asyncRetryTransactionMiddleware(listAbuseMessages)); -abuseRouter.post('/:id/messages', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, middlewares_1.addAbuseMessageValidator, middlewares_1.asyncRetryTransactionMiddleware(addAbuseMessage)); -abuseRouter.delete('/:id/messages/:messageId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, middlewares_1.asyncMiddleware(middlewares_1.deleteAbuseMessageValidator), middlewares_1.asyncRetryTransactionMiddleware(deleteAbuseMessage)); +abuseRouter.get('/', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getAbuses' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(6), middlewares_1.paginationValidator, middlewares_1.abusesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.abuseListForAdminsValidator, (0, middlewares_1.asyncMiddleware)(listAbusesForAdmins)); +abuseRouter.put('/:id', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(6), (0, middlewares_1.asyncMiddleware)(middlewares_1.abuseUpdateValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateAbuse)); +abuseRouter.post('/', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.abuseReportValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(reportAbuse)); +abuseRouter.delete('/:id', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(6), (0, middlewares_1.asyncMiddleware)(middlewares_1.abuseGetValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(deleteAbuse)); +abuseRouter.get('/:id/messages', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(listAbuseMessages)); +abuseRouter.post('/:id/messages', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, middlewares_1.addAbuseMessageValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(addAbuseMessage)); +abuseRouter.delete('/:id/messages/:messageId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.getAbuseValidator), middlewares_1.checkAbuseValidForMessagesValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.deleteAbuseMessageValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(deleteAbuseMessage)); function listAbusesForAdmins(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.user; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield abuse_1.AbuseModel.listForAdminApi({ start: req.query.start, count: req.query.count, @@ -52,7 +52,7 @@ function listAbusesForAdmins(req, res) { }); } function updateAbuse(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuse = res.locals.abuse; let stateUpdated = false; if (req.body.moderationComment !== undefined) @@ -73,7 +73,7 @@ function updateAbuse(req, res) { }); } function deleteAbuse(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuse = res.locals.abuse; yield database_1.sequelizeTypescript.transaction(t => { return abuse.destroy({ transaction: t }); @@ -82,12 +82,12 @@ function deleteAbuse(req, res) { }); } function reportAbuse(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; const commentInstance = res.locals.videoCommentFull; const accountInstance = res.locals.account; const body = req.body; - const { id } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { id } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { var _a; const reporterAccount = yield account_1.AccountModel.load(res.locals.oauth.token.User.Account.id, t); const predefinedReasons = (_a = body.predefinedReasons) === null || _a === void 0 ? void 0 : _a.map(r => abuse_2.abusePredefinedReasonsMap[r]); @@ -98,7 +98,7 @@ function reportAbuse(req, res) { predefinedReasons }; if (body.video) { - return moderation_1.createVideoAbuse({ + return (0, moderation_1.createVideoAbuse)({ baseAbuse, videoInstance, reporterAccount, @@ -108,14 +108,14 @@ function reportAbuse(req, res) { }); } if (body.comment) { - return moderation_1.createVideoCommentAbuse({ + return (0, moderation_1.createVideoCommentAbuse)({ baseAbuse, commentInstance, reporterAccount, transaction: t }); } - return moderation_1.createAccountAbuse({ + return (0, moderation_1.createAccountAbuse)({ baseAbuse, accountInstance, reporterAccount, @@ -126,14 +126,14 @@ function reportAbuse(req, res) { }); } function listAbuseMessages(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuse = res.locals.abuse; const resultList = yield abuse_message_1.AbuseMessageModel.listForApi(abuse.id); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function addAbuseMessage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuse = res.locals.abuse; const user = res.locals.oauth.token.user; const abuseMessage = yield abuse_message_1.AbuseMessageModel.create({ @@ -153,7 +153,7 @@ function addAbuseMessage(req, res) { }); } function deleteAbuseMessage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuseMessage = res.locals.abuseMessage; yield database_1.sequelizeTypescript.transaction(t => { return abuseMessage.destroy({ transaction: t }); diff --git a/dist/server/controllers/api/accounts.js b/dist/server/controllers/api/accounts.js index 65639033..c48f5cb0 100644 --- a/dist/server/controllers/api/accounts.js +++ b/dist/server/controllers/api/accounts.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.accountsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const query_1 = require("@server/helpers/query"); const application_1 = require("@server/models/application/application"); const express_utils_1 = require("../../helpers/express-utils"); @@ -19,12 +19,12 @@ const video_channel_1 = require("../../models/video/video-channel"); const video_playlist_1 = require("../../models/video/video-playlist"); const accountsRouter = express_1.default.Router(); exports.accountsRouter = accountsRouter; -accountsRouter.get('/', middlewares_1.paginationValidator, validators_1.accountsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listAccounts)); -accountsRouter.get('/:accountName', middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), getAccount); -accountsRouter.get('/:accountName/videos', middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(listAccountVideos)); -accountsRouter.get('/:accountName/video-channels', middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), validators_1.videoChannelStatsValidator, middlewares_1.paginationValidator, validators_1.videoChannelsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listAccountChannels)); -accountsRouter.get('/:accountName/video-playlists', middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), middlewares_1.paginationValidator, middlewares_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, video_playlists_1.videoPlaylistsSearchValidator, middlewares_1.asyncMiddleware(listAccountPlaylists)); -accountsRouter.get('/:accountName/ratings', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), validators_1.ensureAuthUserOwnsAccountValidator, middlewares_1.paginationValidator, middlewares_1.videoRatesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.videoRatingValidator, middlewares_1.asyncMiddleware(listAccountRatings)); +accountsRouter.get('/', middlewares_1.paginationValidator, validators_1.accountsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listAccounts)); +accountsRouter.get('/:accountName', (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), getAccount); +accountsRouter.get('/:accountName/videos', (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(listAccountVideos)); +accountsRouter.get('/:accountName/video-channels', (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), validators_1.videoChannelStatsValidator, middlewares_1.paginationValidator, validators_1.videoChannelsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listAccountChannels)); +accountsRouter.get('/:accountName/video-playlists', middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), middlewares_1.paginationValidator, middlewares_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, video_playlists_1.videoPlaylistsSearchValidator, (0, middlewares_1.asyncMiddleware)(listAccountPlaylists)); +accountsRouter.get('/:accountName/ratings', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), validators_1.ensureAuthUserOwnsAccountValidator, middlewares_1.paginationValidator, middlewares_1.videoRatesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.videoRatingValidator, (0, middlewares_1.asyncMiddleware)(listAccountRatings)); function getAccount(req, res) { const account = res.locals.account; if (account.isOutdated()) { @@ -33,13 +33,13 @@ function getAccount(req, res) { return res.json(account.toFormattedJSON()); } function listAccounts(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield account_1.AccountModel.listForApi(req.query.start, req.query.count, req.query.sort); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listAccountChannels(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { accountId: res.locals.account.id, start: req.query.start, @@ -49,12 +49,12 @@ function listAccountChannels(req, res) { search: req.query.search }; const resultList = yield video_channel_1.VideoChannelModel.listByAccount(options); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listAccountPlaylists(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); let listMyPlaylists = false; if (res.locals.oauth && res.locals.oauth.token.User.Account.id === res.locals.account.id) { listMyPlaylists = true; @@ -69,22 +69,22 @@ function listAccountPlaylists(req, res) { listMyPlaylists, type: req.query.playlistType }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listAccountVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; - const followerActorId = express_utils_1.isUserAbleToSearchRemoteURI(res) ? null : undefined; - const countVideos = express_utils_1.getCountVideos(req); - const query = query_1.pickCommonVideoQuery(req.query); - const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { followerActorId, search: req.query.search, includeLocalVideos: true, nsfw: express_utils_1.buildNSFWFilter(res, query.nsfw), withFiles: false, accountId: account.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.accounts.videos.list.params'); + const followerActorId = (0, express_utils_1.isUserAbleToSearchRemoteURI)(res) ? null : undefined; + const countVideos = (0, express_utils_1.getCountVideos)(req); + const query = (0, query_1.pickCommonVideoQuery)(req.query); + const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { followerActorId, search: req.query.search, includeLocalVideos: true, nsfw: (0, express_utils_1.buildNSFWFilter)(res, query.nsfw), withFiles: false, accountId: account.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.accounts.videos.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_1.VideoModel.listForApi, apiOptions, 'filter:api.accounts.videos.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listAccountRatings(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; const resultList = yield account_video_rate_1.AccountVideoRateModel.listByAccountForApi({ accountId: account.id, @@ -93,6 +93,6 @@ function listAccountRatings(req, res) { sort: req.query.sort, type: req.query.rating }); - return res.json(utils_1.getFormattedObjects(resultList.rows, resultList.count)); + return res.json((0, utils_1.getFormattedObjects)(resultList.rows, resultList.count)); }); } diff --git a/dist/server/controllers/api/bulk.js b/dist/server/controllers/api/bulk.js index 241a4bdb..256409d8 100644 --- a/dist/server/controllers/api/bulk.js +++ b/dist/server/controllers/api/bulk.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.bulkRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const video_comment_1 = require("@server/lib/video-comment"); const bulk_1 = require("@server/middlewares/validators/bulk"); const video_comment_2 = require("@server/models/video/video-comment"); @@ -10,9 +10,9 @@ const models_1 = require("@shared/models"); const middlewares_1 = require("../../middlewares"); const bulkRouter = express_1.default.Router(); exports.bulkRouter = bulkRouter; -bulkRouter.post('/remove-comments-of', middlewares_1.authenticate, middlewares_1.asyncMiddleware(bulk_1.bulkRemoveCommentsOfValidator), middlewares_1.asyncMiddleware(bulkRemoveCommentsOf)); +bulkRouter.post('/remove-comments-of', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(bulk_1.bulkRemoveCommentsOfValidator), (0, middlewares_1.asyncMiddleware)(bulkRemoveCommentsOf)); function bulkRemoveCommentsOf(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = res.locals.account; const body = req.body; const user = res.locals.oauth.token.User; @@ -22,7 +22,7 @@ function bulkRemoveCommentsOf(req, res) { const comments = yield video_comment_2.VideoCommentModel.listForBulkDelete(account, filter); res.status(models_1.HttpStatusCode.NO_CONTENT_204).end(); for (const comment of comments) { - yield video_comment_1.removeComment(comment); + yield (0, video_comment_1.removeComment)(comment); } }); } diff --git a/dist/server/controllers/api/config.js b/dist/server/controllers/api/config.js index 896466d7..3345b59e 100644 --- a/dist/server/controllers/api/config.js +++ b/dist/server/controllers/api/config.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.configRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const fs_extra_1 = require("fs-extra"); const lodash_1 = require("lodash"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const server_config_manager_1 = require("@server/lib/server-config-manager"); const audit_logger_1 = require("../../helpers/audit-logger"); const core_utils_1 = require("../../helpers/core-utils"); @@ -15,14 +15,14 @@ const middlewares_1 = require("../../middlewares"); const config_2 = require("../../middlewares/validators/config"); const configRouter = express_1.default.Router(); exports.configRouter = configRouter; -const auditLogger = audit_logger_1.auditLoggerFactory('config'); -configRouter.get('/', middlewares_1.openapiOperationDoc({ operationId: 'getConfig' }), middlewares_1.asyncMiddleware(getConfig)); -configRouter.get('/about', middlewares_1.openapiOperationDoc({ operationId: 'getAbout' }), getAbout); -configRouter.get('/custom', middlewares_1.openapiOperationDoc({ operationId: 'getCustomConfig' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(8), getCustomConfig); -configRouter.put('/custom', middlewares_1.openapiOperationDoc({ operationId: 'putCustomConfig' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(8), config_2.customConfigUpdateValidator, middlewares_1.asyncMiddleware(updateCustomConfig)); -configRouter.delete('/custom', middlewares_1.openapiOperationDoc({ operationId: 'delCustomConfig' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(8), middlewares_1.asyncMiddleware(deleteCustomConfig)); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('config'); +configRouter.get('/', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getConfig' }), (0, middlewares_1.asyncMiddleware)(getConfig)); +configRouter.get('/about', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getAbout' }), getAbout); +configRouter.get('/custom', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getCustomConfig' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(8), getCustomConfig); +configRouter.put('/custom', (0, middlewares_1.openapiOperationDoc)({ operationId: 'putCustomConfig' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(8), config_2.customConfigUpdateValidator, (0, middlewares_1.asyncMiddleware)(updateCustomConfig)); +configRouter.delete('/custom', (0, middlewares_1.openapiOperationDoc)({ operationId: 'delCustomConfig' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(8), (0, middlewares_1.asyncMiddleware)(deleteCustomConfig)); function getConfig(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const json = yield server_config_manager_1.ServerConfigManager.Instance.getServerConfig(req.ip); return res.json(json); }); @@ -52,24 +52,24 @@ function getCustomConfig(req, res) { return res.json(data); } function deleteCustomConfig(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield fs_extra_1.remove(config_1.CONFIG.CUSTOM_FILE); - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.CustomConfigAuditView(customConfig())); - config_1.reloadConfig(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, fs_extra_1.remove)(config_1.CONFIG.CUSTOM_FILE); + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.CustomConfigAuditView(customConfig())); + (0, config_1.reloadConfig)(); client_html_1.ClientHtml.invalidCache(); const data = customConfig(); return res.json(data); }); } function updateCustomConfig(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldCustomConfigAuditKeys = new audit_logger_1.CustomConfigAuditView(customConfig()); const toUpdateJSON = convertCustomConfigBody(req.body); - yield fs_extra_1.writeJSON(config_1.CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 }); - config_1.reloadConfig(); + yield (0, fs_extra_1.writeJSON)(config_1.CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 }); + (0, config_1.reloadConfig)(); client_html_1.ClientHtml.invalidCache(); const data = customConfig(); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.CustomConfigAuditView(data), oldCustomConfigAuditKeys); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.CustomConfigAuditView(data), oldCustomConfigAuditKeys); return res.json(data); }); } @@ -247,12 +247,12 @@ function convertCustomConfigBody(body) { return k; if (k === '0p') return k; - return lodash_1.snakeCase(k); + return (0, lodash_1.snakeCase)(k); } function valueConverter(v) { if (validator_1.default.isNumeric(v + '')) return parseInt('' + v, 10); return v; } - return core_utils_1.objectConverter(body, keyConverter, valueConverter); + return (0, core_utils_1.objectConverter)(body, keyConverter, valueConverter); } diff --git a/dist/server/controllers/api/custom-page.js b/dist/server/controllers/api/custom-page.js index c4c438b2..02ac34c3 100644 --- a/dist/server/controllers/api/custom-page.js +++ b/dist/server/controllers/api/custom-page.js @@ -2,17 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.customPageRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const server_config_manager_1 = require("@server/lib/server-config-manager"); const actor_custom_page_1 = require("@server/models/account/actor-custom-page"); const models_1 = require("@shared/models"); const middlewares_1 = require("../../middlewares"); const customPageRouter = express_1.default.Router(); exports.customPageRouter = customPageRouter; -customPageRouter.get('/homepage/instance', middlewares_1.asyncMiddleware(getInstanceHomepage)); -customPageRouter.put('/homepage/instance', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(9), middlewares_1.asyncMiddleware(updateInstanceHomepage)); +customPageRouter.get('/homepage/instance', (0, middlewares_1.asyncMiddleware)(getInstanceHomepage)); +customPageRouter.put('/homepage/instance', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(9), (0, middlewares_1.asyncMiddleware)(updateInstanceHomepage)); function getInstanceHomepage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const page = yield actor_custom_page_1.ActorCustomPageModel.loadInstanceHomepage(); if (!page) { return res.fail({ @@ -24,7 +24,7 @@ function getInstanceHomepage(req, res) { }); } function updateInstanceHomepage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const content = req.body.content; yield actor_custom_page_1.ActorCustomPageModel.updateInstanceHomepage(content); server_config_manager_1.ServerConfigManager.Instance.updateHomepageState(content); diff --git a/dist/server/controllers/api/images/index.js b/dist/server/controllers/api/images/index.js new file mode 100644 index 00000000..d5b325cd --- /dev/null +++ b/dist/server/controllers/api/images/index.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.imagesRouter = void 0; +const tslib_1 = require("tslib"); +const middlewares_1 = require("@server/middlewares"); +const image_1 = require("@server/models/image/image"); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const sequelize_1 = require("sequelize"); +const upload_1 = require("./upload"); +const imagesRouter = express_1.default.Router(); +exports.imagesRouter = imagesRouter; +const LIMIT_LIST_QUERY = 10; +const DEFAULT_ORDER_BY = 'updatedAt'; +const DEFAULT_ORDER_DIRECTION = 'DESC'; +imagesRouter.use('/', upload_1.uploadRouter); +imagesRouter.get('/', (0, middlewares_1.asyncMiddleware)(listImages)); +function listImages(req, res) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const limit = (req.query.limit && req.query.limit > 0 && req.query.limit <= LIMIT_LIST_QUERY) ? req.query.limit : LIMIT_LIST_QUERY; + var order_by = DEFAULT_ORDER_BY, order_direction = DEFAULT_ORDER_DIRECTION; + if (req.query.order && req.query.order.length >= 2 && req.query.order.startsWith('-')) { + order_direction = 'ASC'; + order_by = req.query.order.substring(1); + } + else if (req.query.order && req.query.order.length >= 1) + order_by = req.query.order; + const offset = (req.query.offset) ? req.query.offset : 0; + const images = yield image_1.ImageModel.findAll({ + where: { + createdAt: { + [sequelize_1.Op.gt]: req.query.createdAt || new Date(0) + } + }, + order: [[order_by, order_direction]], + limit: limit, + offset: offset + }); + return res.json(images); + }); +} diff --git a/dist/server/controllers/api/images/upload.js b/dist/server/controllers/api/images/upload.js new file mode 100644 index 00000000..b21bdeeb --- /dev/null +++ b/dist/server/controllers/api/images/upload.js @@ -0,0 +1,94 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.addImageLegacy = exports.uploadRouter = void 0; +const tslib_1 = require("tslib"); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const fs_extra_1 = require("fs-extra"); +const path_1 = require("path"); +const models_1 = require("../../../../shared/models"); +const express_utils_1 = require("../../../helpers/express-utils"); +const logger_1 = require("../../../helpers/logger"); +const config_1 = require("../../../initializers/config"); +const constants_1 = require("../../../initializers/constants"); +const middlewares_1 = require("../../../middlewares"); +const Jimp = (0, tslib_1.__importStar)(require("jimp")); +const image_1 = require("@server/models/image/image"); +const THUMBNAIL_SIZE = 256; +const uploadRouter = express_1.default.Router(); +exports.uploadRouter = uploadRouter; +const reqImageFileAdd = (0, express_utils_1.createReqFiles)(['imagefile'], Object.assign({}, constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT), { + imagefile: config_1.CONFIG.STORAGE.TMP_DIR +}); +uploadRouter.post('/upload', middlewares_1.authenticate, reqImageFileAdd, (0, middlewares_1.asyncRetryTransactionMiddleware)(addImageLegacy)); +function addImageLegacy(req, res) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + req.setTimeout(1000 * 60 * 10, () => { + logger_1.logger.error('Image upload has timed out.'); + return res.fail({ + status: models_1.HttpStatusCode.REQUEST_TIMEOUT_408, + message: 'Image upload has timed out.' + }); + }); + if (!req.files || !req.files['imagefile']) { + logger_1.logger.error('Missing image file.'); + return res.sendStatus(models_1.HttpStatusCode.NOT_FOUND_404); + } + const imageFile = req.files['imagefile'][0]; + return addImage({ res, imageFile }); + }); +} +exports.addImageLegacy = addImageLegacy; +function addImage(options) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { res, imageFile } = options; + imageFile.imageId = (0, path_1.parse)(imageFile.filename).name; + imageFile.extname = (0, path_1.parse)(imageFile.filename).ext; + const image = new image_1.ImageModel({ + id: imageFile.imageId, + originalname: imageFile.originalname, + filename: imageFile.filename, + thumbnailname: imageFile.filename, + size: imageFile.size, + mimetype: imageFile.mimetype, + extname: imageFile.extname + }); + yield (0, fs_extra_1.ensureDir)((0, path_1.join)(config_1.CONFIG.STORAGE.IMAGES_DIR, imageFile.imageId)); + const newDestination = (0, path_1.join)(config_1.CONFIG.STORAGE.IMAGES_DIR, imageFile.imageId); + const newPath = (0, path_1.join)(newDestination, imageFile.filename); + yield (0, fs_extra_1.move)(imageFile.path, newPath); + imageFile.path = newPath; + imageFile.destination = newDestination; + image.thumbnailname = imageFile.imageId + '-thumbnail' + imageFile.extname; + Jimp.read(imageFile.path).then((destImage) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + var w = destImage.getWidth(), h = destImage.getHeight(); + var newW = w, newH = h; + if (w > THUMBNAIL_SIZE || h > THUMBNAIL_SIZE) { + newW = newH = THUMBNAIL_SIZE; + if (w != h) { + var ratio = (w > h) ? w / h : h / w; + if (w > h) + newH = THUMBNAIL_SIZE / ratio; + else + newW = THUMBNAIL_SIZE / ratio; + } + } + destImage.scaleToFit(newW, newH).quality(90).write((0, path_1.join)(imageFile.destination, image.thumbnailname)); + const imageStaticUrl = image_1.ImageModel.getImageStaticUrl(imageFile.imageId, imageFile.filename); + const thumbnailStaticUrl = image_1.ImageModel.getImageStaticUrl(imageFile.imageId, image.thumbnailname); + const torrentHash = yield image_1.ImageModel.generateTorrentForImage(imageFile.imageId, imageFile.destination); + image.infoHash = torrentHash; + image.save(); + return res.json({ + image: { + id: imageFile.imageId, + url: imageStaticUrl, + thumbnailUrl: thumbnailStaticUrl + } + }); + })) + .catch(err => { + logger_1.logger.error(err); + return res.sendStatus(models_1.HttpStatusCode.INTERNAL_SERVER_ERROR_500); + }); + }); +} diff --git a/dist/server/controllers/api/index.js b/dist/server/controllers/api/index.js index 60397d42..6829cc51 100644 --- a/dist/server/controllers/api/index.js +++ b/dist/server/controllers/api/index.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.apiRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); -const express_rate_limit_1 = tslib_1.__importDefault(require("express-rate-limit")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const express_rate_limit_1 = (0, tslib_1.__importDefault)(require("express-rate-limit")); const models_1 = require("../../../shared/models"); const express_utils_1 = require("../../helpers/express-utils"); const config_1 = require("../../initializers/config"); @@ -23,14 +23,15 @@ const users_1 = require("./users"); const video_channel_1 = require("./video-channel"); const video_playlist_1 = require("./video-playlist"); const videos_1 = require("./videos"); +const images_1 = require("./images"); const apiRouter = express_1.default.Router(); exports.apiRouter = apiRouter; -apiRouter.use(cors_1.default({ +apiRouter.use((0, cors_1.default)({ origin: '*', exposedHeaders: 'Retry-After', credentials: true })); -const apiRateLimiter = express_rate_limit_1.default({ +const apiRateLimiter = (0, express_rate_limit_1.default)({ windowMs: config_1.CONFIG.RATES_LIMIT.API.WINDOW_MS, max: config_1.CONFIG.RATES_LIMIT.API.MAX }); @@ -45,6 +46,7 @@ apiRouter.use('/accounts', accounts_1.accountsRouter); apiRouter.use('/video-channels', video_channel_1.videoChannelRouter); apiRouter.use('/video-playlists', video_playlist_1.videoPlaylistRouter); apiRouter.use('/videos', videos_1.videosRouter); +apiRouter.use('/images', images_1.imagesRouter); apiRouter.use('/jobs', jobs_1.jobsRouter); apiRouter.use('/search', search_1.searchRouter); apiRouter.use('/overviews', overviews_1.overviewsRouter); diff --git a/dist/server/controllers/api/jobs.js b/dist/server/controllers/api/jobs.js index 2a75d351..09708e30 100644 --- a/dist/server/controllers/api/jobs.js +++ b/dist/server/controllers/api/jobs.js @@ -2,16 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.jobsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const misc_1 = require("../../helpers/custom-validators/misc"); const job_queue_1 = require("../../lib/job-queue"); const middlewares_1 = require("../../middlewares"); const jobs_1 = require("../../middlewares/validators/jobs"); const jobsRouter = express_1.default.Router(); exports.jobsRouter = jobsRouter; -jobsRouter.get('/:state?', middlewares_1.openapiOperationDoc({ operationId: 'getJobs' }), middlewares_1.paginationValidatorBuilder(['jobs']), middlewares_1.jobsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, jobs_1.listJobsValidator, middlewares_1.asyncMiddleware(listJobs)); +jobsRouter.get('/:state?', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getJobs' }), (0, middlewares_1.paginationValidatorBuilder)(['jobs']), middlewares_1.jobsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, jobs_1.listJobsValidator, (0, middlewares_1.asyncMiddleware)(listJobs)); function listJobs(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const state = req.params.state; const asc = req.query.sort === 'createdAt'; const jobType = req.query.jobType; @@ -31,8 +31,8 @@ function listJobs(req, res) { }); } function formatJob(job, state) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const error = misc_1.isArray(job.stacktrace) && job.stacktrace.length !== 0 + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const error = (0, misc_1.isArray)(job.stacktrace) && job.stacktrace.length !== 0 ? job.stacktrace[0] : null; return { diff --git a/dist/server/controllers/api/oauth-clients.js b/dist/server/controllers/api/oauth-clients.js index 28f757bb..a52b3d23 100644 --- a/dist/server/controllers/api/oauth-clients.js +++ b/dist/server/controllers/api/oauth-clients.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.oauthClientsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../shared/models/http/http-error-codes"); const logger_1 = require("../../helpers/logger"); const config_1 = require("../../initializers/config"); @@ -10,9 +10,9 @@ const middlewares_1 = require("../../middlewares"); const oauth_client_1 = require("../../models/oauth/oauth-client"); const oauthClientsRouter = express_1.default.Router(); exports.oauthClientsRouter = oauthClientsRouter; -oauthClientsRouter.get('/local', middlewares_1.openapiOperationDoc({ operationId: 'getOAuthClient' }), middlewares_1.asyncMiddleware(getLocalClient)); +oauthClientsRouter.get('/local', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getOAuthClient' }), (0, middlewares_1.asyncMiddleware)(getLocalClient)); function getLocalClient(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverHostname = config_1.CONFIG.WEBSERVER.HOSTNAME; const serverPort = config_1.CONFIG.WEBSERVER.PORT; let headerHostShouldBe = serverHostname; diff --git a/dist/server/controllers/api/overviews.js b/dist/server/controllers/api/overviews.js index 9bbf7097..4783c2d5 100644 --- a/dist/server/controllers/api/overviews.js +++ b/dist/server/controllers/api/overviews.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.overviewsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const memoizee_1 = tslib_1.__importDefault(require("memoizee")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); const logger_1 = require("@server/helpers/logger"); const hooks_1 = require("@server/lib/plugins/hooks"); const video_1 = require("@server/models/video/video"); @@ -13,9 +13,9 @@ const middlewares_1 = require("../../middlewares"); const tag_1 = require("../../models/video/tag"); const overviewsRouter = express_1.default.Router(); exports.overviewsRouter = overviewsRouter; -overviewsRouter.get('/videos', middlewares_1.videosOverviewValidator, middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(getVideosOverview)); -const buildSamples = memoizee_1.default(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { +overviewsRouter.get('/videos', middlewares_1.videosOverviewValidator, middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)(getVideosOverview)); +const buildSamples = (0, memoizee_1.default)(function () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [categories, channels, tags] = yield Promise.all([ video_1.VideoModel.getRandomFieldSamples('category', constants_1.OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, constants_1.OVERVIEWS.VIDEOS.SAMPLES_COUNT), video_1.VideoModel.getRandomFieldSamples('channelId', constants_1.OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, constants_1.OVERVIEWS.VIDEOS.SAMPLES_COUNT), @@ -27,7 +27,7 @@ const buildSamples = memoizee_1.default(function () { }); }, { maxAge: constants_1.MEMOIZE_TTL.OVERVIEWS_SAMPLE }); function getVideosOverview(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = yield buildSamples(); const page = req.query.page || 1; const index = page - 1; @@ -48,7 +48,7 @@ function getVideosOverview(req, res) { }); } function getVideosByTag(tagsSample, index, res, acc) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (tagsSample.length <= index) return; const tag = tagsSample[index]; @@ -62,7 +62,7 @@ function getVideosByTag(tagsSample, index, res, acc) { }); } function getVideosByCategory(categoriesSample, index, res, acc) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (categoriesSample.length <= index) return; const category = categoriesSample[index]; @@ -76,7 +76,7 @@ function getVideosByCategory(categoriesSample, index, res, acc) { }); } function getVideosByChannel(channelsSample, index, res, acc) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (channelsSample.length <= index) return; const channelId = channelsSample[index]; @@ -90,8 +90,8 @@ function getVideosByChannel(channelsSample, index, res, acc) { }); } function getVideos(res, where) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const query = yield hooks_1.Hooks.wrapObject(Object.assign({ start: 0, count: 12, sort: '-createdAt', includeLocalVideos: true, nsfw: express_utils_1.buildNSFWFilter(res), user: res.locals.oauth ? res.locals.oauth.token.User : undefined, withFiles: false, countVideos: false }, where), 'filter:api.overviews.videos.list.params'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const query = yield hooks_1.Hooks.wrapObject(Object.assign({ start: 0, count: 12, sort: '-createdAt', includeLocalVideos: true, nsfw: (0, express_utils_1.buildNSFWFilter)(res), user: res.locals.oauth ? res.locals.oauth.token.User : undefined, withFiles: false, countVideos: false }, where), 'filter:api.overviews.videos.list.params'); const { data } = yield hooks_1.Hooks.wrapPromiseFun(video_1.VideoModel.listForApi, query, 'filter:api.overviews.videos.list.result'); return data.map(d => d.toFormattedJSON()); }); diff --git a/dist/server/controllers/api/plugins.js b/dist/server/controllers/api/plugins.js index 55071e5a..ff30bbd9 100644 --- a/dist/server/controllers/api/plugins.js +++ b/dist/server/controllers/api/plugins.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.pluginRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const utils_1 = require("@server/helpers/utils"); const plugin_index_1 = require("@server/lib/plugins/plugin-index"); @@ -13,17 +13,17 @@ const plugin_1 = require("@server/models/server/plugin"); const models_1 = require("@shared/models"); const pluginRouter = express_1.default.Router(); exports.pluginRouter = pluginRouter; -pluginRouter.get('/available', middlewares_1.openapiOperationDoc({ operationId: 'getAvailablePlugins' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.listAvailablePluginsValidator, middlewares_1.paginationValidator, middlewares_1.availablePluginsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listAvailablePlugins)); -pluginRouter.get('/', middlewares_1.openapiOperationDoc({ operationId: 'getPlugins' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.listPluginsValidator, middlewares_1.paginationValidator, middlewares_1.pluginsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listPlugins)); -pluginRouter.get('/:npmName/registered-settings', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), middlewares_1.asyncMiddleware(plugins_1.existingPluginValidator), getPluginRegisteredSettings); -pluginRouter.get('/:npmName/public-settings', middlewares_1.asyncMiddleware(plugins_1.existingPluginValidator), getPublicPluginSettings); -pluginRouter.put('/:npmName/settings', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.updatePluginSettingsValidator, middlewares_1.asyncMiddleware(plugins_1.existingPluginValidator), middlewares_1.asyncMiddleware(updatePluginSettings)); -pluginRouter.get('/:npmName', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), middlewares_1.asyncMiddleware(plugins_1.existingPluginValidator), getPlugin); -pluginRouter.post('/install', middlewares_1.openapiOperationDoc({ operationId: 'addPlugin' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.installOrUpdatePluginValidator, middlewares_1.asyncMiddleware(installPlugin)); -pluginRouter.post('/update', middlewares_1.openapiOperationDoc({ operationId: 'updatePlugin' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.installOrUpdatePluginValidator, middlewares_1.asyncMiddleware(updatePlugin)); -pluginRouter.post('/uninstall', middlewares_1.openapiOperationDoc({ operationId: 'uninstallPlugin' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(23), plugins_1.uninstallPluginValidator, middlewares_1.asyncMiddleware(uninstallPlugin)); +pluginRouter.get('/available', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getAvailablePlugins' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.listAvailablePluginsValidator, middlewares_1.paginationValidator, middlewares_1.availablePluginsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listAvailablePlugins)); +pluginRouter.get('/', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getPlugins' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.listPluginsValidator, middlewares_1.paginationValidator, middlewares_1.pluginsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listPlugins)); +pluginRouter.get('/:npmName/registered-settings', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), (0, middlewares_1.asyncMiddleware)(plugins_1.existingPluginValidator), getPluginRegisteredSettings); +pluginRouter.get('/:npmName/public-settings', (0, middlewares_1.asyncMiddleware)(plugins_1.existingPluginValidator), getPublicPluginSettings); +pluginRouter.put('/:npmName/settings', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.updatePluginSettingsValidator, (0, middlewares_1.asyncMiddleware)(plugins_1.existingPluginValidator), (0, middlewares_1.asyncMiddleware)(updatePluginSettings)); +pluginRouter.get('/:npmName', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), (0, middlewares_1.asyncMiddleware)(plugins_1.existingPluginValidator), getPlugin); +pluginRouter.post('/install', (0, middlewares_1.openapiOperationDoc)({ operationId: 'addPlugin' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.installOrUpdatePluginValidator, (0, middlewares_1.asyncMiddleware)(installPlugin)); +pluginRouter.post('/update', (0, middlewares_1.openapiOperationDoc)({ operationId: 'updatePlugin' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.installOrUpdatePluginValidator, (0, middlewares_1.asyncMiddleware)(updatePlugin)); +pluginRouter.post('/uninstall', (0, middlewares_1.openapiOperationDoc)({ operationId: 'uninstallPlugin' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(23), plugins_1.uninstallPluginValidator, (0, middlewares_1.asyncMiddleware)(uninstallPlugin)); function listPlugins(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const pluginType = req.query.pluginType; const uninstalled = req.query.uninstalled; const resultList = yield plugin_1.PluginModel.listForApi({ @@ -33,7 +33,7 @@ function listPlugins(req, res) { count: req.query.count, sort: req.query.sort }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function getPlugin(req, res) { @@ -41,7 +41,7 @@ function getPlugin(req, res) { return res.json(plugin.toFormattedJSON()); } function installPlugin(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const fromDisk = !!body.path; const toInstall = body.npmName || body.path; @@ -56,7 +56,7 @@ function installPlugin(req, res) { }); } function updatePlugin(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const fromDisk = !!body.path; const toUpdate = body.npmName || body.path; @@ -71,7 +71,7 @@ function updatePlugin(req, res) { }); } function uninstallPlugin(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; yield plugin_manager_1.PluginManager.Instance.uninstall(body.npmName); return res.status(models_1.HttpStatusCode.NO_CONTENT_204).end(); @@ -90,7 +90,7 @@ function getPluginRegisteredSettings(req, res) { return res.json(json); } function updatePluginSettings(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const plugin = res.locals.plugin; plugin.settings = req.body.settings; yield plugin.save(); @@ -99,9 +99,9 @@ function updatePluginSettings(req, res) { }); } function listAvailablePlugins(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = req.query; - const resultList = yield plugin_index_1.listAvailablePluginsFromIndex(query); + const resultList = yield (0, plugin_index_1.listAvailablePluginsFromIndex)(query); if (!resultList) { return res.fail({ status: models_1.HttpStatusCode.SERVICE_UNAVAILABLE_503, diff --git a/dist/server/controllers/api/search/index.js b/dist/server/controllers/api/search/index.js index d1930b20..25950018 100644 --- a/dist/server/controllers/api/search/index.js +++ b/dist/server/controllers/api/search/index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.searchRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const search_video_channels_1 = require("./search-video-channels"); const search_video_playlists_1 = require("./search-video-playlists"); const search_videos_1 = require("./search-videos"); diff --git a/dist/server/controllers/api/search/search-video-channels.js b/dist/server/controllers/api/search/search-video-channels.js index bd9e9b64..edf979b1 100644 --- a/dist/server/controllers/api/search/search-video-channels.js +++ b/dist/server/controllers/api/search/search-video-channels.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.searchChannelsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@server/helpers/core-utils"); const query_1 = require("@server/helpers/query"); const requests_1 = require("@server/helpers/requests"); @@ -20,31 +20,31 @@ const middlewares_1 = require("../../../middlewares"); const video_channel_1 = require("../../../models/video/video-channel"); const searchChannelsRouter = express_1.default.Router(); exports.searchChannelsRouter = searchChannelsRouter; -searchChannelsRouter.get('/video-channels', middlewares_1.openapiOperationDoc({ operationId: 'searchChannels' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videoChannelsSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.videoChannelsListSearchValidator, middlewares_1.asyncMiddleware(searchVideoChannels)); +searchChannelsRouter.get('/video-channels', (0, middlewares_1.openapiOperationDoc)({ operationId: 'searchChannels' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videoChannelsSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.videoChannelsListSearchValidator, (0, middlewares_1.asyncMiddleware)(searchVideoChannels)); function searchVideoChannels(req, res) { - const query = query_1.pickSearchChannelQuery(req.query); + const query = (0, query_1.pickSearchChannelQuery)(req.query); let search = query.search || ''; const parts = search.split('@'); if (parts.length === 3 && parts[0].length === 0) parts.shift(); const isWebfingerSearch = parts.length === 2 && parts.every(p => p && !p.includes(' ')); - if (search_1.isURISearch(search) || isWebfingerSearch) + if ((0, search_1.isURISearch)(search) || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res); if (search.startsWith('@')) search = search.replace(/^@/, ''); - if (search_1.isSearchIndexSearch(query)) { + if ((0, search_1.isSearchIndexSearch)(query)) { return searchVideoChannelsIndex(query, res); } return searchVideoChannelsDB(query, res); } function searchVideoChannelsIndex(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const result = yield search_1.buildMutedForSearchIndex(res); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const result = yield (0, search_1.buildMutedForSearchIndex)(res); const body = yield hooks_1.Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-channels.index.list.params'); - const url = core_utils_1.sanitizeUrl(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/video-channels'; + const url = (0, core_utils_1.sanitizeUrl)(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/video-channels'; try { logger_1.logger.debug('Doing video channels search index request on %s.', url, { body }); - const { body: searchIndexResult } = yield requests_1.doJSONRequest(url, { method: 'POST', json: body }); + const { body: searchIndexResult } = yield (0, requests_1.doJSONRequest)(url, { method: 'POST', json: body }); const jsonResult = yield hooks_1.Hooks.wrapObject(searchIndexResult, 'filter:api.search.video-channels.index.list.result'); return res.json(jsonResult); } @@ -58,29 +58,29 @@ function searchVideoChannelsIndex(query, res) { }); } function searchVideoChannelsDB(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { actorId: serverActor.id }), 'filter:api.search.video-channels.local.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_channel_1.VideoChannelModel.searchForApi, apiOptions, 'filter:api.search.video-channels.local.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function searchVideoChannelURI(search, isWebfingerSearch, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let videoChannel; let uri = search; if (isWebfingerSearch) { try { - uri = yield actors_1.loadActorUrlOrGetFromWebfinger(search); + uri = yield (0, actors_1.loadActorUrlOrGetFromWebfinger)(search); } catch (err) { logger_1.logger.warn('Cannot load actor URL or get from webfinger.', { search, err }); return res.json({ total: 0, data: [] }); } } - if (express_utils_1.isUserAbleToSearchRemoteURI(res)) { + if ((0, express_utils_1.isUserAbleToSearchRemoteURI)(res)) { try { - const actor = yield actors_1.getOrCreateAPActor(uri, 'all', true, true); + const actor = yield (0, actors_1.getOrCreateAPActor)(uri, 'all', true, true); videoChannel = actor.VideoChannel; } catch (err) { diff --git a/dist/server/controllers/api/search/search-video-playlists.js b/dist/server/controllers/api/search/search-video-playlists.js index d9387fd6..9317e894 100644 --- a/dist/server/controllers/api/search/search-video-playlists.js +++ b/dist/server/controllers/api/search/search-video-playlists.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.searchPlaylistsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@server/helpers/core-utils"); const express_utils_1 = require("@server/helpers/express-utils"); const logger_1 = require("@server/helpers/logger"); @@ -20,25 +20,25 @@ const models_1 = require("@shared/models"); const middlewares_1 = require("../../../middlewares"); const searchPlaylistsRouter = express_1.default.Router(); exports.searchPlaylistsRouter = searchPlaylistsRouter; -searchPlaylistsRouter.get('/video-playlists', middlewares_1.openapiOperationDoc({ operationId: 'searchPlaylists' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videoPlaylistsSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.videoPlaylistsListSearchValidator, middlewares_1.asyncMiddleware(searchVideoPlaylists)); +searchPlaylistsRouter.get('/video-playlists', (0, middlewares_1.openapiOperationDoc)({ operationId: 'searchPlaylists' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videoPlaylistsSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.videoPlaylistsListSearchValidator, (0, middlewares_1.asyncMiddleware)(searchVideoPlaylists)); function searchVideoPlaylists(req, res) { - const query = query_1.pickSearchPlaylistQuery(req.query); + const query = (0, query_1.pickSearchPlaylistQuery)(req.query); const search = query.search; - if (search_1.isURISearch(search)) + if ((0, search_1.isURISearch)(search)) return searchVideoPlaylistsURI(search, res); - if (search_1.isSearchIndexSearch(query)) { + if ((0, search_1.isSearchIndexSearch)(query)) { return searchVideoPlaylistsIndex(query, res); } return searchVideoPlaylistsDB(query, res); } function searchVideoPlaylistsIndex(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const result = yield search_1.buildMutedForSearchIndex(res); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const result = yield (0, search_1.buildMutedForSearchIndex)(res); const body = yield hooks_1.Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-playlists.index.list.params'); - const url = core_utils_1.sanitizeUrl(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/video-playlists'; + const url = (0, core_utils_1.sanitizeUrl)(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/video-playlists'; try { logger_1.logger.debug('Doing video playlists search index request on %s.', url, { body }); - const { body: searchIndexResult } = yield requests_1.doJSONRequest(url, { method: 'POST', json: body }); + const { body: searchIndexResult } = yield (0, requests_1.doJSONRequest)(url, { method: 'POST', json: body }); const jsonResult = yield hooks_1.Hooks.wrapObject(searchIndexResult, 'filter:api.search.video-playlists.index.list.result'); return res.json(jsonResult); } @@ -52,19 +52,19 @@ function searchVideoPlaylistsIndex(query, res) { }); } function searchVideoPlaylistsDB(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { followerActorId: serverActor.id }), 'filter:api.search.video-playlists.local.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_playlist_1.VideoPlaylistModel.searchForApi, apiOptions, 'filter:api.search.video-playlists.local.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function searchVideoPlaylistsURI(search, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let videoPlaylist; - if (express_utils_1.isUserAbleToSearchRemoteURI(res)) { + if ((0, express_utils_1.isUserAbleToSearchRemoteURI)(res)) { try { - videoPlaylist = yield get_1.getOrCreateAPVideoPlaylist(search); + videoPlaylist = yield (0, get_1.getOrCreateAPVideoPlaylist)(search); } catch (err) { logger_1.logger.info('Cannot search remote video playlist %s.', search, { err }); diff --git a/dist/server/controllers/api/search/search-videos.js b/dist/server/controllers/api/search/search-videos.js index b8afb7cb..78d01132 100644 --- a/dist/server/controllers/api/search/search-videos.js +++ b/dist/server/controllers/api/search/search-videos.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.searchVideosRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@server/helpers/core-utils"); const query_1 = require("@server/helpers/query"); const requests_1 = require("@server/helpers/requests"); @@ -19,21 +19,21 @@ const middlewares_1 = require("../../../middlewares"); const video_1 = require("../../../models/video/video"); const searchVideosRouter = express_1.default.Router(); exports.searchVideosRouter = searchVideosRouter; -searchVideosRouter.get('/videos', middlewares_1.openapiOperationDoc({ operationId: 'searchVideos' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videosSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, middlewares_1.videosSearchValidator, middlewares_1.asyncMiddleware(searchVideos)); +searchVideosRouter.get('/videos', (0, middlewares_1.openapiOperationDoc)({ operationId: 'searchVideos' }), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.videosSearchSortValidator, middlewares_1.setDefaultSearchSort, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, middlewares_1.videosSearchValidator, (0, middlewares_1.asyncMiddleware)(searchVideos)); function searchVideos(req, res) { - const query = query_1.pickSearchVideoQuery(req.query); + const query = (0, query_1.pickSearchVideoQuery)(req.query); const search = query.search; - if (search_1.isURISearch(search)) { + if ((0, search_1.isURISearch)(search)) { return searchVideoURI(search, res); } - if (search_1.isSearchIndexSearch(query)) { + if ((0, search_1.isSearchIndexSearch)(query)) { return searchVideosIndex(query, res); } return searchVideosDB(query, res); } function searchVideosIndex(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const result = yield search_1.buildMutedForSearchIndex(res); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const result = yield (0, search_1.buildMutedForSearchIndex)(res); let body = Object.assign(Object.assign({}, query), result); if (!body.nsfw) { const nsfwPolicy = res.locals.oauth @@ -44,10 +44,10 @@ function searchVideosIndex(query, res) { : 'both'; } body = yield hooks_1.Hooks.wrapObject(body, 'filter:api.search.videos.index.list.params'); - const url = core_utils_1.sanitizeUrl(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/videos'; + const url = (0, core_utils_1.sanitizeUrl)(config_1.CONFIG.SEARCH.SEARCH_INDEX.URL) + '/api/v1/search/videos'; try { logger_1.logger.debug('Doing videos search index request on %s.', url, { body }); - const { body: searchIndexResult } = yield requests_1.doJSONRequest(url, { method: 'POST', json: body }); + const { body: searchIndexResult } = yield (0, requests_1.doJSONRequest)(url, { method: 'POST', json: body }); const jsonResult = yield hooks_1.Hooks.wrapObject(searchIndexResult, 'filter:api.search.videos.index.list.result'); return res.json(jsonResult); } @@ -61,18 +61,18 @@ function searchVideosIndex(query, res) { }); } function searchVideosDB(query, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { includeLocalVideos: true, filter: query.filter, nsfw: express_utils_1.buildNSFWFilter(res, query.nsfw), user: res.locals.oauth + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { includeLocalVideos: true, filter: query.filter, nsfw: (0, express_utils_1.buildNSFWFilter)(res, query.nsfw), user: res.locals.oauth ? res.locals.oauth.token.User : undefined }), 'filter:api.search.videos.local.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_1.VideoModel.searchAndPopulateAccountAndServer, apiOptions, 'filter:api.search.videos.local.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function searchVideoURI(url, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let video; - if (express_utils_1.isUserAbleToSearchRemoteURI(res)) { + if ((0, express_utils_1.isUserAbleToSearchRemoteURI)(res)) { try { const syncParam = { likes: false, @@ -82,7 +82,7 @@ function searchVideoURI(url, res) { thumbnail: true, refreshVideo: false }; - const result = yield videos_1.getOrCreateAPVideo({ videoObject: url, syncParam }); + const result = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: url, syncParam }); video = result ? result.video : undefined; } catch (err) { diff --git a/dist/server/controllers/api/server/check-space.js b/dist/server/controllers/api/server/check-space.js index 1c1c8e57..d2695271 100644 --- a/dist/server/controllers/api/server/check-space.js +++ b/dist/server/controllers/api/server/check-space.js @@ -2,16 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.spaceRouter = void 0; const tslib_1 = require("tslib"); -const express = tslib_1.__importStar(require("express")); +const express = (0, tslib_1.__importStar)(require("express")); const middlewares_1 = require("../../../middlewares"); const config_1 = require("../../../../server/initializers/config"); const constants_1 = require("../../../../server/initializers/constants"); -const check_disk_space_1 = tslib_1.__importDefault(require("check-disk-space")); +const check_disk_space_1 = (0, tslib_1.__importDefault)(require("check-disk-space")); const spaceRouter = express.Router(); exports.spaceRouter = spaceRouter; -spaceRouter.get("/space", middlewares_1.asyncMiddleware(getSpace)); +spaceRouter.get("/space", (0, middlewares_1.asyncMiddleware)(getSpace)); function getSpace(_req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - return check_disk_space_1.default(config_1.CONFIG.STORAGE.VIDEOS_DIR).then((diskSpace) => res.json(Object.assign(Object.assign({}, diskSpace), { isFull: diskSpace.free / diskSpace.size >= constants_1.FULL_DISC_SPACE_PERCENTAGE }))); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return (0, check_disk_space_1.default)(config_1.CONFIG.STORAGE.VIDEOS_DIR).then((diskSpace) => res.json(Object.assign(Object.assign({}, diskSpace), { isFull: diskSpace.free / diskSpace.size >= constants_1.FULL_DISC_SPACE_PERCENTAGE }))); }); } diff --git a/dist/server/controllers/api/server/contact.js b/dist/server/controllers/api/server/contact.js index 8f3333cf..fa9cb9f2 100644 --- a/dist/server/controllers/api/server/contact.js +++ b/dist/server/controllers/api/server/contact.js @@ -2,16 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.contactRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const emailer_1 = require("../../../lib/emailer"); const redis_1 = require("../../../lib/redis"); const middlewares_1 = require("../../../middlewares"); const contactRouter = express_1.default.Router(); exports.contactRouter = contactRouter; -contactRouter.post('/contact', middlewares_1.asyncMiddleware(middlewares_1.contactAdministratorValidator), middlewares_1.asyncMiddleware(contactAdministrator)); +contactRouter.post('/contact', (0, middlewares_1.asyncMiddleware)(middlewares_1.contactAdministratorValidator), (0, middlewares_1.asyncMiddleware)(contactAdministrator)); function contactAdministrator(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = req.body; emailer_1.Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body); yield redis_1.Redis.Instance.setContactFormIp(req.ip); diff --git a/dist/server/controllers/api/server/debug.js b/dist/server/controllers/api/server/debug.js index 7d06e10f..754a8bdd 100644 --- a/dist/server/controllers/api/server/debug.js +++ b/dist/server/controllers/api/server/debug.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.debugRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const inbox_manager_1 = require("@server/lib/activitypub/inbox-manager"); const remove_dangling_resumable_uploads_scheduler_1 = require("@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const middlewares_1 = require("../../../middlewares"); const debugRouter = express_1.default.Router(); exports.debugRouter = debugRouter; -debugRouter.get('/debug', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(4), getDebug); -debugRouter.post('/debug/run-command', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(4), runCommand); +debugRouter.get('/debug', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(4), getDebug); +debugRouter.post('/debug/run-command', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(4), runCommand); function getDebug(req, res) { return res.json({ ip: req.ip, @@ -18,7 +18,7 @@ function getDebug(req, res) { }); } function runCommand(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; if (body.command === 'remove-dandling-resumable-uploads') { yield remove_dangling_resumable_uploads_scheduler_1.RemoveDanglingResumableUploadsScheduler.Instance.execute(); diff --git a/dist/server/controllers/api/server/follows.js b/dist/server/controllers/api/server/follows.js index 12472035..9421b26b 100644 --- a/dist/server/controllers/api/server/follows.js +++ b/dist/server/controllers/api/server/follows.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.serverFollowsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const application_1 = require("@server/models/application/application"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const logger_1 = require("../../../helpers/logger"); @@ -18,16 +18,16 @@ const validators_1 = require("../../../middlewares/validators"); const actor_follow_1 = require("../../../models/actor/actor-follow"); const serverFollowsRouter = express_1.default.Router(); exports.serverFollowsRouter = serverFollowsRouter; -serverFollowsRouter.get('/following', validators_1.listFollowsValidator, middlewares_1.paginationValidator, validators_1.followingSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listFollowing)); -serverFollowsRouter.post('/following', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), validators_1.followValidator, middlewares_1.setBodyHostsPort, middlewares_1.asyncMiddleware(addFollow)); -serverFollowsRouter.delete('/following/:hostOrHandle', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), middlewares_1.asyncMiddleware(validators_1.removeFollowingValidator), middlewares_1.asyncMiddleware(removeFollowing)); -serverFollowsRouter.get('/followers', validators_1.listFollowsValidator, middlewares_1.paginationValidator, validators_1.followersSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listFollowers)); -serverFollowsRouter.delete('/followers/:nameWithHost', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), middlewares_1.asyncMiddleware(validators_1.getFollowerValidator), middlewares_1.asyncMiddleware(removeOrRejectFollower)); -serverFollowsRouter.post('/followers/:nameWithHost/reject', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), middlewares_1.asyncMiddleware(validators_1.getFollowerValidator), validators_1.acceptOrRejectFollowerValidator, middlewares_1.asyncMiddleware(removeOrRejectFollower)); -serverFollowsRouter.post('/followers/:nameWithHost/accept', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), middlewares_1.asyncMiddleware(validators_1.getFollowerValidator), validators_1.acceptOrRejectFollowerValidator, middlewares_1.asyncMiddleware(acceptFollower)); +serverFollowsRouter.get('/following', validators_1.listFollowsValidator, middlewares_1.paginationValidator, validators_1.followingSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listFollowing)); +serverFollowsRouter.post('/following', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), validators_1.followValidator, middlewares_1.setBodyHostsPort, (0, middlewares_1.asyncMiddleware)(addFollow)); +serverFollowsRouter.delete('/following/:hostOrHandle', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), (0, middlewares_1.asyncMiddleware)(validators_1.removeFollowingValidator), (0, middlewares_1.asyncMiddleware)(removeFollowing)); +serverFollowsRouter.get('/followers', validators_1.listFollowsValidator, middlewares_1.paginationValidator, validators_1.followersSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listFollowers)); +serverFollowsRouter.delete('/followers/:nameWithHost', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), (0, middlewares_1.asyncMiddleware)(validators_1.getFollowerValidator), (0, middlewares_1.asyncMiddleware)(removeOrRejectFollower)); +serverFollowsRouter.post('/followers/:nameWithHost/reject', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), (0, middlewares_1.asyncMiddleware)(validators_1.getFollowerValidator), validators_1.acceptOrRejectFollowerValidator, (0, middlewares_1.asyncMiddleware)(removeOrRejectFollower)); +serverFollowsRouter.post('/followers/:nameWithHost/accept', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), (0, middlewares_1.asyncMiddleware)(validators_1.getFollowerValidator), validators_1.acceptOrRejectFollowerValidator, (0, middlewares_1.asyncMiddleware)(acceptFollower)); function listFollowing(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield actor_follow_1.ActorFollowModel.listFollowingForApi({ id: serverActor.id, start: req.query.start, @@ -37,12 +37,12 @@ function listFollowing(req, res) { actorType: req.query.actorType, state: req.query.state }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listFollowers(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield actor_follow_1.ActorFollowModel.listFollowersForApi({ actorId: serverActor.id, start: req.query.start, @@ -52,13 +52,13 @@ function listFollowers(req, res) { actorType: req.query.actorType, state: req.query.state }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function addFollow(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { hosts, handles } = req.body; - const follower = yield application_1.getServerActor(); + const follower = yield (0, application_1.getServerActor)(); for (const host of hosts) { const payload = { host, @@ -80,15 +80,15 @@ function addFollow(req, res) { }); } function removeFollowing(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const follow = res.locals.follow; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (follow.state === 'accepted') - yield send_1.sendUndoFollow(follow, t); + yield (0, send_1.sendUndoFollow)(follow, t); const server = follow.ActorFollowing.Server; server.redundancyAllowed = false; yield server.save({ transaction: t }); - redundancy_1.removeRedundanciesOfServer(server.id) + (0, redundancy_1.removeRedundanciesOfServer)(server.id) .catch(err => logger_1.logger.error('Cannot remove redundancy of %s.', server.host, err)); yield follow.destroy({ transaction: t }); })); @@ -96,20 +96,20 @@ function removeFollowing(req, res) { }); } function removeOrRejectFollower(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const follow = res.locals.follow; - yield send_1.sendReject(follow.url, follow.ActorFollower, follow.ActorFollowing); + yield (0, send_1.sendReject)(follow.url, follow.ActorFollower, follow.ActorFollowing); yield follow.destroy(); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function acceptFollower(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const follow = res.locals.follow; - send_1.sendAccept(follow); + (0, send_1.sendAccept)(follow); follow.state = 'accepted'; yield follow.save(); - yield follow_1.autoFollowBackIfNeeded(follow); + yield (0, follow_1.autoFollowBackIfNeeded)(follow); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } diff --git a/dist/server/controllers/api/server/index.js b/dist/server/controllers/api/server/index.js index da935048..f04a754b 100644 --- a/dist/server/controllers/api/server/index.js +++ b/dist/server/controllers/api/server/index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.serverRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const contact_1 = require("./contact"); const debug_1 = require("./debug"); const follows_1 = require("./follows"); diff --git a/dist/server/controllers/api/server/logs.js b/dist/server/controllers/api/server/logs.js index f367270a..78346d24 100644 --- a/dist/server/controllers/api/server/logs.js +++ b/dist/server/controllers/api/server/logs.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.logsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const logger_1 = require("@server/helpers/logger"); @@ -12,11 +12,11 @@ const middlewares_1 = require("../../../middlewares"); const logs_1 = require("../../../middlewares/validators/logs"); const logsRouter = express_1.default.Router(); exports.logsRouter = logsRouter; -logsRouter.get('/logs', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(3), logs_1.getLogsValidator, middlewares_1.asyncMiddleware(getLogs)); -logsRouter.get('/audit-logs', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(3), logs_1.getAuditLogsValidator, middlewares_1.asyncMiddleware(getAuditLogs)); +logsRouter.get('/logs', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(3), logs_1.getLogsValidator, (0, middlewares_1.asyncMiddleware)(getLogs)); +logsRouter.get('/audit-logs', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(3), logs_1.getAuditLogsValidator, (0, middlewares_1.asyncMiddleware)(getAuditLogs)); const auditLogNameFilter = generateLogNameFilter(constants_1.AUDIT_LOG_FILENAME); function getAuditLogs(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const output = yield generateOutput({ startDateQuery: req.query.startDate, endDateQuery: req.query.endDate, @@ -28,7 +28,7 @@ function getAuditLogs(req, res) { } const logNameFilter = generateLogNameFilter(constants_1.LOG_FILENAME); function getLogs(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const output = yield generateOutput({ startDateQuery: req.query.startDate, endDateQuery: req.query.endDate, @@ -39,10 +39,10 @@ function getLogs(req, res) { }); } function generateOutput(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { startDateQuery, level, nameFilter } = options; - const logFiles = yield fs_extra_1.readdir(config_1.CONFIG.STORAGE.LOG_DIR); - const sortedLogFiles = yield logger_1.mtimeSortFilesDesc(logFiles, config_1.CONFIG.STORAGE.LOG_DIR); + const logFiles = yield (0, fs_extra_1.readdir)(config_1.CONFIG.STORAGE.LOG_DIR); + const sortedLogFiles = yield (0, logger_1.mtimeSortFilesDesc)(logFiles, config_1.CONFIG.STORAGE.LOG_DIR); let currentSize = 0; const startDate = new Date(startDateQuery); const endDate = options.endDateQuery ? new Date(options.endDateQuery) : new Date(); @@ -50,7 +50,7 @@ function generateOutput(options) { for (const meta of sortedLogFiles) { if (nameFilter.exec(meta.file) === null) continue; - const path = path_1.join(config_1.CONFIG.STORAGE.LOG_DIR, meta.file); + const path = (0, path_1.join)(config_1.CONFIG.STORAGE.LOG_DIR, meta.file); logger_1.logger.debug('Opening %s to fetch logs.', path); const result = yield getOutputFromFile(path, startDate, endDate, level, currentSize); if (!result.output) @@ -64,7 +64,7 @@ function generateOutput(options) { }); } function getOutputFromFile(path, startDate, endDate, level, currentSize) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startTime = startDate.getTime(); const endTime = endDate.getTime(); let logTime; @@ -75,7 +75,7 @@ function getOutputFromFile(path, startDate, endDate, level, currentSize) { warn: 2, error: 3 }; - const content = yield fs_extra_1.readFile(path); + const content = yield (0, fs_extra_1.readFile)(path); const lines = content.toString().split('\n'); const output = []; for (let i = lines.length - 1; i >= 0; i--) { diff --git a/dist/server/controllers/api/server/redundancy.js b/dist/server/controllers/api/server/redundancy.js index eb7e11e2..237af247 100644 --- a/dist/server/controllers/api/server/redundancy.js +++ b/dist/server/controllers/api/server/redundancy.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.serverRedundancyRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const job_queue_1 = require("@server/lib/job-queue"); const video_redundancy_1 = require("@server/models/redundancy/video-redundancy"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); @@ -12,12 +12,12 @@ const middlewares_1 = require("../../../middlewares"); const redundancy_2 = require("../../../middlewares/validators/redundancy"); const serverRedundancyRouter = express_1.default.Router(); exports.serverRedundancyRouter = serverRedundancyRouter; -serverRedundancyRouter.put('/redundancy/:host', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(2), middlewares_1.asyncMiddleware(redundancy_2.updateServerRedundancyValidator), middlewares_1.asyncMiddleware(updateRedundancy)); -serverRedundancyRouter.get('/redundancy/videos', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(24), redundancy_2.listVideoRedundanciesValidator, middlewares_1.paginationValidator, middlewares_1.videoRedundanciesSortValidator, middlewares_1.setDefaultVideoRedundanciesSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listVideoRedundancies)); -serverRedundancyRouter.post('/redundancy/videos', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(24), redundancy_2.addVideoRedundancyValidator, middlewares_1.asyncMiddleware(addVideoRedundancy)); -serverRedundancyRouter.delete('/redundancy/videos/:redundancyId', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(24), redundancy_2.removeVideoRedundancyValidator, middlewares_1.asyncMiddleware(removeVideoRedundancyController)); +serverRedundancyRouter.put('/redundancy/:host', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(2), (0, middlewares_1.asyncMiddleware)(redundancy_2.updateServerRedundancyValidator), (0, middlewares_1.asyncMiddleware)(updateRedundancy)); +serverRedundancyRouter.get('/redundancy/videos', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(24), redundancy_2.listVideoRedundanciesValidator, middlewares_1.paginationValidator, middlewares_1.videoRedundanciesSortValidator, middlewares_1.setDefaultVideoRedundanciesSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listVideoRedundancies)); +serverRedundancyRouter.post('/redundancy/videos', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(24), redundancy_2.addVideoRedundancyValidator, (0, middlewares_1.asyncMiddleware)(addVideoRedundancy)); +serverRedundancyRouter.delete('/redundancy/videos/:redundancyId', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(24), redundancy_2.removeVideoRedundancyValidator, (0, middlewares_1.asyncMiddleware)(removeVideoRedundancyController)); function listVideoRedundancies(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield video_redundancy_1.VideoRedundancyModel.listForApi({ start: req.query.start, count: req.query.count, @@ -33,7 +33,7 @@ function listVideoRedundancies(req, res) { }); } function addVideoRedundancy(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = { videoId: res.locals.onlyVideo.id }; @@ -45,18 +45,18 @@ function addVideoRedundancy(req, res) { }); } function removeVideoRedundancyController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield redundancy_1.removeVideoRedundancy(res.locals.videoRedundancy); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, redundancy_1.removeVideoRedundancy)(res.locals.videoRedundancy); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function updateRedundancy(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = res.locals.server; server.redundancyAllowed = req.body.redundancyAllowed; yield server.save(); if (server.redundancyAllowed !== true) { - redundancy_1.removeRedundanciesOfServer(server.id) + (0, redundancy_1.removeRedundanciesOfServer)(server.id) .catch(err => logger_1.logger.error('Cannot remove redundancy of %s.', server.host, { err })); } return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); diff --git a/dist/server/controllers/api/server/server-blocklist.js b/dist/server/controllers/api/server/server-blocklist.js index 2308d3aa..2593737c 100644 --- a/dist/server/controllers/api/server/server-blocklist.js +++ b/dist/server/controllers/api/server/server-blocklist.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.serverBlocklistRouter = void 0; const tslib_1 = require("tslib"); require("multer"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const application_1 = require("@server/models/application/application"); const user_notification_1 = require("@server/models/user/user-notification"); @@ -16,15 +16,15 @@ const account_blocklist_1 = require("../../../models/account/account-blocklist") const server_blocklist_1 = require("../../../models/server/server-blocklist"); const serverBlocklistRouter = express_1.default.Router(); exports.serverBlocklistRouter = serverBlocklistRouter; -serverBlocklistRouter.get('/blocklist/accounts', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(10), middlewares_1.paginationValidator, validators_1.accountsBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listBlockedAccounts)); -serverBlocklistRouter.post('/blocklist/accounts', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(10), middlewares_1.asyncMiddleware(validators_1.blockAccountValidator), middlewares_1.asyncRetryTransactionMiddleware(blockAccount)); -serverBlocklistRouter.delete('/blocklist/accounts/:accountName', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(10), middlewares_1.asyncMiddleware(validators_1.unblockAccountByServerValidator), middlewares_1.asyncRetryTransactionMiddleware(unblockAccount)); -serverBlocklistRouter.get('/blocklist/servers', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(11), middlewares_1.paginationValidator, validators_1.serversBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listBlockedServers)); -serverBlocklistRouter.post('/blocklist/servers', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(11), middlewares_1.asyncMiddleware(validators_1.blockServerValidator), middlewares_1.asyncRetryTransactionMiddleware(blockServer)); -serverBlocklistRouter.delete('/blocklist/servers/:host', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(11), middlewares_1.asyncMiddleware(validators_1.unblockServerByServerValidator), middlewares_1.asyncRetryTransactionMiddleware(unblockServer)); +serverBlocklistRouter.get('/blocklist/accounts', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(10), middlewares_1.paginationValidator, validators_1.accountsBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listBlockedAccounts)); +serverBlocklistRouter.post('/blocklist/accounts', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(10), (0, middlewares_1.asyncMiddleware)(validators_1.blockAccountValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(blockAccount)); +serverBlocklistRouter.delete('/blocklist/accounts/:accountName', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(10), (0, middlewares_1.asyncMiddleware)(validators_1.unblockAccountByServerValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(unblockAccount)); +serverBlocklistRouter.get('/blocklist/servers', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(11), middlewares_1.paginationValidator, validators_1.serversBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listBlockedServers)); +serverBlocklistRouter.post('/blocklist/servers', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(11), (0, middlewares_1.asyncMiddleware)(validators_1.blockServerValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(blockServer)); +serverBlocklistRouter.delete('/blocklist/servers/:host', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(11), (0, middlewares_1.asyncMiddleware)(validators_1.unblockServerByServerValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(unblockServer)); function listBlockedAccounts(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield account_blocklist_1.AccountBlocklistModel.listForApi({ start: req.query.start, count: req.query.count, @@ -32,14 +32,14 @@ function listBlockedAccounts(req, res) { search: req.query.search, accountId: serverActor.Account.id }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function blockAccount(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const accountToBlock = res.locals.account; - yield blocklist_1.addAccountInBlocklist(serverActor.Account.id, accountToBlock.id); + yield (0, blocklist_1.addAccountInBlocklist)(serverActor.Account.id, accountToBlock.id); user_notification_1.UserNotificationModel.removeNotificationsOf({ id: accountToBlock.id, type: 'account', @@ -49,15 +49,15 @@ function blockAccount(req, res) { }); } function unblockAccount(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountBlock = res.locals.accountBlock; - yield blocklist_1.removeAccountFromBlocklist(accountBlock); + yield (0, blocklist_1.removeAccountFromBlocklist)(accountBlock); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function listBlockedServers(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield server_blocklist_1.ServerBlocklistModel.listForApi({ start: req.query.start, count: req.query.count, @@ -65,14 +65,14 @@ function listBlockedServers(req, res) { search: req.query.search, accountId: serverActor.Account.id }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function blockServer(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const serverToBlock = res.locals.server; - yield blocklist_1.addServerInBlocklist(serverActor.Account.id, serverToBlock.id); + yield (0, blocklist_1.addServerInBlocklist)(serverActor.Account.id, serverToBlock.id); user_notification_1.UserNotificationModel.removeNotificationsOf({ id: serverToBlock.id, type: 'server', @@ -82,9 +82,9 @@ function blockServer(req, res) { }); } function unblockServer(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverBlock = res.locals.serverBlock; - yield blocklist_1.removeServerFromBlocklist(serverBlock); + yield (0, blocklist_1.removeServerFromBlocklist)(serverBlock); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } diff --git a/dist/server/controllers/api/server/stats.js b/dist/server/controllers/api/server/stats.js index 685a572b..aa08a1ea 100644 --- a/dist/server/controllers/api/server/stats.js +++ b/dist/server/controllers/api/server/stats.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.statsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const stat_manager_1 = require("@server/lib/stat-manager"); const middlewares_1 = require("../../../middlewares"); const statsRouter = express_1.default.Router(); exports.statsRouter = statsRouter; -statsRouter.get('/stats', middlewares_1.asyncMiddleware(getStats)); +statsRouter.get('/stats', (0, middlewares_1.asyncMiddleware)(getStats)); function getStats(_req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield stat_manager_1.StatsManager.Instance.getStats(); return res.json(data); }); diff --git a/dist/server/controllers/api/users/index.js b/dist/server/controllers/api/users/index.js index 825a7c47..c76a4fa9 100644 --- a/dist/server/controllers/api/users/index.js +++ b/dist/server/controllers/api/users/index.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.usersRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const express_rate_limit_1 = tslib_1.__importDefault(require("express-rate-limit")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const express_rate_limit_1 = (0, tslib_1.__importDefault)(require("express-rate-limit")); const token_1 = require("@server/controllers/api/users/token"); const hooks_1 = require("@server/lib/plugins/hooks"); const oauth_token_1 = require("@server/models/oauth/oauth-token"); @@ -29,13 +29,13 @@ const my_history_1 = require("./my-history"); const my_notifications_1 = require("./my-notifications"); const my_subscriptions_1 = require("./my-subscriptions"); const my_video_playlists_1 = require("./my-video-playlists"); -const auditLogger = audit_logger_1.auditLoggerFactory('users'); -const signupRateLimiter = express_rate_limit_1.default({ +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('users'); +const signupRateLimiter = (0, express_rate_limit_1.default)({ windowMs: config_1.CONFIG.RATES_LIMIT.SIGNUP.WINDOW_MS, max: config_1.CONFIG.RATES_LIMIT.SIGNUP.MAX, skipFailedRequests: true }); -const askSendEmailLimiter = express_rate_limit_1.default({ +const askSendEmailLimiter = (0, express_rate_limit_1.default)({ windowMs: config_1.CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.WINDOW_MS, max: config_1.CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.MAX }); @@ -49,21 +49,21 @@ usersRouter.use('/', my_history_1.myVideosHistoryRouter); usersRouter.use('/', my_video_playlists_1.myVideoPlaylistsRouter); usersRouter.use('/', my_abuses_1.myAbusesRouter); usersRouter.use('/', me_1.meRouter); -usersRouter.get('/autocomplete', middlewares_1.userAutocompleteValidator, middlewares_1.asyncMiddleware(autocompleteUsers)); -usersRouter.get('/', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.paginationValidator, middlewares_1.usersSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.usersListValidator, middlewares_1.asyncMiddleware(listUsers)); -usersRouter.post('/:id/block', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(validators_1.usersBlockingValidator), validators_1.ensureCanManageUser, middlewares_1.asyncMiddleware(blockUser)); -usersRouter.post('/:id/unblock', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(validators_1.usersBlockingValidator), validators_1.ensureCanManageUser, middlewares_1.asyncMiddleware(unblockUser)); -usersRouter.get('/:id', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(middlewares_1.usersGetValidator), getUser); -usersRouter.post('/', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(middlewares_1.usersAddValidator), middlewares_1.asyncRetryTransactionMiddleware(createUser)); -usersRouter.post('/register', signupRateLimiter, middlewares_1.asyncMiddleware(middlewares_1.ensureUserRegistrationAllowed), middlewares_1.ensureUserRegistrationAllowedForIP, middlewares_1.asyncMiddleware(middlewares_1.usersRegisterValidator), middlewares_1.asyncRetryTransactionMiddleware(registerUser)); -usersRouter.put('/:id', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(middlewares_1.usersUpdateValidator), validators_1.ensureCanManageUser, middlewares_1.asyncMiddleware(updateUser)); -usersRouter.delete('/:id', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(1), middlewares_1.asyncMiddleware(middlewares_1.usersRemoveValidator), validators_1.ensureCanManageUser, middlewares_1.asyncMiddleware(removeUser)); -usersRouter.post('/ask-reset-password', middlewares_1.asyncMiddleware(validators_1.usersAskResetPasswordValidator), middlewares_1.asyncMiddleware(askResetUserPassword)); -usersRouter.post('/:id/reset-password', middlewares_1.asyncMiddleware(validators_1.usersResetPasswordValidator), middlewares_1.asyncMiddleware(resetUserPassword)); -usersRouter.post('/ask-send-verify-email', askSendEmailLimiter, middlewares_1.asyncMiddleware(validators_1.usersAskSendVerifyEmailValidator), middlewares_1.asyncMiddleware(reSendVerifyUserEmail)); -usersRouter.post('/:id/verify-email', middlewares_1.asyncMiddleware(validators_1.usersVerifyEmailValidator), middlewares_1.asyncMiddleware(verifyUserEmail)); +usersRouter.get('/autocomplete', middlewares_1.userAutocompleteValidator, (0, middlewares_1.asyncMiddleware)(autocompleteUsers)); +usersRouter.get('/', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), middlewares_1.paginationValidator, middlewares_1.usersSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.usersListValidator, (0, middlewares_1.asyncMiddleware)(listUsers)); +usersRouter.post('/:id/block', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(validators_1.usersBlockingValidator), validators_1.ensureCanManageUser, (0, middlewares_1.asyncMiddleware)(blockUser)); +usersRouter.post('/:id/unblock', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(validators_1.usersBlockingValidator), validators_1.ensureCanManageUser, (0, middlewares_1.asyncMiddleware)(unblockUser)); +usersRouter.get('/:id', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(middlewares_1.usersGetValidator), getUser); +usersRouter.post('/', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(middlewares_1.usersAddValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(createUser)); +usersRouter.post('/register', signupRateLimiter, (0, middlewares_1.asyncMiddleware)(middlewares_1.ensureUserRegistrationAllowed), middlewares_1.ensureUserRegistrationAllowedForIP, (0, middlewares_1.asyncMiddleware)(middlewares_1.usersRegisterValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(registerUser)); +usersRouter.put('/:id', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(middlewares_1.usersUpdateValidator), validators_1.ensureCanManageUser, (0, middlewares_1.asyncMiddleware)(updateUser)); +usersRouter.delete('/:id', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(1), (0, middlewares_1.asyncMiddleware)(middlewares_1.usersRemoveValidator), validators_1.ensureCanManageUser, (0, middlewares_1.asyncMiddleware)(removeUser)); +usersRouter.post('/ask-reset-password', (0, middlewares_1.asyncMiddleware)(validators_1.usersAskResetPasswordValidator), (0, middlewares_1.asyncMiddleware)(askResetUserPassword)); +usersRouter.post('/:id/reset-password', (0, middlewares_1.asyncMiddleware)(validators_1.usersResetPasswordValidator), (0, middlewares_1.asyncMiddleware)(resetUserPassword)); +usersRouter.post('/ask-send-verify-email', askSendEmailLimiter, (0, middlewares_1.asyncMiddleware)(validators_1.usersAskSendVerifyEmailValidator), (0, middlewares_1.asyncMiddleware)(reSendVerifyUserEmail)); +usersRouter.post('/:id/verify-email', (0, middlewares_1.asyncMiddleware)(validators_1.usersVerifyEmailValidator), (0, middlewares_1.asyncMiddleware)(verifyUserEmail)); function createUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const userToCreate = new user_2.UserModel({ username: body.username, @@ -78,13 +78,13 @@ function createUser(req, res) { }); const createPassword = userToCreate.password === ''; if (createPassword) { - userToCreate.password = yield utils_1.generateRandomString(20); + userToCreate.password = yield (0, utils_1.generateRandomString)(20); } - const { user, account, videoChannel } = yield user_1.createUserAccountAndChannelAndPlaylist({ + const { user, account, videoChannel } = yield (0, user_1.createUserAccountAndChannelAndPlaylist)({ userToCreate, channelNames: body.channelName && { name: body.channelName, displayName: body.channelName } }); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); logger_1.logger.info('User %s with its channel and account created.', body.username); if (createPassword) { logger_1.logger.info('Sending to user %s a create password email', body.username); @@ -104,7 +104,7 @@ function createUser(req, res) { }); } function registerUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const userToCreate = new user_2.UserModel({ username: body.username, @@ -117,7 +117,7 @@ function registerUser(req, res) { videoQuotaDaily: config_1.CONFIG.USER.VIDEO_QUOTA_DAILY, emailVerified: config_1.CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION ? false : null }); - const { user, account, videoChannel } = yield user_1.createUserAccountAndChannelAndPlaylist({ + const { user, account, videoChannel } = yield (0, user_1.createUserAccountAndChannelAndPlaylist)({ userToCreate: userToCreate, userDisplayName: body.displayName || undefined, channelNames: body.channel @@ -125,7 +125,7 @@ function registerUser(req, res) { auditLogger.create(body.username, new audit_logger_1.UserAuditView(user.toFormattedJSON())); logger_1.logger.info('User %s with its channel and account registered.', body.username); if (config_1.CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { - yield user_1.sendVerifyUserEmail(user); + yield (0, user_1.sendVerifyUserEmail)(user); } notifier_1.Notifier.Instance.notifyOnNewUserRegistration(user); hooks_1.Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel }); @@ -133,7 +133,7 @@ function registerUser(req, res) { }); } function unblockUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; yield changeUserBlock(res, user, false); hooks_1.Hooks.runAction('action:api.user.unblocked', { user }); @@ -141,7 +141,7 @@ function unblockUser(req, res) { }); } function blockUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; const reason = req.body.reason; yield changeUserBlock(res, user, true, reason); @@ -153,13 +153,13 @@ function getUser(req, res) { return res.json(res.locals.user.toFormattedJSON({ withAdminFlags: true })); } function autocompleteUsers(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield user_2.UserModel.autoComplete(req.query.search); return res.json(resultList); }); } function listUsers(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield user_2.UserModel.listForApi({ start: req.query.start, count: req.query.count, @@ -167,14 +167,14 @@ function listUsers(req, res) { search: req.query.search, blocked: req.query.blocked }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total, { withAdminFlags: true })); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total, { withAdminFlags: true })); }); } function removeUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield user.destroy({ transaction: t }); })); hooks_1.Hooks.runAction('action:api.user.deleted', { user }); @@ -182,7 +182,7 @@ function removeUser(req, res) { }); } function updateUser(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const userToUpdate = res.locals.user; const oldUserAuditView = new audit_logger_1.UserAuditView(userToUpdate.toFormattedJSON()); @@ -204,13 +204,13 @@ function updateUser(req, res) { const user = yield userToUpdate.save(); if (roleChanged || body.password !== undefined) yield oauth_token_1.OAuthTokenModel.deleteUserToken(userToUpdate.id); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.UserAuditView(user.toFormattedJSON()), oldUserAuditView); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.UserAuditView(user.toFormattedJSON()), oldUserAuditView); hooks_1.Hooks.runAction('action:api.user.updated', { user }); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function askResetUserPassword(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; const verificationString = yield redis_1.Redis.Instance.setResetPasswordVerificationString(user.id); const url = constants_1.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString; @@ -219,7 +219,7 @@ function askResetUserPassword(req, res) { }); } function resetUserPassword(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; user.password = req.body.password; yield user.save(); @@ -228,14 +228,14 @@ function resetUserPassword(req, res) { }); } function reSendVerifyUserEmail(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; - yield user_1.sendVerifyUserEmail(user); + yield (0, user_1.sendVerifyUserEmail)(user); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function verifyUserEmail(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.user; user.emailVerified = true; if (req.body.isPendingEmail === true) { @@ -247,15 +247,15 @@ function verifyUserEmail(req, res) { }); } function changeUserBlock(res, user, block, reason) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldUserAuditView = new audit_logger_1.UserAuditView(user.toFormattedJSON()); user.blocked = block; user.blockedReason = reason || null; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield oauth_token_1.OAuthTokenModel.deleteUserToken(user.id, t); yield user.save({ transaction: t }); })); yield emailer_1.Emailer.Instance.addUserBlockJob(user, block, reason); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.UserAuditView(user.toFormattedJSON()), oldUserAuditView); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.UserAuditView(user.toFormattedJSON()), oldUserAuditView); }); } diff --git a/dist/server/controllers/api/users/me.js b/dist/server/controllers/api/users/me.js index b934c656..69e165e9 100644 --- a/dist/server/controllers/api/users/me.js +++ b/dist/server/controllers/api/users/me.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.meRouter = void 0; const tslib_1 = require("tslib"); require("multer"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const audit_logger_1 = require("@server/helpers/audit-logger"); const hooks_1 = require("@server/lib/plugins/hooks"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); @@ -23,22 +23,22 @@ const account_video_rate_1 = require("../../../models/account/account-video-rate const user_2 = require("../../../models/user/user"); const video_1 = require("../../../models/video/video"); const video_import_1 = require("../../../models/video/video-import"); -const auditLogger = audit_logger_1.auditLoggerFactory('users'); -const reqAvatarFile = express_utils_1.createReqFiles(['avatarfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: config_1.CONFIG.STORAGE.TMP_DIR }); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('users'); +const reqAvatarFile = (0, express_utils_1.createReqFiles)(['avatarfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: config_1.CONFIG.STORAGE.TMP_DIR }); const meRouter = express_1.default.Router(); exports.meRouter = meRouter; -meRouter.get('/me', middlewares_1.authenticate, middlewares_1.asyncMiddleware(getUserInformation)); -meRouter.delete('/me', middlewares_1.authenticate, validators_1.deleteMeValidator, middlewares_1.asyncMiddleware(deleteMe)); -meRouter.get('/me/video-quota-used', middlewares_1.authenticate, middlewares_1.asyncMiddleware(getUserVideoQuotaUsed)); -meRouter.get('/me/videos/imports', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videoImportsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(getUserVideoImports)); -meRouter.get('/me/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(getUserVideos)); -meRouter.get('/me/video-views', middlewares_1.authenticate, middlewares_1.asyncMiddleware(getUserVideoViews)); -meRouter.get('/me/videos/:videoId/rating', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.usersVideoRatingValidator), middlewares_1.asyncMiddleware(getUserVideoRating)); -meRouter.put('/me', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.usersUpdateMeValidator), middlewares_1.asyncRetryTransactionMiddleware(updateMe)); -meRouter.post('/me/avatar/pick', middlewares_1.authenticate, reqAvatarFile, actor_image_1.updateAvatarValidator, middlewares_1.asyncRetryTransactionMiddleware(updateMyAvatar)); -meRouter.delete('/me/avatar', middlewares_1.authenticate, middlewares_1.asyncRetryTransactionMiddleware(deleteMyAvatar)); +meRouter.get('/me', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(getUserInformation)); +meRouter.delete('/me', middlewares_1.authenticate, validators_1.deleteMeValidator, (0, middlewares_1.asyncMiddleware)(deleteMe)); +meRouter.get('/me/video-quota-used', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(getUserVideoQuotaUsed)); +meRouter.get('/me/videos/imports', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videoImportsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(getUserVideoImports)); +meRouter.get('/me/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(getUserVideos)); +meRouter.get('/me/video-views', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(getUserVideoViews)); +meRouter.get('/me/videos/:videoId/rating', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.usersVideoRatingValidator), (0, middlewares_1.asyncMiddleware)(getUserVideoRating)); +meRouter.put('/me', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.usersUpdateMeValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateMe)); +meRouter.post('/me/avatar/pick', middlewares_1.authenticate, reqAvatarFile, actor_image_1.updateAvatarValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(updateMyAvatar)); +meRouter.delete('/me/avatar', middlewares_1.authenticate, (0, middlewares_1.asyncRetryTransactionMiddleware)(deleteMyAvatar)); function getUserVideoViews(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const username = res.locals.oauth.token.User.username; const startDate = req.params.startDate || null; const totalViews = yield video_1.VideoModel.meVideoViews(username, startDate); @@ -48,7 +48,7 @@ function getUserVideoViews(req, res) { }); } function getUserVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const apiOptions = yield hooks_1.Hooks.wrapObject({ user: user, @@ -66,27 +66,27 @@ function getUserVideos(req, res) { scheduledUpdate: true, blacklistInfo: true }; - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total, { additionalAttributes })); }); } function getUserVideoImports(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const resultList = yield video_import_1.VideoImportModel.listUserVideoImportsForApi(user.id, req.query.start, req.query.count, req.query.sort); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function getUserInformation(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield user_2.UserModel.loadForMeAPI(res.locals.oauth.token.user.id); return res.json(user.toMeFormattedJSON()); }); } function getUserVideoQuotaUsed(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.user; - const videoQuotaUsed = yield user_1.getOriginalVideoFileTotalFromUser(user); - const videoQuotaUsedDaily = yield user_1.getOriginalVideoFileTotalDailyFromUser(user); + const videoQuotaUsed = yield (0, user_1.getOriginalVideoFileTotalFromUser)(user); + const videoQuotaUsedDaily = yield (0, user_1.getOriginalVideoFileTotalDailyFromUser)(user); const data = { videoQuotaUsed, videoQuotaUsedDaily @@ -95,7 +95,7 @@ function getUserVideoQuotaUsed(req, res) { }); } function getUserVideoRating(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoId = res.locals.videoId.id; const accountId = +res.locals.oauth.token.User.Account.id; const ratingObj = yield account_video_rate_1.AccountVideoRateModel.load(accountId, videoId, null); @@ -108,15 +108,15 @@ function getUserVideoRating(req, res) { }); } function deleteMe(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield user_2.UserModel.loadByIdWithChannels(res.locals.oauth.token.User.id); - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.UserAuditView(user.toFormattedJSON())); yield user.destroy(); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function updateMe(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; let sendVerificationEmail = false; const user = res.locals.oauth.token.user; @@ -147,7 +147,7 @@ function updateMe(req, res) { user.email = body.email; } } - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield user.save({ transaction: t }); if (body.displayName === undefined && body.description === undefined) return; @@ -157,28 +157,28 @@ function updateMe(req, res) { if (body.description !== undefined) userAccount.description = body.description; yield userAccount.save({ transaction: t }); - yield send_1.sendUpdateActor(userAccount, t); + yield (0, send_1.sendUpdateActor)(userAccount, t); })); if (sendVerificationEmail === true) { - yield user_1.sendVerifyUserEmail(user, true); + yield (0, user_1.sendVerifyUserEmail)(user, true); } return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function updateMyAvatar(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const avatarPhysicalFile = req.files['avatarfile'][0]; const user = res.locals.oauth.token.user; const userAccount = yield account_1.AccountModel.load(user.Account.id); - const avatar = yield local_actor_1.updateLocalActorImageFile(userAccount, avatarPhysicalFile, 1); + const avatar = yield (0, local_actor_1.updateLocalActorImageFile)(userAccount, avatarPhysicalFile, 1); return res.json({ avatar: avatar.toFormattedJSON() }); }); } function deleteMyAvatar(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.user; const userAccount = yield account_1.AccountModel.load(user.Account.id); - yield local_actor_1.deleteLocalActorImageFile(userAccount, 1); + yield (0, local_actor_1.deleteLocalActorImageFile)(userAccount, 1); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } diff --git a/dist/server/controllers/api/users/my-abuses.js b/dist/server/controllers/api/users/my-abuses.js index ef4e39ac..eb3411b8 100644 --- a/dist/server/controllers/api/users/my-abuses.js +++ b/dist/server/controllers/api/users/my-abuses.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.myAbusesRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const abuse_1 = require("@server/models/abuse/abuse"); const middlewares_1 = require("../../../middlewares"); const myAbusesRouter = express_1.default.Router(); exports.myAbusesRouter = myAbusesRouter; -myAbusesRouter.get('/me/abuses', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.abusesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.abuseListForUserValidator, middlewares_1.asyncMiddleware(listMyAbuses)); +myAbusesRouter.get('/me/abuses', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.abusesSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.abuseListForUserValidator, (0, middlewares_1.asyncMiddleware)(listMyAbuses)); function listMyAbuses(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield abuse_1.AbuseModel.listForUserApi({ start: req.query.start, count: req.query.count, diff --git a/dist/server/controllers/api/users/my-blocklist.js b/dist/server/controllers/api/users/my-blocklist.js index 56649876..85c21dec 100644 --- a/dist/server/controllers/api/users/my-blocklist.js +++ b/dist/server/controllers/api/users/my-blocklist.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.myBlocklistRouter = void 0; const tslib_1 = require("tslib"); require("multer"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const user_notification_1 = require("@server/models/user/user-notification"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); @@ -15,14 +15,14 @@ const account_blocklist_1 = require("../../../models/account/account-blocklist") const server_blocklist_1 = require("../../../models/server/server-blocklist"); const myBlocklistRouter = express_1.default.Router(); exports.myBlocklistRouter = myBlocklistRouter; -myBlocklistRouter.get('/me/blocklist/accounts', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.accountsBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listBlockedAccounts)); -myBlocklistRouter.post('/me/blocklist/accounts', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.blockAccountValidator), middlewares_1.asyncRetryTransactionMiddleware(blockAccount)); -myBlocklistRouter.delete('/me/blocklist/accounts/:accountName', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.unblockAccountByAccountValidator), middlewares_1.asyncRetryTransactionMiddleware(unblockAccount)); -myBlocklistRouter.get('/me/blocklist/servers', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.serversBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(listBlockedServers)); -myBlocklistRouter.post('/me/blocklist/servers', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.blockServerValidator), middlewares_1.asyncRetryTransactionMiddleware(blockServer)); -myBlocklistRouter.delete('/me/blocklist/servers/:host', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.unblockServerByAccountValidator), middlewares_1.asyncRetryTransactionMiddleware(unblockServer)); +myBlocklistRouter.get('/me/blocklist/accounts', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.accountsBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listBlockedAccounts)); +myBlocklistRouter.post('/me/blocklist/accounts', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.blockAccountValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(blockAccount)); +myBlocklistRouter.delete('/me/blocklist/accounts/:accountName', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.unblockAccountByAccountValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(unblockAccount)); +myBlocklistRouter.get('/me/blocklist/servers', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.serversBlocklistSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(listBlockedServers)); +myBlocklistRouter.post('/me/blocklist/servers', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.blockServerValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(blockServer)); +myBlocklistRouter.delete('/me/blocklist/servers/:host', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.unblockServerByAccountValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(unblockServer)); function listBlockedAccounts(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const resultList = yield account_blocklist_1.AccountBlocklistModel.listForApi({ start: req.query.start, @@ -31,14 +31,14 @@ function listBlockedAccounts(req, res) { search: req.query.search, accountId: user.Account.id }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function blockAccount(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const accountToBlock = res.locals.account; - yield blocklist_1.addAccountInBlocklist(user.Account.id, accountToBlock.id); + yield (0, blocklist_1.addAccountInBlocklist)(user.Account.id, accountToBlock.id); user_notification_1.UserNotificationModel.removeNotificationsOf({ id: accountToBlock.id, type: 'account', @@ -48,14 +48,14 @@ function blockAccount(req, res) { }); } function unblockAccount(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountBlock = res.locals.accountBlock; - yield blocklist_1.removeAccountFromBlocklist(accountBlock); + yield (0, blocklist_1.removeAccountFromBlocklist)(accountBlock); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function listBlockedServers(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const resultList = yield server_blocklist_1.ServerBlocklistModel.listForApi({ start: req.query.start, @@ -64,14 +64,14 @@ function listBlockedServers(req, res) { search: req.query.search, accountId: user.Account.id }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function blockServer(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const serverToBlock = res.locals.server; - yield blocklist_1.addServerInBlocklist(user.Account.id, serverToBlock.id); + yield (0, blocklist_1.addServerInBlocklist)(user.Account.id, serverToBlock.id); user_notification_1.UserNotificationModel.removeNotificationsOf({ id: serverToBlock.id, type: 'server', @@ -81,9 +81,9 @@ function blockServer(req, res) { }); } function unblockServer(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverBlock = res.locals.serverBlock; - yield blocklist_1.removeServerFromBlocklist(serverBlock); + yield (0, blocklist_1.removeServerFromBlocklist)(serverBlock); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } diff --git a/dist/server/controllers/api/users/my-history.js b/dist/server/controllers/api/users/my-history.js index 00896d0d..90bd71da 100644 --- a/dist/server/controllers/api/users/my-history.js +++ b/dist/server/controllers/api/users/my-history.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.myVideosHistoryRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const utils_1 = require("../../../helpers/utils"); const database_1 = require("../../../initializers/database"); @@ -10,17 +10,17 @@ const middlewares_1 = require("../../../middlewares"); const user_video_history_1 = require("../../../models/user/user-video-history"); const myVideosHistoryRouter = express_1.default.Router(); exports.myVideosHistoryRouter = myVideosHistoryRouter; -myVideosHistoryRouter.get('/me/history/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.userHistoryListValidator, middlewares_1.asyncMiddleware(listMyVideosHistory)); -myVideosHistoryRouter.post('/me/history/videos/remove', middlewares_1.authenticate, middlewares_1.userHistoryRemoveValidator, middlewares_1.asyncRetryTransactionMiddleware(removeUserHistory)); +myVideosHistoryRouter.get('/me/history/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.userHistoryListValidator, (0, middlewares_1.asyncMiddleware)(listMyVideosHistory)); +myVideosHistoryRouter.post('/me/history/videos/remove', middlewares_1.authenticate, middlewares_1.userHistoryRemoveValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(removeUserHistory)); function listMyVideosHistory(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const resultList = yield user_video_history_1.UserVideoHistoryModel.listForApi(user, req.query.start, req.query.count, req.query.search); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function removeUserHistory(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const beforeDate = req.body.beforeDate || null; yield database_1.sequelizeTypescript.transaction(t => { diff --git a/dist/server/controllers/api/users/my-notifications.js b/dist/server/controllers/api/users/my-notifications.js index 41edf34a..cfd531a4 100644 --- a/dist/server/controllers/api/users/my-notifications.js +++ b/dist/server/controllers/api/users/my-notifications.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.myNotificationsRouter = void 0; const tslib_1 = require("tslib"); require("multer"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const user_notification_1 = require("@server/models/user/user-notification"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const utils_1 = require("../../../helpers/utils"); @@ -13,12 +13,12 @@ const user_notification_setting_1 = require("../../../models/user/user-notificat const me_1 = require("./me"); const myNotificationsRouter = express_1.default.Router(); exports.myNotificationsRouter = myNotificationsRouter; -me_1.meRouter.put('/me/notification-settings', middlewares_1.authenticate, user_notifications_1.updateNotificationSettingsValidator, middlewares_1.asyncRetryTransactionMiddleware(updateNotificationSettings)); -myNotificationsRouter.get('/me/notifications', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.userNotificationsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, user_notifications_1.listUserNotificationsValidator, middlewares_1.asyncMiddleware(listUserNotifications)); -myNotificationsRouter.post('/me/notifications/read', middlewares_1.authenticate, user_notifications_1.markAsReadUserNotificationsValidator, middlewares_1.asyncMiddleware(markAsReadUserNotifications)); -myNotificationsRouter.post('/me/notifications/read-all', middlewares_1.authenticate, middlewares_1.asyncMiddleware(markAsReadAllUserNotifications)); +me_1.meRouter.put('/me/notification-settings', middlewares_1.authenticate, user_notifications_1.updateNotificationSettingsValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(updateNotificationSettings)); +myNotificationsRouter.get('/me/notifications', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.userNotificationsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, user_notifications_1.listUserNotificationsValidator, (0, middlewares_1.asyncMiddleware)(listUserNotifications)); +myNotificationsRouter.post('/me/notifications/read', middlewares_1.authenticate, user_notifications_1.markAsReadUserNotificationsValidator, (0, middlewares_1.asyncMiddleware)(markAsReadUserNotifications)); +myNotificationsRouter.post('/me/notifications/read-all', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(markAsReadAllUserNotifications)); function updateNotificationSettings(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const body = req.body; const query = { @@ -49,21 +49,21 @@ function updateNotificationSettings(req, res) { }); } function listUserNotifications(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const resultList = yield user_notification_1.UserNotificationModel.listForApi(user.id, req.query.start, req.query.count, req.query.sort, req.query.unread); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function markAsReadUserNotifications(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; yield user_notification_1.UserNotificationModel.markAsRead(user.id, req.body.ids); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function markAsReadAllUserNotifications(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; yield user_notification_1.UserNotificationModel.markAllAsRead(user.id); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); diff --git a/dist/server/controllers/api/users/my-subscriptions.js b/dist/server/controllers/api/users/my-subscriptions.js index fbd749c2..f254aed5 100644 --- a/dist/server/controllers/api/users/my-subscriptions.js +++ b/dist/server/controllers/api/users/my-subscriptions.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.mySubscriptionsRouter = void 0; const tslib_1 = require("tslib"); require("multer"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const query_1 = require("@server/helpers/query"); const send_1 = require("@server/lib/activitypub/send"); const video_channel_1 = require("@server/models/video/video-channel"); @@ -19,14 +19,14 @@ const actor_follow_1 = require("../../../models/actor/actor-follow"); const video_1 = require("../../../models/video/video"); const mySubscriptionsRouter = express_1.default.Router(); exports.mySubscriptionsRouter = mySubscriptionsRouter; -mySubscriptionsRouter.get('/me/subscriptions/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(getUserSubscriptionVideos)); -mySubscriptionsRouter.get('/me/subscriptions/exist', middlewares_1.authenticate, validators_1.areSubscriptionsExistValidator, middlewares_1.asyncMiddleware(areSubscriptionsExist)); -mySubscriptionsRouter.get('/me/subscriptions', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.userSubscriptionsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.userSubscriptionListValidator, middlewares_1.asyncMiddleware(getUserSubscriptions)); +mySubscriptionsRouter.get('/me/subscriptions/videos', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(getUserSubscriptionVideos)); +mySubscriptionsRouter.get('/me/subscriptions/exist', middlewares_1.authenticate, validators_1.areSubscriptionsExistValidator, (0, middlewares_1.asyncMiddleware)(areSubscriptionsExist)); +mySubscriptionsRouter.get('/me/subscriptions', middlewares_1.authenticate, middlewares_1.paginationValidator, validators_1.userSubscriptionsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.userSubscriptionListValidator, (0, middlewares_1.asyncMiddleware)(getUserSubscriptions)); mySubscriptionsRouter.post('/me/subscriptions', middlewares_1.authenticate, middlewares_1.userSubscriptionAddValidator, addUserSubscription); -mySubscriptionsRouter.get('/me/subscriptions/:uri', middlewares_1.authenticate, middlewares_1.userSubscriptionGetValidator, middlewares_1.asyncMiddleware(getUserSubscription)); -mySubscriptionsRouter.delete('/me/subscriptions/:uri', middlewares_1.authenticate, middlewares_1.userSubscriptionGetValidator, middlewares_1.asyncRetryTransactionMiddleware(deleteUserSubscription)); +mySubscriptionsRouter.get('/me/subscriptions/:uri', middlewares_1.authenticate, middlewares_1.userSubscriptionGetValidator, (0, middlewares_1.asyncMiddleware)(getUserSubscription)); +mySubscriptionsRouter.delete('/me/subscriptions/:uri', middlewares_1.authenticate, middlewares_1.userSubscriptionGetValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(deleteUserSubscription)); function areSubscriptionsExist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uris = req.query.uris; const user = res.locals.oauth.token.User; const handles = uris.map(u => { @@ -62,18 +62,18 @@ function addUserSubscription(req, res) { return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); } function getUserSubscription(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const subscription = res.locals.subscription; const videoChannel = yield video_channel_1.VideoChannelModel.loadAndPopulateAccount(subscription.ActorFollowing.VideoChannel.id); return res.json(videoChannel.toFormattedJSON()); }); } function deleteUserSubscription(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const subscription = res.locals.subscription; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (subscription.state === 'accepted') - yield send_1.sendUndoFollow(subscription, t); + yield (0, send_1.sendUndoFollow)(subscription, t); return subscription.destroy({ transaction: t }); })); return res.type('json') @@ -82,7 +82,7 @@ function deleteUserSubscription(req, res) { }); } function getUserSubscriptions(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const actorId = user.Account.Actor.id; const resultList = yield actor_follow_1.ActorFollowModel.listSubscriptionsForApi({ @@ -92,16 +92,16 @@ function getUserSubscriptions(req, res) { sort: req.query.sort, search: req.query.search }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function getUserSubscriptionVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; - const countVideos = express_utils_1.getCountVideos(req); - const query = query_1.pickCommonVideoQuery(req.query); - const resultList = yield video_1.VideoModel.listForApi(Object.assign(Object.assign({}, query), { includeLocalVideos: false, nsfw: express_utils_1.buildNSFWFilter(res, query.nsfw), withFiles: false, followerActorId: user.Account.Actor.id, user, + const countVideos = (0, express_utils_1.getCountVideos)(req); + const query = (0, query_1.pickCommonVideoQuery)(req.query); + const resultList = yield video_1.VideoModel.listForApi(Object.assign(Object.assign({}, query), { includeLocalVideos: false, nsfw: (0, express_utils_1.buildNSFWFilter)(res, query.nsfw), withFiles: false, followerActorId: user.Account.Actor.id, user, countVideos })); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } diff --git a/dist/server/controllers/api/users/my-video-playlists.js b/dist/server/controllers/api/users/my-video-playlists.js index d6e1f810..b80931f7 100644 --- a/dist/server/controllers/api/users/my-video-playlists.js +++ b/dist/server/controllers/api/users/my-video-playlists.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.myVideoPlaylistsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const middlewares_1 = require("../../../middlewares"); const video_playlists_1 = require("../../../middlewares/validators/videos/video-playlists"); const video_playlist_1 = require("../../../models/video/video-playlist"); const myVideoPlaylistsRouter = express_1.default.Router(); exports.myVideoPlaylistsRouter = myVideoPlaylistsRouter; -myVideoPlaylistsRouter.get('/me/video-playlists/videos-exist', middlewares_1.authenticate, video_playlists_1.doVideosInPlaylistExistValidator, middlewares_1.asyncMiddleware(doVideosInPlaylistExist)); +myVideoPlaylistsRouter.get('/me/video-playlists/videos-exist', middlewares_1.authenticate, video_playlists_1.doVideosInPlaylistExistValidator, (0, middlewares_1.asyncMiddleware)(doVideosInPlaylistExist)); function doVideosInPlaylistExist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoIds = req.query.videoIds.map(i => parseInt(i + '', 10)); const user = res.locals.oauth.token.User; const results = yield video_playlist_1.VideoPlaylistModel.listPlaylistIdsOf(user.Account.id, videoIds); diff --git a/dist/server/controllers/api/users/token.js b/dist/server/controllers/api/users/token.js index 578f18d5..33b8cc01 100644 --- a/dist/server/controllers/api/users/token.js +++ b/dist/server/controllers/api/users/token.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.tokensRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const express_rate_limit_1 = tslib_1.__importDefault(require("express-rate-limit")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const express_rate_limit_1 = (0, tslib_1.__importDefault)(require("express-rate-limit")); const logger_1 = require("@server/helpers/logger"); const uuid_1 = require("@server/helpers/uuid"); const config_1 = require("@server/initializers/config"); @@ -14,27 +14,27 @@ const hooks_1 = require("@server/lib/plugins/hooks"); const middlewares_1 = require("@server/middlewares"); const tokensRouter = express_1.default.Router(); exports.tokensRouter = tokensRouter; -const loginRateLimiter = express_rate_limit_1.default({ +const loginRateLimiter = (0, express_rate_limit_1.default)({ windowMs: config_1.CONFIG.RATES_LIMIT.LOGIN.WINDOW_MS, max: config_1.CONFIG.RATES_LIMIT.LOGIN.MAX }); -tokensRouter.post('/token', loginRateLimiter, middlewares_1.openapiOperationDoc({ operationId: 'getOAuthToken' }), middlewares_1.asyncMiddleware(handleToken)); -tokensRouter.post('/revoke-token', middlewares_1.openapiOperationDoc({ operationId: 'revokeOAuthToken' }), middlewares_1.authenticate, middlewares_1.asyncMiddleware(handleTokenRevocation)); +tokensRouter.post('/token', loginRateLimiter, (0, middlewares_1.openapiOperationDoc)({ operationId: 'getOAuthToken' }), (0, middlewares_1.asyncMiddleware)(handleToken)); +tokensRouter.post('/revoke-token', (0, middlewares_1.openapiOperationDoc)({ operationId: 'revokeOAuthToken' }), middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(handleTokenRevocation)); tokensRouter.get('/scoped-tokens', middlewares_1.authenticate, getScopedTokens); -tokensRouter.post('/scoped-tokens', middlewares_1.authenticate, middlewares_1.asyncMiddleware(renewScopedTokens)); +tokensRouter.post('/scoped-tokens', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(renewScopedTokens)); function handleToken(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const grantType = req.body.grant_type; try { const bypassLogin = yield buildByPassLogin(req, grantType); const refreshTokenAuthName = grantType === 'refresh_token' - ? yield external_auth_1.getAuthNameFromRefreshGrant(req.body.refresh_token) + ? yield (0, external_auth_1.getAuthNameFromRefreshGrant)(req.body.refresh_token) : undefined; const options = { refreshTokenAuthName, bypassLogin }; - const token = yield oauth_1.handleOAuthToken(req, options); + const token = yield (0, oauth_1.handleOAuthToken)(req, options); res.set('Cache-Control', 'no-store'); res.set('Pragma', 'no-cache'); hooks_1.Hooks.runAction('action:api.user.oauth2-got-token', { username: token.user.username, ip: req.ip }); @@ -57,9 +57,9 @@ function handleToken(req, res, next) { }); } function handleTokenRevocation(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const token = res.locals.oauth.token; - const result = yield oauth_model_1.revokeToken(token, { req, explicitLogout: true }); + const result = yield (0, oauth_model_1.revokeToken)(token, { req, explicitLogout: true }); return res.json(result); }); } @@ -70,9 +70,9 @@ function getScopedTokens(req, res) { }); } function renewScopedTokens(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.user; - user.feedToken = uuid_1.buildUUID(); + user.feedToken = (0, uuid_1.buildUUID)(); yield user.save(); return res.json({ feedToken: user.feedToken @@ -80,12 +80,12 @@ function renewScopedTokens(req, res) { }); } function buildByPassLogin(req, grantType) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (grantType !== 'password') return undefined; if (req.body.externalAuthToken) { - return external_auth_1.getBypassFromExternalAuth(req.body.username, req.body.externalAuthToken); + return (0, external_auth_1.getBypassFromExternalAuth)(req.body.username, req.body.externalAuthToken); } - return external_auth_1.getBypassFromPasswordGrant(req.body.username, req.body.password); + return (0, external_auth_1.getBypassFromPasswordGrant)(req.body.username, req.body.password); }); } diff --git a/dist/server/controllers/api/video-channel.js b/dist/server/controllers/api/video-channel.js index 23debd4b..be501157 100644 --- a/dist/server/controllers/api/video-channel.js +++ b/dist/server/controllers/api/video-channel.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videoChannelRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const query_1 = require("@server/helpers/query"); const hooks_1 = require("@server/lib/plugins/hooks"); const application_1 = require("@server/models/application/application"); @@ -27,78 +27,78 @@ const account_1 = require("../../models/account/account"); const video_1 = require("../../models/video/video"); const video_channel_2 = require("../../models/video/video-channel"); const video_playlist_1 = require("../../models/video/video-playlist"); -const auditLogger = audit_logger_1.auditLoggerFactory('channels'); -const reqAvatarFile = express_utils_1.createReqFiles(['avatarfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: config_1.CONFIG.STORAGE.TMP_DIR }); -const reqBannerFile = express_utils_1.createReqFiles(['bannerfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { bannerfile: config_1.CONFIG.STORAGE.TMP_DIR }); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('channels'); +const reqAvatarFile = (0, express_utils_1.createReqFiles)(['avatarfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: config_1.CONFIG.STORAGE.TMP_DIR }); +const reqBannerFile = (0, express_utils_1.createReqFiles)(['bannerfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { bannerfile: config_1.CONFIG.STORAGE.TMP_DIR }); const videoChannelRouter = express_1.default.Router(); exports.videoChannelRouter = videoChannelRouter; -videoChannelRouter.get('/', middlewares_1.paginationValidator, middlewares_1.videoChannelsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.videoChannelsListValidator, middlewares_1.asyncMiddleware(listVideoChannels)); -videoChannelRouter.post('/', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsAddValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoChannel)); -videoChannelRouter.post('/:nameWithHost/avatar/pick', middlewares_1.authenticate, reqAvatarFile, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsUpdateValidator), actor_image_1.updateAvatarValidator, middlewares_1.asyncMiddleware(updateVideoChannelAvatar)); -videoChannelRouter.post('/:nameWithHost/banner/pick', middlewares_1.authenticate, reqBannerFile, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsUpdateValidator), actor_image_1.updateBannerValidator, middlewares_1.asyncMiddleware(updateVideoChannelBanner)); -videoChannelRouter.delete('/:nameWithHost/avatar', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsUpdateValidator), middlewares_1.asyncMiddleware(deleteVideoChannelAvatar)); -videoChannelRouter.delete('/:nameWithHost/banner', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsUpdateValidator), middlewares_1.asyncMiddleware(deleteVideoChannelBanner)); -videoChannelRouter.put('/:nameWithHost', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsUpdateValidator), middlewares_1.asyncRetryTransactionMiddleware(updateVideoChannel)); -videoChannelRouter.delete('/:nameWithHost', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoChannelsRemoveValidator), middlewares_1.asyncRetryTransactionMiddleware(removeVideoChannel)); -videoChannelRouter.get('/:nameWithHost', middlewares_1.asyncMiddleware(validators_1.videoChannelsNameWithHostValidator), getVideoChannel); -videoChannelRouter.get('/:nameWithHost/video-playlists', middlewares_1.asyncMiddleware(validators_1.videoChannelsNameWithHostValidator), middlewares_1.paginationValidator, middlewares_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, middlewares_1.asyncMiddleware(listVideoChannelPlaylists)); -videoChannelRouter.get('/:nameWithHost/videos', middlewares_1.asyncMiddleware(validators_1.videoChannelsNameWithHostValidator), middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(listVideoChannelVideos)); +videoChannelRouter.get('/', middlewares_1.paginationValidator, middlewares_1.videoChannelsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.videoChannelsListValidator, (0, middlewares_1.asyncMiddleware)(listVideoChannels)); +videoChannelRouter.post('/', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsAddValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoChannel)); +videoChannelRouter.post('/:nameWithHost/avatar/pick', middlewares_1.authenticate, reqAvatarFile, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsUpdateValidator), actor_image_1.updateAvatarValidator, (0, middlewares_1.asyncMiddleware)(updateVideoChannelAvatar)); +videoChannelRouter.post('/:nameWithHost/banner/pick', middlewares_1.authenticate, reqBannerFile, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsUpdateValidator), actor_image_1.updateBannerValidator, (0, middlewares_1.asyncMiddleware)(updateVideoChannelBanner)); +videoChannelRouter.delete('/:nameWithHost/avatar', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsUpdateValidator), (0, middlewares_1.asyncMiddleware)(deleteVideoChannelAvatar)); +videoChannelRouter.delete('/:nameWithHost/banner', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsUpdateValidator), (0, middlewares_1.asyncMiddleware)(deleteVideoChannelBanner)); +videoChannelRouter.put('/:nameWithHost', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsUpdateValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateVideoChannel)); +videoChannelRouter.delete('/:nameWithHost', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoChannelsRemoveValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(removeVideoChannel)); +videoChannelRouter.get('/:nameWithHost', (0, middlewares_1.asyncMiddleware)(validators_1.videoChannelsNameWithHostValidator), getVideoChannel); +videoChannelRouter.get('/:nameWithHost/video-playlists', (0, middlewares_1.asyncMiddleware)(validators_1.videoChannelsNameWithHostValidator), middlewares_1.paginationValidator, middlewares_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, (0, middlewares_1.asyncMiddleware)(listVideoChannelPlaylists)); +videoChannelRouter.get('/:nameWithHost/videos', (0, middlewares_1.asyncMiddleware)(validators_1.videoChannelsNameWithHostValidator), middlewares_1.paginationValidator, validators_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(listVideoChannelVideos)); function listVideoChannels(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield video_channel_2.VideoChannelModel.listForApi({ actorId: serverActor.id, start: req.query.start, count: req.query.count, sort: req.query.sort }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function updateVideoChannelBanner(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const bannerPhysicalFile = req.files['bannerfile'][0]; const videoChannel = res.locals.videoChannel; const oldVideoChannelAuditKeys = new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()); - const banner = yield local_actor_1.updateLocalActorImageFile(videoChannel, bannerPhysicalFile, 2); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys); + const banner = yield (0, local_actor_1.updateLocalActorImageFile)(videoChannel, bannerPhysicalFile, 2); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys); return res.json({ banner: banner.toFormattedJSON() }); }); } function updateVideoChannelAvatar(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const avatarPhysicalFile = req.files['avatarfile'][0]; const videoChannel = res.locals.videoChannel; const oldVideoChannelAuditKeys = new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()); - const avatar = yield local_actor_1.updateLocalActorImageFile(videoChannel, avatarPhysicalFile, 1); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys); + const avatar = yield (0, local_actor_1.updateLocalActorImageFile)(videoChannel, avatarPhysicalFile, 1); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys); return res.json({ avatar: avatar.toFormattedJSON() }); }); } function deleteVideoChannelAvatar(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = res.locals.videoChannel; - yield local_actor_1.deleteLocalActorImageFile(videoChannel, 1); + yield (0, local_actor_1.deleteLocalActorImageFile)(videoChannel, 1); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function deleteVideoChannelBanner(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = res.locals.videoChannel; - yield local_actor_1.deleteLocalActorImageFile(videoChannel, 2); + yield (0, local_actor_1.deleteLocalActorImageFile)(videoChannel, 2); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function addVideoChannel(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannelInfo = req.body; - const videoChannelCreated = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const videoChannelCreated = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = yield account_1.AccountModel.load(res.locals.oauth.token.User.Account.id, t); - return video_channel_1.createLocalVideoChannel(videoChannelInfo, account, t); + return (0, video_channel_1.createLocalVideoChannel)(videoChannelInfo, account, t); })); const payload = { actorId: videoChannelCreated.actorId }; yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'actor-keys', payload }); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoChannelAuditView(videoChannelCreated.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoChannelAuditView(videoChannelCreated.toFormattedJSON())); logger_1.logger.info('Video channel %s created.', videoChannelCreated.Actor.url); return res.json({ videoChannel: { @@ -108,14 +108,14 @@ function addVideoChannel(req, res) { }); } function updateVideoChannel(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannelInstance = res.locals.videoChannel; const videoChannelFieldsSave = videoChannelInstance.toJSON(); const oldVideoChannelAuditKeys = new audit_logger_1.VideoChannelAuditView(videoChannelInstance.toFormattedJSON()); const videoChannelInfoToUpdate = req.body; let doBulkVideoUpdate = false; try { - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (videoChannelInfoToUpdate.displayName !== undefined) videoChannelInstance.name = videoChannelInfoToUpdate.displayName; if (videoChannelInfoToUpdate.description !== undefined) @@ -129,29 +129,29 @@ function updateVideoChannel(req, res) { } } const videoChannelInstanceUpdated = yield videoChannelInstance.save({ transaction: t }); - yield send_1.sendUpdateActor(videoChannelInstanceUpdated, t); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), oldVideoChannelAuditKeys); + yield (0, send_1.sendUpdateActor)(videoChannelInstanceUpdated, t); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), oldVideoChannelAuditKeys); logger_1.logger.info('Video channel %s updated.', videoChannelInstance.Actor.url); })); } catch (err) { logger_1.logger.debug('Cannot update the video channel.', { err }); - database_utils_1.resetSequelizeInstance(videoChannelInstance, videoChannelFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(videoChannelInstance, videoChannelFieldsSave); throw err; } res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); if (doBulkVideoUpdate) { - yield video_channel_1.federateAllVideosOfChannel(videoChannelInstance); + yield (0, video_channel_1.federateAllVideosOfChannel)(videoChannelInstance); } }); } function removeVideoChannel(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannelInstance = res.locals.videoChannel; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_playlist_1.VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t); yield videoChannelInstance.destroy({ transaction: t }); - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoChannelAuditView(videoChannelInstance.toFormattedJSON())); + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoChannelAuditView(videoChannelInstance.toFormattedJSON())); logger_1.logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url); })); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); @@ -165,8 +165,8 @@ function getVideoChannel(req, res) { return res.json(videoChannel.toFormattedJSON()); } function listVideoChannelPlaylists(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield video_playlist_1.VideoPlaylistModel.listForApi({ followerActorId: serverActor.id, start: req.query.start, @@ -175,17 +175,17 @@ function listVideoChannelPlaylists(req, res) { videoChannelId: res.locals.videoChannel.id, type: req.query.playlistType }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function listVideoChannelVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannelInstance = res.locals.videoChannel; - const followerActorId = express_utils_1.isUserAbleToSearchRemoteURI(res) ? null : undefined; - const countVideos = express_utils_1.getCountVideos(req); - const query = query_1.pickCommonVideoQuery(req.query); - const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { followerActorId, includeLocalVideos: true, nsfw: express_utils_1.buildNSFWFilter(res, query.nsfw), withFiles: false, videoChannelId: videoChannelInstance.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.video-channels.videos.list.params'); + const followerActorId = (0, express_utils_1.isUserAbleToSearchRemoteURI)(res) ? null : undefined; + const countVideos = (0, express_utils_1.getCountVideos)(req); + const query = (0, query_1.pickCommonVideoQuery)(req.query); + const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { followerActorId, includeLocalVideos: true, nsfw: (0, express_utils_1.buildNSFWFilter)(res, query.nsfw), withFiles: false, videoChannelId: videoChannelInstance.id, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.video-channels.videos.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_1.VideoModel.listForApi, apiOptions, 'filter:api.video-channels.videos.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } diff --git a/dist/server/controllers/api/video-playlist.js b/dist/server/controllers/api/video-playlist.js index 5205e00d..d1f4dc15 100644 --- a/dist/server/controllers/api/video-playlist.js +++ b/dist/server/controllers/api/video-playlist.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videoPlaylistRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const path_1 = require("path"); const uuid_1 = require("@server/helpers/uuid"); const playlists_1 = require("@server/lib/activitypub/playlists"); @@ -25,26 +25,26 @@ const video_playlists_1 = require("../../middlewares/validators/videos/video-pla const account_1 = require("../../models/account/account"); const video_playlist_1 = require("../../models/video/video-playlist"); const video_playlist_element_1 = require("../../models/video/video-playlist-element"); -const reqThumbnailFile = express_utils_1.createReqFiles(['thumbnailfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR }); +const reqThumbnailFile = (0, express_utils_1.createReqFiles)(['thumbnailfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR }); const videoPlaylistRouter = express_1.default.Router(); exports.videoPlaylistRouter = videoPlaylistRouter; videoPlaylistRouter.get('/privacies', listVideoPlaylistPrivacies); -videoPlaylistRouter.get('/', middlewares_1.paginationValidator, validators_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, middlewares_1.asyncMiddleware(listVideoPlaylists)); -videoPlaylistRouter.get('/:playlistId', middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsGetValidator('summary')), getVideoPlaylist); -videoPlaylistRouter.post('/', middlewares_1.authenticate, reqThumbnailFile, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsAddValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoPlaylist)); -videoPlaylistRouter.put('/:playlistId', middlewares_1.authenticate, reqThumbnailFile, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsUpdateValidator), middlewares_1.asyncRetryTransactionMiddleware(updateVideoPlaylist)); -videoPlaylistRouter.delete('/:playlistId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsDeleteValidator), middlewares_1.asyncRetryTransactionMiddleware(removeVideoPlaylist)); -videoPlaylistRouter.get('/:playlistId/videos', middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsGetValidator('summary')), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(getVideoPlaylistVideos)); -videoPlaylistRouter.post('/:playlistId/videos', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsAddVideoValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoInPlaylist)); -videoPlaylistRouter.post('/:playlistId/videos/reorder', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsReorderVideosValidator), middlewares_1.asyncRetryTransactionMiddleware(reorderVideosPlaylist)); -videoPlaylistRouter.put('/:playlistId/videos/:playlistElementId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsUpdateOrRemoveVideoValidator), middlewares_1.asyncRetryTransactionMiddleware(updateVideoPlaylistElement)); -videoPlaylistRouter.delete('/:playlistId/videos/:playlistElementId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_playlists_1.videoPlaylistsUpdateOrRemoveVideoValidator), middlewares_1.asyncRetryTransactionMiddleware(removeVideoFromPlaylist)); +videoPlaylistRouter.get('/', middlewares_1.paginationValidator, validators_1.videoPlaylistsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, video_playlists_1.commonVideoPlaylistFiltersValidator, (0, middlewares_1.asyncMiddleware)(listVideoPlaylists)); +videoPlaylistRouter.get('/:playlistId', (0, middlewares_1.asyncMiddleware)((0, video_playlists_1.videoPlaylistsGetValidator)('summary')), getVideoPlaylist); +videoPlaylistRouter.post('/', middlewares_1.authenticate, reqThumbnailFile, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsAddValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoPlaylist)); +videoPlaylistRouter.put('/:playlistId', middlewares_1.authenticate, reqThumbnailFile, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsUpdateValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateVideoPlaylist)); +videoPlaylistRouter.delete('/:playlistId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsDeleteValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(removeVideoPlaylist)); +videoPlaylistRouter.get('/:playlistId/videos', (0, middlewares_1.asyncMiddleware)((0, video_playlists_1.videoPlaylistsGetValidator)('summary')), middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)(getVideoPlaylistVideos)); +videoPlaylistRouter.post('/:playlistId/videos', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsAddVideoValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoInPlaylist)); +videoPlaylistRouter.post('/:playlistId/videos/reorder', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsReorderVideosValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(reorderVideosPlaylist)); +videoPlaylistRouter.put('/:playlistId/videos/:playlistElementId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsUpdateOrRemoveVideoValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateVideoPlaylistElement)); +videoPlaylistRouter.delete('/:playlistId/videos/:playlistElementId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_playlists_1.videoPlaylistsUpdateOrRemoveVideoValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(removeVideoFromPlaylist)); function listVideoPlaylistPrivacies(req, res) { res.json(constants_1.VIDEO_PLAYLIST_PRIVACIES); } function listVideoPlaylists(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const resultList = yield video_playlist_1.VideoPlaylistModel.listForApi({ followerActorId: serverActor.id, start: req.query.start, @@ -52,16 +52,16 @@ function listVideoPlaylists(req, res) { sort: req.query.sort, type: req.query.type }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function getVideoPlaylist(req, res) { const videoPlaylist = res.locals.videoPlaylistSummary; - playlists_1.scheduleRefreshIfNeeded(videoPlaylist); + (0, playlists_1.scheduleRefreshIfNeeded)(videoPlaylist); return res.json(videoPlaylist.toFormattedJSON()); } function addVideoPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistInfo = req.body; const user = res.locals.oauth.token.User; const videoPlaylist = new video_playlist_1.VideoPlaylistModel({ @@ -70,7 +70,7 @@ function addVideoPlaylist(req, res) { privacy: videoPlaylistInfo.privacy || 3, ownerAccountId: user.Account.id }); - videoPlaylist.url = url_1.getLocalVideoPlaylistActivityPubUrl(videoPlaylist); + videoPlaylist.url = (0, url_1.getLocalVideoPlaylistActivityPubUrl)(videoPlaylist); if (videoPlaylistInfo.videoChannelId) { const videoChannel = res.locals.videoChannel; videoPlaylist.videoChannelId = videoChannel.id; @@ -78,34 +78,34 @@ function addVideoPlaylist(req, res) { } const thumbnailField = req.files['thumbnailfile']; const thumbnailModel = thumbnailField - ? yield thumbnail_1.updatePlaylistMiniatureFromExisting({ + ? yield (0, thumbnail_1.updatePlaylistMiniatureFromExisting)({ inputPath: thumbnailField[0].path, playlist: videoPlaylist, automaticallyGenerated: false }) : undefined; - const videoPlaylistCreated = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const videoPlaylistCreated = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistCreated = yield videoPlaylist.save({ transaction: t }); if (thumbnailModel) { thumbnailModel.automaticallyGenerated = false; yield videoPlaylistCreated.setAndSaveThumbnail(thumbnailModel, t); } videoPlaylistCreated.OwnerAccount = yield account_1.AccountModel.load(user.Account.id, t); - yield send_1.sendCreateVideoPlaylist(videoPlaylistCreated, t); + yield (0, send_1.sendCreateVideoPlaylist)(videoPlaylistCreated, t); return videoPlaylistCreated; })); logger_1.logger.info('Video playlist with uuid %s created.', videoPlaylist.uuid); return res.json({ videoPlaylist: { id: videoPlaylistCreated.id, - shortUUID: uuid_1.uuidToShort(videoPlaylistCreated.uuid), + shortUUID: (0, uuid_1.uuidToShort)(videoPlaylistCreated.uuid), uuid: videoPlaylistCreated.uuid } }); }); } function updateVideoPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistInstance = res.locals.videoPlaylistFull; const videoPlaylistFieldsSave = videoPlaylistInstance.toJSON(); const videoPlaylistInfoToUpdate = req.body; @@ -113,14 +113,14 @@ function updateVideoPlaylist(req, res) { const wasNotPrivatePlaylist = videoPlaylistInstance.privacy !== 3; const thumbnailField = req.files['thumbnailfile']; const thumbnailModel = thumbnailField - ? yield thumbnail_1.updatePlaylistMiniatureFromExisting({ + ? yield (0, thumbnail_1.updatePlaylistMiniatureFromExisting)({ inputPath: thumbnailField[0].path, playlist: videoPlaylistInstance, automaticallyGenerated: false }) : undefined; try { - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; @@ -141,7 +141,7 @@ function updateVideoPlaylist(req, res) { if (videoPlaylistInfoToUpdate.privacy !== undefined) { videoPlaylistInstance.privacy = parseInt(videoPlaylistInfoToUpdate.privacy.toString(), 10); if (wasNotPrivatePlaylist === true && videoPlaylistInstance.privacy === 3) { - yield send_1.sendDeleteVideoPlaylist(videoPlaylistInstance, t); + yield (0, send_1.sendDeleteVideoPlaylist)(videoPlaylistInstance, t); } } const playlistUpdated = yield videoPlaylistInstance.save(sequelizeOptions); @@ -151,10 +151,10 @@ function updateVideoPlaylist(req, res) { } const isNewPlaylist = wasPrivatePlaylist && playlistUpdated.privacy !== 3; if (isNewPlaylist) { - yield send_1.sendCreateVideoPlaylist(playlistUpdated, t); + yield (0, send_1.sendCreateVideoPlaylist)(playlistUpdated, t); } else { - yield send_1.sendUpdateVideoPlaylist(playlistUpdated, t); + yield (0, send_1.sendUpdateVideoPlaylist)(playlistUpdated, t); } logger_1.logger.info('Video playlist %s updated.', videoPlaylistInstance.uuid); return playlistUpdated; @@ -162,29 +162,29 @@ function updateVideoPlaylist(req, res) { } catch (err) { logger_1.logger.debug('Cannot update the video playlist.', { err }); - database_utils_1.resetSequelizeInstance(videoPlaylistInstance, videoPlaylistFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(videoPlaylistInstance, videoPlaylistFieldsSave); throw err; } return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function removeVideoPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistInstance = res.locals.videoPlaylistSummary; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoPlaylistInstance.destroy({ transaction: t }); - yield send_1.sendDeleteVideoPlaylist(videoPlaylistInstance, t); + yield (0, send_1.sendDeleteVideoPlaylist)(videoPlaylistInstance, t); logger_1.logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid); })); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function addVideoInPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const videoPlaylist = res.locals.videoPlaylistFull; const video = res.locals.onlyVideo; - const playlistElement = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const playlistElement = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const position = yield video_playlist_element_1.VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t); const playlistElement = yield video_playlist_element_1.VideoPlaylistElementModel.create({ position, @@ -193,7 +193,7 @@ function addVideoInPlaylist(req, res) { videoPlaylistId: videoPlaylist.id, videoId: video.id }, { transaction: t }); - playlistElement.url = url_1.getLocalVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement); + playlistElement.url = (0, url_1.getLocalVideoPlaylistElementActivityPubUrl)(videoPlaylist, playlistElement); yield playlistElement.save({ transaction: t }); videoPlaylist.changed('updatedAt', true); yield videoPlaylist.save({ transaction: t }); @@ -202,7 +202,7 @@ function addVideoInPlaylist(req, res) { if (videoPlaylist.hasThumbnail() === false || (videoPlaylist.hasGeneratedThumbnail() && playlistElement.position === 1)) { yield generateThumbnailForPlaylist(videoPlaylist, video); } - send_1.sendUpdateVideoPlaylist(videoPlaylist, undefined) + (0, send_1.sendUpdateVideoPlaylist)(videoPlaylist, undefined) .catch(err => logger_1.logger.error('Cannot send video playlist update.', { err })); logger_1.logger.info('Video added in playlist %s at position %d.', videoPlaylist.uuid, playlistElement.position); hooks_1.Hooks.runAction('action:api.video-playlist-element.created', { playlistElement }); @@ -214,11 +214,11 @@ function addVideoInPlaylist(req, res) { }); } function updateVideoPlaylistElement(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const videoPlaylist = res.locals.videoPlaylistFull; const videoPlaylistElement = res.locals.videoPlaylistElement; - const playlistElement = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const playlistElement = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (body.startTimestamp !== undefined) videoPlaylistElement.startTimestamp = body.startTimestamp; if (body.stopTimestamp !== undefined) @@ -226,7 +226,7 @@ function updateVideoPlaylistElement(req, res) { const element = yield videoPlaylistElement.save({ transaction: t }); videoPlaylist.changed('updatedAt', true); yield videoPlaylist.save({ transaction: t }); - yield send_1.sendUpdateVideoPlaylist(videoPlaylist, t); + yield (0, send_1.sendUpdateVideoPlaylist)(videoPlaylist, t); return element; })); logger_1.logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid); @@ -234,11 +234,11 @@ function updateVideoPlaylistElement(req, res) { }); } function removeVideoFromPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistElement = res.locals.videoPlaylistElement; const videoPlaylist = res.locals.videoPlaylistFull; const positionToDelete = videoPlaylistElement.position; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoPlaylistElement.destroy({ transaction: t }); yield video_playlist_element_1.VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t); videoPlaylist.changed('updatedAt', true); @@ -248,13 +248,13 @@ function removeVideoFromPlaylist(req, res) { if (positionToDelete === 1 && videoPlaylist.hasGeneratedThumbnail()) { yield regeneratePlaylistThumbnail(videoPlaylist); } - send_1.sendUpdateVideoPlaylist(videoPlaylist, undefined) + (0, send_1.sendUpdateVideoPlaylist)(videoPlaylist, undefined) .catch(err => logger_1.logger.error('Cannot send video playlist update.', { err })); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function reorderVideosPlaylist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylist = res.locals.videoPlaylistFull; const body = req.body; const start = body.startPosition; @@ -263,7 +263,7 @@ function reorderVideosPlaylist(req, res) { if (start === insertAfter) { return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); } - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newPosition = insertAfter + 1; yield video_playlist_element_1.VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, newPosition, null, reorderLength, t); let oldPosition = start; @@ -274,7 +274,7 @@ function reorderVideosPlaylist(req, res) { yield video_playlist_element_1.VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t); videoPlaylist.changed('updatedAt', true); yield videoPlaylist.save({ transaction: t }); - yield send_1.sendUpdateVideoPlaylist(videoPlaylist, t); + yield (0, send_1.sendUpdateVideoPlaylist)(videoPlaylist, t); })); if ((start === 1 || insertAfter === 0) && videoPlaylist.hasGeneratedThumbnail()) { yield regeneratePlaylistThumbnail(videoPlaylist); @@ -284,10 +284,10 @@ function reorderVideosPlaylist(req, res) { }); } function getVideoPlaylistVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylistInstance = res.locals.videoPlaylistSummary; const user = res.locals.oauth ? res.locals.oauth.token.User : undefined; - const server = yield application_1.getServerActor(); + const server = yield (0, application_1.getServerActor)(); const resultList = yield video_playlist_element_1.VideoPlaylistElementModel.listForApi({ start: req.query.start, count: req.query.count, @@ -296,14 +296,14 @@ function getVideoPlaylistVideos(req, res) { user }); const options = { - displayNSFW: express_utils_1.buildNSFWFilter(res, req.query.nsfw), + displayNSFW: (0, express_utils_1.buildNSFWFilter)(res, req.query.nsfw), accountId: user ? user.Account.id : undefined }; - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total, options)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total, options)); }); } function regeneratePlaylistThumbnail(videoPlaylist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoPlaylist.Thumbnail.destroy(); videoPlaylist.Thumbnail = null; const firstElement = yield video_playlist_element_1.VideoPlaylistElementModel.loadFirstElementWithVideoThumbnail(videoPlaylist.id); @@ -312,15 +312,15 @@ function regeneratePlaylistThumbnail(videoPlaylist) { }); } function generateThumbnailForPlaylist(videoPlaylist, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url); const videoMiniature = video.getMiniature(); if (!videoMiniature) { logger_1.logger.info('Cannot generate thumbnail for playlist %s because video %s does not have any.', videoPlaylist.url, video.url); return; } - const inputPath = path_1.join(config_1.CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename); - const thumbnailModel = yield thumbnail_1.updatePlaylistMiniatureFromExisting({ + const inputPath = (0, path_1.join)(config_1.CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename); + const thumbnailModel = yield (0, thumbnail_1.updatePlaylistMiniatureFromExisting)({ inputPath, playlist: videoPlaylist, automaticallyGenerated: true, diff --git a/dist/server/controllers/api/videos/blacklist.js b/dist/server/controllers/api/videos/blacklist.js index b6bfb2fa..4ee818bf 100644 --- a/dist/server/controllers/api/videos/blacklist.js +++ b/dist/server/controllers/api/videos/blacklist.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.blacklistRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const video_blacklist_1 = require("@server/lib/video-blacklist"); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const logger_1 = require("../../../helpers/logger"); @@ -12,21 +12,21 @@ const middlewares_1 = require("../../../middlewares"); const video_blacklist_2 = require("../../../models/video/video-blacklist"); const blacklistRouter = express_1.default.Router(); exports.blacklistRouter = blacklistRouter; -blacklistRouter.post('/:videoId/blacklist', middlewares_1.openapiOperationDoc({ operationId: 'addVideoBlock' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(12), middlewares_1.asyncMiddleware(middlewares_1.videosBlacklistAddValidator), middlewares_1.asyncMiddleware(addVideoToBlacklistController)); -blacklistRouter.get('/blacklist', middlewares_1.openapiOperationDoc({ operationId: 'getVideoBlocks' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(12), middlewares_1.paginationValidator, middlewares_1.blacklistSortValidator, middlewares_1.setBlacklistSort, middlewares_1.setDefaultPagination, middlewares_1.videosBlacklistFiltersValidator, middlewares_1.asyncMiddleware(listBlacklist)); -blacklistRouter.put('/:videoId/blacklist', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(12), middlewares_1.asyncMiddleware(middlewares_1.videosBlacklistUpdateValidator), middlewares_1.asyncMiddleware(updateVideoBlacklistController)); -blacklistRouter.delete('/:videoId/blacklist', middlewares_1.openapiOperationDoc({ operationId: 'delVideoBlock' }), middlewares_1.authenticate, middlewares_1.ensureUserHasRight(12), middlewares_1.asyncMiddleware(middlewares_1.videosBlacklistRemoveValidator), middlewares_1.asyncMiddleware(removeVideoFromBlacklistController)); +blacklistRouter.post('/:videoId/blacklist', (0, middlewares_1.openapiOperationDoc)({ operationId: 'addVideoBlock' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(12), (0, middlewares_1.asyncMiddleware)(middlewares_1.videosBlacklistAddValidator), (0, middlewares_1.asyncMiddleware)(addVideoToBlacklistController)); +blacklistRouter.get('/blacklist', (0, middlewares_1.openapiOperationDoc)({ operationId: 'getVideoBlocks' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(12), middlewares_1.paginationValidator, middlewares_1.blacklistSortValidator, middlewares_1.setBlacklistSort, middlewares_1.setDefaultPagination, middlewares_1.videosBlacklistFiltersValidator, (0, middlewares_1.asyncMiddleware)(listBlacklist)); +blacklistRouter.put('/:videoId/blacklist', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(12), (0, middlewares_1.asyncMiddleware)(middlewares_1.videosBlacklistUpdateValidator), (0, middlewares_1.asyncMiddleware)(updateVideoBlacklistController)); +blacklistRouter.delete('/:videoId/blacklist', (0, middlewares_1.openapiOperationDoc)({ operationId: 'delVideoBlock' }), middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(12), (0, middlewares_1.asyncMiddleware)(middlewares_1.videosBlacklistRemoveValidator), (0, middlewares_1.asyncMiddleware)(removeVideoFromBlacklistController)); function addVideoToBlacklistController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; const body = req.body; - yield video_blacklist_1.blacklistVideo(videoInstance, body); + yield (0, video_blacklist_1.blacklistVideo)(videoInstance, body); logger_1.logger.info('Video %s blacklisted.', videoInstance.uuid); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function updateVideoBlacklistController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoBlacklist = res.locals.videoBlacklist; if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason; @@ -37,7 +37,7 @@ function updateVideoBlacklistController(req, res) { }); } function listBlacklist(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resultList = yield video_blacklist_2.VideoBlacklistModel.listForApi({ start: req.query.start, count: req.query.count, @@ -45,14 +45,14 @@ function listBlacklist(req, res) { search: req.query.search, type: req.query.type }); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function removeVideoFromBlacklistController(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoBlacklist = res.locals.videoBlacklist; const video = res.locals.videoAll; - yield video_blacklist_1.unblacklistVideo(videoBlacklist, video); + yield (0, video_blacklist_1.unblacklistVideo)(videoBlacklist, video); logger_1.logger.info('Video %s removed from blacklist.', video.uuid); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); diff --git a/dist/server/controllers/api/videos/captions.js b/dist/server/controllers/api/videos/captions.js index 6c34a708..c6c0fc9c 100644 --- a/dist/server/controllers/api/videos/captions.js +++ b/dist/server/controllers/api/videos/captions.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videoCaptionsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const captions_utils_1 = require("../../../helpers/captions-utils"); const express_utils_1 = require("../../../helpers/express-utils"); @@ -15,22 +15,22 @@ const videos_1 = require("../../../lib/activitypub/videos"); const middlewares_1 = require("../../../middlewares"); const validators_1 = require("../../../middlewares/validators"); const video_caption_1 = require("../../../models/video/video-caption"); -const reqVideoCaptionAdd = express_utils_1.createReqFiles(['captionfile'], constants_1.MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT, { +const reqVideoCaptionAdd = (0, express_utils_1.createReqFiles)(['captionfile'], constants_1.MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT, { captionfile: config_1.CONFIG.STORAGE.CAPTIONS_DIR }); const videoCaptionsRouter = express_1.default.Router(); exports.videoCaptionsRouter = videoCaptionsRouter; -videoCaptionsRouter.get('/:videoId/captions', middlewares_1.asyncMiddleware(validators_1.listVideoCaptionsValidator), middlewares_1.asyncMiddleware(listVideoCaptions)); -videoCaptionsRouter.put('/:videoId/captions/:captionLanguage', middlewares_1.authenticate, reqVideoCaptionAdd, middlewares_1.asyncMiddleware(validators_1.addVideoCaptionValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoCaption)); -videoCaptionsRouter.delete('/:videoId/captions/:captionLanguage', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.deleteVideoCaptionValidator), middlewares_1.asyncRetryTransactionMiddleware(deleteVideoCaption)); +videoCaptionsRouter.get('/:videoId/captions', (0, middlewares_1.asyncMiddleware)(validators_1.listVideoCaptionsValidator), (0, middlewares_1.asyncMiddleware)(listVideoCaptions)); +videoCaptionsRouter.put('/:videoId/captions/:captionLanguage', middlewares_1.authenticate, reqVideoCaptionAdd, (0, middlewares_1.asyncMiddleware)(validators_1.addVideoCaptionValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoCaption)); +videoCaptionsRouter.delete('/:videoId/captions/:captionLanguage', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.deleteVideoCaptionValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(deleteVideoCaption)); function listVideoCaptions(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield video_caption_1.VideoCaptionModel.listVideoCaptions(res.locals.videoId.id); - return res.json(utils_1.getFormattedObjects(data, data.length)); + return res.json((0, utils_1.getFormattedObjects)(data, data.length)); }); } function addVideoCaption(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCaptionPhysicalFile = req.files['captionfile'][0]; const video = res.locals.videoAll; const captionLanguage = req.params.captionLanguage; @@ -39,21 +39,21 @@ function addVideoCaption(req, res) { filename: video_caption_1.VideoCaptionModel.generateCaptionName(captionLanguage), language: captionLanguage }); - yield captions_utils_1.moveAndProcessCaptionFile(videoCaptionPhysicalFile, videoCaption); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, captions_utils_1.moveAndProcessCaptionFile)(videoCaptionPhysicalFile, videoCaption); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_caption_1.VideoCaptionModel.insertOrReplaceLanguage(videoCaption, t); - yield videos_1.federateVideoIfNeeded(video, false, t); + yield (0, videos_1.federateVideoIfNeeded)(video, false, t); })); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function deleteVideoCaption(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.videoAll; const videoCaption = res.locals.videoCaption; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoCaption.destroy({ transaction: t }); - yield videos_1.federateVideoIfNeeded(video, false, t); + yield (0, videos_1.federateVideoIfNeeded)(video, false, t); })); logger_1.logger.info('Video caption %s of video %s deleted.', videoCaption.language, video.uuid); return res.type('json').status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); diff --git a/dist/server/controllers/api/videos/comment.js b/dist/server/controllers/api/videos/comment.js index ca1ca371..32bbc4d4 100644 --- a/dist/server/controllers/api/videos/comment.js +++ b/dist/server/controllers/api/videos/comment.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videoCommentRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const audit_logger_1 = require("../../../helpers/audit-logger"); const utils_1 = require("../../../helpers/utils"); @@ -14,17 +14,17 @@ const middlewares_1 = require("../../../middlewares"); const validators_1 = require("../../../middlewares/validators"); const account_1 = require("../../../models/account/account"); const video_comment_2 = require("../../../models/video/video-comment"); -const auditLogger = audit_logger_1.auditLoggerFactory('comments'); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('comments'); const videoCommentRouter = express_1.default.Router(); exports.videoCommentRouter = videoCommentRouter; -videoCommentRouter.get('/:videoId/comment-threads', middlewares_1.paginationValidator, validators_1.videoCommentThreadsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, middlewares_1.asyncMiddleware(validators_1.listVideoCommentThreadsValidator), middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(listVideoThreads)); -videoCommentRouter.get('/:videoId/comment-threads/:threadId', middlewares_1.asyncMiddleware(validators_1.listVideoThreadCommentsValidator), middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(listVideoThreadComments)); -videoCommentRouter.post('/:videoId/comment-threads', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.addVideoCommentThreadValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoCommentThread)); -videoCommentRouter.post('/:videoId/comments/:commentId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.addVideoCommentReplyValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoCommentReply)); -videoCommentRouter.delete('/:videoId/comments/:commentId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(validators_1.removeVideoCommentValidator), middlewares_1.asyncRetryTransactionMiddleware(removeVideoComment)); -videoCommentRouter.get('/comments', middlewares_1.authenticate, middlewares_1.ensureUserHasRight(21), middlewares_1.paginationValidator, validators_1.videoCommentsValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.listVideoCommentsValidator, middlewares_1.asyncMiddleware(listComments)); +videoCommentRouter.get('/:videoId/comment-threads', middlewares_1.paginationValidator, validators_1.videoCommentThreadsSortValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncMiddleware)(validators_1.listVideoCommentThreadsValidator), middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)(listVideoThreads)); +videoCommentRouter.get('/:videoId/comment-threads/:threadId', (0, middlewares_1.asyncMiddleware)(validators_1.listVideoThreadCommentsValidator), middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)(listVideoThreadComments)); +videoCommentRouter.post('/:videoId/comment-threads', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.addVideoCommentThreadValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoCommentThread)); +videoCommentRouter.post('/:videoId/comments/:commentId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.addVideoCommentReplyValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoCommentReply)); +videoCommentRouter.delete('/:videoId/comments/:commentId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(validators_1.removeVideoCommentValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(removeVideoComment)); +videoCommentRouter.get('/comments', middlewares_1.authenticate, (0, middlewares_1.ensureUserHasRight)(21), middlewares_1.paginationValidator, validators_1.videoCommentsValidator, middlewares_1.setDefaultSort, middlewares_1.setDefaultPagination, validators_1.listVideoCommentsValidator, (0, middlewares_1.asyncMiddleware)(listComments)); function listComments(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { start: req.query.start, count: req.query.count, @@ -42,7 +42,7 @@ function listComments(req, res) { }); } function listVideoThreads(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyVideo; const user = res.locals.oauth ? res.locals.oauth.token.User : undefined; let resultList; @@ -64,11 +64,11 @@ function listVideoThreads(req, res) { data: [] }; } - return res.json(Object.assign(Object.assign({}, utils_1.getFormattedObjects(resultList.data, resultList.total)), { totalNotDeletedComments: resultList.totalNotDeletedComments })); + return res.json(Object.assign(Object.assign({}, (0, utils_1.getFormattedObjects)(resultList.data, resultList.total)), { totalNotDeletedComments: resultList.totalNotDeletedComments })); }); } function listVideoThreadComments(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.onlyVideo; const user = res.locals.oauth ? res.locals.oauth.token.User : undefined; let resultList; @@ -93,15 +93,15 @@ function listVideoThreadComments(req, res) { message: 'No comments were found' }); } - return res.json(video_comment_1.buildFormattedCommentTree(resultList)); + return res.json((0, video_comment_1.buildFormattedCommentTree)(resultList)); }); } function addVideoCommentThread(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCommentInfo = req.body; - const comment = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const comment = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = yield account_1.AccountModel.load(res.locals.oauth.token.User.Account.id, t); - return video_comment_1.createVideoComment({ + return (0, video_comment_1.createVideoComment)({ text: videoCommentInfo.text, inReplyToComment: null, video: res.locals.videoAll, @@ -109,17 +109,17 @@ function addVideoCommentThread(req, res) { }, t); })); notifier_1.Notifier.Instance.notifyOnNewComment(comment); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.CommentAuditView(comment.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.CommentAuditView(comment.toFormattedJSON())); hooks_1.Hooks.runAction('action:api.video-thread.created', { comment }); return res.json({ comment: comment.toFormattedJSON() }); }); } function addVideoCommentReply(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCommentInfo = req.body; - const comment = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const comment = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = yield account_1.AccountModel.load(res.locals.oauth.token.User.Account.id, t); - return video_comment_1.createVideoComment({ + return (0, video_comment_1.createVideoComment)({ text: videoCommentInfo.text, inReplyToComment: res.locals.videoCommentFull, video: res.locals.videoAll, @@ -127,16 +127,16 @@ function addVideoCommentReply(req, res) { }, t); })); notifier_1.Notifier.Instance.notifyOnNewComment(comment); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.CommentAuditView(comment.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.CommentAuditView(comment.toFormattedJSON())); hooks_1.Hooks.runAction('action:api.video-comment-reply.created', { comment }); return res.json({ comment: comment.toFormattedJSON() }); }); } function removeVideoComment(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCommentInstance = res.locals.videoCommentFull; - yield video_comment_1.removeComment(videoCommentInstance); - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.CommentAuditView(videoCommentInstance.toFormattedJSON())); + yield (0, video_comment_1.removeComment)(videoCommentInstance); + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.CommentAuditView(videoCommentInstance.toFormattedJSON())); return res.type('json') .status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204) .end(); diff --git a/dist/server/controllers/api/videos/import.js b/dist/server/controllers/api/videos/import.js index eb7a3bd0..f72c04f2 100644 --- a/dist/server/controllers/api/videos/import.js +++ b/dist/server/controllers/api/videos/import.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videoImportsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const fs_extra_1 = require("fs-extra"); const magnet_uri_1 = require("magnet-uri"); -const parse_torrent_1 = tslib_1.__importDefault(require("parse-torrent")); +const parse_torrent_1 = (0, tslib_1.__importDefault)(require("parse-torrent")); const path_1 = require("path"); const videos_1 = require("@server/helpers/custom-validators/videos"); const server_config_manager_1 = require("@server/lib/server-config-manager"); @@ -28,15 +28,15 @@ const middlewares_1 = require("../../../middlewares"); const video_2 = require("../../../models/video/video"); const video_caption_1 = require("../../../models/video/video-caption"); const video_import_1 = require("../../../models/video/video-import"); -const auditLogger = audit_logger_1.auditLoggerFactory('video-imports'); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('video-imports'); const videoImportsRouter = express_1.default.Router(); exports.videoImportsRouter = videoImportsRouter; -const reqVideoFileImport = express_utils_1.createReqFiles(['thumbnailfile', 'previewfile', 'torrentfile'], Object.assign({}, constants_1.MIMETYPES.TORRENT.MIMETYPE_EXT, constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT), { +const reqVideoFileImport = (0, express_utils_1.createReqFiles)(['thumbnailfile', 'previewfile', 'torrentfile'], Object.assign({}, constants_1.MIMETYPES.TORRENT.MIMETYPE_EXT, constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT), { thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR, previewfile: config_1.CONFIG.STORAGE.TMP_DIR, torrentfile: config_1.CONFIG.STORAGE.TMP_DIR }); -videoImportsRouter.post('/imports', middlewares_1.authenticate, reqVideoFileImport, middlewares_1.asyncMiddleware(middlewares_1.videoImportAddValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoImport)); +videoImportsRouter.post('/imports', middlewares_1.authenticate, reqVideoFileImport, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoImportAddValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoImport)); function addVideoImport(req, res) { var _a, _b; if (req.body.targetUrl) @@ -46,7 +46,7 @@ function addVideoImport(req, res) { return addTorrentImport(req, res, file); } function addTorrentImport(req, res, torrentfile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const user = res.locals.oauth.token.User; let videoName; @@ -89,12 +89,12 @@ function addTorrentImport(req, res, torrentfile) { magnetUri }; yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoImportAuditView(videoImport.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoImportAuditView(videoImport.toFormattedJSON())); return res.json(videoImport.toFormattedJSON()).end(); }); } function addYoutubeDLImport(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const targetUrl = body.targetUrl; const user = res.locals.oauth.token.User; @@ -146,7 +146,7 @@ function addYoutubeDLImport(req, res) { }); yield processYoutubeSubtitles(youtubeDL, targetUrl, video.id); let fileExt = `.${youtubeDLInfo.ext}`; - if (!videos_1.isVideoFileExtnameValid(fileExt)) + if (!(0, videos_1.isVideoFileExtnameValid)(fileExt)) fileExt = '.mp4'; const payload = { type: 'youtube-dl', @@ -154,7 +154,7 @@ function addYoutubeDLImport(req, res) { fileExt }; yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoImportAuditView(videoImport.toFormattedJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoImportAuditView(videoImport.toFormattedJSON())); return res.json(videoImport.toFormattedJSON()).end(); }); } @@ -180,15 +180,15 @@ function buildVideo(channelId, body, importData) { : importData.originallyPublishedAt }; const video = new video_2.VideoModel(videoData); - video.url = url_1.getLocalVideoActivityPubUrl(video); + video.url = (0, url_1.getLocalVideoActivityPubUrl)(video); return video; } function processThumbnail(req, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const thumbnailField = req.files ? req.files['thumbnailfile'] : undefined; if (thumbnailField) { const thumbnailPhysicalFile = thumbnailField[0]; - return thumbnail_1.updateVideoMiniatureFromExisting({ + return (0, thumbnail_1.updateVideoMiniatureFromExisting)({ inputPath: thumbnailPhysicalFile.path, video, type: 1, @@ -199,11 +199,11 @@ function processThumbnail(req, video) { }); } function processPreview(req, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const previewField = req.files ? req.files['previewfile'] : undefined; if (previewField) { const previewPhysicalFile = previewField[0]; - return thumbnail_1.updateVideoMiniatureFromExisting({ + return (0, thumbnail_1.updateVideoMiniatureFromExisting)({ inputPath: previewPhysicalFile.path, video, type: 2, @@ -214,9 +214,9 @@ function processPreview(req, video) { }); } function processThumbnailFromUrl(url, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - return thumbnail_1.updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: 1 }); + return (0, thumbnail_1.updateVideoMiniatureFromUrl)({ downloadUrl: url, video, type: 1 }); } catch (err) { logger_1.logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err }); @@ -225,9 +225,9 @@ function processThumbnailFromUrl(url, video) { }); } function processPreviewFromUrl(url, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - return thumbnail_1.updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: 2 }); + return (0, thumbnail_1.updateVideoMiniatureFromUrl)({ downloadUrl: url, video, type: 2 }); } catch (err) { logger_1.logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err }); @@ -236,9 +236,9 @@ function processPreviewFromUrl(url, video) { }); } function insertIntoDB(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters; - const videoImport = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const videoImport = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; const videoCreated = yield video.save(sequelizeOptions); videoCreated.VideoChannel = videoChannel; @@ -246,7 +246,7 @@ function insertIntoDB(parameters) { yield videoCreated.addAndSaveThumbnail(thumbnailModel, t); if (previewModel) yield videoCreated.addAndSaveThumbnail(previewModel, t); - yield video_blacklist_1.autoBlacklistVideoIfNeeded({ + yield (0, video_blacklist_1.autoBlacklistVideoIfNeeded)({ video: videoCreated, user, notify: false, @@ -254,7 +254,7 @@ function insertIntoDB(parameters) { isNew: true, transaction: t }); - yield video_1.setVideoTags({ video: videoCreated, tags, transaction: t }); + yield (0, video_1.setVideoTags)({ video: videoCreated, tags, transaction: t }); const videoImport = yield video_import_1.VideoImportModel.create(Object.assign({ videoId: videoCreated.id }, videoImportAttributes), sequelizeOptions); videoImport.Video = videoCreated; return videoImport; @@ -263,15 +263,15 @@ function insertIntoDB(parameters) { }); } function processTorrentOrAbortRequest(req, res, torrentfile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const torrentName = torrentfile.originalname; - const newTorrentPath = path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, utils_1.getSecureTorrentName(torrentName)); - yield fs_extra_1.move(torrentfile.path, newTorrentPath, { overwrite: true }); + const newTorrentPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, (0, utils_1.getSecureTorrentName)(torrentName)); + yield (0, fs_extra_1.move)(torrentfile.path, newTorrentPath, { overwrite: true }); torrentfile.path = newTorrentPath; - const buf = yield fs_extra_1.readFile(torrentfile.path); - const parsedTorrent = parse_torrent_1.default(buf); + const buf = yield (0, fs_extra_1.readFile)(torrentfile.path); + const parsedTorrent = (0, parse_torrent_1.default)(buf); if (parsedTorrent.files.length !== 1) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); res.fail({ type: "incorrect_files_in_torrent", message: 'Torrents with only 1 file are supported.' @@ -286,17 +286,17 @@ function processTorrentOrAbortRequest(req, res, torrentfile) { } function processMagnetURI(body) { const magnetUri = body.magnetUri; - const parsed = magnet_uri_1.decode(magnetUri); + const parsed = (0, magnet_uri_1.decode)(magnetUri); return { name: extractNameFromArray(parsed.name), magnetUri }; } function extractNameFromArray(name) { - return misc_1.isArray(name) ? name[0] : name; + return (0, misc_1.isArray)(name) ? name[0] : name; } function processYoutubeSubtitles(youtubeDL, targetUrl, videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const subtitles = yield youtubeDL.getYoutubeDLSubs(); logger_1.logger.info('Will create %s subtitles from youtube import %s.', subtitles.length, targetUrl); @@ -306,8 +306,8 @@ function processYoutubeSubtitles(youtubeDL, targetUrl, videoId) { language: subtitle.language, filename: video_caption_1.VideoCaptionModel.generateCaptionName(subtitle.language) }); - yield captions_utils_1.moveAndProcessCaptionFile(subtitle, videoCaption); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, captions_utils_1.moveAndProcessCaptionFile)(subtitle, videoCaption); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_caption_1.VideoCaptionModel.insertOrReplaceLanguage(videoCaption, t); })); } diff --git a/dist/server/controllers/api/videos/index.js b/dist/server/controllers/api/videos/index.js index a898a2b7..30923b07 100644 --- a/dist/server/controllers/api/videos/index.js +++ b/dist/server/controllers/api/videos/index.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.videosRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const toInt_1 = tslib_1.__importDefault(require("validator/lib/toInt")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const toInt_1 = (0, tslib_1.__importDefault)(require("validator/lib/toInt")); const query_1 = require("@server/helpers/query"); const requests_1 = require("@server/helpers/requests"); const live_1 = require("@server/lib/live"); @@ -33,7 +33,7 @@ const rate_1 = require("./rate"); const update_1 = require("./update"); const upload_1 = require("./upload"); const watching_1 = require("./watching"); -const auditLogger = audit_logger_1.auditLoggerFactory('videos'); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('videos'); const videosRouter = express_1.default.Router(); exports.videosRouter = videosRouter; videosRouter.use('/', blacklist_1.blacklistRouter); @@ -46,16 +46,16 @@ videosRouter.use('/', watching_1.watchingRouter); videosRouter.use('/', live_2.liveRouter); videosRouter.use('/', upload_1.uploadRouter); videosRouter.use('/', update_1.updateRouter); -videosRouter.get('/categories', doc_1.openapiOperationDoc({ operationId: 'getCategories' }), listVideoCategories); -videosRouter.get('/licences', doc_1.openapiOperationDoc({ operationId: 'getLicences' }), listVideoLicences); -videosRouter.get('/languages', doc_1.openapiOperationDoc({ operationId: 'getLanguages' }), listVideoLanguages); -videosRouter.get('/privacies', doc_1.openapiOperationDoc({ operationId: 'getPrivacies' }), listVideoPrivacies); -videosRouter.get('/', doc_1.openapiOperationDoc({ operationId: 'getVideos' }), middlewares_1.paginationValidator, middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(listVideos)); -videosRouter.get('/:id/description', doc_1.openapiOperationDoc({ operationId: 'getVideoDesc' }), middlewares_1.asyncMiddleware(middlewares_1.videosGetValidator), middlewares_1.asyncMiddleware(getVideoDescription)); -videosRouter.get('/:id/metadata/:videoFileId', middlewares_1.asyncMiddleware(middlewares_1.videoFileMetadataGetValidator), middlewares_1.asyncMiddleware(getVideoFileMetadata)); -videosRouter.get('/:id', doc_1.openapiOperationDoc({ operationId: 'getVideo' }), middlewares_1.optionalAuthenticate, middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('for-api')), middlewares_1.asyncMiddleware(middlewares_1.checkVideoFollowConstraints), getVideo); -videosRouter.post('/:id/views', doc_1.openapiOperationDoc({ operationId: 'addView' }), middlewares_1.asyncMiddleware(middlewares_1.videosCustomGetValidator('only-immutable-attributes')), middlewares_1.asyncMiddleware(viewVideo)); -videosRouter.delete('/:id', doc_1.openapiOperationDoc({ operationId: 'delVideo' }), middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videosRemoveValidator), middlewares_1.asyncRetryTransactionMiddleware(removeVideo)); +videosRouter.get('/categories', (0, doc_1.openapiOperationDoc)({ operationId: 'getCategories' }), listVideoCategories); +videosRouter.get('/licences', (0, doc_1.openapiOperationDoc)({ operationId: 'getLicences' }), listVideoLicences); +videosRouter.get('/languages', (0, doc_1.openapiOperationDoc)({ operationId: 'getLanguages' }), listVideoLanguages); +videosRouter.get('/privacies', (0, doc_1.openapiOperationDoc)({ operationId: 'getPrivacies' }), listVideoPrivacies); +videosRouter.get('/', (0, doc_1.openapiOperationDoc)({ operationId: 'getVideos' }), middlewares_1.paginationValidator, middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.setDefaultPagination, middlewares_1.optionalAuthenticate, middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(listVideos)); +videosRouter.get('/:id/description', (0, doc_1.openapiOperationDoc)({ operationId: 'getVideoDesc' }), (0, middlewares_1.asyncMiddleware)(middlewares_1.videosGetValidator), (0, middlewares_1.asyncMiddleware)(getVideoDescription)); +videosRouter.get('/:id/metadata/:videoFileId', (0, middlewares_1.asyncMiddleware)(middlewares_1.videoFileMetadataGetValidator), (0, middlewares_1.asyncMiddleware)(getVideoFileMetadata)); +videosRouter.get('/:id', (0, doc_1.openapiOperationDoc)({ operationId: 'getVideo' }), middlewares_1.optionalAuthenticate, (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('for-api')), (0, middlewares_1.asyncMiddleware)(middlewares_1.checkVideoFollowConstraints), getVideo); +videosRouter.post('/:id/views', (0, doc_1.openapiOperationDoc)({ operationId: 'addView' }), (0, middlewares_1.asyncMiddleware)((0, middlewares_1.videosCustomGetValidator)('only-immutable-attributes')), (0, middlewares_1.asyncMiddleware)(viewVideo)); +videosRouter.delete('/:id', (0, doc_1.openapiOperationDoc)({ operationId: 'delVideo' }), middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosRemoveValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(removeVideo)); function listVideoCategories(_req, res) { res.json(constants_1.VIDEO_CATEGORIES); } @@ -76,7 +76,7 @@ function getVideo(_req, res) { return res.json(video.toFormattedDetailsJSON()); } function viewVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const immutableVideoAttrs = res.locals.onlyImmutableVideo; const ip = req.ip; const exists = yield redis_1.Redis.Instance.doesVideoIPViewExist(ip, immutableVideoAttrs.uuid); @@ -97,8 +97,8 @@ function viewVideo(req, res) { promises.push(redis_1.Redis.Instance.addVideoView(video.id)); } if (federateView) { - const serverActor = yield application_1.getServerActor(); - promises.push(send_view_1.sendView(serverActor, video, undefined)); + const serverActor = yield (0, application_1.getServerActor)(); + promises.push((0, send_view_1.sendView)(serverActor, video, undefined)); } yield Promise.all(promises); hooks_1.Hooks.runAction('action:api.video.viewed', { video, ip }); @@ -106,7 +106,7 @@ function viewVideo(req, res) { }); } function getVideoDescription(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; const description = videoInstance.isOwned() ? videoInstance.description @@ -115,27 +115,27 @@ function getVideoDescription(req, res) { }); } function getVideoFileMetadata(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoFile = yield video_file_1.VideoFileModel.loadWithMetadata(toInt_1.default(req.params.videoFileId)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoFile = yield video_file_1.VideoFileModel.loadWithMetadata((0, toInt_1.default)(req.params.videoFileId)); return res.json(videoFile.metadata); }); } function listVideos(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const query = query_1.pickCommonVideoQuery(req.query); - const countVideos = express_utils_1.getCountVideos(req); - const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { includeLocalVideos: true, nsfw: express_utils_1.buildNSFWFilter(res, query.nsfw), withFiles: false, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.videos.list.params'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const query = (0, query_1.pickCommonVideoQuery)(req.query); + const countVideos = (0, express_utils_1.getCountVideos)(req); + const apiOptions = yield hooks_1.Hooks.wrapObject(Object.assign(Object.assign({}, query), { includeLocalVideos: true, nsfw: (0, express_utils_1.buildNSFWFilter)(res, query.nsfw), withFiles: false, user: res.locals.oauth ? res.locals.oauth.token.User : undefined, countVideos }), 'filter:api.videos.list.params'); const resultList = yield hooks_1.Hooks.wrapPromiseFun(video_1.VideoModel.listForApi, apiOptions, 'filter:api.videos.list.result'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function removeVideo(_req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoInstance.destroy({ transaction: t }); })); - auditLogger.delete(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoAuditView(videoInstance.toFormattedDetailsJSON())); + auditLogger.delete((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoAuditView(videoInstance.toFormattedDetailsJSON())); logger_1.logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid); hooks_1.Hooks.runAction('action:api.video.deleted', { video: videoInstance }); return res.type('json') @@ -144,11 +144,11 @@ function removeVideo(_req, res) { }); } function fetchRemoteVideoDescription(video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const host = video.VideoChannel.Account.Actor.Server.host; const path = video.getDescriptionAPIPath(); const url = constants_1.REMOTE_SCHEME.HTTP + '://' + host + path; - const { body } = yield requests_1.doJSONRequest(url); + const { body } = yield (0, requests_1.doJSONRequest)(url); return body.description || ''; }); } diff --git a/dist/server/controllers/api/videos/live.js b/dist/server/controllers/api/videos/live.js index 78032d40..93f2dba6 100644 --- a/dist/server/controllers/api/videos/live.js +++ b/dist/server/controllers/api/videos/live.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.liveRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const express_utils_1 = require("@server/helpers/express-utils"); const uuid_1 = require("@server/helpers/uuid"); const config_1 = require("@server/initializers/config"); @@ -21,47 +21,47 @@ const middlewares_1 = require("../../../middlewares"); const video_2 = require("../../../models/video/video"); const liveRouter = express_1.default.Router(); exports.liveRouter = liveRouter; -const reqVideoFileLive = express_utils_1.createReqFiles(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { +const reqVideoFileLive = (0, express_utils_1.createReqFiles)(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR, previewfile: config_1.CONFIG.STORAGE.TMP_DIR }); -liveRouter.post('/live', middlewares_1.authenticate, reqVideoFileLive, middlewares_1.asyncMiddleware(video_live_1.videoLiveAddValidator), middlewares_1.asyncRetryTransactionMiddleware(addLiveVideo)); -liveRouter.get('/live/:videoId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_live_1.videoLiveGetValidator), getLiveVideo); -liveRouter.put('/live/:videoId', middlewares_1.authenticate, middlewares_1.asyncMiddleware(video_live_1.videoLiveGetValidator), video_live_1.videoLiveUpdateValidator, middlewares_1.asyncRetryTransactionMiddleware(updateLiveVideo)); +liveRouter.post('/live', middlewares_1.authenticate, reqVideoFileLive, (0, middlewares_1.asyncMiddleware)(video_live_1.videoLiveAddValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addLiveVideo)); +liveRouter.get('/live/:videoId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_live_1.videoLiveGetValidator), getLiveVideo); +liveRouter.put('/live/:videoId', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(video_live_1.videoLiveGetValidator), video_live_1.videoLiveUpdateValidator, (0, middlewares_1.asyncRetryTransactionMiddleware)(updateLiveVideo)); function getLiveVideo(req, res) { const videoLive = res.locals.videoLive; return res.json(videoLive.toFormattedJSON()); } function updateLiveVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const video = res.locals.videoAll; const videoLive = res.locals.videoLive; videoLive.saveReplay = body.saveReplay || false; videoLive.permanentLive = body.permanentLive || false; video.VideoLive = yield videoLive.save(); - yield videos_1.federateVideoIfNeeded(video, false); + yield (0, videos_1.federateVideoIfNeeded)(video, false); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); }); } function addLiveVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInfo = req.body; - const videoData = video_1.buildLocalVideoFromReq(videoInfo, res.locals.videoChannel.id); + const videoData = (0, video_1.buildLocalVideoFromReq)(videoInfo, res.locals.videoChannel.id); videoData.isLive = true; videoData.state = 4; videoData.duration = 0; const video = new video_2.VideoModel(videoData); - video.url = url_1.getLocalVideoActivityPubUrl(video); + video.url = (0, url_1.getLocalVideoActivityPubUrl)(video); const videoLive = new video_live_2.VideoLiveModel(); videoLive.saveReplay = videoInfo.saveReplay || false; videoLive.permanentLive = videoInfo.permanentLive || false; - videoLive.streamKey = uuid_1.buildUUID(); - const [thumbnailModel, previewModel] = yield video_1.buildVideoThumbnailsFromReq({ + videoLive.streamKey = (0, uuid_1.buildUUID)(); + const [thumbnailModel, previewModel] = yield (0, video_1.buildVideoThumbnailsFromReq)({ video, files: req.files, fallback: type => { - return thumbnail_1.updateVideoMiniatureFromExisting({ + return (0, thumbnail_1.updateVideoMiniatureFromExisting)({ inputPath: constants_1.ASSETS_PATH.DEFAULT_LIVE_BACKGROUND, video, type, @@ -70,7 +70,7 @@ function addLiveVideo(req, res) { }); } }); - const { videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; const videoCreated = yield video.save(sequelizeOptions); if (thumbnailModel) @@ -80,8 +80,8 @@ function addLiveVideo(req, res) { videoCreated.VideoChannel = res.locals.videoChannel; videoLive.videoId = videoCreated.id; videoCreated.VideoLive = yield videoLive.save(sequelizeOptions); - yield video_1.setVideoTags({ video, tags: videoInfo.tags, transaction: t }); - yield videos_1.federateVideoIfNeeded(videoCreated, true, t); + yield (0, video_1.setVideoTags)({ video, tags: videoInfo.tags, transaction: t }); + yield (0, videos_1.federateVideoIfNeeded)(videoCreated, true, t); logger_1.logger.info('Video live %s with uuid %s created.', videoInfo.name, videoCreated.uuid); return { videoCreated }; })); @@ -89,7 +89,7 @@ function addLiveVideo(req, res) { return res.json({ video: { id: videoCreated.id, - shortUUID: uuid_1.uuidToShort(videoCreated.uuid), + shortUUID: (0, uuid_1.uuidToShort)(videoCreated.uuid), uuid: videoCreated.uuid } }); diff --git a/dist/server/controllers/api/videos/ownership.js b/dist/server/controllers/api/videos/ownership.js index a0348981..b9984463 100644 --- a/dist/server/controllers/api/videos/ownership.js +++ b/dist/server/controllers/api/videos/ownership.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.ownershipVideoRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const logger_1 = require("../../../helpers/logger"); const utils_1 = require("../../../helpers/utils"); @@ -15,12 +15,12 @@ const video_change_ownership_1 = require("../../../models/video/video-change-own const video_channel_1 = require("../../../models/video/video-channel"); const ownershipVideoRouter = express_1.default.Router(); exports.ownershipVideoRouter = ownershipVideoRouter; -ownershipVideoRouter.post('/:videoId/give-ownership', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videosChangeOwnershipValidator), middlewares_1.asyncRetryTransactionMiddleware(giveVideoOwnership)); -ownershipVideoRouter.get('/ownership', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, middlewares_1.asyncRetryTransactionMiddleware(listVideoOwnership)); -ownershipVideoRouter.post('/ownership/:id/accept', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videosTerminateChangeOwnershipValidator), middlewares_1.asyncMiddleware(middlewares_1.videosAcceptChangeOwnershipValidator), middlewares_1.asyncRetryTransactionMiddleware(acceptOwnership)); -ownershipVideoRouter.post('/ownership/:id/refuse', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videosTerminateChangeOwnershipValidator), middlewares_1.asyncRetryTransactionMiddleware(refuseOwnership)); +ownershipVideoRouter.post('/:videoId/give-ownership', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosChangeOwnershipValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(giveVideoOwnership)); +ownershipVideoRouter.get('/ownership', middlewares_1.authenticate, middlewares_1.paginationValidator, middlewares_1.setDefaultPagination, (0, middlewares_1.asyncRetryTransactionMiddleware)(listVideoOwnership)); +ownershipVideoRouter.post('/ownership/:id/accept', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosTerminateChangeOwnershipValidator), (0, middlewares_1.asyncMiddleware)(middlewares_1.videosAcceptChangeOwnershipValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(acceptOwnership)); +ownershipVideoRouter.post('/ownership/:id/refuse', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosTerminateChangeOwnershipValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(refuseOwnership)); function giveVideoOwnership(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; const initiatorAccountId = res.locals.oauth.token.User.Account.id; const nextOwner = res.locals.nextOwner; @@ -48,14 +48,14 @@ function giveVideoOwnership(req, res) { }); } function listVideoOwnership(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const currentAccountId = res.locals.oauth.token.User.Account.id; const resultList = yield video_change_ownership_1.VideoChangeOwnershipModel.listForApi(currentAccountId, req.query.start || 0, req.query.count || 10, req.query.sort || 'createdAt'); - return res.json(utils_1.getFormattedObjects(resultList.data, resultList.total)); + return res.json((0, utils_1.getFormattedObjects)(resultList.data, resultList.total)); }); } function acceptOwnership(req, res) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChangeOwnership = res.locals.videoChangeOwnership; const channel = res.locals.videoChannel; const targetVideo = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(videoChangeOwnership.Video.id, t); @@ -64,8 +64,8 @@ function acceptOwnership(req, res) { const targetVideoUpdated = yield targetVideo.save({ transaction: t }); targetVideoUpdated.VideoChannel = channel; if (targetVideoUpdated.hasPrivacyForFederation() && targetVideoUpdated.state === 1) { - yield share_1.changeVideoChannelShare(targetVideoUpdated, oldVideoChannel, t); - yield send_1.sendUpdateVideo(targetVideoUpdated, t, oldVideoChannel.Account.Actor); + yield (0, share_1.changeVideoChannelShare)(targetVideoUpdated, oldVideoChannel, t); + yield (0, send_1.sendUpdateVideo)(targetVideoUpdated, t, oldVideoChannel.Account.Actor); } videoChangeOwnership.status = "ACCEPTED"; yield videoChangeOwnership.save({ transaction: t }); @@ -73,7 +73,7 @@ function acceptOwnership(req, res) { })); } function refuseOwnership(req, res) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChangeOwnership = res.locals.videoChangeOwnership; videoChangeOwnership.status = "REFUSED"; yield videoChangeOwnership.save({ transaction: t }); diff --git a/dist/server/controllers/api/videos/rate.js b/dist/server/controllers/api/videos/rate.js index 22eccd36..1d7ad1ac 100644 --- a/dist/server/controllers/api/videos/rate.js +++ b/dist/server/controllers/api/videos/rate.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.rateVideoRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const logger_1 = require("../../../helpers/logger"); const constants_1 = require("../../../initializers/constants"); @@ -13,14 +13,14 @@ const account_1 = require("../../../models/account/account"); const account_video_rate_1 = require("../../../models/account/account-video-rate"); const rateVideoRouter = express_1.default.Router(); exports.rateVideoRouter = rateVideoRouter; -rateVideoRouter.put('/:id/rate', middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoUpdateRateValidator), middlewares_1.asyncRetryTransactionMiddleware(rateVideo)); +rateVideoRouter.put('/:id/rate', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoUpdateRateValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(rateVideo)); function rateVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const rateType = body.rating; const videoInstance = res.locals.videoAll; const userAccount = res.locals.oauth.token.User.Account; - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; const accountInstance = yield account_1.AccountModel.load(userAccount.id, t); const previousRate = yield account_video_rate_1.AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t); @@ -42,7 +42,7 @@ function rateVideo(req, res) { } else { previousRate.type = rateType; - previousRate.url = video_rates_1.getLocalRateUrl(rateType, userAccount.Actor, videoInstance); + previousRate.url = (0, video_rates_1.getLocalRateUrl)(rateType, userAccount.Actor, videoInstance); yield previousRate.save(sequelizeOptions); } } @@ -51,7 +51,7 @@ function rateVideo(req, res) { accountId: accountInstance.id, videoId: videoInstance.id, type: rateType, - url: video_rates_1.getLocalRateUrl(rateType, userAccount.Actor, videoInstance) + url: (0, video_rates_1.getLocalRateUrl)(rateType, userAccount.Actor, videoInstance) }; yield account_video_rate_1.AccountVideoRateModel.create(query, sequelizeOptions); } @@ -60,7 +60,7 @@ function rateVideo(req, res) { dislikes: dislikesToIncrement }; yield videoInstance.increment(incrementQuery, sequelizeOptions); - yield video_rates_1.sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t); + yield (0, video_rates_1.sendVideoRateChange)(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t); logger_1.logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name); })); return res.type('json') diff --git a/dist/server/controllers/api/videos/update.js b/dist/server/controllers/api/videos/update.js index a525fe3f..7b112b98 100644 --- a/dist/server/controllers/api/videos/update.js +++ b/dist/server/controllers/api/videos/update.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.updateVideo = exports.updateRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const share_1 = require("@server/lib/activitypub/share"); const video_1 = require("@server/lib/video"); const doc_1 = require("@server/middlewares/doc"); @@ -21,31 +21,31 @@ const video_blacklist_1 = require("../../../lib/video-blacklist"); const middlewares_1 = require("../../../middlewares"); const schedule_video_update_1 = require("../../../models/video/schedule-video-update"); const video_2 = require("../../../models/video/video"); -const lTags = logger_1.loggerTagsFactory('api', 'video'); -const auditLogger = audit_logger_1.auditLoggerFactory('videos'); +const lTags = (0, logger_1.loggerTagsFactory)('api', 'video'); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('videos'); const updateRouter = express_1.default.Router(); exports.updateRouter = updateRouter; -const reqVideoFileUpdate = express_utils_1.createReqFiles(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { +const reqVideoFileUpdate = (0, express_utils_1.createReqFiles)(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR, previewfile: config_1.CONFIG.STORAGE.TMP_DIR }); -updateRouter.put('/:id', doc_1.openapiOperationDoc({ operationId: 'putVideo' }), middlewares_1.authenticate, reqVideoFileUpdate, middlewares_1.asyncMiddleware(middlewares_1.videosUpdateValidator), middlewares_1.asyncRetryTransactionMiddleware(updateVideo)); +updateRouter.put('/:id', (0, doc_1.openapiOperationDoc)({ operationId: 'putVideo' }), middlewares_1.authenticate, reqVideoFileUpdate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosUpdateValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(updateVideo)); function updateVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoInstance = res.locals.videoAll; const videoFieldsSave = videoInstance.toJSON(); const oldVideoAuditView = new audit_logger_1.VideoAuditView(videoInstance.toFormattedDetailsJSON()); const videoInfoToUpdate = req.body; const wasConfidentialVideo = videoInstance.isConfidential(); const hadPrivacyForFederation = videoInstance.hasPrivacyForFederation(); - const [thumbnailModel, previewModel] = yield video_1.buildVideoThumbnailsFromReq({ + const [thumbnailModel, previewModel] = yield (0, video_1.buildVideoThumbnailsFromReq)({ video: videoInstance, files: req.files, fallback: () => Promise.resolve(undefined), automaticallyGenerated: false }); try { - const videoInstanceUpdated = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const videoInstanceUpdated = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; const oldVideoChannel = videoInstance.VideoChannel; const keysToUpdate = [ @@ -77,24 +77,24 @@ function updateVideo(req, res) { if (previewModel) yield videoInstanceUpdated.addAndSaveThumbnail(previewModel, t); if (videoInfoToUpdate.tags !== undefined) { - yield video_1.setVideoTags({ video: videoInstanceUpdated, tags: videoInfoToUpdate.tags, transaction: t }); + yield (0, video_1.setVideoTags)({ video: videoInstanceUpdated, tags: videoInfoToUpdate.tags, transaction: t }); } if (res.locals.videoChannel && videoInstanceUpdated.channelId !== res.locals.videoChannel.id) { yield videoInstanceUpdated.$set('VideoChannel', res.locals.videoChannel, { transaction: t }); videoInstanceUpdated.VideoChannel = res.locals.videoChannel; if (hadPrivacyForFederation === true) - yield share_1.changeVideoChannelShare(videoInstanceUpdated, oldVideoChannel, t); + yield (0, share_1.changeVideoChannelShare)(videoInstanceUpdated, oldVideoChannel, t); } yield updateSchedule(videoInstanceUpdated, videoInfoToUpdate, t); - yield video_blacklist_1.autoBlacklistVideoIfNeeded({ + yield (0, video_blacklist_1.autoBlacklistVideoIfNeeded)({ video: videoInstanceUpdated, user: res.locals.oauth.token.User, isRemote: false, isNew: false, transaction: t }); - yield videos_1.federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t); - auditLogger.update(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), oldVideoAuditView); + yield (0, videos_1.federateVideoIfNeeded)(videoInstanceUpdated, isNewVideo, t); + auditLogger.update((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), oldVideoAuditView); logger_1.logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid, lTags(videoInstance.uuid)); return videoInstanceUpdated; })); @@ -104,7 +104,7 @@ function updateVideo(req, res) { hooks_1.Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body }); } catch (err) { - database_utils_1.resetSequelizeInstance(videoInstance, videoFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(videoInstance, videoFieldsSave); throw err; } return res.type('json') @@ -114,7 +114,7 @@ function updateVideo(req, res) { } exports.updateVideo = updateVideo; function updateVideoPrivacy(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoInstance, videoInfoToUpdate, hadPrivacyForFederation, transaction } = options; const isNewVideo = videoInstance.isNewVideo(videoInfoToUpdate.privacy); const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10); diff --git a/dist/server/controllers/api/videos/upload.js b/dist/server/controllers/api/videos/upload.js index 159c320f..253f1c10 100644 --- a/dist/server/controllers/api/videos/upload.js +++ b/dist/server/controllers/api/videos/upload.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.addVideoResumable = exports.addVideoLegacy = exports.uploadRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const core_utils_1 = require("@server/helpers/core-utils"); @@ -34,26 +34,26 @@ const middlewares_1 = require("../../../middlewares"); const schedule_video_update_1 = require("../../../models/video/schedule-video-update"); const video_2 = require("../../../models/video/video"); const video_file_1 = require("../../../models/video/video-file"); -const lTags = logger_1.loggerTagsFactory('api', 'video'); -const auditLogger = audit_logger_1.auditLoggerFactory('videos'); +const lTags = (0, logger_1.loggerTagsFactory)('api', 'video'); +const auditLogger = (0, audit_logger_1.auditLoggerFactory)('videos'); const uploadRouter = express_1.default.Router(); exports.uploadRouter = uploadRouter; -const uploadxMiddleware = core_1.uploadx.upload({ directory: upload_1.getResumableUploadPath() }); -const reqVideoFileAdd = express_utils_1.createReqFiles(['videofile', 'thumbnailfile', 'previewfile'], Object.assign({}, constants_1.MIMETYPES.VIDEO.MIMETYPE_EXT, constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT), { +const uploadxMiddleware = core_1.uploadx.upload({ directory: (0, upload_1.getResumableUploadPath)() }); +const reqVideoFileAdd = (0, express_utils_1.createReqFiles)(['videofile', 'thumbnailfile', 'previewfile'], Object.assign({}, constants_1.MIMETYPES.VIDEO.MIMETYPE_EXT, constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT), { videofile: config_1.CONFIG.STORAGE.TMP_DIR, thumbnailfile: config_1.CONFIG.STORAGE.TMP_DIR, previewfile: config_1.CONFIG.STORAGE.TMP_DIR }); -const reqVideoFileAddResumable = express_utils_1.createReqFiles(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { - thumbnailfile: upload_1.getResumableUploadPath(), - previewfile: upload_1.getResumableUploadPath() +const reqVideoFileAddResumable = (0, express_utils_1.createReqFiles)(['thumbnailfile', 'previewfile'], constants_1.MIMETYPES.IMAGE.MIMETYPE_EXT, { + thumbnailfile: (0, upload_1.getResumableUploadPath)(), + previewfile: (0, upload_1.getResumableUploadPath)() }); -uploadRouter.post('/upload', doc_1.openapiOperationDoc({ operationId: 'uploadLegacy' }), middlewares_1.authenticate, reqVideoFileAdd, middlewares_1.asyncMiddleware(middlewares_1.videosAddLegacyValidator), middlewares_1.asyncRetryTransactionMiddleware(addVideoLegacy)); -uploadRouter.post('/upload-resumable', doc_1.openapiOperationDoc({ operationId: 'uploadResumableInit' }), middlewares_1.authenticate, reqVideoFileAddResumable, middlewares_1.asyncMiddleware(middlewares_1.videosAddResumableInitValidator), uploadxMiddleware); +uploadRouter.post('/upload', (0, doc_1.openapiOperationDoc)({ operationId: 'uploadLegacy' }), middlewares_1.authenticate, reqVideoFileAdd, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosAddLegacyValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(addVideoLegacy)); +uploadRouter.post('/upload-resumable', (0, doc_1.openapiOperationDoc)({ operationId: 'uploadResumableInit' }), middlewares_1.authenticate, reqVideoFileAddResumable, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosAddResumableInitValidator), uploadxMiddleware); uploadRouter.delete('/upload-resumable', middlewares_1.authenticate, uploadxMiddleware); -uploadRouter.put('/upload-resumable', doc_1.openapiOperationDoc({ operationId: 'uploadResumable' }), middlewares_1.authenticate, uploadxMiddleware, middlewares_1.asyncMiddleware(middlewares_1.videosAddResumableValidator), middlewares_1.asyncMiddleware(addVideoResumable)); +uploadRouter.put('/upload-resumable', (0, doc_1.openapiOperationDoc)({ operationId: 'uploadResumable' }), middlewares_1.authenticate, uploadxMiddleware, (0, middlewares_1.asyncMiddleware)(middlewares_1.videosAddResumableValidator), (0, middlewares_1.asyncMiddleware)(addVideoResumable)); function addVideoLegacy(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { req.setTimeout(1000 * 60 * 10, () => { logger_1.logger.error('Video upload has timed out.'); return res.fail({ @@ -69,7 +69,7 @@ function addVideoLegacy(req, res) { } exports.addVideoLegacy = addVideoLegacy; function addVideoResumable(_req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPhysicalFile = res.locals.videoFileResumable; const videoInfo = videoPhysicalFile.metadata; const files = { previewfile: videoInfo.previewfile }; @@ -78,11 +78,11 @@ function addVideoResumable(_req, res) { } exports.addVideoResumable = addVideoResumable; function addVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { res, videoPhysicalFile, videoInfo, files } = options; const videoChannel = res.locals.videoChannel; const user = res.locals.oauth.token.User; - const videoResolutionInfo = yield ffprobe_utils_1.getVideoFileResolution(videoPhysicalFile.path); + const videoResolutionInfo = yield (0, ffprobe_utils_1.getVideoFileResolution)(videoPhysicalFile.path); const MAX_IMAGE_SIZE = 640 * 640; const wallpaperResolution = videoResolutionInfo.width * videoResolutionInfo.height; const denominator = wallpaperResolution > MAX_IMAGE_SIZE ? wallpaperResolution / MAX_IMAGE_SIZE : 1; @@ -91,24 +91,24 @@ function addVideo(options) { height: Math.floor(videoResolutionInfo.height / Math.sqrt(denominator)) }; videoInfo.aspectRatio = size.width / size.height; - const videoData = video_1.buildLocalVideoFromReq(videoInfo, videoChannel.id); - videoData.state = video_state_1.buildNextVideoState(); + const videoData = (0, video_1.buildLocalVideoFromReq)(videoInfo, videoChannel.id); + videoData.state = (0, video_state_1.buildNextVideoState)(); videoData.duration = videoPhysicalFile.duration; const video = new video_2.VideoModel(videoData); video.VideoChannel = videoChannel; - video.url = url_1.getLocalVideoActivityPubUrl(video); + video.url = (0, url_1.getLocalVideoActivityPubUrl)(video); const videoFile = yield buildNewFile(videoPhysicalFile); const destination = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(video, videoFile); - yield fs_extra_1.move(videoPhysicalFile.path, destination); - videoPhysicalFile.filename = path_1.basename(destination); + yield (0, fs_extra_1.move)(videoPhysicalFile.path, destination); + videoPhysicalFile.filename = (0, path_1.basename)(destination); videoPhysicalFile.path = destination; - const [thumbnailModel, previewModel] = yield video_1.buildVideoThumbnailsFromReq({ + const [thumbnailModel, previewModel] = yield (0, video_1.buildVideoThumbnailsFromReq)({ video, files, - fallback: type => thumbnail_1.generateVideoMiniature({ video, videoFile, type, size }), + fallback: type => (0, thumbnail_1.generateVideoMiniature)({ video, videoFile, type, size }), size }); - const { videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sequelizeOptions = { transaction: t }; const videoCreated = yield video.save(sequelizeOptions); yield videoCreated.addAndSaveThumbnail(thumbnailModel, t); @@ -117,7 +117,7 @@ function addVideo(options) { videoFile.videoId = video.id; yield videoFile.save(sequelizeOptions); video.VideoFiles = [videoFile]; - yield video_1.setVideoTags({ video, tags: videoInfo.tags, transaction: t }); + yield (0, video_1.setVideoTags)({ video, tags: videoInfo.tags, transaction: t }); if (videoInfo.scheduleUpdate) { yield schedule_video_update_1.ScheduleVideoUpdateModel.create({ videoId: video.id, @@ -125,14 +125,14 @@ function addVideo(options) { privacy: videoInfo.scheduleUpdate.privacy || null }, sequelizeOptions); } - yield video_blacklist_1.autoBlacklistVideoIfNeeded({ + yield (0, video_blacklist_1.autoBlacklistVideoIfNeeded)({ video, user, isRemote: false, isNew: true, transaction: t }); - auditLogger.create(audit_logger_1.getAuditIdFromRes(res), new audit_logger_1.VideoAuditView(videoCreated.toFormattedDetailsJSON())); + auditLogger.create((0, audit_logger_1.getAuditIdFromRes)(res), new audit_logger_1.VideoAuditView(videoCreated.toFormattedDetailsJSON())); logger_1.logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid, lTags(videoCreated.uuid)); return { videoCreated }; })); @@ -140,10 +140,10 @@ function addVideo(options) { createTorrentFederate(video, videoFile) .then(() => { if (video.state === 6) { - return video_1.addMoveToObjectStorageJob(video); + return (0, video_1.addMoveToObjectStorageJob)(video); } if (video.state === 2) { - return video_1.addOptimizeOrMergeAudioJob(videoCreated, videoFile, user); + return (0, video_1.addOptimizeOrMergeAudioJob)(videoCreated, videoFile, user); } }) .catch(err => logger_1.logger.error('Cannot add optimize/merge audio job for %s.', videoCreated.uuid, Object.assign({ err }, lTags(videoCreated.uuid)))); @@ -151,34 +151,34 @@ function addVideo(options) { return res.json({ video: { id: videoCreated.id, - shortUUID: uuid_1.uuidToShort(videoCreated.uuid), + shortUUID: (0, uuid_1.uuidToShort)(videoCreated.uuid), uuid: videoCreated.uuid } }); }); } function buildNewFile(videoPhysicalFile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoFile = new video_file_1.VideoFileModel({ - extname: core_utils_1.getLowercaseExtension(videoPhysicalFile.filename), + extname: (0, core_utils_1.getLowercaseExtension)(videoPhysicalFile.filename), size: videoPhysicalFile.size, videoStreamingPlaylistId: null, - metadata: yield ffprobe_utils_1.getMetadataFromFile(videoPhysicalFile.path) + metadata: yield (0, ffprobe_utils_1.getMetadataFromFile)(videoPhysicalFile.path) }); if (videoFile.isAudio()) { videoFile.resolution = constants_1.DEFAULT_AUDIO_RESOLUTION; } else { - videoFile.fps = yield ffprobe_utils_1.getVideoFileFPS(videoPhysicalFile.path); - videoFile.resolution = (yield ffprobe_utils_1.getVideoFileResolution(videoPhysicalFile.path)).resolution; + videoFile.fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(videoPhysicalFile.path); + videoFile.resolution = (yield (0, ffprobe_utils_1.getVideoFileResolution)(videoPhysicalFile.path)).resolution; } - videoFile.filename = paths_1.generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname); + videoFile.filename = (0, paths_1.generateWebTorrentVideoFilename)(videoFile.resolution, videoFile.extname); return videoFile; }); } function createTorrentAndSetInfoHashAsync(video, fileArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield webtorrent_1.createTorrentAndSetInfoHash(video, fileArg); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, webtorrent_1.createTorrentAndSetInfoHash)(video, fileArg); const refreshedFile = yield video_file_1.VideoFileModel.loadWithVideo(fileArg.id); if (!refreshedFile) return fileArg.removeTorrent(); @@ -195,8 +195,8 @@ function createTorrentFederate(video, videoFile) { if (!refreshedVideo) return; notifier_1.Notifier.Instance.notifyOnNewVideoIfNeeded(refreshedVideo); - return database_utils_1.retryTransactionWrapper(() => { - return database_1.sequelizeTypescript.transaction(t => videos_1.federateVideoIfNeeded(refreshedVideo, true, t)); + return (0, database_utils_1.retryTransactionWrapper)(() => { + return database_1.sequelizeTypescript.transaction(t => (0, videos_1.federateVideoIfNeeded)(refreshedVideo, true, t)); }); }) .catch(err => logger_1.logger.error('Cannot federate or notify video creation %s', video.url, Object.assign({ err }, lTags(video.uuid)))); diff --git a/dist/server/controllers/api/videos/watching.js b/dist/server/controllers/api/videos/watching.js index 68743c2c..9bef70d8 100644 --- a/dist/server/controllers/api/videos/watching.js +++ b/dist/server/controllers/api/videos/watching.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.watchingRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_error_codes_1 = require("../../../../shared/models/http/http-error-codes"); const middlewares_1 = require("../../../middlewares"); const user_video_history_1 = require("../../../models/user/user-video-history"); const watchingRouter = express_1.default.Router(); exports.watchingRouter = watchingRouter; -watchingRouter.put('/:videoId/watching', middlewares_1.openapiOperationDoc({ operationId: 'setProgress' }), middlewares_1.authenticate, middlewares_1.asyncMiddleware(middlewares_1.videoWatchingValidator), middlewares_1.asyncRetryTransactionMiddleware(userWatchVideo)); +watchingRouter.put('/:videoId/watching', (0, middlewares_1.openapiOperationDoc)({ operationId: 'setProgress' }), middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoWatchingValidator), (0, middlewares_1.asyncRetryTransactionMiddleware)(userWatchVideo)); function userWatchVideo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const body = req.body; const { id: videoId } = res.locals.videoId; diff --git a/dist/server/controllers/bots.js b/dist/server/controllers/bots.js index 92807b0d..17e08dee 100644 --- a/dist/server/controllers/bots.js +++ b/dist/server/controllers/bots.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.botsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const lodash_1 = require("lodash"); const sitemap_1 = require("sitemap"); const express_utils_1 = require("../helpers/express-utils"); @@ -14,9 +14,9 @@ const video_1 = require("../models/video/video"); const video_channel_1 = require("../models/video/video-channel"); const botsRouter = express_1.default.Router(); exports.botsRouter = botsRouter; -botsRouter.use('/sitemap.xml', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.SITEMAP), middlewares_1.asyncMiddleware(getSitemap)); +botsRouter.use('/sitemap.xml', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.SITEMAP), (0, middlewares_1.asyncMiddleware)(getSitemap)); function getSitemap(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let urls = getSitemapBasicUrls(); urls = urls.concat(yield getSitemapLocalVideoUrls()); urls = urls.concat(yield getSitemapVideoChannelUrls()); @@ -26,13 +26,13 @@ function getSitemap(req, res) { sitemapStream.write(urlObj); } sitemapStream.end(); - const xml = yield sitemap_1.streamToPromise(sitemapStream); + const xml = yield (0, sitemap_1.streamToPromise)(sitemapStream); res.header('Content-Type', 'application/xml'); res.send(xml); }); } function getSitemapVideoChannelUrls() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const rows = yield video_channel_1.VideoChannelModel.listLocalsForSitemap('createdAt'); return rows.map(channel => ({ url: constants_1.WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername @@ -40,7 +40,7 @@ function getSitemapVideoChannelUrls() { }); } function getSitemapAccountUrls() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const rows = yield account_1.AccountModel.listLocalsForSitemap('createdAt'); return rows.map(channel => ({ url: constants_1.WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername @@ -48,13 +48,13 @@ function getSitemapAccountUrls() { }); } function getSitemapLocalVideoUrls() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield video_1.VideoModel.listForApi({ start: 0, count: undefined, sort: 'createdAt', includeLocalVideos: true, - nsfw: express_utils_1.buildNSFWFilter(), + nsfw: (0, express_utils_1.buildNSFWFilter)(), filter: 'local', withFiles: false, countVideos: false @@ -64,7 +64,7 @@ function getSitemapLocalVideoUrls() { video: [ { title: v.name, - description: lodash_1.truncate(v.description || v.name, { length: 2000, omission: '...' }), + description: (0, lodash_1.truncate)(v.description || v.name, { length: 2000, omission: '...' }), player_loc: constants_1.WEBSERVER.URL + v.getEmbedStaticPath(), thumbnail_loc: constants_1.WEBSERVER.URL + v.getMiniatureStaticPath() } diff --git a/dist/server/controllers/client.js b/dist/server/controllers/client.js index 63f6f357..59521cca 100644 --- a/dist/server/controllers/client.js +++ b/dist/server/controllers/client.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.clientsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); @@ -17,13 +17,13 @@ const client_html_1 = require("../lib/client-html"); const middlewares_1 = require("../middlewares"); const clientsRouter = express_1.default.Router(); exports.clientsRouter = clientsRouter; -const distPath = path_1.join(core_utils_1.root(), 'client', 'dist'); -const testEmbedPath = path_1.join(distPath, 'standalone', 'videos', 'test-embed.html'); -clientsRouter.use(['/w/p/:id', '/videos/watch/playlist/:id'], middlewares_1.asyncMiddleware(generateWatchPlaylistHtmlPage)); -clientsRouter.use(['/w/:id', '/videos/watch/:id'], middlewares_1.asyncMiddleware(generateWatchHtmlPage)); -clientsRouter.use(['/accounts/:nameWithHost', '/a/:nameWithHost'], middlewares_1.asyncMiddleware(generateAccountHtmlPage)); -clientsRouter.use(['/video-channels/:nameWithHost', '/c/:nameWithHost'], middlewares_1.asyncMiddleware(generateVideoChannelHtmlPage)); -clientsRouter.use('/@:nameWithHost', middlewares_1.asyncMiddleware(generateActorHtmlPage)); +const distPath = (0, path_1.join)((0, core_utils_1.root)(), 'client', 'dist'); +const testEmbedPath = (0, path_1.join)(distPath, 'standalone', 'videos', 'test-embed.html'); +clientsRouter.use(['/w/p/:id', '/videos/watch/playlist/:id'], (0, middlewares_1.asyncMiddleware)(generateWatchPlaylistHtmlPage)); +clientsRouter.use(['/w/:id', '/videos/watch/:id'], (0, middlewares_1.asyncMiddleware)(generateWatchHtmlPage)); +clientsRouter.use(['/accounts/:nameWithHost', '/a/:nameWithHost'], (0, middlewares_1.asyncMiddleware)(generateAccountHtmlPage)); +clientsRouter.use(['/video-channels/:nameWithHost', '/c/:nameWithHost'], (0, middlewares_1.asyncMiddleware)(generateVideoChannelHtmlPage)); +clientsRouter.use('/@:nameWithHost', (0, middlewares_1.asyncMiddleware)(generateActorHtmlPage)); const embedMiddlewares = [ config_1.CONFIG.CSP.ENABLED ? middlewares_1.embedCSP @@ -33,14 +33,14 @@ const embedMiddlewares = [ res.setHeader('Cache-Control', 'public, max-age=0'); next(); }, - middlewares_1.asyncMiddleware(generateEmbedHtmlPage) + (0, middlewares_1.asyncMiddleware)(generateEmbedHtmlPage) ]; clientsRouter.use('/videos/embed', ...embedMiddlewares); clientsRouter.use('/video-playlists/embed', ...embedMiddlewares); const testEmbedController = (req, res) => res.sendFile(testEmbedPath); clientsRouter.use('/videos/test-embed', testEmbedController); clientsRouter.use('/video-playlists/test-embed', testEmbedController); -clientsRouter.get('/manifest.webmanifest', middlewares_1.asyncMiddleware(generateManifest)); +clientsRouter.get('/manifest.webmanifest', (0, middlewares_1.asyncMiddleware)(generateManifest)); const staticClientOverrides = [ 'assets/images/logo.svg', 'assets/images/favicon.png', @@ -53,29 +53,29 @@ const staticClientOverrides = [ 'assets/images/icons/icon-512x512.png' ]; for (const staticClientOverride of staticClientOverrides) { - const overridePhysicalPath = path_1.join(config_1.CONFIG.STORAGE.CLIENT_OVERRIDES_DIR, staticClientOverride); - clientsRouter.use(`/client/${staticClientOverride}`, middlewares_1.asyncMiddleware(serveClientOverride(overridePhysicalPath))); + const overridePhysicalPath = (0, path_1.join)(config_1.CONFIG.STORAGE.CLIENT_OVERRIDES_DIR, staticClientOverride); + clientsRouter.use(`/client/${staticClientOverride}`, (0, middlewares_1.asyncMiddleware)(serveClientOverride(overridePhysicalPath))); } clientsRouter.use('/client/locales/:locale/:file.json', serveServerTranslations); clientsRouter.use('/client', express_1.default.static(distPath, { maxAge: constants_1.STATIC_MAX_AGE.CLIENT })); clientsRouter.use('/client/*', (req, res) => { res.status(models_1.HttpStatusCode.NOT_FOUND_404).end(); }); -clientsRouter.all('/about/peertube', middlewares_1.disableRobots, middlewares_1.asyncMiddleware(client_html_1.serveIndexHTML)); -clientsRouter.use('/(:language)?', middlewares_1.asyncMiddleware(client_html_1.serveIndexHTML)); +clientsRouter.all('/about/peertube', middlewares_1.disableRobots, (0, middlewares_1.asyncMiddleware)(client_html_1.serveIndexHTML)); +clientsRouter.use('/(:language)?', (0, middlewares_1.asyncMiddleware)(client_html_1.serveIndexHTML)); function serveServerTranslations(req, res) { const locale = req.params.locale; const file = req.params.file; - if (i18n_1.is18nLocale(locale) && i18n_1.LOCALE_FILES.includes(file)) { - const completeLocale = i18n_1.getCompleteLocale(locale); - const completeFileLocale = i18n_1.buildFileLocale(completeLocale); - const path = path_1.join(__dirname, `../../../client/dist/locale/${file}.${completeFileLocale}.json`); + if ((0, i18n_1.is18nLocale)(locale) && i18n_1.LOCALE_FILES.includes(file)) { + const completeLocale = (0, i18n_1.getCompleteLocale)(locale); + const completeFileLocale = (0, i18n_1.buildFileLocale)(completeLocale); + const path = (0, path_1.join)(__dirname, `../../../client/dist/locale/${file}.${completeFileLocale}.json`); return res.sendFile(path, { maxAge: constants_1.STATIC_MAX_AGE.SERVER }); } return res.status(models_1.HttpStatusCode.NOT_FOUND_404).end(); } function generateEmbedHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const hookName = req.originalUrl.startsWith('/video-playlists/') ? 'filter:html.embed.video-playlist.allowed.result' : 'filter:html.embed.video.allowed.result'; @@ -83,46 +83,46 @@ function generateEmbedHtmlPage(req, res) { const allowedResult = yield hooks_1.Hooks.wrapFun(isEmbedAllowed, allowParameters, hookName); if (!allowedResult || allowedResult.allowed !== true) { logger_1.logger.info('Embed is not allowed.', { allowedResult }); - return client_html_1.sendHTML((allowedResult === null || allowedResult === void 0 ? void 0 : allowedResult.html) || '', res); + return (0, client_html_1.sendHTML)((allowedResult === null || allowedResult === void 0 ? void 0 : allowedResult.html) || '', res); } const html = yield client_html_1.ClientHtml.getEmbedHTML(); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateWatchHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield client_html_1.ClientHtml.getWatchHTMLPage(req.params.id + '', req, res); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateWatchPlaylistHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield client_html_1.ClientHtml.getWatchPlaylistHTMLPage(req.params.id + '', req, res); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateAccountHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield client_html_1.ClientHtml.getAccountHTMLPage(req.params.nameWithHost, req, res); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateVideoChannelHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield client_html_1.ClientHtml.getVideoChannelHTMLPage(req.params.nameWithHost, req, res); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateActorHtmlPage(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield client_html_1.ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res); - return client_html_1.sendHTML(html, res); + return (0, client_html_1.sendHTML)(html, res); }); } function generateManifest(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const manifestPhysicalPath = path_1.join(core_utils_1.root(), 'client', 'dist', 'manifest.webmanifest'); - const manifestJson = yield fs_extra_1.readFile(manifestPhysicalPath, 'utf8'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const manifestPhysicalPath = (0, path_1.join)((0, core_utils_1.root)(), 'client', 'dist', 'manifest.webmanifest'); + const manifestJson = yield (0, fs_extra_1.readFile)(manifestPhysicalPath, 'utf8'); const manifest = JSON.parse(manifestJson); manifest.name = config_1.CONFIG.INSTANCE.NAME; manifest.short_name = config_1.CONFIG.INSTANCE.NAME; @@ -131,7 +131,7 @@ function generateManifest(req, res) { }); } function serveClientOverride(path) { - return (req, res, next) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (req, res, next) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield fs_1.promises.access(path, fs_1.constants.F_OK); res.sendFile(path, { maxAge: constants_1.STATIC_MAX_AGE.SERVER }); diff --git a/dist/server/controllers/download.js b/dist/server/controllers/download.js index f29fcb1b..9baec02c 100644 --- a/dist/server/controllers/download.js +++ b/dist/server/controllers/download.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.downloadRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const videos_torrent_cache_1 = require("@server/lib/files-cache/videos-torrent-cache"); const hooks_1 = require("@server/lib/plugins/hooks"); @@ -13,12 +13,12 @@ const constants_1 = require("../initializers/constants"); const middlewares_1 = require("../middlewares"); const downloadRouter = express_1.default.Router(); exports.downloadRouter = downloadRouter; -downloadRouter.use(cors_1.default()); -downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.TORRENTS + ':filename', middlewares_1.asyncMiddleware(downloadTorrent)); -downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.VIDEOS + ':id-:resolution([0-9]+).:extension', middlewares_1.asyncMiddleware(middlewares_1.videosDownloadValidator), middlewares_1.asyncMiddleware(downloadVideoFile)); -downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.HLS_VIDEOS + ':id-:resolution([0-9]+)-fragmented.:extension', middlewares_1.asyncMiddleware(middlewares_1.videosDownloadValidator), middlewares_1.asyncMiddleware(downloadHLSVideoFile)); +downloadRouter.use((0, cors_1.default)()); +downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.TORRENTS + ':filename', (0, middlewares_1.asyncMiddleware)(downloadTorrent)); +downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.VIDEOS + ':id-:resolution([0-9]+).:extension', (0, middlewares_1.asyncMiddleware)(middlewares_1.videosDownloadValidator), (0, middlewares_1.asyncMiddleware)(downloadVideoFile)); +downloadRouter.use(constants_1.STATIC_DOWNLOAD_PATHS.HLS_VIDEOS + ':id-:resolution([0-9]+)-fragmented.:extension', (0, middlewares_1.asyncMiddleware)(middlewares_1.videosDownloadValidator), (0, middlewares_1.asyncMiddleware)(downloadHLSVideoFile)); function downloadTorrent(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield videos_torrent_cache_1.VideosTorrentCache.Instance.getFilePath(req.params.filename); if (!result) { return res.fail({ @@ -34,7 +34,7 @@ function downloadTorrent(req, res) { }); } function downloadVideoFile(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.videoAll; const videoFile = getVideoFile(req, video.VideoFiles); if (!videoFile) { @@ -57,7 +57,7 @@ function downloadVideoFile(req, res) { }); } function downloadHLSVideoFile(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = res.locals.videoAll; const streamingPlaylist = getHLSPlaylist(video); if (!streamingPlaylist) diff --git a/dist/server/controllers/feeds.js b/dist/server/controllers/feeds.js index 55036c12..1b147cb6 100644 --- a/dist/server/controllers/feeds.js +++ b/dist/server/controllers/feeds.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.feedsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const pfeed_1 = tslib_1.__importDefault(require("pfeed")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const pfeed_1 = (0, tslib_1.__importDefault)(require("pfeed")); const video_format_utils_1 = require("@server/models/video/formatter/video-format-utils"); const express_utils_1 = require("../helpers/express-utils"); const config_1 = require("../initializers/config"); @@ -14,14 +14,14 @@ const video_1 = require("../models/video/video"); const video_comment_1 = require("../models/video/video-comment"); const feedsRouter = express_1.default.Router(); exports.feedsRouter = feedsRouter; -const cacheRoute = cache_1.cacheRouteFactory({ +const cacheRoute = (0, cache_1.cacheRouteFactory)({ headerBlacklist: ['Content-Type'] }); -feedsRouter.get('/feeds/video-comments.:format', middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), middlewares_1.asyncMiddleware(middlewares_1.videoFeedsValidator), middlewares_1.asyncMiddleware(middlewares_1.videoCommentsFeedsValidator), middlewares_1.asyncMiddleware(generateVideoCommentsFeed)); -feedsRouter.get('/feeds/videos.:format', middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(middlewares_1.videoFeedsValidator), middlewares_1.asyncMiddleware(generateVideoFeed)); -feedsRouter.get('/feeds/subscriptions.:format', middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), middlewares_1.commonVideosFiltersValidator, middlewares_1.asyncMiddleware(middlewares_1.videoSubscriptionFeedsValidator), middlewares_1.asyncMiddleware(generateVideoFeedForSubscriptions)); +feedsRouter.get('/feeds/video-comments.:format', middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), (0, middlewares_1.asyncMiddleware)(middlewares_1.videoFeedsValidator), (0, middlewares_1.asyncMiddleware)(middlewares_1.videoCommentsFeedsValidator), (0, middlewares_1.asyncMiddleware)(generateVideoCommentsFeed)); +feedsRouter.get('/feeds/videos.:format', middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoFeedsValidator), (0, middlewares_1.asyncMiddleware)(generateVideoFeed)); +feedsRouter.get('/feeds/subscriptions.:format', middlewares_1.videosSortValidator, middlewares_1.setDefaultVideosSort, middlewares_1.feedsFormatValidator, middlewares_1.setFeedFormatContentType, cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.FEEDS), middlewares_1.commonVideosFiltersValidator, (0, middlewares_1.asyncMiddleware)(middlewares_1.videoSubscriptionFeedsValidator), (0, middlewares_1.asyncMiddleware)(generateVideoFeedForSubscriptions)); function generateVideoCommentsFeed(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const start = 0; const video = res.locals.videoAll; const account = res.locals.account; @@ -77,11 +77,11 @@ function generateVideoCommentsFeed(req, res) { }); } function generateVideoFeed(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const start = 0; const account = res.locals.account; const videoChannel = res.locals.videoChannel; - const nsfw = express_utils_1.buildNSFWFilter(res, req.query.nsfw); + const nsfw = (0, express_utils_1.buildNSFWFilter)(res, req.query.nsfw); let name; let description; if (videoChannel) { @@ -112,10 +112,10 @@ function generateVideoFeed(req, res) { }); } function generateVideoFeedForSubscriptions(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const start = 0; const account = res.locals.account; - const nsfw = express_utils_1.buildNSFWFilter(res, req.query.nsfw); + const nsfw = (0, express_utils_1.buildNSFWFilter)(res, req.query.nsfw); const name = account.getDisplayName(); const description = account.description; const feed = initFeed({ @@ -191,7 +191,7 @@ function addVideosToFeed(feed, videos) { if (video.category) { categories.push({ value: video.category, - label: video_format_utils_1.getCategoryLabel(video.category) + label: (0, video_format_utils_1.getCategoryLabel)(video.category) }); } feed.addItem({ diff --git a/dist/server/controllers/index.js b/dist/server/controllers/index.js index c61e0588..d6b1f014 100644 --- a/dist/server/controllers/index.js +++ b/dist/server/controllers/index.js @@ -1,16 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./activitypub"), exports); -tslib_1.__exportStar(require("./api"), exports); -tslib_1.__exportStar(require("./client"), exports); -tslib_1.__exportStar(require("./download"), exports); -tslib_1.__exportStar(require("./feeds"), exports); -tslib_1.__exportStar(require("./services"), exports); -tslib_1.__exportStar(require("./static"), exports); -tslib_1.__exportStar(require("./lazy-static"), exports); -tslib_1.__exportStar(require("./live"), exports); -tslib_1.__exportStar(require("./webfinger"), exports); -tslib_1.__exportStar(require("./tracker"), exports); -tslib_1.__exportStar(require("./bots"), exports); -tslib_1.__exportStar(require("./plugins"), exports); +(0, tslib_1.__exportStar)(require("./activitypub"), exports); +(0, tslib_1.__exportStar)(require("./api"), exports); +(0, tslib_1.__exportStar)(require("./client"), exports); +(0, tslib_1.__exportStar)(require("./download"), exports); +(0, tslib_1.__exportStar)(require("./feeds"), exports); +(0, tslib_1.__exportStar)(require("./services"), exports); +(0, tslib_1.__exportStar)(require("./static"), exports); +(0, tslib_1.__exportStar)(require("./lazy-static"), exports); +(0, tslib_1.__exportStar)(require("./live"), exports); +(0, tslib_1.__exportStar)(require("./webfinger"), exports); +(0, tslib_1.__exportStar)(require("./tracker"), exports); +(0, tslib_1.__exportStar)(require("./bots"), exports); +(0, tslib_1.__exportStar)(require("./plugins"), exports); diff --git a/dist/server/controllers/lazy-static.js b/dist/server/controllers/lazy-static.js index f584e973..c7787d57 100644 --- a/dist/server/controllers/lazy-static.js +++ b/dist/server/controllers/lazy-static.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getVideoCaption = exports.getPreview = exports.lazyStaticRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const videos_torrent_cache_1 = require("@server/lib/files-cache/videos-torrent-cache"); const http_error_codes_1 = require("../../shared/models/http/http-error-codes"); const logger_1 = require("../helpers/logger"); @@ -14,14 +14,14 @@ const middlewares_1 = require("../middlewares"); const actor_image_1 = require("../models/actor/actor-image"); const lazyStaticRouter = express_1.default.Router(); exports.lazyStaticRouter = lazyStaticRouter; -lazyStaticRouter.use(cors_1.default()); -lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.AVATARS + ':filename', middlewares_1.asyncMiddleware(getActorImage)); -lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.BANNERS + ':filename', middlewares_1.asyncMiddleware(getActorImage)); -lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.PREVIEWS + ':filename', middlewares_1.asyncMiddleware(getPreview)); -lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.VIDEO_CAPTIONS + ':filename', middlewares_1.asyncMiddleware(getVideoCaption)); -lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.TORRENTS + ':filename', middlewares_1.asyncMiddleware(getTorrent)); +lazyStaticRouter.use((0, cors_1.default)()); +lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.AVATARS + ':filename', (0, middlewares_1.asyncMiddleware)(getActorImage)); +lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.BANNERS + ':filename', (0, middlewares_1.asyncMiddleware)(getActorImage)); +lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.PREVIEWS + ':filename', (0, middlewares_1.asyncMiddleware)(getPreview)); +lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.VIDEO_CAPTIONS + ':filename', (0, middlewares_1.asyncMiddleware)(getVideoCaption)); +lazyStaticRouter.use(constants_1.LAZY_STATIC_PATHS.TORRENTS + ':filename', (0, middlewares_1.asyncMiddleware)(getTorrent)); function getActorImage(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const filename = req.params.filename; if (local_actor_1.actorImagePathUnsafeCache.has(filename)) { return res.sendFile(local_actor_1.actorImagePathUnsafeCache.get(filename), { maxAge: constants_1.STATIC_MAX_AGE.SERVER }); @@ -34,7 +34,7 @@ function getActorImage(req, res, next) { return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); logger_1.logger.info('Lazy serve remote actor image %s.', image.fileUrl); try { - yield local_actor_1.pushActorImageProcessInQueue({ filename: image.filename, fileUrl: image.fileUrl, type: image.type }); + yield (0, local_actor_1.pushActorImageProcessInQueue)({ filename: image.filename, fileUrl: image.fileUrl, type: image.type }); } catch (err) { logger_1.logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err }); @@ -61,7 +61,7 @@ function getActorImage(req, res, next) { }); } function getPreview(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield files_cache_1.VideosPreviewCache.Instance.getFilePath(req.params.filename); if (!result) return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); @@ -70,7 +70,7 @@ function getPreview(req, res) { } exports.getPreview = getPreview; function getVideoCaption(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield files_cache_1.VideosCaptionCache.Instance.getFilePath(req.params.filename); if (!result) return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); @@ -79,7 +79,7 @@ function getVideoCaption(req, res) { } exports.getVideoCaption = getVideoCaption; function getTorrent(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const result = yield videos_torrent_cache_1.VideosTorrentCache.Instance.getFilePath(req.params.filename); if (!result) return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); diff --git a/dist/server/controllers/live.js b/dist/server/controllers/live.js index e0abc9b8..3cc53baf 100644 --- a/dist/server/controllers/live.js +++ b/dist/server/controllers/live.js @@ -2,19 +2,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.liveRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@server/helpers/core-utils"); const live_1 = require("@server/lib/live"); const models_1 = require("@shared/models"); const liveRouter = express_1.default.Router(); exports.liveRouter = liveRouter; -liveRouter.use('/segments-sha256/:videoUUID', cors_1.default(), getSegmentsSha256); +liveRouter.use('/segments-sha256/:videoUUID', (0, cors_1.default)(), getSegmentsSha256); function getSegmentsSha256(req, res) { const videoUUID = req.params.videoUUID; const result = live_1.LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID); if (!result) { return res.status(models_1.HttpStatusCode.NOT_FOUND_404).end(); } - return res.json(core_utils_1.mapToJSON(result)); + return res.json((0, core_utils_1.mapToJSON)(result)); } diff --git a/dist/server/controllers/plugins.js b/dist/server/controllers/plugins.js index b3fee7d2..9c582854 100644 --- a/dist/server/controllers/plugins.js +++ b/dist/server/controllers/plugins.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.pluginsRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const path_1 = require("path"); const logger_1 = require("@server/helpers/logger"); const auth_1 = require("@server/middlewares/auth"); @@ -16,19 +16,19 @@ const plugins_1 = require("../middlewares/validators/plugins"); const themes_1 = require("../middlewares/validators/themes"); const sendFileOptions = { maxAge: '30 days', - immutable: !core_utils_1.isTestInstance() + immutable: !(0, core_utils_1.isTestInstance)() }; const pluginsRouter = express_1.default.Router(); exports.pluginsRouter = pluginsRouter; pluginsRouter.get('/plugins/global.css', servePluginGlobalCSS); pluginsRouter.get('/plugins/translations/:locale.json', getPluginTranslations); -pluginsRouter.get('/plugins/:pluginName/:pluginVersion/auth/:authName', plugins_1.getPluginValidator(plugin_type_1.PluginType.PLUGIN), plugins_1.getExternalAuthValidator, handleAuthInPlugin); -pluginsRouter.get('/plugins/:pluginName/:pluginVersion/static/:staticEndpoint(*)', plugins_1.getPluginValidator(plugin_type_1.PluginType.PLUGIN), plugins_1.pluginStaticDirectoryValidator, servePluginStaticDirectory); -pluginsRouter.get('/plugins/:pluginName/:pluginVersion/client-scripts/:staticEndpoint(*)', plugins_1.getPluginValidator(plugin_type_1.PluginType.PLUGIN), plugins_1.pluginStaticDirectoryValidator, servePluginClientScripts); -pluginsRouter.use('/plugins/:pluginName/router', plugins_1.getPluginValidator(plugin_type_1.PluginType.PLUGIN, false), auth_1.optionalAuthenticate, servePluginCustomRoutes); -pluginsRouter.use('/plugins/:pluginName/:pluginVersion/router', plugins_1.getPluginValidator(plugin_type_1.PluginType.PLUGIN), auth_1.optionalAuthenticate, servePluginCustomRoutes); -pluginsRouter.get('/themes/:pluginName/:pluginVersion/static/:staticEndpoint(*)', plugins_1.getPluginValidator(plugin_type_1.PluginType.THEME), plugins_1.pluginStaticDirectoryValidator, servePluginStaticDirectory); -pluginsRouter.get('/themes/:pluginName/:pluginVersion/client-scripts/:staticEndpoint(*)', plugins_1.getPluginValidator(plugin_type_1.PluginType.THEME), plugins_1.pluginStaticDirectoryValidator, servePluginClientScripts); +pluginsRouter.get('/plugins/:pluginName/:pluginVersion/auth/:authName', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.PLUGIN), plugins_1.getExternalAuthValidator, handleAuthInPlugin); +pluginsRouter.get('/plugins/:pluginName/:pluginVersion/static/:staticEndpoint(*)', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.PLUGIN), plugins_1.pluginStaticDirectoryValidator, servePluginStaticDirectory); +pluginsRouter.get('/plugins/:pluginName/:pluginVersion/client-scripts/:staticEndpoint(*)', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.PLUGIN), plugins_1.pluginStaticDirectoryValidator, servePluginClientScripts); +pluginsRouter.use('/plugins/:pluginName/router', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.PLUGIN, false), auth_1.optionalAuthenticate, servePluginCustomRoutes); +pluginsRouter.use('/plugins/:pluginName/:pluginVersion/router', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.PLUGIN), auth_1.optionalAuthenticate, servePluginCustomRoutes); +pluginsRouter.get('/themes/:pluginName/:pluginVersion/static/:staticEndpoint(*)', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.THEME), plugins_1.pluginStaticDirectoryValidator, servePluginStaticDirectory); +pluginsRouter.get('/themes/:pluginName/:pluginVersion/client-scripts/:staticEndpoint(*)', (0, plugins_1.getPluginValidator)(plugin_type_1.PluginType.THEME), plugins_1.pluginStaticDirectoryValidator, servePluginClientScripts); pluginsRouter.get('/themes/:themeName/:themeVersion/css/:staticEndpoint(*)', themes_1.serveThemeCSSValidator, serveThemeCSSDirectory); function servePluginGlobalCSS(req, res) { const globalCSSOptions = req.query.hash @@ -38,8 +38,8 @@ function servePluginGlobalCSS(req, res) { } function getPluginTranslations(req, res) { const locale = req.params.locale; - if (i18n_1.is18nLocale(locale)) { - const completeLocale = i18n_1.getCompleteLocale(locale); + if ((0, i18n_1.is18nLocale)(locale)) { + const completeLocale = (0, i18n_1.getCompleteLocale)(locale); const json = plugin_manager_1.PluginManager.Instance.getTranslations(completeLocale); return res.json(json); } @@ -53,7 +53,7 @@ function servePluginStaticDirectory(req, res) { if (!staticPath) return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); const filepath = file.join('/'); - return res.sendFile(path_1.join(plugin.path, staticPath, filepath), sendFileOptions); + return res.sendFile((0, path_1.join)(plugin.path, staticPath, filepath), sendFileOptions); } function servePluginCustomRoutes(req, res, next) { const plugin = res.locals.registeredPlugin; @@ -68,7 +68,7 @@ function servePluginClientScripts(req, res) { const file = plugin.clientScripts[staticEndpoint]; if (!file) return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); - return res.sendFile(path_1.join(plugin.path, staticEndpoint), sendFileOptions); + return res.sendFile((0, path_1.join)(plugin.path, staticEndpoint), sendFileOptions); } function serveThemeCSSDirectory(req, res) { const plugin = res.locals.registeredPlugin; @@ -76,7 +76,7 @@ function serveThemeCSSDirectory(req, res) { if (plugin.css.includes(staticEndpoint) === false) { return res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404).end(); } - return res.sendFile(path_1.join(plugin.path, staticEndpoint), sendFileOptions); + return res.sendFile((0, path_1.join)(plugin.path, staticEndpoint), sendFileOptions); } function handleAuthInPlugin(req, res) { const authOptions = res.locals.externalAuth; diff --git a/dist/server/controllers/services.js b/dist/server/controllers/services.js index 3ae19263..dff2ff3f 100644 --- a/dist/server/controllers/services.js +++ b/dist/server/controllers/services.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.servicesRouter = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const constants_1 = require("../initializers/constants"); const middlewares_1 = require("../middlewares"); const validators_1 = require("../middlewares/validators"); const renderer_1 = require("@shared/core-utils/renderer"); const servicesRouter = express_1.default.Router(); exports.servicesRouter = servicesRouter; -servicesRouter.use('/oembed', middlewares_1.asyncMiddleware(middlewares_1.oembedValidator), generateOEmbed); -servicesRouter.use('/redirect/accounts/:accountName', middlewares_1.asyncMiddleware(validators_1.accountNameWithHostGetValidator), redirectToAccountUrl); +servicesRouter.use('/oembed', (0, middlewares_1.asyncMiddleware)(middlewares_1.oembedValidator), generateOEmbed); +servicesRouter.use('/redirect/accounts/:accountName', (0, middlewares_1.asyncMiddleware)(validators_1.accountNameWithHostGetValidator), redirectToAccountUrl); function generateOEmbed(req, res) { if (res.locals.videoAll) return generateVideoOEmbed(req, res); @@ -46,7 +46,7 @@ function buildOEmbed(options) { const maxHeight = parseInt(req.query.maxheight, 10); const maxWidth = parseInt(req.query.maxwidth, 10); const embedUrl = webserverUrl + embedPath; - const embedTitle = renderer_1.escapeHTML(title); + const embedTitle = (0, renderer_1.escapeHTML)(title); let thumbnailUrl = previewPath ? webserverUrl + previewPath : undefined; diff --git a/dist/server/controllers/static.js b/dist/server/controllers/static.js index dfac92a2..ee1cecda 100644 --- a/dist/server/controllers/static.js +++ b/dist/server/controllers/static.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.staticRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const path_1 = require("path"); const client_html_1 = require("@server/lib/client-html"); const server_config_manager_1 = require("@server/lib/server-config-manager"); @@ -19,27 +19,29 @@ const video_1 = require("../models/video/video"); const video_comment_1 = require("../models/video/video-comment"); const staticRouter = express_1.default.Router(); exports.staticRouter = staticRouter; -staticRouter.use(cors_1.default()); +staticRouter.use((0, cors_1.default)()); const torrentsPhysicalPath = config_1.CONFIG.STORAGE.TORRENTS_DIR; staticRouter.use(constants_1.STATIC_PATHS.TORRENTS, express_1.default.static(torrentsPhysicalPath, { maxAge: 0 })); +staticRouter.use(constants_1.STATIC_PATHS.IMAGES, express_1.default.static(config_1.CONFIG.STORAGE.IMAGES_DIR, { fallthrough: false })); +staticRouter.use(constants_1.STATIC_PATHS.IMAGES_WEBSEED, express_1.default.static(config_1.CONFIG.STORAGE.IMAGES_DIR, { fallthrough: false })); staticRouter.use(constants_1.STATIC_PATHS.WEBSEED, express_1.default.static(config_1.CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false })); staticRouter.use(constants_1.STATIC_PATHS.REDUNDANCY, express_1.default.static(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false })); -staticRouter.use(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, cors_1.default(), express_1.default.static(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false })); +staticRouter.use(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, (0, cors_1.default)(), express_1.default.static(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false })); const thumbnailsPhysicalPath = config_1.CONFIG.STORAGE.THUMBNAILS_DIR; staticRouter.use(constants_1.STATIC_PATHS.THUMBNAILS, express_1.default.static(thumbnailsPhysicalPath, { maxAge: constants_1.STATIC_MAX_AGE.SERVER, fallthrough: false })); -staticRouter.get('/robots.txt', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.ROBOTS), (_, res) => { +staticRouter.get('/robots.txt', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.ROBOTS), (_, res) => { res.type('text/plain'); return res.send(config_1.CONFIG.INSTANCE.ROBOTS); }); -staticRouter.all('/teapot', getCup, middlewares_1.asyncMiddleware(client_html_1.serveIndexHTML)); +staticRouter.all('/teapot', getCup, (0, middlewares_1.asyncMiddleware)(client_html_1.serveIndexHTML)); staticRouter.get('/security.txt', (_, res) => { return res.redirect(models_1.HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt'); }); -staticRouter.get('/.well-known/security.txt', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.SECURITYTXT), (_, res) => { +staticRouter.get('/.well-known/security.txt', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.SECURITYTXT), (_, res) => { res.type('text/plain'); return res.send(config_1.CONFIG.INSTANCE.SECURITYTXT + config_1.CONFIG.INSTANCE.SECURITYTXT_CONTACT); }); -staticRouter.use('/.well-known/nodeinfo', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.NODEINFO), (_, res) => { +staticRouter.use('/.well-known/nodeinfo', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.NODEINFO), (_, res) => { return res.json({ links: [ { @@ -49,10 +51,10 @@ staticRouter.use('/.well-known/nodeinfo', cache_1.cacheRoute(constants_1.ROUTE_C ] }); }); -staticRouter.use('/nodeinfo/:version.json', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.NODEINFO), middlewares_1.asyncMiddleware(generateNodeinfo)); -staticRouter.use('/.well-known/dnt-policy.txt', cache_1.cacheRoute(constants_1.ROUTE_CACHE_LIFETIME.DNT_POLICY), (_, res) => { +staticRouter.use('/nodeinfo/:version.json', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.NODEINFO), (0, middlewares_1.asyncMiddleware)(generateNodeinfo)); +staticRouter.use('/.well-known/dnt-policy.txt', (0, cache_1.cacheRoute)(constants_1.ROUTE_CACHE_LIFETIME.DNT_POLICY), (_, res) => { res.type('text/plain'); - return res.sendFile(path_1.join(core_utils_1.root(), 'dist/server/static/dnt-policy/dnt-policy-1.0.txt')); + return res.sendFile((0, path_1.join)((0, core_utils_1.root)(), 'dist/server/static/dnt-policy/dnt-policy-1.0.txt')); }); staticRouter.use('/.well-known/dnt/', (_, res) => { res.json({ tracking: 'N' }); @@ -69,7 +71,7 @@ staticRouter.use('/.well-known/host-meta', (_, res) => { res.send(xml).end(); }); function generateNodeinfo(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { totalVideos } = yield video_1.VideoModel.getStats(); const { totalLocalVideoComments } = yield video_comment_1.VideoCommentModel.getStats(); const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = yield user_1.UserModel.getStats(); @@ -123,10 +125,10 @@ function generateNodeinfo(req, res) { }, theme: { registered: server_config_manager_1.ServerConfigManager.Instance.getRegisteredThemes(), - default: theme_utils_1.getThemeOrDefault(config_1.CONFIG.THEME.DEFAULT, constants_1.DEFAULT_THEME_NAME) + default: (0, theme_utils_1.getThemeOrDefault)(config_1.CONFIG.THEME.DEFAULT, constants_1.DEFAULT_THEME_NAME) }, email: { - enabled: config_1.isEmailEnabled() + enabled: (0, config_1.isEmailEnabled)() }, contactForm: { enabled: config_1.CONFIG.CONTACT_FORM.ENABLED diff --git a/dist/server/controllers/tracker.js b/dist/server/controllers/tracker.js index dcd63df4..e1cc41b1 100644 --- a/dist/server/controllers/tracker.js +++ b/dist/server/controllers/tracker.js @@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createWebsocketTrackerServer = exports.trackerRouter = void 0; const tslib_1 = require("tslib"); const bittorrent_tracker_1 = require("bittorrent-tracker"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const http_1 = require("http"); -const proxy_addr_1 = tslib_1.__importDefault(require("proxy-addr")); +const proxy_addr_1 = (0, tslib_1.__importDefault)(require("proxy-addr")); const ws_1 = require("ws"); const redis_1 = require("@server/lib/redis"); const logger_1 = require("../helpers/logger"); @@ -13,6 +13,7 @@ const config_1 = require("../initializers/config"); const constants_1 = require("../initializers/constants"); const video_file_1 = require("../models/video/video-file"); const video_streaming_playlist_1 = require("../models/video/video-streaming-playlist"); +const image_1 = require("@server/models/image/image"); const trackerRouter = express_1.default.Router(); exports.trackerRouter = trackerRouter; let peersIps = {}; @@ -23,7 +24,7 @@ const trackerServer = new bittorrent_tracker_1.Server({ udp: false, ws: false, filter: function (infoHash, params, cb) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.TRACKER.ENABLED === false) { return cb(new Error('Tracker is disabled on this instance.')); } @@ -49,6 +50,9 @@ const trackerServer = new bittorrent_tracker_1.Server({ const playlistExists = yield video_streaming_playlist_1.VideoStreamingPlaylistModel.doesInfohashExistCached(infoHash); if (playlistExists === true) return cb(); + const imageExists = yield image_1.ImageModel.doesInfohashExistCached(infoHash); + if (imageExists === true) + return cb(); cb(new Error(`Unknown infoHash ${infoHash} requested by ip ${ip}`)); if (params.type === 'ws') { redis_1.Redis.Instance.setTrackerBlockIP(ip) @@ -75,15 +79,15 @@ const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer); trackerRouter.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' })); trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' })); function createWebsocketTrackerServer(app) { - const server = http_1.createServer(app); + const server = (0, http_1.createServer)(app); const wss = new ws_1.WebSocketServer({ noServer: true }); wss.on('connection', function (ws, req) { - ws['ip'] = proxy_addr_1.default(req, config_1.CONFIG.TRUST_PROXY); + ws['ip'] = (0, proxy_addr_1.default)(req, config_1.CONFIG.TRUST_PROXY); trackerServer.onWebSocketConnection(ws); }); server.on('upgrade', (request, socket, head) => { if (request.url === '/tracker/socket') { - const ip = proxy_addr_1.default(request, config_1.CONFIG.TRUST_PROXY); + const ip = (0, proxy_addr_1.default)(request, config_1.CONFIG.TRUST_PROXY); redis_1.Redis.Instance.doesTrackerBlockIPExist(ip) .then(result => { if (result === true) { diff --git a/dist/server/controllers/webfinger.js b/dist/server/controllers/webfinger.js index 6e4722da..a2bd6003 100644 --- a/dist/server/controllers/webfinger.js +++ b/dist/server/controllers/webfinger.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.webfingerRouter = void 0; const tslib_1 = require("tslib"); -const cors_1 = tslib_1.__importDefault(require("cors")); -const express_1 = tslib_1.__importDefault(require("express")); +const cors_1 = (0, tslib_1.__importDefault)(require("cors")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const constants_1 = require("@server/initializers/constants"); const middlewares_1 = require("../middlewares"); const validators_1 = require("../middlewares/validators"); const webfingerRouter = express_1.default.Router(); exports.webfingerRouter = webfingerRouter; -webfingerRouter.use(cors_1.default()); -webfingerRouter.get('/.well-known/webfinger', middlewares_1.asyncMiddleware(validators_1.webfingerValidator), webfingerController); +webfingerRouter.use((0, cors_1.default)()); +webfingerRouter.get('/.well-known/webfinger', (0, middlewares_1.asyncMiddleware)(validators_1.webfingerValidator), webfingerController); function webfingerController(req, res) { const actor = res.locals.actorUrl; const json = { diff --git a/dist/server/helpers/activitypub.js b/dist/server/helpers/activitypub.js index c9c7c6d4..6fb3c276 100644 --- a/dist/server/helpers/activitypub.js +++ b/dist/server/helpers/activitypub.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildRemoteVideoBaseUrl = exports.buildSignedActivity = exports.activityPubCollectionPagination = exports.activityPubContextify = exports.getAPId = exports.checkUrlsSameHost = void 0; const tslib_1 = require("tslib"); const url_1 = require("url"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../initializers/constants"); const core_utils_1 = require("./core-utils"); const peertube_crypto_1 = require("./peertube-crypto"); @@ -125,7 +125,7 @@ function activityPubContextify(data, type = 'All') { } exports.activityPubContextify = activityPubContextify; function activityPubCollectionPagination(baseUrl, handler, page, size = constants_1.ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!page || !validator_1.default.isInt(page)) { const result = yield handler(0, 1); return { @@ -135,7 +135,7 @@ function activityPubCollectionPagination(baseUrl, handler, page, size = constant first: baseUrl + '?page=1' }; } - const { start, count } = core_utils_1.pageToStartAndCount(page, size); + const { start, count } = (0, core_utils_1.pageToStartAndCount)(page, size); const result = yield handler(start, count); let next; let prev; @@ -160,7 +160,7 @@ function activityPubCollectionPagination(baseUrl, handler, page, size = constant exports.activityPubCollectionPagination = activityPubCollectionPagination; function buildSignedActivity(byActor, data, contextType) { const activity = activityPubContextify(data, contextType); - return peertube_crypto_1.signJsonLDObject(byActor, activity); + return (0, peertube_crypto_1.signJsonLDObject)(byActor, activity); } exports.buildSignedActivity = buildSignedActivity; function getAPId(activity) { diff --git a/dist/server/helpers/audit-logger.js b/dist/server/helpers/audit-logger.js index 4574bad6..c53a1937 100644 --- a/dist/server/helpers/audit-logger.js +++ b/dist/server/helpers/audit-logger.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomConfigAuditView = exports.AbuseAuditView = exports.VideoAuditView = exports.UserAuditView = exports.CommentAuditView = exports.VideoChannelAuditView = exports.VideoImportAuditView = exports.auditLoggerFactory = exports.getAuditIdFromRes = void 0; const tslib_1 = require("tslib"); const deep_object_diff_1 = require("deep-object-diff"); -const flat_1 = tslib_1.__importDefault(require("flat")); +const flat_1 = (0, tslib_1.__importDefault)(require("flat")); const lodash_1 = require("lodash"); const path_1 = require("path"); const winston_1 = require("winston"); @@ -22,16 +22,16 @@ var AUDIT_TYPE; })(AUDIT_TYPE || (AUDIT_TYPE = {})); const colors = winston_1.config.npm.colors; colors.audit = winston_1.config.npm.colors.info; -winston_1.addColors(colors); -const auditLogger = winston_1.createLogger({ +(0, winston_1.addColors)(colors); +const auditLogger = (0, winston_1.createLogger)({ levels: { audit: 0 }, transports: [ new winston_1.transports.File({ - filename: path_1.join(config_1.CONFIG.STORAGE.LOG_DIR, constants_1.AUDIT_LOG_FILENAME), + filename: (0, path_1.join)(config_1.CONFIG.STORAGE.LOG_DIR, constants_1.AUDIT_LOG_FILENAME), level: 'audit', maxsize: 5242880, maxFiles: 5, - format: winston_1.format.combine(winston_1.format.timestamp(), logger_1.labelFormatter(), winston_1.format.splat(), logger_1.jsonLoggerFormat) + format: winston_1.format.combine(winston_1.format.timestamp(), (0, logger_1.labelFormatter)(), winston_1.format.splat(), logger_1.jsonLoggerFormat) }) ], exitOnError: true @@ -40,7 +40,7 @@ function auditLoggerWrapper(domain, user, action, entity, oldEntity = null) { let entityInfos; if (action === AUDIT_TYPE.UPDATE && oldEntity) { const oldEntityKeys = oldEntity.toLogKeys(); - const diffObject = deep_object_diff_1.diff(oldEntityKeys, entity.toLogKeys()); + const diffObject = (0, deep_object_diff_1.diff)(oldEntityKeys, entity.toLogKeys()); const diffKeys = Object.entries(diffObject).reduce((newKeys, entry) => { newKeys[`new-${entry[0]}`] = entry[1]; return newKeys; @@ -75,7 +75,7 @@ class EntityAuditView { this.entityInfos = entityInfos; } toLogKeys() { - return lodash_1.chain(flat_1.default(this.entityInfos, { delimiter: '-', safe: true })) + return (0, lodash_1.chain)((0, flat_1.default)(this.entityInfos, { delimiter: '-', safe: true })) .pick(this.keysToKeep) .mapKeys((_value, key) => `${this.prefix}-${key}`) .value(); diff --git a/dist/server/helpers/captions-utils.js b/dist/server/helpers/captions-utils.js index eae676d6..8875f5bd 100644 --- a/dist/server/helpers/captions-utils.js +++ b/dist/server/helpers/captions-utils.js @@ -4,20 +4,20 @@ exports.moveAndProcessCaptionFile = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); -const srt_to_vtt_1 = tslib_1.__importDefault(require("srt-to-vtt")); +const srt_to_vtt_1 = (0, tslib_1.__importDefault)(require("srt-to-vtt")); const stream_1 = require("stream"); const config_1 = require("../initializers/config"); const core_utils_1 = require("./core-utils"); function moveAndProcessCaptionFile(physicalFile, videoCaption) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCaptionsDir = config_1.CONFIG.STORAGE.CAPTIONS_DIR; - const destination = path_1.join(videoCaptionsDir, videoCaption.filename); + const destination = (0, path_1.join)(videoCaptionsDir, videoCaption.filename); if (physicalFile.path.endsWith('.srt')) { yield convertSrtToVtt(physicalFile.path, destination); - yield fs_extra_1.remove(physicalFile.path); + yield (0, fs_extra_1.remove)(physicalFile.path); } else if (physicalFile.path !== destination) { - yield fs_extra_1.move(physicalFile.path, destination, { overwrite: true }); + yield (0, fs_extra_1.move)(physicalFile.path, destination, { overwrite: true }); } physicalFile.filename = videoCaption.filename; physicalFile.path = destination; @@ -34,5 +34,5 @@ function convertSrtToVtt(source, destination) { return cb(undefined, block); } }); - return core_utils_1.pipelinePromise(fs_extra_1.createReadStream(source), srt_to_vtt_1.default(), fixVTT, fs_extra_1.createWriteStream(destination)); + return (0, core_utils_1.pipelinePromise)((0, fs_extra_1.createReadStream)(source), (0, srt_to_vtt_1.default)(), fixVTT, (0, fs_extra_1.createWriteStream)(destination)); } diff --git a/dist/server/helpers/core-utils.js b/dist/server/helpers/core-utils.js index a60ade89..b38a2f36 100644 --- a/dist/server/helpers/core-utils.js +++ b/dist/server/helpers/core-utils.js @@ -147,32 +147,32 @@ function root() { if (rootPath) return rootPath; rootPath = __dirname; - if (path_1.basename(rootPath) === 'helpers') - rootPath = path_1.resolve(rootPath, '..'); - if (path_1.basename(rootPath) === 'server') - rootPath = path_1.resolve(rootPath, '..'); - if (path_1.basename(rootPath) === 'dist') - rootPath = path_1.resolve(rootPath, '..'); + if ((0, path_1.basename)(rootPath) === 'helpers') + rootPath = (0, path_1.resolve)(rootPath, '..'); + if ((0, path_1.basename)(rootPath) === 'server') + rootPath = (0, path_1.resolve)(rootPath, '..'); + if ((0, path_1.basename)(rootPath) === 'dist') + rootPath = (0, path_1.resolve)(rootPath, '..'); return rootPath; } exports.root = root; function buildPath(path) { - if (path_1.isAbsolute(path)) + if ((0, path_1.isAbsolute)(path)) return path; - return path_1.join(root(), path); + return (0, path_1.join)(root(), path); } exports.buildPath = buildPath; function getLowercaseExtension(filename) { - const ext = path_1.extname(filename) || ''; + const ext = (0, path_1.extname)(filename) || ''; return ext.toLowerCase(); } exports.getLowercaseExtension = getLowercaseExtension; function peertubeTruncate(str, options) { - const truncatedStr = lodash_1.truncate(str, options); + const truncatedStr = (0, lodash_1.truncate)(str, options); if (truncatedStr.length <= options.length) return truncatedStr; options.length -= truncatedStr.length - options.length; - return lodash_1.truncate(str, options); + return (0, lodash_1.truncate)(str, options); } exports.peertubeTruncate = peertubeTruncate; function pageToStartAndCount(page, itemsPerPage) { @@ -190,16 +190,16 @@ function parseSemVersion(s) { } exports.parseSemVersion = parseSemVersion; function sha256(str, encoding = 'hex') { - return crypto_1.createHash('sha256').update(str).digest(encoding); + return (0, crypto_1.createHash)('sha256').update(str).digest(encoding); } exports.sha256 = sha256; function sha1(str, encoding = 'hex') { - return crypto_1.createHash('sha1').update(str).digest(encoding); + return (0, crypto_1.createHash)('sha1').update(str).digest(encoding); } exports.sha1 = sha1; function execShell(command, options) { return new Promise((res, rej) => { - child_process_1.exec(command, options, (err, stdout, stderr) => { + (0, child_process_1.exec)(command, options, (err, stdout, stderr) => { if (err) return rej({ err, stdout, stderr }); return res({ stdout, stderr }); @@ -251,5 +251,5 @@ const execPromise2 = promisify2(child_process_1.exec); exports.execPromise2 = execPromise2; const execPromise = promisify1(child_process_1.exec); exports.execPromise = execPromise; -const pipelinePromise = util_1.promisify(stream_1.pipeline); +const pipelinePromise = (0, util_1.promisify)(stream_1.pipeline); exports.pipelinePromise = pipelinePromise; diff --git a/dist/server/helpers/custom-jsonld-signature.js b/dist/server/helpers/custom-jsonld-signature.js index fd1ebc44..608fd664 100644 --- a/dist/server/helpers/custom-jsonld-signature.js +++ b/dist/server/helpers/custom-jsonld-signature.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.jsonld = void 0; const tslib_1 = require("tslib"); -const async_lru_1 = tslib_1.__importDefault(require("async-lru")); +const async_lru_1 = (0, tslib_1.__importDefault)(require("async-lru")); const logger_1 = require("./logger"); const jsonld = require("jsonld"); exports.jsonld = jsonld; diff --git a/dist/server/helpers/custom-validators/abuses.js b/dist/server/helpers/custom-validators/abuses.js index d74f2163..87204065 100644 --- a/dist/server/helpers/custom-validators/abuses.js +++ b/dist/server/helpers/custom-validators/abuses.js @@ -2,18 +2,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isAbuseVideoIsValid = exports.isAbuseStateValid = exports.isAbuseModerationCommentValid = exports.isAbuseTimestampCoherent = exports.isAbuseTimestampValid = exports.areAbusePredefinedReasonsValid = exports.isAbuseMessageValid = exports.isAbusePredefinedReasonValid = exports.isAbuseFilterValid = exports.isAbuseReasonValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const abuse_1 = require("@shared/core-utils/abuse"); const constants_1 = require("../../initializers/constants"); const misc_1 = require("./misc"); const ABUSES_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.ABUSES; const ABUSE_MESSAGES_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.ABUSE_MESSAGES; function isAbuseReasonValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON); } exports.isAbuseReasonValid = isAbuseReasonValid; function isAbusePredefinedReasonValid(value) { - return misc_1.exists(value) && value in abuse_1.abusePredefinedReasonsMap; + return (0, misc_1.exists)(value) && value in abuse_1.abusePredefinedReasonsMap; } exports.isAbusePredefinedReasonValid = isAbusePredefinedReasonValid; function isAbuseFilterValid(value) { @@ -21,32 +21,32 @@ function isAbuseFilterValid(value) { } exports.isAbuseFilterValid = isAbuseFilterValid; function areAbusePredefinedReasonsValid(value) { - return misc_1.exists(value) && misc_1.isArray(value) && value.every(v => v in abuse_1.abusePredefinedReasonsMap); + return (0, misc_1.exists)(value) && (0, misc_1.isArray)(value) && value.every(v => v in abuse_1.abusePredefinedReasonsMap); } exports.areAbusePredefinedReasonsValid = areAbusePredefinedReasonsValid; function isAbuseTimestampValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isInt('' + value, { min: 0 })); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isInt('' + value, { min: 0 })); } exports.isAbuseTimestampValid = isAbuseTimestampValid; function isAbuseTimestampCoherent(endAt, { req }) { const startAt = req.body.video.startAt; - return misc_1.exists(startAt) && endAt > startAt; + return (0, misc_1.exists)(startAt) && endAt > startAt; } exports.isAbuseTimestampCoherent = isAbuseTimestampCoherent; function isAbuseModerationCommentValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT); } exports.isAbuseModerationCommentValid = isAbuseModerationCommentValid; function isAbuseStateValid(value) { - return misc_1.exists(value) && constants_1.ABUSE_STATES[value] !== undefined; + return (0, misc_1.exists)(value) && constants_1.ABUSE_STATES[value] !== undefined; } exports.isAbuseStateValid = isAbuseStateValid; function isAbuseVideoIsValid(value) { - return misc_1.exists(value) && (value === 'deleted' || + return (0, misc_1.exists)(value) && (value === 'deleted' || value === 'blacklisted'); } exports.isAbuseVideoIsValid = isAbuseVideoIsValid; function isAbuseMessageValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE); } exports.isAbuseMessageValid = isAbuseMessageValid; diff --git a/dist/server/helpers/custom-validators/accounts.js b/dist/server/helpers/custom-validators/accounts.js index 7783e7d5..81d82aa6 100644 --- a/dist/server/helpers/custom-validators/accounts.js +++ b/dist/server/helpers/custom-validators/accounts.js @@ -4,14 +4,14 @@ exports.isAccountNameValid = exports.isAccountDescriptionValid = exports.isAccou const users_1 = require("./users"); const misc_1 = require("./misc"); function isAccountNameValid(value) { - return users_1.isUserUsernameValid(value); + return (0, users_1.isUserUsernameValid)(value); } exports.isAccountNameValid = isAccountNameValid; function isAccountIdValid(value) { - return misc_1.exists(value); + return (0, misc_1.exists)(value); } exports.isAccountIdValid = isAccountIdValid; function isAccountDescriptionValid(value) { - return users_1.isUserDescriptionValid(value); + return (0, users_1.isUserDescriptionValid)(value); } exports.isAccountDescriptionValid = isAccountDescriptionValid; diff --git a/dist/server/helpers/custom-validators/activitypub/activity.js b/dist/server/helpers/custom-validators/activitypub/activity.js index 36ea3cce..391d383c 100644 --- a/dist/server/helpers/custom-validators/activitypub/activity.js +++ b/dist/server/helpers/custom-validators/activitypub/activity.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isUndoActivityValid = exports.isRejectActivityValid = exports.isAcceptActivityValid = exports.isFollowActivityValid = exports.isDeleteActivityValid = exports.isUpdateActivityValid = exports.isCreateActivityValid = exports.isViewActivityValid = exports.isAnnounceActivityValid = exports.isDislikeActivityValid = exports.isLikeActivityValid = exports.isFlagActivityValid = exports.isActivityValid = exports.isRootActivityValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const abuses_1 = require("../abuses"); const misc_1 = require("../misc"); const actor_1 = require("./actor"); @@ -21,9 +21,9 @@ function isCollection(activity) { Array.isArray(activity.items); } function isActivity(activity) { - return misc_2.isActivityPubUrlValid(activity.id) && - misc_1.exists(activity.actor) && - (misc_2.isActivityPubUrlValid(activity.actor) || misc_2.isActivityPubUrlValid(activity.actor.id)); + return (0, misc_2.isActivityPubUrlValid)(activity.id) && + (0, misc_1.exists)(activity.actor) && + ((0, misc_2.isActivityPubUrlValid)(activity.actor) || (0, misc_2.isActivityPubUrlValid)(activity.actor.id)); } const activityCheckers = { Create: isCreateActivityValid, @@ -47,71 +47,71 @@ function isActivityValid(activity) { } exports.isActivityValid = isActivityValid; function isFlagActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Flag') && - abuses_1.isAbuseReasonValid(activity.content) && - misc_2.isActivityPubUrlValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Flag') && + (0, abuses_1.isAbuseReasonValid)(activity.content) && + (0, misc_2.isActivityPubUrlValid)(activity.object); } exports.isFlagActivityValid = isFlagActivityValid; function isLikeActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Like') && - misc_2.isObjectValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Like') && + (0, misc_2.isObjectValid)(activity.object); } exports.isLikeActivityValid = isLikeActivityValid; function isDislikeActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Dislike') && - misc_2.isObjectValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Dislike') && + (0, misc_2.isObjectValid)(activity.object); } exports.isDislikeActivityValid = isDislikeActivityValid; function isAnnounceActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Announce') && - misc_2.isObjectValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Announce') && + (0, misc_2.isObjectValid)(activity.object); } exports.isAnnounceActivityValid = isAnnounceActivityValid; function isViewActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'View') && - misc_2.isActivityPubUrlValid(activity.actor) && - misc_2.isActivityPubUrlValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'View') && + (0, misc_2.isActivityPubUrlValid)(activity.actor) && + (0, misc_2.isActivityPubUrlValid)(activity.object); } exports.isViewActivityValid = isViewActivityValid; function isCreateActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Create') && + return (0, misc_2.isBaseActivityValid)(activity, 'Create') && (isViewActivityValid(activity.object) || isDislikeActivityValid(activity.object) || isFlagActivityValid(activity.object) || - playlist_1.isPlaylistObjectValid(activity.object) || - cache_file_1.isCacheFileObjectValid(activity.object) || - video_comments_1.sanitizeAndCheckVideoCommentObject(activity.object) || - videos_1.sanitizeAndCheckVideoTorrentObject(activity.object)); + (0, playlist_1.isPlaylistObjectValid)(activity.object) || + (0, cache_file_1.isCacheFileObjectValid)(activity.object) || + (0, video_comments_1.sanitizeAndCheckVideoCommentObject)(activity.object) || + (0, videos_1.sanitizeAndCheckVideoTorrentObject)(activity.object)); } exports.isCreateActivityValid = isCreateActivityValid; function isUpdateActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Update') && - (cache_file_1.isCacheFileObjectValid(activity.object) || - playlist_1.isPlaylistObjectValid(activity.object) || - videos_1.sanitizeAndCheckVideoTorrentObject(activity.object) || - actor_1.sanitizeAndCheckActorObject(activity.object)); + return (0, misc_2.isBaseActivityValid)(activity, 'Update') && + ((0, cache_file_1.isCacheFileObjectValid)(activity.object) || + (0, playlist_1.isPlaylistObjectValid)(activity.object) || + (0, videos_1.sanitizeAndCheckVideoTorrentObject)(activity.object) || + (0, actor_1.sanitizeAndCheckActorObject)(activity.object)); } exports.isUpdateActivityValid = isUpdateActivityValid; function isDeleteActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Delete') && - misc_2.isObjectValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Delete') && + (0, misc_2.isObjectValid)(activity.object); } exports.isDeleteActivityValid = isDeleteActivityValid; function isFollowActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Follow') && - misc_2.isObjectValid(activity.object); + return (0, misc_2.isBaseActivityValid)(activity, 'Follow') && + (0, misc_2.isObjectValid)(activity.object); } exports.isFollowActivityValid = isFollowActivityValid; function isAcceptActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Accept'); + return (0, misc_2.isBaseActivityValid)(activity, 'Accept'); } exports.isAcceptActivityValid = isAcceptActivityValid; function isRejectActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Reject'); + return (0, misc_2.isBaseActivityValid)(activity, 'Reject'); } exports.isRejectActivityValid = isRejectActivityValid; function isUndoActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Undo') && + return (0, misc_2.isBaseActivityValid)(activity, 'Undo') && (isFollowActivityValid(activity.object) || isLikeActivityValid(activity.object) || isDislikeActivityValid(activity.object) || diff --git a/dist/server/helpers/custom-validators/activitypub/actor.js b/dist/server/helpers/custom-validators/activitypub/actor.js index 99805bd0..11253adc 100644 --- a/dist/server/helpers/custom-validators/activitypub/actor.js +++ b/dist/server/helpers/custom-validators/activitypub/actor.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidActorHandle = exports.sanitizeAndCheckActorObject = exports.isActorDeleteActivityValid = exports.isActorFollowersCountValid = exports.isActorFollowingCountValid = exports.isActorPrivateKeyValid = exports.isActorPreferredUsernameValid = exports.isActorPublicKeyValid = exports.isActorTypeValid = exports.isActorPublicKeyObjectValid = exports.isActorEndpointsObjectValid = exports.areValidActorHandles = exports.actorNameAlphabet = exports.normalizeActor = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../../initializers/constants"); const misc_1 = require("../misc"); const misc_2 = require("./misc"); @@ -10,14 +10,14 @@ const servers_1 = require("../servers"); const core_utils_1 = require("@server/helpers/core-utils"); function isActorEndpointsObjectValid(endpointObject) { if (endpointObject === null || endpointObject === void 0 ? void 0 : endpointObject.sharedInbox) { - return misc_2.isActivityPubUrlValid(endpointObject.sharedInbox); + return (0, misc_2.isActivityPubUrlValid)(endpointObject.sharedInbox); } return true; } exports.isActorEndpointsObjectValid = isActorEndpointsObjectValid; function isActorPublicKeyObjectValid(publicKeyObject) { - return misc_2.isActivityPubUrlValid(publicKeyObject.id) && - misc_2.isActivityPubUrlValid(publicKeyObject.owner) && + return (0, misc_2.isActivityPubUrlValid)(publicKeyObject.id) && + (0, misc_2.isActivityPubUrlValid)(publicKeyObject.owner) && isActorPublicKeyValid(publicKeyObject.publicKeyPem); } exports.isActorPublicKeyObjectValid = isActorPublicKeyObjectValid; @@ -26,7 +26,7 @@ function isActorTypeValid(type) { } exports.isActorTypeValid = isActorTypeValid; function isActorPublicKeyValid(publicKey) { - return misc_1.exists(publicKey) && + return (0, misc_1.exists)(publicKey) && typeof publicKey === 'string' && publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && publicKey.includes('-----END PUBLIC KEY-----') && @@ -37,11 +37,11 @@ const actorNameAlphabet = '[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz exports.actorNameAlphabet = actorNameAlphabet; const actorNameRegExp = new RegExp(`^${actorNameAlphabet}+$`); function isActorPreferredUsernameValid(preferredUsername) { - return misc_1.exists(preferredUsername) && validator_1.default.matches(preferredUsername, actorNameRegExp); + return (0, misc_1.exists)(preferredUsername) && validator_1.default.matches(preferredUsername, actorNameRegExp); } exports.isActorPreferredUsernameValid = isActorPreferredUsernameValid; function isActorPrivateKeyValid(privateKey) { - return misc_1.exists(privateKey) && + return (0, misc_1.exists)(privateKey) && typeof privateKey === 'string' && privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') && privateKey.includes('-----END RSA PRIVATE KEY-----') && @@ -49,31 +49,31 @@ function isActorPrivateKeyValid(privateKey) { } exports.isActorPrivateKeyValid = isActorPrivateKeyValid; function isActorFollowingCountValid(value) { - return misc_1.exists(value) && validator_1.default.isInt('' + value, { min: 0 }); + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value, { min: 0 }); } exports.isActorFollowingCountValid = isActorFollowingCountValid; function isActorFollowersCountValid(value) { - return misc_1.exists(value) && validator_1.default.isInt('' + value, { min: 0 }); + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value, { min: 0 }); } exports.isActorFollowersCountValid = isActorFollowersCountValid; function isActorDeleteActivityValid(activity) { - return misc_2.isBaseActivityValid(activity, 'Delete'); + return (0, misc_2.isBaseActivityValid)(activity, 'Delete'); } exports.isActorDeleteActivityValid = isActorDeleteActivityValid; function sanitizeAndCheckActorObject(actor) { normalizeActor(actor); - return misc_1.exists(actor) && - misc_2.isActivityPubUrlValid(actor.id) && + return (0, misc_1.exists)(actor) && + (0, misc_2.isActivityPubUrlValid)(actor.id) && isActorTypeValid(actor.type) && - misc_2.isActivityPubUrlValid(actor.inbox) && + (0, misc_2.isActivityPubUrlValid)(actor.inbox) && isActorPreferredUsernameValid(actor.preferredUsername) && - misc_2.isActivityPubUrlValid(actor.url) && + (0, misc_2.isActivityPubUrlValid)(actor.url) && isActorPublicKeyObjectValid(actor.publicKey) && isActorEndpointsObjectValid(actor.endpoints) && - (!actor.outbox || misc_2.isActivityPubUrlValid(actor.outbox)) && - (!actor.following || misc_2.isActivityPubUrlValid(actor.following)) && - (!actor.followers || misc_2.isActivityPubUrlValid(actor.followers)) && - misc_2.setValidAttributedTo(actor) && + (!actor.outbox || (0, misc_2.isActivityPubUrlValid)(actor.outbox)) && + (!actor.following || (0, misc_2.isActivityPubUrlValid)(actor.following)) && + (!actor.followers || (0, misc_2.isActivityPubUrlValid)(actor.followers)) && + (0, misc_2.setValidAttributedTo)(actor) && setValidDescription(actor) && (actor.type !== 'Group' || actor.attributedTo.length !== 0); } @@ -87,10 +87,10 @@ function normalizeActor(actor) { else if (typeof actor.url !== 'string') { actor.url = actor.url.href || actor.url.url; } - if (!misc_1.isDateValid(actor.published)) + if (!(0, misc_1.isDateValid)(actor.published)) actor.published = undefined; if (actor.summary && typeof actor.summary === 'string') { - actor.summary = core_utils_1.peertubeTruncate(actor.summary, { length: constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max }); + actor.summary = (0, core_utils_1.peertubeTruncate)(actor.summary, { length: constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max }); if (actor.summary.length < constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION.min) { actor.summary = null; } @@ -98,16 +98,16 @@ function normalizeActor(actor) { } exports.normalizeActor = normalizeActor; function isValidActorHandle(handle) { - if (!misc_1.exists(handle)) + if (!(0, misc_1.exists)(handle)) return false; const parts = handle.split('@'); if (parts.length !== 2) return false; - return servers_1.isHostValid(parts[1]); + return (0, servers_1.isHostValid)(parts[1]); } exports.isValidActorHandle = isValidActorHandle; function areValidActorHandles(handles) { - return misc_1.isArray(handles) && handles.every(h => isValidActorHandle(h)); + return (0, misc_1.isArray)(handles) && handles.every(h => isValidActorHandle(h)); } exports.areValidActorHandles = areValidActorHandles; function setValidDescription(obj) { diff --git a/dist/server/helpers/custom-validators/activitypub/cache-file.js b/dist/server/helpers/custom-validators/activitypub/cache-file.js index 1a467906..722f4a78 100644 --- a/dist/server/helpers/custom-validators/activitypub/cache-file.js +++ b/dist/server/helpers/custom-validators/activitypub/cache-file.js @@ -5,15 +5,15 @@ const misc_1 = require("./misc"); const videos_1 = require("./videos"); const misc_2 = require("../misc"); function isCacheFileObjectValid(object) { - return misc_2.exists(object) && + return (0, misc_2.exists)(object) && object.type === 'CacheFile' && - (object.expires === null || misc_2.isDateValid(object.expires)) && - misc_1.isActivityPubUrlValid(object.object) && - (videos_1.isRemoteVideoUrlValid(object.url) || isPlaylistRedundancyUrlValid(object.url)); + (object.expires === null || (0, misc_2.isDateValid)(object.expires)) && + (0, misc_1.isActivityPubUrlValid)(object.object) && + ((0, videos_1.isRemoteVideoUrlValid)(object.url) || isPlaylistRedundancyUrlValid(object.url)); } exports.isCacheFileObjectValid = isCacheFileObjectValid; function isPlaylistRedundancyUrlValid(url) { return url.type === 'Link' && (url.mediaType || url.mimeType) === 'application/x-mpegURL' && - misc_1.isActivityPubUrlValid(url.href); + (0, misc_1.isActivityPubUrlValid)(url.href); } diff --git a/dist/server/helpers/custom-validators/activitypub/misc.js b/dist/server/helpers/custom-validators/activitypub/misc.js index 720a2925..b37f8f9e 100644 --- a/dist/server/helpers/custom-validators/activitypub/misc.js +++ b/dist/server/helpers/custom-validators/activitypub/misc.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isObjectValid = exports.setValidAttributedTo = exports.isBaseActivityValid = exports.isActivityPubUrlValid = exports.isUrlValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../../initializers/constants"); const core_utils_1 = require("../../core-utils"); const misc_1 = require("../misc"); @@ -14,10 +14,10 @@ function isUrlValid(url) { require_valid_protocol: true, protocols: ['http', 'https'] }; - if (core_utils_1.isTestInstance()) { + if ((0, core_utils_1.isTestInstance)()) { isURLOptions.require_tld = false; } - return misc_1.exists(url) && validator_1.default.isURL('' + url, isURLOptions); + return (0, misc_1.exists)(url) && validator_1.default.isURL('' + url, isURLOptions); } exports.isUrlValid = isUrlValid; function isActivityPubUrlValid(url) { @@ -37,7 +37,7 @@ function isUrlCollectionValid(collection) { (Array.isArray(collection) && collection.every(t => isActivityPubUrlValid(t))); } function isObjectValid(object) { - return misc_1.exists(object) && + return (0, misc_1.exists)(object) && (isActivityPubUrlValid(object) || isActivityPubUrlValid(object.id)); } exports.isObjectValid = isObjectValid; diff --git a/dist/server/helpers/custom-validators/activitypub/playlist.js b/dist/server/helpers/custom-validators/activitypub/playlist.js index 750a6b90..3136c3d3 100644 --- a/dist/server/helpers/custom-validators/activitypub/playlist.js +++ b/dist/server/helpers/custom-validators/activitypub/playlist.js @@ -2,24 +2,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isPlaylistElementObjectValid = exports.isPlaylistObjectValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("../misc"); const video_playlists_1 = require("../video-playlists"); const misc_2 = require("./misc"); function isPlaylistObjectValid(object) { - return misc_1.exists(object) && + return (0, misc_1.exists)(object) && object.type === 'Playlist' && validator_1.default.isInt(object.totalItems + '') && - video_playlists_1.isVideoPlaylistNameValid(object.name) && - misc_1.isUUIDValid(object.uuid) && - misc_1.isDateValid(object.published) && - misc_1.isDateValid(object.updated); + (0, video_playlists_1.isVideoPlaylistNameValid)(object.name) && + (0, misc_1.isUUIDValid)(object.uuid) && + (0, misc_1.isDateValid)(object.published) && + (0, misc_1.isDateValid)(object.updated); } exports.isPlaylistObjectValid = isPlaylistObjectValid; function isPlaylistElementObjectValid(object) { - return misc_1.exists(object) && + return (0, misc_1.exists)(object) && object.type === 'PlaylistElement' && validator_1.default.isInt(object.position + '') && - misc_2.isActivityPubUrlValid(object.url); + (0, misc_2.isActivityPubUrlValid)(object.url); } exports.isPlaylistElementObjectValid = isPlaylistElementObjectValid; diff --git a/dist/server/helpers/custom-validators/activitypub/signature.js b/dist/server/helpers/custom-validators/activitypub/signature.js index 7c69cfb4..d0385120 100644 --- a/dist/server/helpers/custom-validators/activitypub/signature.js +++ b/dist/server/helpers/custom-validators/activitypub/signature.js @@ -4,14 +4,14 @@ exports.isSignatureValueValid = exports.isSignatureCreatorValid = exports.isSign const misc_1 = require("../misc"); const misc_2 = require("./misc"); function isSignatureTypeValid(signatureType) { - return misc_1.exists(signatureType) && signatureType === 'RsaSignature2017'; + return (0, misc_1.exists)(signatureType) && signatureType === 'RsaSignature2017'; } exports.isSignatureTypeValid = isSignatureTypeValid; function isSignatureCreatorValid(signatureCreator) { - return misc_1.exists(signatureCreator) && misc_2.isActivityPubUrlValid(signatureCreator); + return (0, misc_1.exists)(signatureCreator) && (0, misc_2.isActivityPubUrlValid)(signatureCreator); } exports.isSignatureCreatorValid = isSignatureCreatorValid; function isSignatureValueValid(signatureValue) { - return misc_1.exists(signatureValue) && signatureValue.length > 0; + return (0, misc_1.exists)(signatureValue) && signatureValue.length > 0; } exports.isSignatureValueValid = isSignatureValueValid; diff --git a/dist/server/helpers/custom-validators/activitypub/video-comments.js b/dist/server/helpers/custom-validators/activitypub/video-comments.js index 68002088..20e6a83e 100644 --- a/dist/server/helpers/custom-validators/activitypub/video-comments.js +++ b/dist/server/helpers/custom-validators/activitypub/video-comments.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeAndCheckVideoCommentObject = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../../initializers/constants"); const misc_1 = require("../misc"); const misc_2 = require("./misc"); @@ -13,23 +13,23 @@ function sanitizeAndCheckVideoCommentObject(comment) { return false; normalizeComment(comment); if (comment.type === 'Tombstone') { - return misc_2.isActivityPubUrlValid(comment.id) && - misc_1.isDateValid(comment.published) && - misc_1.isDateValid(comment.deleted) && - misc_2.isActivityPubUrlValid(comment.url); + return (0, misc_2.isActivityPubUrlValid)(comment.id) && + (0, misc_1.isDateValid)(comment.published) && + (0, misc_1.isDateValid)(comment.deleted) && + (0, misc_2.isActivityPubUrlValid)(comment.url); } - return misc_2.isActivityPubUrlValid(comment.id) && + return (0, misc_2.isActivityPubUrlValid)(comment.id) && isCommentContentValid(comment.content) && - misc_2.isActivityPubUrlValid(comment.inReplyTo) && - misc_1.isDateValid(comment.published) && - misc_2.isActivityPubUrlValid(comment.url) && - misc_1.isArray(comment.to) && + (0, misc_2.isActivityPubUrlValid)(comment.inReplyTo) && + (0, misc_1.isDateValid)(comment.published) && + (0, misc_2.isActivityPubUrlValid)(comment.url) && + (0, misc_1.isArray)(comment.to) && (comment.to.indexOf(constants_1.ACTIVITY_PUB.PUBLIC) !== -1 || comment.cc.indexOf(constants_1.ACTIVITY_PUB.PUBLIC) !== -1); } exports.sanitizeAndCheckVideoCommentObject = sanitizeAndCheckVideoCommentObject; function isCommentContentValid(content) { - return misc_1.exists(content) && validator_1.default.isLength('' + content, { min: 1 }); + return (0, misc_1.exists)(content) && validator_1.default.isLength('' + content, { min: 1 }); } function normalizeComment(comment) { if (!comment) diff --git a/dist/server/helpers/custom-validators/activitypub/videos.js b/dist/server/helpers/custom-validators/activitypub/videos.js index 5103acb7..f77fb9f6 100644 --- a/dist/server/helpers/custom-validators/activitypub/videos.js +++ b/dist/server/helpers/custom-validators/activitypub/videos.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isAPVideoTrackerUrlObject = exports.isAPVideoFileUrlMetadataObject = exports.isRemoteVideoUrlValid = exports.sanitizeAndCheckVideoTorrentObject = exports.isRemoteStringIdentifierValid = exports.sanitizeAndCheckVideoTorrentUpdateActivity = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const logger_1 = require("@server/helpers/logger"); const constants_1 = require("../../../initializers/constants"); const core_utils_1 = require("../../core-utils"); @@ -10,16 +10,16 @@ const misc_1 = require("../misc"); const videos_1 = require("../videos"); const misc_2 = require("./misc"); function sanitizeAndCheckVideoTorrentUpdateActivity(activity) { - return misc_2.isBaseActivityValid(activity, 'Update') && + return (0, misc_2.isBaseActivityValid)(activity, 'Update') && sanitizeAndCheckVideoTorrentObject(activity.object); } exports.sanitizeAndCheckVideoTorrentUpdateActivity = sanitizeAndCheckVideoTorrentUpdateActivity; function isActivityPubVideoDurationValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && typeof value === 'string' && value.startsWith('PT') && value.endsWith('S') && - videos_1.isVideoDurationValid(value.replace(/[^0-9]+/g, '')); + (0, videos_1.isVideoDurationValid)(value.replace(/[^0-9]+/g, '')); } function sanitizeAndCheckVideoTorrentObject(video) { if (!video || video.type !== 'Video') @@ -36,7 +36,7 @@ function sanitizeAndCheckVideoTorrentObject(video) { logger_1.logger.debug('Video has invalid content', { video }); return false; } - if (!misc_2.setValidAttributedTo(video)) { + if (!(0, misc_2.setValidAttributedTo)(video)) { logger_1.logger.debug('Video has invalid attributedTo', { video }); return false; } @@ -48,32 +48,32 @@ function sanitizeAndCheckVideoTorrentObject(video) { logger_1.logger.debug('Video has invalid icons', { video }); return false; } - if (!videos_1.isVideoStateValid(video.state)) + if (!(0, videos_1.isVideoStateValid)(video.state)) video.state = 1; - if (!misc_1.isBooleanValid(video.waitTranscoding)) + if (!(0, misc_1.isBooleanValid)(video.waitTranscoding)) video.waitTranscoding = false; - if (!misc_1.isBooleanValid(video.downloadEnabled)) + if (!(0, misc_1.isBooleanValid)(video.downloadEnabled)) video.downloadEnabled = true; - if (!misc_1.isBooleanValid(video.commentsEnabled)) + if (!(0, misc_1.isBooleanValid)(video.commentsEnabled)) video.commentsEnabled = false; - if (!misc_1.isBooleanValid(video.isLiveBroadcast)) + if (!(0, misc_1.isBooleanValid)(video.isLiveBroadcast)) video.isLiveBroadcast = false; - if (!misc_1.isBooleanValid(video.liveSaveReplay)) + if (!(0, misc_1.isBooleanValid)(video.liveSaveReplay)) video.liveSaveReplay = false; - if (!misc_1.isBooleanValid(video.permanentLive)) + if (!(0, misc_1.isBooleanValid)(video.permanentLive)) video.permanentLive = false; - return misc_2.isActivityPubUrlValid(video.id) && - videos_1.isVideoNameValid(video.name) && + return (0, misc_2.isActivityPubUrlValid)(video.id) && + (0, videos_1.isVideoNameValid)(video.name) && isActivityPubVideoDurationValid(video.duration) && - misc_1.isUUIDValid(video.uuid) && + (0, misc_1.isUUIDValid)(video.uuid) && (!video.category || isRemoteNumberIdentifierValid(video.category)) && (!video.licence || isRemoteNumberIdentifierValid(video.licence)) && (!video.language || isRemoteStringIdentifierValid(video.language)) && - videos_1.isVideoViewsValid(video.views) && - misc_1.isBooleanValid(video.sensitive) && - misc_1.isDateValid(video.published) && - misc_1.isDateValid(video.updated) && - (!video.originallyPublishedAt || misc_1.isDateValid(video.originallyPublishedAt)) && + (0, videos_1.isVideoViewsValid)(video.views) && + (0, misc_1.isBooleanValid)(video.sensitive) && + (0, misc_1.isDateValid)(video.published) && + (0, misc_1.isDateValid)(video.updated) && + (!video.originallyPublishedAt || (0, misc_1.isDateValid)(video.originallyPublishedAt)) && (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && video.attributedTo.length !== 0; } @@ -81,19 +81,19 @@ exports.sanitizeAndCheckVideoTorrentObject = sanitizeAndCheckVideoTorrentObject; function isRemoteVideoUrlValid(url) { return url.type === 'Link' && (constants_1.ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.includes(url.mediaType) && - misc_2.isActivityPubUrlValid(url.href) && + (0, misc_2.isActivityPubUrlValid)(url.href) && validator_1.default.isInt(url.height + '', { min: 0 }) && validator_1.default.isInt(url.size + '', { min: 0 }) && (!url.fps || validator_1.default.isInt(url.fps + '', { min: -1 }))) || (constants_1.ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.includes(url.mediaType) && - misc_2.isActivityPubUrlValid(url.href) && + (0, misc_2.isActivityPubUrlValid)(url.href) && validator_1.default.isInt(url.height + '', { min: 0 })) || (constants_1.ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.includes(url.mediaType) && validator_1.default.isLength(url.href, { min: 5 }) && validator_1.default.isInt(url.height + '', { min: 0 })) || ((url.mediaType || url.mimeType) === 'application/x-mpegURL' && - misc_2.isActivityPubUrlValid(url.href) && - misc_1.isArray(url.tag)) || + (0, misc_2.isActivityPubUrlValid)(url.href) && + (0, misc_1.isArray)(url.tag)) || isAPVideoTrackerUrlObject(url) || isAPVideoFileUrlMetadataObject(url); } @@ -102,13 +102,13 @@ function isAPVideoFileUrlMetadataObject(url) { return url && url.type === 'Link' && url.mediaType === 'application/json' && - misc_1.isArray(url.rel) && url.rel.includes('metadata'); + (0, misc_1.isArray)(url.rel) && url.rel.includes('metadata'); } exports.isAPVideoFileUrlMetadataObject = isAPVideoFileUrlMetadataObject; function isAPVideoTrackerUrlObject(url) { - return misc_1.isArray(url.rel) && + return (0, misc_1.isArray)(url.rel) && url.rel.includes('tracker') && - misc_2.isActivityPubUrlValid(url.href); + (0, misc_2.isActivityPubUrlValid)(url.href); } exports.isAPVideoTrackerUrlObject = isAPVideoTrackerUrlObject; function setValidRemoteTags(video) { @@ -116,7 +116,7 @@ function setValidRemoteTags(video) { return false; video.tag = video.tag.filter(t => { return t.type === 'Hashtag' && - videos_1.isVideoTagValid(t.name); + (0, videos_1.isVideoTagValid)(t.name); }); return true; } @@ -126,7 +126,7 @@ function setValidRemoteCaptions(video) { if (Array.isArray(video.subtitleLanguage) === false) return false; video.subtitleLanguage = video.subtitleLanguage.filter(caption => { - if (!misc_2.isActivityPubUrlValid(caption.url)) + if (!(0, misc_2.isActivityPubUrlValid)(caption.url)) caption.url = null; return isRemoteStringIdentifierValid(caption); }); @@ -140,16 +140,16 @@ function isRemoteStringIdentifierValid(data) { } exports.isRemoteStringIdentifierValid = isRemoteStringIdentifierValid; function isRemoteVideoContentValid(mediaType, content) { - return mediaType === 'text/markdown' && videos_1.isVideoTruncatedDescriptionValid(content); + return mediaType === 'text/markdown' && (0, videos_1.isVideoTruncatedDescriptionValid)(content); } function setValidRemoteIcon(video) { - if (video.icon && !misc_1.isArray(video.icon)) + if (video.icon && !(0, misc_1.isArray)(video.icon)) video.icon = [video.icon]; if (!video.icon) video.icon = []; video.icon = video.icon.filter(icon => { return icon.type === 'Image' && - misc_2.isActivityPubUrlValid(icon.url) && + (0, misc_2.isActivityPubUrlValid)(icon.url) && icon.mediaType === 'image/jpeg' && validator_1.default.isInt(icon.width + '', { min: 0 }) && validator_1.default.isInt(icon.height + '', { min: 0 }); @@ -164,7 +164,7 @@ function setValidRemoteVideoUrls(video) { } function setRemoteVideoTruncatedContent(video) { if (video.content) { - video.content = core_utils_1.peertubeTruncate(video.content, { length: constants_1.CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max }); + video.content = (0, core_utils_1.peertubeTruncate)(video.content, { length: constants_1.CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max }); } return true; } diff --git a/dist/server/helpers/custom-validators/actor-images.js b/dist/server/helpers/custom-validators/actor-images.js index a079c361..66b32ab7 100644 --- a/dist/server/helpers/custom-validators/actor-images.js +++ b/dist/server/helpers/custom-validators/actor-images.js @@ -8,6 +8,6 @@ const imageMimeTypes = constants_1.CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME .join('|'); const imageMimeTypesRegex = `image/(${imageMimeTypes})`; function isActorImageFile(files, fieldname) { - return misc_1.isFileValid(files, imageMimeTypesRegex, fieldname, constants_1.CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max); + return (0, misc_1.isFileValid)(files, imageMimeTypesRegex, fieldname, constants_1.CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max); } exports.isActorImageFile = isActorImageFile; diff --git a/dist/server/helpers/custom-validators/feeds.js b/dist/server/helpers/custom-validators/feeds.js index e6043e68..0a8fdcf2 100644 --- a/dist/server/helpers/custom-validators/feeds.js +++ b/dist/server/helpers/custom-validators/feeds.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidRSSFeed = void 0; const misc_1 = require("./misc"); function isValidRSSFeed(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; const feedExtensions = [ 'xml', diff --git a/dist/server/helpers/custom-validators/follows.js b/dist/server/helpers/custom-validators/follows.js index 597c376c..ba8e703f 100644 --- a/dist/server/helpers/custom-validators/follows.js +++ b/dist/server/helpers/custom-validators/follows.js @@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isEachUniqueHandleValid = exports.isRemoteHandleValid = exports.isFollowStateValid = void 0; const misc_1 = require("./misc"); function isFollowStateValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; return value === 'pending' || value === 'accepted'; } exports.isFollowStateValid = isFollowStateValid; function isRemoteHandleValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; if (typeof value !== 'string') return false; @@ -17,7 +17,7 @@ function isRemoteHandleValid(value) { } exports.isRemoteHandleValid = isRemoteHandleValid; function isEachUniqueHandleValid(handles) { - return misc_1.isArray(handles) && + return (0, misc_1.isArray)(handles) && handles.every(handle => { return isRemoteHandleValid(handle) && handles.indexOf(handle) === handles.lastIndexOf(handle); }); diff --git a/dist/server/helpers/custom-validators/jobs.js b/dist/server/helpers/custom-validators/jobs.js index fb3b1d04..6cbd8785 100644 --- a/dist/server/helpers/custom-validators/jobs.js +++ b/dist/server/helpers/custom-validators/jobs.js @@ -6,10 +6,10 @@ const job_queue_1 = require("@server/lib/job-queue/job-queue"); const jobStates = ['active', 'completed', 'failed', 'waiting', 'delayed', 'paused']; exports.jobStates = jobStates; function isValidJobState(value) { - return misc_1.exists(value) && jobStates.includes(value); + return (0, misc_1.exists)(value) && jobStates.includes(value); } exports.isValidJobState = isValidJobState; function isValidJobType(value) { - return misc_1.exists(value) && job_queue_1.jobTypes.includes(value); + return (0, misc_1.exists)(value) && job_queue_1.jobTypes.includes(value); } exports.isValidJobType = isValidJobType; diff --git a/dist/server/helpers/custom-validators/logs.js b/dist/server/helpers/custom-validators/logs.js index 2afe1c2d..e3b4f3c9 100644 --- a/dist/server/helpers/custom-validators/logs.js +++ b/dist/server/helpers/custom-validators/logs.js @@ -4,6 +4,6 @@ exports.isValidLogLevel = void 0; const misc_1 = require("./misc"); const logLevels = ['debug', 'info', 'warn', 'error']; function isValidLogLevel(value) { - return misc_1.exists(value) && logLevels.includes(value); + return (0, misc_1.exists)(value) && logLevels.includes(value); } exports.isValidLogLevel = isValidLogLevel; diff --git a/dist/server/helpers/custom-validators/misc.js b/dist/server/helpers/custom-validators/misc.js index 66e2741b..41d841f2 100644 --- a/dist/server/helpers/custom-validators/misc.js +++ b/dist/server/helpers/custom-validators/misc.js @@ -4,7 +4,7 @@ exports.isFileValid = exports.isFileMimeTypeValid = exports.isFileFieldValid = e const tslib_1 = require("tslib"); require("multer"); const path_1 = require("path"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const uuid_1 = require("../uuid"); function exists(value) { return value !== undefined && value !== null; @@ -109,8 +109,8 @@ function isFileValid(files, mimeTypeRegex, field, maxSize, optional = false) { } exports.isFileValid = isFileValid; function toCompleteUUID(value) { - if (uuid_1.isShortUUID(value)) - return uuid_1.shortToUUID(value); + if ((0, uuid_1.isShortUUID)(value)) + return (0, uuid_1.shortToUUID)(value); return value; } exports.toCompleteUUID = toCompleteUUID; diff --git a/dist/server/helpers/custom-validators/plugins.js b/dist/server/helpers/custom-validators/plugins.js index a47083bb..99d23fa5 100644 --- a/dist/server/helpers/custom-validators/plugins.js +++ b/dist/server/helpers/custom-validators/plugins.js @@ -3,76 +3,76 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isNpmPluginNameValid = exports.isLibraryCodeValid = exports.isPluginDescriptionValid = exports.isPluginNameValid = exports.isPluginVersionValid = exports.isPluginHomepage = exports.isThemeNameValid = exports.isPackageJSONValid = exports.isPluginTypeValid = void 0; const tslib_1 = require("tslib"); const misc_1 = require("./misc"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const plugin_type_1 = require("../../../shared/models/plugins/plugin.type"); const constants_1 = require("../../initializers/constants"); const misc_2 = require("./activitypub/misc"); const PLUGINS_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.PLUGINS; function isPluginTypeValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && (value === plugin_type_1.PluginType.PLUGIN || value === plugin_type_1.PluginType.THEME); } exports.isPluginTypeValid = isPluginTypeValid; function isPluginNameValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && validator_1.default.matches(value, /^[a-z-0-9]+$/); } exports.isPluginNameValid = isPluginNameValid; function isNpmPluginNameValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && validator_1.default.matches(value, /^[a-z\-._0-9]+$/) && (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-')); } exports.isNpmPluginNameValid = isNpmPluginNameValid; function isPluginDescriptionValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.DESCRIPTION); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.DESCRIPTION); } exports.isPluginDescriptionValid = isPluginDescriptionValid; function isPluginVersionValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; const parts = (value + '').split('.'); return parts.length === 3 && parts.every(p => validator_1.default.isInt(p)); } exports.isPluginVersionValid = isPluginVersionValid; function isPluginEngineValid(engine) { - return misc_1.exists(engine) && misc_1.exists(engine.peertube); + return (0, misc_1.exists)(engine) && (0, misc_1.exists)(engine.peertube); } function isPluginHomepage(value) { - return misc_1.exists(value) && (!value || misc_2.isUrlValid(value)); + return (0, misc_1.exists)(value) && (!value || (0, misc_2.isUrlValid)(value)); } exports.isPluginHomepage = isPluginHomepage; function isPluginBugs(value) { - return misc_1.exists(value) && (!value || misc_2.isUrlValid(value)); + return (0, misc_1.exists)(value) && (!value || (0, misc_2.isUrlValid)(value)); } function areStaticDirectoriesValid(staticDirs) { - if (!misc_1.exists(staticDirs) || typeof staticDirs !== 'object') + if (!(0, misc_1.exists)(staticDirs) || typeof staticDirs !== 'object') return false; for (const key of Object.keys(staticDirs)) { - if (!misc_1.isSafePath(staticDirs[key])) + if (!(0, misc_1.isSafePath)(staticDirs[key])) return false; } return true; } function areClientScriptsValid(clientScripts) { - return misc_1.isArray(clientScripts) && + return (0, misc_1.isArray)(clientScripts) && clientScripts.every(c => { - return misc_1.isSafePath(c.script) && misc_1.isArray(c.scopes); + return (0, misc_1.isSafePath)(c.script) && (0, misc_1.isArray)(c.scopes); }); } function areTranslationPathsValid(translations) { - if (!misc_1.exists(translations) || typeof translations !== 'object') + if (!(0, misc_1.exists)(translations) || typeof translations !== 'object') return false; for (const key of Object.keys(translations)) { - if (!misc_1.isSafePath(translations[key])) + if (!(0, misc_1.isSafePath)(translations[key])) return false; } return true; } function areCSSPathsValid(css) { - return misc_1.isArray(css) && css.every(c => misc_1.isSafePath(c)); + return (0, misc_1.isArray)(css) && css.every(c => (0, misc_1.isSafePath)(c)); } function isThemeNameValid(name) { return isPluginNameValid(name); @@ -97,7 +97,7 @@ function isPackageJSONValid(packageJSON, pluginType) { result = false; badFields.push('homepage'); } - if (!misc_1.exists(packageJSON.author)) { + if (!(0, misc_1.exists)(packageJSON.author)) { result = false; badFields.push('author'); } @@ -105,7 +105,7 @@ function isPackageJSONValid(packageJSON, pluginType) { result = false; badFields.push('bugs'); } - if (pluginType === plugin_type_1.PluginType.PLUGIN && !misc_1.isSafePath(packageJSON.library)) { + if (pluginType === plugin_type_1.PluginType.PLUGIN && !(0, misc_1.isSafePath)(packageJSON.library)) { result = false; badFields.push('library'); } diff --git a/dist/server/helpers/custom-validators/search.js b/dist/server/helpers/custom-validators/search.js index 9a933eb6..7fba2cd4 100644 --- a/dist/server/helpers/custom-validators/search.js +++ b/dist/server/helpers/custom-validators/search.js @@ -2,15 +2,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isSearchTargetValid = exports.isBooleanBothQueryValid = exports.isStringArray = exports.isNumberArray = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("./misc"); const config_1 = require("@server/initializers/config"); function isNumberArray(value) { - return misc_1.isArray(value) && value.every(v => validator_1.default.isInt('' + v)); + return (0, misc_1.isArray)(value) && value.every(v => validator_1.default.isInt('' + v)); } exports.isNumberArray = isNumberArray; function isStringArray(value) { - return misc_1.isArray(value) && value.every(v => typeof v === 'string'); + return (0, misc_1.isArray)(value) && value.every(v => typeof v === 'string'); } exports.isStringArray = isStringArray; function isBooleanBothQueryValid(value) { @@ -18,7 +18,7 @@ function isBooleanBothQueryValid(value) { } exports.isBooleanBothQueryValid = isBooleanBothQueryValid; function isSearchTargetValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return true; const searchIndexConfig = config_1.CONFIG.SEARCH.SEARCH_INDEX; if (value === 'local' && (!searchIndexConfig.ENABLED || !searchIndexConfig.DISABLE_LOCAL_SEARCH)) diff --git a/dist/server/helpers/custom-validators/servers.js b/dist/server/helpers/custom-validators/servers.js index 3062b8f5..c5fd3c79 100644 --- a/dist/server/helpers/custom-validators/servers.js +++ b/dist/server/helpers/custom-validators/servers.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isHostValid = exports.isEachUniqueHostValid = exports.isValidContactFromName = exports.isValidContactBody = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("./misc"); const core_utils_1 = require("../core-utils"); const constants_1 = require("../../initializers/constants"); @@ -11,24 +11,24 @@ function isHostValid(host) { require_host: true, require_tld: true }; - if (core_utils_1.isTestInstance()) { + if ((0, core_utils_1.isTestInstance)()) { isURLOptions.require_tld = false; } - return misc_1.exists(host) && validator_1.default.isURL(host, isURLOptions) && host.split('://').length === 1; + return (0, misc_1.exists)(host) && validator_1.default.isURL(host, isURLOptions) && host.split('://').length === 1; } exports.isHostValid = isHostValid; function isEachUniqueHostValid(hosts) { - return misc_1.isArray(hosts) && + return (0, misc_1.isArray)(hosts) && hosts.every(host => { return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host); }); } exports.isEachUniqueHostValid = isEachUniqueHostValid; function isValidContactBody(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.BODY); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.BODY); } exports.isValidContactBody = isValidContactBody; function isValidContactFromName(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME); } exports.isValidContactFromName = isValidContactFromName; diff --git a/dist/server/helpers/custom-validators/user-notifications.js b/dist/server/helpers/custom-validators/user-notifications.js index ec2027c4..cce20440 100644 --- a/dist/server/helpers/custom-validators/user-notifications.js +++ b/dist/server/helpers/custom-validators/user-notifications.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isUserNotificationTypeValid = exports.isUserNotificationSettingValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("./misc"); function isUserNotificationTypeValid(value) { - return misc_1.exists(value) && validator_1.default.isInt('' + value); + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value); } exports.isUserNotificationTypeValid = isUserNotificationTypeValid; function isUserNotificationSettingValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value) && (value === 0 || value === 1 || diff --git a/dist/server/helpers/custom-validators/users.js b/dist/server/helpers/custom-validators/users.js index 648c6a1c..865328ca 100644 --- a/dist/server/helpers/custom-validators/users.js +++ b/dist/server/helpers/custom-validators/users.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isUserNoModal = exports.isUserDescriptionValid = exports.isUserDisplayNameValid = exports.isUserAutoPlayNextVideoPlaylistValid = exports.isUserAutoPlayNextVideoValid = exports.isUserAutoPlayVideoValid = exports.isUserWebTorrentEnabledValid = exports.isUserNSFWPolicyValid = exports.isUserEmailVerifiedValid = exports.isUserAdminFlagsValid = exports.isUserUsernameValid = exports.isUserVideoQuotaDailyValid = exports.isUserVideoQuotaValid = exports.isUserRoleValid = exports.isUserBlockedReasonValid = exports.isUserVideoLanguages = exports.isUserPasswordValidOrEmpty = exports.isUserPasswordValid = exports.isUserBlockedValid = exports.isUserVideosHistoryEnabledValid = void 0; const tslib_1 = require("tslib"); const lodash_1 = require("lodash"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const shared_1 = require("../../../shared"); const config_1 = require("../../initializers/config"); const constants_1 = require("../../initializers/constants"); @@ -15,82 +15,82 @@ function isUserPasswordValid(value) { exports.isUserPasswordValid = isUserPasswordValid; function isUserPasswordValidOrEmpty(value) { if (value === '') - return config_1.isEmailEnabled(); + return (0, config_1.isEmailEnabled)(); return isUserPasswordValid(value); } exports.isUserPasswordValidOrEmpty = isUserPasswordValidOrEmpty; function isUserVideoQuotaValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA); } exports.isUserVideoQuotaValid = isUserVideoQuotaValid; function isUserVideoQuotaDailyValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA_DAILY); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA_DAILY); } exports.isUserVideoQuotaDailyValid = isUserVideoQuotaDailyValid; function isUserUsernameValid(value) { const max = USERS_CONSTRAINTS_FIELDS.USERNAME.max; const min = USERS_CONSTRAINTS_FIELDS.USERNAME.min; - return misc_1.exists(value) && validator_1.default.matches(value, new RegExp(`^[a-zA-Z0-9._]{${min},${max}}$`)); + return (0, misc_1.exists)(value) && validator_1.default.matches(value, new RegExp(`^[a-zA-Z0-9._]{${min},${max}}$`)); } exports.isUserUsernameValid = isUserUsernameValid; function isUserDisplayNameValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.NAME)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.NAME)); } exports.isUserDisplayNameValid = isUserDisplayNameValid; function isUserDescriptionValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION)); } exports.isUserDescriptionValid = isUserDescriptionValid; function isUserEmailVerifiedValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserEmailVerifiedValid = isUserEmailVerifiedValid; -const nsfwPolicies = lodash_1.values(constants_1.NSFW_POLICY_TYPES); +const nsfwPolicies = (0, lodash_1.values)(constants_1.NSFW_POLICY_TYPES); function isUserNSFWPolicyValid(value) { - return misc_1.exists(value) && nsfwPolicies.includes(value); + return (0, misc_1.exists)(value) && nsfwPolicies.includes(value); } exports.isUserNSFWPolicyValid = isUserNSFWPolicyValid; function isUserWebTorrentEnabledValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserWebTorrentEnabledValid = isUserWebTorrentEnabledValid; function isUserVideosHistoryEnabledValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserVideosHistoryEnabledValid = isUserVideosHistoryEnabledValid; function isUserAutoPlayVideoValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserAutoPlayVideoValid = isUserAutoPlayVideoValid; function isUserVideoLanguages(value) { - return value === null || (misc_1.isArray(value) && value.length < constants_1.CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max); + return value === null || ((0, misc_1.isArray)(value) && value.length < constants_1.CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max); } exports.isUserVideoLanguages = isUserVideoLanguages; function isUserAdminFlagsValid(value) { - return misc_1.exists(value) && validator_1.default.isInt('' + value); + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value); } exports.isUserAdminFlagsValid = isUserAdminFlagsValid; function isUserBlockedValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserBlockedValid = isUserBlockedValid; function isUserAutoPlayNextVideoValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserAutoPlayNextVideoValid = isUserAutoPlayNextVideoValid; function isUserAutoPlayNextVideoPlaylistValid(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserAutoPlayNextVideoPlaylistValid = isUserAutoPlayNextVideoPlaylistValid; function isUserNoModal(value) { - return misc_1.isBooleanValid(value); + return (0, misc_1.isBooleanValid)(value); } exports.isUserNoModal = isUserNoModal; function isUserBlockedReasonValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON)); } exports.isUserBlockedReasonValid = isUserBlockedReasonValid; function isUserRoleValid(value) { - return misc_1.exists(value) && validator_1.default.isInt('' + value) && shared_1.UserRole[value] !== undefined; + return (0, misc_1.exists)(value) && validator_1.default.isInt('' + value) && shared_1.UserRole[value] !== undefined; } exports.isUserRoleValid = isUserRoleValid; diff --git a/dist/server/helpers/custom-validators/video-blacklist.js b/dist/server/helpers/custom-validators/video-blacklist.js index 3f1fb412..0f94639f 100644 --- a/dist/server/helpers/custom-validators/video-blacklist.js +++ b/dist/server/helpers/custom-validators/video-blacklist.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoBlacklistTypeValid = exports.isVideoBlacklistReasonValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("./misc"); const constants_1 = require("../../initializers/constants"); const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.VIDEO_BLACKLIST; @@ -11,7 +11,7 @@ function isVideoBlacklistReasonValid(value) { } exports.isVideoBlacklistReasonValid = isVideoBlacklistReasonValid; function isVideoBlacklistTypeValid(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && (value === 2 || value === 1); } exports.isVideoBlacklistTypeValid = isVideoBlacklistTypeValid; diff --git a/dist/server/helpers/custom-validators/video-captions.js b/dist/server/helpers/custom-validators/video-captions.js index 2ee2f6b6..6e795412 100644 --- a/dist/server/helpers/custom-validators/video-captions.js +++ b/dist/server/helpers/custom-validators/video-captions.js @@ -4,7 +4,7 @@ exports.isVideoCaptionLanguageValid = exports.isVideoCaptionFile = void 0; const constants_1 = require("../../initializers/constants"); const misc_1 = require("./misc"); function isVideoCaptionLanguageValid(value) { - return misc_1.exists(value) && constants_1.VIDEO_LANGUAGES[value] !== undefined; + return (0, misc_1.exists)(value) && constants_1.VIDEO_LANGUAGES[value] !== undefined; } exports.isVideoCaptionLanguageValid = isVideoCaptionLanguageValid; const videoCaptionTypesRegex = Object.keys(constants_1.MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) @@ -12,6 +12,6 @@ const videoCaptionTypesRegex = Object.keys(constants_1.MIMETYPES.VIDEO_CAPTIONS. .map(m => `(${m})`) .join('|'); function isVideoCaptionFile(files, field) { - return misc_1.isFileValid(files, videoCaptionTypesRegex, field, constants_1.CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max); + return (0, misc_1.isFileValid)(files, videoCaptionTypesRegex, field, constants_1.CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max); } exports.isVideoCaptionFile = isVideoCaptionFile; diff --git a/dist/server/helpers/custom-validators/video-channels.js b/dist/server/helpers/custom-validators/video-channels.js index 88622b05..58270695 100644 --- a/dist/server/helpers/custom-validators/video-channels.js +++ b/dist/server/helpers/custom-validators/video-channels.js @@ -2,13 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoChannelSupportValid = exports.isVideoChannelDisplayNameValid = exports.isVideoChannelDescriptionValid = exports.isVideoChannelUsernameValid = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../initializers/constants"); const misc_1 = require("./misc"); const users_1 = require("./users"); const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.VIDEO_CHANNELS; function isVideoChannelUsernameValid(value) { - return users_1.isUserUsernameValid(value); + return (0, users_1.isUserUsernameValid)(value); } exports.isVideoChannelUsernameValid = isVideoChannelUsernameValid; function isVideoChannelDescriptionValid(value) { @@ -16,10 +16,10 @@ function isVideoChannelDescriptionValid(value) { } exports.isVideoChannelDescriptionValid = isVideoChannelDescriptionValid; function isVideoChannelDisplayNameValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME); } exports.isVideoChannelDisplayNameValid = isVideoChannelDisplayNameValid; function isVideoChannelSupportValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)); } exports.isVideoChannelSupportValid = isVideoChannelSupportValid; diff --git a/dist/server/helpers/custom-validators/video-comments.js b/dist/server/helpers/custom-validators/video-comments.js index 6dffb599..b605f9ea 100644 --- a/dist/server/helpers/custom-validators/video-comments.js +++ b/dist/server/helpers/custom-validators/video-comments.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidVideoCommentText = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../initializers/constants"); const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.VIDEO_COMMENTS; function isValidVideoCommentText(value) { diff --git a/dist/server/helpers/custom-validators/video-imports.js b/dist/server/helpers/custom-validators/video-imports.js index 57d3fca1..7c268456 100644 --- a/dist/server/helpers/custom-validators/video-imports.js +++ b/dist/server/helpers/custom-validators/video-imports.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoImportTorrentFile = exports.isVideoImportTargetUrlValid = exports.isVideoImportStateValid = void 0; const tslib_1 = require("tslib"); require("multer"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../initializers/constants"); const misc_1 = require("./misc"); function isVideoImportTargetUrlValid(url) { @@ -14,13 +14,13 @@ function isVideoImportTargetUrlValid(url) { require_valid_protocol: true, protocols: ['http', 'https'] }; - return misc_1.exists(url) && + return (0, misc_1.exists)(url) && validator_1.default.isURL('' + url, isURLOptions) && validator_1.default.isLength('' + url, constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL); } exports.isVideoImportTargetUrlValid = isVideoImportTargetUrlValid; function isVideoImportStateValid(value) { - return misc_1.exists(value) && constants_1.VIDEO_IMPORT_STATES[value] !== undefined; + return (0, misc_1.exists)(value) && constants_1.VIDEO_IMPORT_STATES[value] !== undefined; } exports.isVideoImportStateValid = isVideoImportStateValid; const videoTorrentImportRegex = Object.keys(constants_1.MIMETYPES.TORRENT.MIMETYPE_EXT) @@ -28,6 +28,6 @@ const videoTorrentImportRegex = Object.keys(constants_1.MIMETYPES.TORRENT.MIMETY .map(m => `(${m})`) .join('|'); function isVideoImportTorrentFile(files) { - return misc_1.isFileValid(files, videoTorrentImportRegex, 'torrentfile', constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true); + return (0, misc_1.isFileValid)(files, videoTorrentImportRegex, 'torrentfile', constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true); } exports.isVideoImportTorrentFile = isVideoImportTorrentFile; diff --git a/dist/server/helpers/custom-validators/video-playlists.js b/dist/server/helpers/custom-validators/video-playlists.js index e7f7cf90..a782046c 100644 --- a/dist/server/helpers/custom-validators/video-playlists.js +++ b/dist/server/helpers/custom-validators/video-playlists.js @@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoPlaylistTypeValid = exports.isVideoPlaylistTimestampValid = exports.isVideoPlaylistPrivacyValid = exports.isVideoPlaylistDescriptionValid = exports.isVideoPlaylistNameValid = void 0; const tslib_1 = require("tslib"); const misc_1 = require("./misc"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../initializers/constants"); const PLAYLISTS_CONSTRAINT_FIELDS = constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS; function isVideoPlaylistNameValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.NAME); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.NAME); } exports.isVideoPlaylistNameValid = isVideoPlaylistNameValid; function isVideoPlaylistDescriptionValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.DESCRIPTION)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, PLAYLISTS_CONSTRAINT_FIELDS.DESCRIPTION)); } exports.isVideoPlaylistDescriptionValid = isVideoPlaylistDescriptionValid; function isVideoPlaylistPrivacyValid(value) { @@ -19,10 +19,10 @@ function isVideoPlaylistPrivacyValid(value) { } exports.isVideoPlaylistPrivacyValid = isVideoPlaylistPrivacyValid; function isVideoPlaylistTimestampValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isInt('' + value, { min: 0 })); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isInt('' + value, { min: 0 })); } exports.isVideoPlaylistTimestampValid = isVideoPlaylistTimestampValid; function isVideoPlaylistTypeValid(value) { - return misc_1.exists(value) && constants_1.VIDEO_PLAYLIST_TYPES[value] !== undefined; + return (0, misc_1.exists)(value) && constants_1.VIDEO_PLAYLIST_TYPES[value] !== undefined; } exports.isVideoPlaylistTypeValid = isVideoPlaylistTypeValid; diff --git a/dist/server/helpers/custom-validators/video-redundancies.js b/dist/server/helpers/custom-validators/video-redundancies.js index 1a3d7d0c..acc582db 100644 --- a/dist/server/helpers/custom-validators/video-redundancies.js +++ b/dist/server/helpers/custom-validators/video-redundancies.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoRedundancyTarget = void 0; const misc_1 = require("./misc"); function isVideoRedundancyTarget(value) { - return misc_1.exists(value) && + return (0, misc_1.exists)(value) && (value === 'my-videos' || value === 'remote-videos'); } exports.isVideoRedundancyTarget = isVideoRedundancyTarget; diff --git a/dist/server/helpers/custom-validators/videos.js b/dist/server/helpers/custom-validators/videos.js index 1c3f32f5..4a055e25 100644 --- a/dist/server/helpers/custom-validators/videos.js +++ b/dist/server/helpers/custom-validators/videos.js @@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isVideoFilterValid = exports.isVideoSupportValid = exports.isVideoImage = exports.isVideoFileSizeValid = exports.isVideoFileResolutionValid = exports.isVideoPrivacyValid = exports.isVideoTagValid = exports.isVideoDurationValid = exports.isVideoFileMimeTypeValid = exports.isVideoFileExtnameValid = exports.isVideoRatingTypeValid = exports.isVideoViewsValid = exports.isVideoStateValid = exports.isVideoMagnetUriValid = exports.isVideoOriginallyPublishedAtValid = exports.isScheduleVideoUpdatePrivacyValid = exports.isVideoFPSResolutionValid = exports.isVideoTagsValid = exports.isVideoNameValid = exports.isVideoFileInfoHashValid = exports.isVideoDescriptionValid = exports.isVideoTruncatedDescriptionValid = exports.isVideoLanguageValid = exports.isVideoLicenceValid = exports.isVideoCategoryValid = void 0; const tslib_1 = require("tslib"); const lodash_1 = require("lodash"); -const magnet_uri_1 = tslib_1.__importDefault(require("magnet-uri")); -const validator_1 = tslib_1.__importDefault(require("validator")); +const magnet_uri_1 = (0, tslib_1.__importDefault)(require("magnet-uri")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const constants_1 = require("../../initializers/constants"); const misc_1 = require("./misc"); const VIDEOS_CONSTRAINTS_FIELDS = constants_1.CONSTRAINTS_FIELDS.VIDEOS; @@ -17,7 +17,7 @@ function isVideoCategoryValid(value) { } exports.isVideoCategoryValid = isVideoCategoryValid; function isVideoStateValid(value) { - return misc_1.exists(value) && constants_1.VIDEO_STATES[value] !== undefined; + return (0, misc_1.exists)(value) && constants_1.VIDEO_STATES[value] !== undefined; } exports.isVideoStateValid = isVideoStateValid; function isVideoLicenceValid(value) { @@ -30,49 +30,49 @@ function isVideoLanguageValid(value) { } exports.isVideoLanguageValid = isVideoLanguageValid; function isVideoDurationValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION); } exports.isVideoDurationValid = isVideoDurationValid; function isVideoTruncatedDescriptionValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION); } exports.isVideoTruncatedDescriptionValid = isVideoTruncatedDescriptionValid; function isVideoDescriptionValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)); } exports.isVideoDescriptionValid = isVideoDescriptionValid; function isVideoSupportValid(value) { - return value === null || (misc_1.exists(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.SUPPORT)); + return value === null || ((0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.SUPPORT)); } exports.isVideoSupportValid = isVideoSupportValid; function isVideoNameValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME); } exports.isVideoNameValid = isVideoNameValid; function isVideoTagValid(tag) { - return misc_1.exists(tag) && validator_1.default.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG); + return (0, misc_1.exists)(tag) && validator_1.default.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG); } exports.isVideoTagValid = isVideoTagValid; function isVideoTagsValid(tags) { - return tags === null || (misc_1.isArray(tags) && + return tags === null || ((0, misc_1.isArray)(tags) && validator_1.default.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) && tags.every(tag => isVideoTagValid(tag))); } exports.isVideoTagsValid = isVideoTagsValid; function isVideoViewsValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS); } exports.isVideoViewsValid = isVideoViewsValid; function isVideoRatingTypeValid(value) { - return value === 'none' || lodash_1.values(constants_1.VIDEO_RATE_TYPES).includes(value); + return value === 'none' || (0, lodash_1.values)(constants_1.VIDEO_RATE_TYPES).includes(value); } exports.isVideoRatingTypeValid = isVideoRatingTypeValid; function isVideoFileExtnameValid(value) { - return misc_1.exists(value) && (value === constants_1.VIDEO_LIVE.EXTENSION || constants_1.MIMETYPES.VIDEO.EXT_MIMETYPE[value] !== undefined); + return (0, misc_1.exists)(value) && (value === constants_1.VIDEO_LIVE.EXTENSION || constants_1.MIMETYPES.VIDEO.EXT_MIMETYPE[value] !== undefined); } exports.isVideoFileExtnameValid = isVideoFileExtnameValid; function isVideoFileMimeTypeValid(files) { - return misc_1.isFileMimeTypeValid(files, constants_1.MIMETYPES.VIDEO.MIMETYPES_REGEX, 'videofile'); + return (0, misc_1.isFileMimeTypeValid)(files, constants_1.MIMETYPES.VIDEO.MIMETYPES_REGEX, 'videofile'); } exports.isVideoFileMimeTypeValid = isVideoFileMimeTypeValid; const videoImageTypes = constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME @@ -80,7 +80,7 @@ const videoImageTypes = constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME .join('|'); const videoImageTypesRegex = `image/(${videoImageTypes})`; function isVideoImage(files, field) { - return misc_1.isFileValid(files, videoImageTypesRegex, field, constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max, true); + return (0, misc_1.isFileValid)(files, videoImageTypesRegex, field, constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max, true); } exports.isVideoImage = isVideoImage; function isVideoPrivacyValid(value) { @@ -92,15 +92,15 @@ function isScheduleVideoUpdatePrivacyValid(value) { } exports.isScheduleVideoUpdatePrivacyValid = isScheduleVideoUpdatePrivacyValid; function isVideoOriginallyPublishedAtValid(value) { - return value === null || misc_1.isDateValid(value); + return value === null || (0, misc_1.isDateValid)(value); } exports.isVideoOriginallyPublishedAtValid = isVideoOriginallyPublishedAtValid; function isVideoFileInfoHashValid(value) { - return misc_1.exists(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH); + return (0, misc_1.exists)(value) && validator_1.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH); } exports.isVideoFileInfoHashValid = isVideoFileInfoHashValid; function isVideoFileResolutionValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + ''); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + ''); } exports.isVideoFileResolutionValid = isVideoFileResolutionValid; function isVideoFPSResolutionValid(value) { @@ -108,11 +108,11 @@ function isVideoFPSResolutionValid(value) { } exports.isVideoFPSResolutionValid = isVideoFPSResolutionValid; function isVideoFileSizeValid(value) { - return misc_1.exists(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE); + return (0, misc_1.exists)(value) && validator_1.default.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE); } exports.isVideoFileSizeValid = isVideoFileSizeValid; function isVideoMagnetUriValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; const parsed = magnet_uri_1.default.decode(value); return parsed && isVideoFileInfoHashValid(parsed.infoHash); diff --git a/dist/server/helpers/custom-validators/webfinger.js b/dist/server/helpers/custom-validators/webfinger.js index 9295291f..03e1be00 100644 --- a/dist/server/helpers/custom-validators/webfinger.js +++ b/dist/server/helpers/custom-validators/webfinger.js @@ -5,7 +5,7 @@ const constants_1 = require("../../initializers/constants"); const core_utils_1 = require("../core-utils"); const misc_1 = require("./misc"); function isWebfingerLocalResourceValid(value) { - if (!misc_1.exists(value)) + if (!(0, misc_1.exists)(value)) return false; if (value.startsWith('acct:') === false) return false; @@ -14,6 +14,6 @@ function isWebfingerLocalResourceValid(value) { if (actorParts.length !== 2) return false; const host = actorParts[1]; - return core_utils_1.sanitizeHost(host, constants_1.REMOTE_SCHEME.HTTP) === constants_1.WEBSERVER.HOST; + return (0, core_utils_1.sanitizeHost)(host, constants_1.REMOTE_SCHEME.HTTP) === constants_1.WEBSERVER.HOST; } exports.isWebfingerLocalResourceValid = isWebfingerLocalResourceValid; diff --git a/dist/server/helpers/database-utils.js b/dist/server/helpers/database-utils.js index 7ea8ba7d..95bb0798 100644 --- a/dist/server/helpers/database-utils.js +++ b/dist/server/helpers/database-utils.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.runInReadCommittedTransaction = exports.deleteAllModels = exports.filterNonExistingModels = exports.afterCommitIfTransaction = exports.updateInstanceWithAnother = exports.transactionRetryer = exports.retryTransactionWrapper = exports.resetSequelizeInstance = void 0; const tslib_1 = require("tslib"); -const retry_1 = tslib_1.__importDefault(require("async/retry")); +const retry_1 = (0, tslib_1.__importDefault)(require("async/retry")); const sequelize_1 = require("sequelize"); const database_1 = require("@server/initializers/database"); const logger_1 = require("./logger"); @@ -20,7 +20,7 @@ function retryTransactionWrapper(functionToRetry, ...args) { exports.retryTransactionWrapper = retryTransactionWrapper; function transactionRetryer(func) { return new Promise((res, rej) => { - retry_1.default({ + (0, retry_1.default)({ times: 5, errorFilter: err => { const willRetry = (err.name === 'SequelizeDatabaseError'); diff --git a/dist/server/helpers/express-utils.js b/dist/server/helpers/express-utils.js index 96749c26..0aafb743 100644 --- a/dist/server/helpers/express-utils.js +++ b/dist/server/helpers/express-utils.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getCountVideos = exports.cleanUpReqFiles = exports.createReqFiles = exports.badRequest = exports.isUserAbleToSearchRemoteURI = exports.getHostWithPort = exports.buildNSFWFilter = void 0; const tslib_1 = require("tslib"); -const multer_1 = tslib_1.__importStar(require("multer")); +const multer_1 = (0, tslib_1.__importStar)(require("multer")); const http_error_codes_1 = require("../../shared/models/http/http-error-codes"); const config_1 = require("../initializers/config"); const constants_1 = require("../initializers/constants"); @@ -33,13 +33,13 @@ function cleanUpReqFiles(req) { const filesObject = req.files; if (!filesObject) return; - if (misc_1.isArray(filesObject)) { - filesObject.forEach(f => utils_1.deleteFileAndCatch(f.path)); + if ((0, misc_1.isArray)(filesObject)) { + filesObject.forEach(f => (0, utils_1.deleteFileAndCatch)(f.path)); return; } for (const key of Object.keys(filesObject)) { const files = filesObject[key]; - files.forEach(f => utils_1.deleteFileAndCatch(f.path)); + files.forEach(f => (0, utils_1.deleteFileAndCatch)(f.path)); } } exports.cleanUpReqFiles = cleanUpReqFiles; @@ -60,14 +60,14 @@ function badRequest(req, res) { } exports.badRequest = badRequest; function createReqFiles(fieldNames, mimeTypes, destinations) { - const storage = multer_1.diskStorage({ + const storage = (0, multer_1.diskStorage)({ destination: (req, file, cb) => { cb(null, destinations[file.fieldname]); }, - filename: (req, file, cb) => tslib_1.__awaiter(this, void 0, void 0, function* () { + filename: (req, file, cb) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let extension; - const fileExtension = core_utils_1.getLowercaseExtension(file.originalname); - const extensionFromMimetype = video_1.getExtFromMimetype(mimeTypes, file.mimetype); + const fileExtension = (0, core_utils_1.getLowercaseExtension)(file.originalname); + const extensionFromMimetype = (0, video_1.getExtFromMimetype)(mimeTypes, file.mimetype); if (!extensionFromMimetype) { extension = fileExtension; } @@ -76,7 +76,7 @@ function createReqFiles(fieldNames, mimeTypes, destinations) { } let randomString = ''; try { - randomString = yield utils_1.generateRandomString(16); + randomString = yield (0, utils_1.generateRandomString)(16); } catch (err) { logger_1.logger.error('Cannot generate random string for file name.', { err }); @@ -92,7 +92,7 @@ function createReqFiles(fieldNames, mimeTypes, destinations) { maxCount: 1 }); } - return multer_1.default({ storage }).fields(fields); + return (0, multer_1.default)({ storage }).fields(fields); } exports.createReqFiles = createReqFiles; function isUserAbleToSearchRemoteURI(res) { diff --git a/dist/server/helpers/ffmpeg-utils.js b/dist/server/helpers/ffmpeg-utils.js index bb1154e0..e1a859b6 100644 --- a/dist/server/helpers/ffmpeg-utils.js +++ b/dist/server/helpers/ffmpeg-utils.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildx264VODCommand = exports.resetSupportedEncoders = exports.getFFmpegVersion = exports.runCommand = exports.transcode = exports.generateImageFromVideoFile = exports.processGIF = exports.convertWebPToJPG = exports.buildStreamSuffix = exports.getLiveMuxingCommand = exports.getLiveTranscodingCommand = void 0; const tslib_1 = require("tslib"); -const fluent_ffmpeg_1 = tslib_1.__importStar(require("fluent-ffmpeg")); +const fluent_ffmpeg_1 = (0, tslib_1.__importStar)(require("fluent-ffmpeg")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const constants_1 = require("@server/initializers/constants"); @@ -14,11 +14,11 @@ const image_utils_1 = require("./image-utils"); const logger_1 = require("./logger"); let supportedEncoders; function checkFFmpegEncoders(peertubeAvailableEncoders) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (supportedEncoders !== undefined) { return supportedEncoders; } - const getAvailableEncodersPromise = core_utils_2.promisify0(fluent_ffmpeg_1.getAvailableEncoders); + const getAvailableEncodersPromise = (0, core_utils_2.promisify0)(fluent_ffmpeg_1.getAvailableEncoders); const availableFFmpegEncoders = yield getAvailableEncodersPromise(); const searchEncoders = new Set(); for (const type of ['live', 'vod']) { @@ -41,13 +41,13 @@ function resetSupportedEncoders() { } exports.resetSupportedEncoders = resetSupportedEncoders; function convertWebPToJPG(path, destination) { - const command = fluent_ffmpeg_1.default(path, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) + const command = (0, fluent_ffmpeg_1.default)(path, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) .output(destination); return runCommand({ command, silent: true }); } exports.convertWebPToJPG = convertWebPToJPG; function processGIF(path, destination, newSize) { - const command = fluent_ffmpeg_1.default(path, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) + const command = (0, fluent_ffmpeg_1.default)(path, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) .fps(20) .size(`${newSize.width}x${newSize.height}`) .output(destination); @@ -55,28 +55,28 @@ function processGIF(path, destination, newSize) { } exports.processGIF = processGIF; function generateImageFromVideoFile(fromPath, folder, imageName, size) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const pendingImageName = 'pending-' + imageName; const options = { filename: pendingImageName, count: 1, folder }; - const pendingImagePath = path_1.join(folder, pendingImageName); + const pendingImagePath = (0, path_1.join)(folder, pendingImageName); try { yield new Promise((res, rej) => { - fluent_ffmpeg_1.default(fromPath, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) + (0, fluent_ffmpeg_1.default)(fromPath, { niceness: constants_1.FFMPEG_NICE.THUMBNAIL }) .on('error', rej) .on('end', () => res(imageName)) .thumbnail(options); }); - const destination = path_1.join(folder, imageName); - yield image_utils_1.processImage(pendingImagePath, destination, size); + const destination = (0, path_1.join)(folder, imageName); + yield (0, image_utils_1.processImage)(pendingImagePath, destination, size); } catch (err) { logger_1.logger.error('Cannot generate image from video %s.', fromPath, { err }); try { - yield fs_extra_1.remove(pendingImagePath); + yield (0, fs_extra_1.remove)(pendingImagePath); } catch (err) { logger_1.logger.debug('Cannot remove pending image path after generation error.', { err }); @@ -94,7 +94,7 @@ const builders = { 'video': buildx264VODCommand }; function transcode(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Will run transcode.', { options }); let command = getFFmpeg(options.inputPath, 'vod') .output(options.outputPath); @@ -105,7 +105,7 @@ function transcode(options) { } exports.transcode = transcode; function getLiveTranscodingCommand(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { rtmpUrl, outPath, resolutions, fps, bitrate, availableEncoders, profile, masterPlaylistName, ratio } = options; const input = rtmpUrl; const command = getFFmpeg(input, 'live'); @@ -122,7 +122,7 @@ function getLiveTranscodingCommand(options) { addDefaultEncoderGlobalParams({ command }); for (let i = 0; i < resolutions.length; i++) { const resolution = resolutions[i]; - const resolutionFPS = ffprobe_utils_1.computeFPS(fps, resolution); + const resolutionFPS = (0, ffprobe_utils_1.computeFPS)(fps, resolution); const baseEncoderBuilderParams = { input, availableEncoders, @@ -212,16 +212,16 @@ function addDefaultLiveHLSParams(command, outPath, masterPlaylistName) { command.outputOption('-hls_list_size ' + constants_1.VIDEO_LIVE.SEGMENTS_LIST_SIZE); command.outputOption('-hls_flags delete_segments+independent_segments'); command.outputOption('-strftime 1'); - command.outputOption(`-hls_segment_filename ${path_1.join(outPath, '%v-%Y%m%d-%s.ts')}`); + command.outputOption(`-hls_segment_filename ${(0, path_1.join)(outPath, '%v-%Y%m%d-%s.ts')}`); command.outputOption('-master_pl_name master.m3u8'); command.outputOption('-hls_flags delete_segments'); command.outputOption(`-f hls`); - command.output(path_1.join(outPath, '%v.m3u8')); + command.output((0, path_1.join)(outPath, '%v.m3u8')); } function buildx264VODCommand(command, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - let fps = yield ffprobe_utils_1.getVideoFileFPS(options.inputPath); - fps = ffprobe_utils_1.computeFPS(fps, options.resolution); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + let fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(options.inputPath); + fps = (0, ffprobe_utils_1.computeFPS)(fps, options.resolution); let scaleFilterValue; if (options.resolution !== undefined) { scaleFilterValue = options.isPortraitMode === true @@ -234,7 +234,7 @@ function buildx264VODCommand(command, options) { } exports.buildx264VODCommand = buildx264VODCommand; function buildAudioMergeCommand(command, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { command = command.loop(undefined); const scaleFilterValue = getScaleCleanerValue(); command = yield presetVideo({ command, input: options.audioPath, transcodeOptions: options, scaleFilterValue }); @@ -265,7 +265,7 @@ function addCommonHLSVODCommandOptions(command, outputPath) { .outputOption('-hls_flags single_file'); } function buildHLSVODCommand(command, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPath = getHLSVideoPath(options); if (options.copyCodecs) command = presetCopy(command); @@ -287,22 +287,22 @@ function buildHLSVODFromTSCommand(command, options) { return command; } function fixHLSPlaylistIfNeeded(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (options.type !== 'hls' && options.type !== 'hls-from-ts') return; - const fileContent = yield fs_extra_1.readFile(options.outputPath); + const fileContent = yield (0, fs_extra_1.readFile)(options.outputPath); const videoFileName = options.hlsPlaylist.videoFilename; const videoFilePath = getHLSVideoPath(options); const newContent = fileContent.toString() .replace(`#EXT-X-MAP:URI="${videoFilePath}",`, `#EXT-X-MAP:URI="${videoFileName}",`); - yield fs_extra_1.writeFile(options.outputPath, newContent); + yield (0, fs_extra_1.writeFile)(options.outputPath, newContent); }); } function getHLSVideoPath(options) { - return `${path_1.dirname(options.outputPath)}/${options.hlsPlaylist.videoFilename}`; + return `${(0, path_1.dirname)(options.outputPath)}/${options.hlsPlaylist.videoFilename}`; } function getEncoderBuilderResult(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { availableEncoders, profile, streamType, videoType } = options; const encodersToTry = availableEncoders.encodersToTry[videoType][streamType]; const encoders = availableEncoders.available[videoType]; @@ -325,7 +325,7 @@ function getEncoderBuilderResult(options) { continue; } } - const result = yield builder(core_utils_1.pick(options, ['input', 'resolution', 'inputBitrate', 'fps', 'inputRatio', 'streamNum'])); + const result = yield builder((0, core_utils_1.pick)(options, ['input', 'resolution', 'inputBitrate', 'fps', 'inputRatio', 'streamNum'])); return { result, encoder: result.copy === true @@ -337,16 +337,16 @@ function getEncoderBuilderResult(options) { }); } function presetVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { command, input, transcodeOptions, fps, scaleFilterValue } = options; let localCommand = command .format('mp4') .outputOption('-movflags faststart'); addDefaultEncoderGlobalParams({ command }); - const probe = yield ffprobe_utils_1.ffprobePromise(input); - const parsedAudio = yield ffprobe_utils_1.getAudioStream(input, probe); - const bitrate = yield ffprobe_utils_1.getVideoFileBitrate(input, probe); - const { ratio } = yield ffprobe_utils_1.getVideoFileResolution(input, probe); + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(input); + const parsedAudio = yield (0, ffprobe_utils_1.getAudioStream)(input, probe); + const bitrate = yield (0, ffprobe_utils_1.getVideoFileBitrate)(input, probe); + const { ratio } = yield (0, ffprobe_utils_1.getVideoFileResolution)(input, probe); let streamsToProcess = ['audio', 'video']; if (!parsedAudio.audioStream) { localCommand = localCommand.noAudio(); @@ -408,7 +408,7 @@ function getScaleFilter(options) { return 'scale'; } function getFFmpeg(input, type) { - const command = fluent_ffmpeg_1.default(input, { + const command = (0, fluent_ffmpeg_1.default)(input, { niceness: type === 'live' ? constants_1.FFMPEG_NICE.LIVE : constants_1.FFMPEG_NICE.VOD, cwd: config_1.CONFIG.STORAGE.TMP_DIR }); @@ -422,12 +422,12 @@ function getFFmpeg(input, type) { } function getFFmpegVersion() { return new Promise((res, rej) => { - fluent_ffmpeg_1.default()._getFfmpegPath((err, ffmpegPath) => { + (0, fluent_ffmpeg_1.default)()._getFfmpegPath((err, ffmpegPath) => { if (err) return rej(err); if (!ffmpegPath) return rej(new Error('Could not find ffmpeg path')); - return core_utils_2.execPromise(`${ffmpegPath} -version`) + return (0, core_utils_2.execPromise)(`${ffmpegPath} -version`) .then(stdout => { const parsed = stdout.match(/ffmpeg version .?(\d+\.\d+(\.\d+)?)/); if (!parsed || !parsed[1]) @@ -444,7 +444,7 @@ function getFFmpegVersion() { } exports.getFFmpegVersion = getFFmpegVersion; function runCommand(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { command, silent = false, job } = options; return new Promise((res, rej) => { let shellCommand; diff --git a/dist/server/helpers/ffprobe-utils.js b/dist/server/helpers/ffprobe-utils.js index ba183c6d..d8367090 100644 --- a/dist/server/helpers/ffprobe-utils.js +++ b/dist/server/helpers/ffprobe-utils.js @@ -10,7 +10,7 @@ const constants_1 = require("../initializers/constants"); const logger_1 = require("./logger"); function ffprobePromise(path) { return new Promise((res, rej) => { - fluent_ffmpeg_1.ffprobe(path, (err, data) => { + (0, fluent_ffmpeg_1.ffprobe)(path, (err, data) => { if (err) return rej(err); return res(data); @@ -19,7 +19,7 @@ function ffprobePromise(path) { } exports.ffprobePromise = ffprobePromise; function getAudioStream(videoPath, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = existingProbe || (yield ffprobePromise(videoPath)); if (Array.isArray(data.streams)) { const audioStream = data.streams.find(stream => stream['codec_type'] === 'audio'); @@ -59,7 +59,7 @@ function getMaxAudioBitrate(type, bitrate) { } exports.getMaxAudioBitrate = getMaxAudioBitrate; function getVideoStreamSize(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoStream = yield getVideoStreamFromFile(path, existingProbe); return videoStream === null ? { width: 0, height: 0 } @@ -68,7 +68,7 @@ function getVideoStreamSize(path, existingProbe) { } exports.getVideoStreamSize = getVideoStreamSize; function getVideoStreamCodec(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoStream = yield getVideoStreamFromFile(path); if (!videoStream) return ''; @@ -106,7 +106,7 @@ function getVideoStreamCodec(path) { } exports.getVideoStreamCodec = getVideoStreamCodec; function getAudioStreamCodec(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { audioStream } = yield getAudioStream(path, existingProbe); if (!audioStream) return ''; @@ -123,7 +123,7 @@ function getAudioStreamCodec(path, existingProbe) { } exports.getAudioStreamCodec = getAudioStreamCodec; function getVideoFileResolution(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const size = yield getVideoStreamSize(path, existingProbe); return { width: size.width, @@ -136,7 +136,7 @@ function getVideoFileResolution(path, existingProbe) { } exports.getVideoFileResolution = getVideoFileResolution; function getVideoFileFPS(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoStream = yield getVideoStreamFromFile(path, existingProbe); if (videoStream === null) return 0; @@ -156,14 +156,14 @@ function getVideoFileFPS(path, existingProbe) { } exports.getVideoFileFPS = getVideoFileFPS; function getMetadataFromFile(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const metadata = existingProbe || (yield ffprobePromise(path)); return new videos_1.VideoFileMetadata(metadata); }); } exports.getMetadataFromFile = getMetadataFromFile; function getVideoFileBitrate(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const metadata = yield getMetadataFromFile(path, existingProbe); let bitrate = metadata.format.bit_rate; if (bitrate && !isNaN(bitrate)) @@ -179,14 +179,14 @@ function getVideoFileBitrate(path, existingProbe) { } exports.getVideoFileBitrate = getVideoFileBitrate; function getDurationFromVideoFile(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const metadata = yield getMetadataFromFile(path, existingProbe); return Math.round(metadata.format.duration); }); } exports.getDurationFromVideoFile = getDurationFromVideoFile; function getVideoStreamFromFile(path, existingProbe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const metadata = yield getMetadataFromFile(path, existingProbe); return metadata.streams.find(s => s.codec_type === 'video') || null; }); @@ -217,7 +217,7 @@ function computeResolutionsToTranscode(videoFileResolution, type) { } exports.computeResolutionsToTranscode = computeResolutionsToTranscode; function canDoQuickTranscode(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.TRANSCODING.PROFILE !== 'default') return false; const probe = yield ffprobePromise(path); @@ -227,7 +227,7 @@ function canDoQuickTranscode(path) { } exports.canDoQuickTranscode = canDoQuickTranscode; function canDoQuickVideoTranscode(path, probe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoStream = yield getVideoStreamFromFile(path, probe); const fps = yield getVideoFileFPS(path, probe); const bitRate = yield getVideoFileBitrate(path, probe); @@ -242,14 +242,14 @@ function canDoQuickVideoTranscode(path, probe) { return false; if (fps < constants_1.VIDEO_TRANSCODING_FPS.MIN || fps > constants_1.VIDEO_TRANSCODING_FPS.MAX) return false; - if (bitRate > core_utils_1.getMaxBitrate(Object.assign(Object.assign({}, resolutionData), { fps }))) + if (bitRate > (0, core_utils_1.getMaxBitrate)(Object.assign(Object.assign({}, resolutionData), { fps }))) return false; return true; }); } exports.canDoQuickVideoTranscode = canDoQuickVideoTranscode; function canDoQuickAudioTranscode(path, probe) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const parsedAudio = yield getAudioStream(path, probe); if (!parsedAudio.audioStream) return true; diff --git a/dist/server/helpers/image-utils.js b/dist/server/helpers/image-utils.js index 320ddd8d..00c148ce 100644 --- a/dist/server/helpers/image-utils.js +++ b/dist/server/helpers/image-utils.js @@ -9,45 +9,45 @@ const ffmpeg_utils_1 = require("./ffmpeg-utils"); const logger_1 = require("./logger"); const uuid_1 = require("./uuid"); function generateImageFilename(extension = '.jpg') { - return uuid_1.buildUUID() + extension; + return (0, uuid_1.buildUUID)() + extension; } exports.generateImageFilename = generateImageFilename; function processImage(path, destination, newSize, keepOriginal = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const extension = core_utils_1.getLowercaseExtension(path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const extension = (0, core_utils_1.getLowercaseExtension)(path); if (path === destination) { throw new Error('Jimp/FFmpeg needs an input path different that the output path.'); } logger_1.logger.debug('Processing image %s to %s.', path, destination); if (extension === '.gif') { - yield ffmpeg_utils_1.processGIF(path, destination, newSize); + yield (0, ffmpeg_utils_1.processGIF)(path, destination, newSize); } else { yield jimpProcessor(path, destination, newSize, extension); } if (keepOriginal !== true) - yield fs_extra_1.remove(path); + yield (0, fs_extra_1.remove)(path); }); } exports.processImage = processImage; function jimpProcessor(path, destination, newSize, inputExt) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let jimpInstance; - const inputBuffer = yield fs_extra_1.readFile(path); + const inputBuffer = yield (0, fs_extra_1.readFile)(path); try { - jimpInstance = yield jimp_1.read(inputBuffer); + jimpInstance = yield (0, jimp_1.read)(inputBuffer); } catch (err) { logger_1.logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err }); const newName = path + '.jpg'; - yield ffmpeg_utils_1.convertWebPToJPG(path, newName); - yield fs_extra_1.rename(newName, path); - jimpInstance = yield jimp_1.read(path); + yield (0, ffmpeg_utils_1.convertWebPToJPG)(path, newName); + yield (0, fs_extra_1.rename)(newName, path); + jimpInstance = yield (0, jimp_1.read)(path); } - yield fs_extra_1.remove(destination); - const outputExt = core_utils_1.getLowercaseExtension(destination); + yield (0, fs_extra_1.remove)(destination); + const outputExt = (0, core_utils_1.getLowercaseExtension)(destination); if (skipProcessing({ jimpInstance, newSize, imageBytes: inputBuffer.byteLength, inputExt, outputExt })) { - return fs_extra_1.copy(path, destination); + return (0, fs_extra_1.copy)(path, destination); } yield jimpInstance .quality(95) diff --git a/dist/server/helpers/logger.js b/dist/server/helpers/logger.js index aad78236..1074e0a3 100644 --- a/dist/server/helpers/logger.js +++ b/dist/server/helpers/logger.js @@ -10,7 +10,7 @@ const winston_1 = require("winston"); const config_1 = require("../initializers/config"); const constants_1 = require("../initializers/constants"); const label = config_1.CONFIG.WEBSERVER.HOSTNAME + ':' + config_1.CONFIG.WEBSERVER.PORT; -fs_extra_1.mkdirpSync(config_1.CONFIG.STORAGE.LOG_DIR); +(0, fs_extra_1.mkdirpSync)(config_1.CONFIG.STORAGE.LOG_DIR); function getLoggerReplacer() { const seen = new WeakSet(); return (key, value) => { @@ -37,7 +37,7 @@ function getLoggerReplacer() { } const consoleLoggerFormat = winston_1.format.printf(info => { const toOmit = ['label', 'timestamp', 'level', 'message', 'sql', 'tags']; - const obj = lodash_1.omit(info, ...toOmit); + const obj = (0, lodash_1.omit)(info, ...toOmit); let additionalInfos = JSON.stringify(obj, getLoggerReplacer(), 2); if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''; @@ -45,7 +45,7 @@ const consoleLoggerFormat = winston_1.format.printf(info => { additionalInfos = ' ' + additionalInfos; if (info.sql) { if (config_1.CONFIG.LOG.PRETTIFY_SQL) { - additionalInfos += '\n' + sql_formatter_1.format(info.sql, { + additionalInfos += '\n' + (0, sql_formatter_1.format)(info.sql, { language: 'sql', indent: ' ' }); @@ -72,7 +72,7 @@ const labelFormatter = (suffix) => { }; exports.labelFormatter = labelFormatter; const fileLoggerOptions = { - filename: path_1.join(config_1.CONFIG.STORAGE.LOG_DIR, constants_1.LOG_FILENAME), + filename: (0, path_1.join)(config_1.CONFIG.STORAGE.LOG_DIR, constants_1.LOG_FILENAME), handleExceptions: true, format: winston_1.format.combine(winston_1.format.timestamp(), jsonLoggerFormat) }; @@ -83,7 +83,7 @@ if (config_1.CONFIG.LOG.ROTATION.ENABLED) { const logger = buildLogger(); exports.logger = logger; function buildLogger(labelSuffix) { - return winston_1.createLogger({ + return (0, winston_1.createLogger)({ level: config_1.CONFIG.LOG.LEVEL, format: winston_1.format.combine(labelFormatter(labelSuffix), winston_1.format.splat()), transports: [ @@ -131,11 +131,11 @@ function loggerTagsFactory(...defaultTags) { } exports.loggerTagsFactory = loggerTagsFactory; function mtimeSortFilesDesc(files, basePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const promises = []; const out = []; for (const file of files) { - const p = fs_extra_1.stat(basePath + '/' + file) + const p = (0, fs_extra_1.stat)(basePath + '/' + file) .then(stats => { if (stats.isFile()) out.push({ file, mtime: stats.mtime.getTime() }); diff --git a/dist/server/helpers/markdown.js b/dist/server/helpers/markdown.js index 62151ee9..09f591c5 100644 --- a/dist/server/helpers/markdown.js +++ b/dist/server/helpers/markdown.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.mdToPlainText = exports.toSafeHtml = void 0; const core_utils_1 = require("@shared/core-utils"); -const sanitizeOptions = core_utils_1.getSanitizeOptions(); +const sanitizeOptions = (0, core_utils_1.getSanitizeOptions)(); const sanitizeHtml = require('sanitize-html'); const markdownItEmoji = require('markdown-it-emoji/light'); const MarkdownItClass = require('markdown-it'); diff --git a/dist/server/helpers/peertube-crypto.js b/dist/server/helpers/peertube-crypto.js index 5d502c20..760c37a1 100644 --- a/dist/server/helpers/peertube-crypto.js +++ b/dist/server/helpers/peertube-crypto.js @@ -9,15 +9,15 @@ const constants_1 = require("../initializers/constants"); const core_utils_1 = require("./core-utils"); const custom_jsonld_signature_1 = require("./custom-jsonld-signature"); const logger_1 = require("./logger"); -const bcryptComparePromise = core_utils_1.promisify2(bcrypt_1.compare); -const bcryptGenSaltPromise = core_utils_1.promisify1(bcrypt_1.genSalt); -const bcryptHashPromise = core_utils_1.promisify2(bcrypt_1.hash); +const bcryptComparePromise = (0, core_utils_1.promisify2)(bcrypt_1.compare); +const bcryptGenSaltPromise = (0, core_utils_1.promisify1)(bcrypt_1.genSalt); +const bcryptHashPromise = (0, core_utils_1.promisify2)(bcrypt_1.hash); const httpSignature = require('http-signature'); function createPrivateAndPublicKeys() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Generating a RSA key...'); - const { key } = yield core_utils_1.createPrivateKey(constants_1.PRIVATE_RSA_KEY_SIZE); - const { publicKey } = yield core_utils_1.getPublicKey(key); + const { key } = yield (0, core_utils_1.createPrivateKey)(constants_1.PRIVATE_RSA_KEY_SIZE); + const { publicKey } = yield (0, core_utils_1.getPublicKey)(key); return { privateKey: key, publicKey }; }); } @@ -27,7 +27,7 @@ function comparePassword(plainPassword, hashPassword) { } exports.comparePassword = comparePassword; function cryptPassword(password) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const salt = yield bcryptGenSaltPromise(constants_1.BCRYPT_SALT_SIZE); return bcryptHashPromise(password, salt); }); @@ -60,19 +60,19 @@ function isJsonLDSignatureVerified(fromActor, signedDocument) { } exports.isJsonLDSignatureVerified = isJsonLDSignatureVerified; function isJsonLDRSA2017Verified(fromActor, signedDocument) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [documentHash, optionsHash] = yield Promise.all([ createDocWithoutSignatureHash(signedDocument), createSignatureHash(signedDocument.signature) ]); const toVerify = optionsHash + documentHash; - const verify = crypto_1.createVerify('RSA-SHA256'); + const verify = (0, crypto_1.createVerify)('RSA-SHA256'); verify.update(toVerify, 'utf8'); return verify.verify(fromActor.publicKey, signedDocument.signature.signatureValue, 'base64'); }); } function signJsonLDObject(byActor, data) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const signature = { type: 'RsaSignature2017', creator: byActor.url, @@ -83,7 +83,7 @@ function signJsonLDObject(byActor, data) { createSignatureHash(signature) ]); const toSign = optionsHash + documentHash; - const sign = crypto_1.createSign('RSA-SHA256'); + const sign = (0, crypto_1.createSign)('RSA-SHA256'); sign.update(toSign, 'utf8'); const signatureValue = sign.sign(byActor.privateKey, 'base64'); Object.assign(signature, { signatureValue }); @@ -93,7 +93,7 @@ function signJsonLDObject(byActor, data) { exports.signJsonLDObject = signJsonLDObject; function buildDigest(body) { const rawBody = typeof body === 'string' ? body : JSON.stringify(body); - return 'SHA-256=' + core_utils_1.sha256(rawBody, 'base64'); + return 'SHA-256=' + (0, core_utils_1.sha256)(rawBody, 'base64'); } exports.buildDigest = buildDigest; function hashObject(obj) { @@ -102,10 +102,10 @@ function hashObject(obj) { algorithm: 'URDNA2015', format: 'application/n-quads' }) - .then(res => core_utils_1.sha256(res)); + .then(res => (0, core_utils_1.sha256)(res)); } function createSignatureHash(signature) { - const signatureCopy = lodash_1.cloneDeep(signature); + const signatureCopy = (0, lodash_1.cloneDeep)(signature); Object.assign(signatureCopy, { '@context': [ 'https://w3id.org/security/v1', @@ -118,7 +118,7 @@ function createSignatureHash(signature) { return hashObject(signatureCopy); } function createDocWithoutSignatureHash(doc) { - const docWithoutSignature = lodash_1.cloneDeep(doc); + const docWithoutSignature = (0, lodash_1.cloneDeep)(doc); delete docWithoutSignature.signature; return hashObject(docWithoutSignature); } diff --git a/dist/server/helpers/query.js b/dist/server/helpers/query.js index d5f9b6c0..679ee9f6 100644 --- a/dist/server/helpers/query.js +++ b/dist/server/helpers/query.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.pickSearchChannelQuery = exports.pickSearchPlaylistQuery = exports.pickSearchVideoQuery = exports.pickCommonVideoQuery = void 0; const core_utils_1 = require("@shared/core-utils"); function pickCommonVideoQuery(query) { - return core_utils_1.pick(query, [ + return (0, core_utils_1.pick)(query, [ 'start', 'count', 'sort', @@ -20,7 +20,7 @@ function pickCommonVideoQuery(query) { } exports.pickCommonVideoQuery = pickCommonVideoQuery; function pickSearchVideoQuery(query) { - return Object.assign(Object.assign({}, pickCommonVideoQuery(query)), core_utils_1.pick(query, [ + return Object.assign(Object.assign({}, pickCommonVideoQuery(query)), (0, core_utils_1.pick)(query, [ 'searchTarget', 'search', 'host', @@ -35,7 +35,7 @@ function pickSearchVideoQuery(query) { } exports.pickSearchVideoQuery = pickSearchVideoQuery; function pickSearchChannelQuery(query) { - return core_utils_1.pick(query, [ + return (0, core_utils_1.pick)(query, [ 'searchTarget', 'search', 'start', @@ -47,7 +47,7 @@ function pickSearchChannelQuery(query) { } exports.pickSearchChannelQuery = pickSearchChannelQuery; function pickSearchPlaylistQuery(query) { - return core_utils_1.pick(query, [ + return (0, core_utils_1.pick)(query, [ 'searchTarget', 'search', 'start', diff --git a/dist/server/helpers/register-ts-paths.js b/dist/server/helpers/register-ts-paths.js index 09c94afe..7e20bd25 100644 --- a/dist/server/helpers/register-ts-paths.js +++ b/dist/server/helpers/register-ts-paths.js @@ -6,7 +6,7 @@ const tsConfigPaths = require("tsconfig-paths"); const tsConfig = require('../../tsconfig.json'); function registerTSPaths() { tsConfigPaths.register({ - baseUrl: path_1.resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''), + baseUrl: (0, path_1.resolve)(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''), paths: tsConfig.compilerOptions.paths }); } diff --git a/dist/server/helpers/requests.js b/dist/server/helpers/requests.js index 8f725c4c..2d7c53b0 100644 --- a/dist/server/helpers/requests.js +++ b/dist/server/helpers/requests.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.downloadImage = exports.doRequestAndSaveToFile = exports.doJSONRequest = exports.doRequest = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); -const got_1 = tslib_1.__importDefault(require("got")); +const got_1 = (0, tslib_1.__importDefault)(require("got")); const hpagent_1 = require("hpagent"); const path_1 = require("path"); const config_1 = require("../initializers/config"); @@ -81,14 +81,14 @@ function doJSONRequest(url, options = {}) { } exports.doJSONRequest = doJSONRequest; function doRequestAndSaveToFile(url, destPath, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const gotOptions = buildGotOptions(options); - const outFile = fs_extra_1.createWriteStream(destPath); + const outFile = (0, fs_extra_1.createWriteStream)(destPath); try { - yield core_utils_1.pipelinePromise(peertubeGot.stream(url, gotOptions), outFile); + yield (0, core_utils_1.pipelinePromise)(peertubeGot.stream(url, gotOptions), outFile); } catch (err) { - fs_extra_1.remove(destPath) + (0, fs_extra_1.remove)(destPath) .catch(err => logger_1.logger.error('Cannot remove %s after request failure.', destPath, { err })); throw buildRequestError(err); } @@ -96,24 +96,24 @@ function doRequestAndSaveToFile(url, destPath, options = {}) { } exports.doRequestAndSaveToFile = doRequestAndSaveToFile; function downloadImage(url, destDir, destName, size) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const tmpPath = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, 'pending-' + destName); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const tmpPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, 'pending-' + destName); yield doRequestAndSaveToFile(url, tmpPath); - const destPath = path_1.join(destDir, destName); + const destPath = (0, path_1.join)(destDir, destName); try { - yield image_utils_1.processImage(tmpPath, destPath, size); + yield (0, image_utils_1.processImage)(tmpPath, destPath, size); } catch (err) { - yield fs_extra_1.remove(tmpPath); + yield (0, fs_extra_1.remove)(tmpPath); throw err; } }); } exports.downloadImage = downloadImage; function getAgent() { - if (!proxy_1.isProxyEnabled()) + if (!(0, proxy_1.isProxyEnabled)()) return {}; - const proxy = proxy_1.getProxy(); + const proxy = (0, proxy_1.getProxy)(); logger_1.logger.info('Using proxy %s.', proxy); const proxyAgentOptions = { keepAlive: true, diff --git a/dist/server/helpers/upload.js b/dist/server/helpers/upload.js index af61fd0d..d1771580 100644 --- a/dist/server/helpers/upload.js +++ b/dist/server/helpers/upload.js @@ -5,7 +5,7 @@ const path_1 = require("path"); const constants_1 = require("../initializers/constants"); function getResumableUploadPath(filename) { if (filename) - return path_1.join(constants_1.RESUMABLE_UPLOAD_DIRECTORY, filename); + return (0, path_1.join)(constants_1.RESUMABLE_UPLOAD_DIRECTORY, filename); return constants_1.RESUMABLE_UPLOAD_DIRECTORY; } exports.getResumableUploadPath = getResumableUploadPath; diff --git a/dist/server/helpers/utils.js b/dist/server/helpers/utils.js index dbe85dc5..90cac0a8 100644 --- a/dist/server/helpers/utils.js +++ b/dist/server/helpers/utils.js @@ -8,13 +8,13 @@ const config_1 = require("../initializers/config"); const core_utils_1 = require("./core-utils"); const logger_1 = require("./logger"); function deleteFileAndCatch(path) { - fs_extra_1.remove(path) + (0, fs_extra_1.remove)(path) .catch(err => logger_1.logger.error('Cannot delete the file %s asynchronously.', path, { err })); } exports.deleteFileAndCatch = deleteFileAndCatch; function generateRandomString(size) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const raw = yield core_utils_1.randomBytesPromise(size); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const raw = yield (0, core_utils_1.randomBytesPromise)(size); return raw.toString('hex'); }); } @@ -31,18 +31,18 @@ function generateVideoImportTmpPath(target, extension = '.mp4') { const id = typeof target === 'string' ? target : target.infoHash; - const hash = core_utils_1.sha256(id); - return path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`); + const hash = (0, core_utils_1.sha256)(id); + return (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`); } exports.generateVideoImportTmpPath = generateVideoImportTmpPath; function getSecureTorrentName(originalName) { - return core_utils_1.sha256(originalName) + '.torrent'; + return (0, core_utils_1.sha256)(originalName) + '.torrent'; } exports.getSecureTorrentName = getSecureTorrentName; function getServerCommit() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - const tag = yield core_utils_1.execPromise2('[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0, 1, 2] }); + const tag = yield (0, core_utils_1.execPromise2)('[ ! -d .git ] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0, 1, 2] }); if (tag) return tag.replace(/^v/, ''); } @@ -50,7 +50,7 @@ function getServerCommit() { logger_1.logger.debug('Cannot get version from git tags.', { err }); } try { - const version = yield core_utils_1.execPromise('[ ! -d .git ] || git rev-parse --short HEAD'); + const version = yield (0, core_utils_1.execPromise)('[ ! -d .git ] || git rev-parse --short HEAD'); if (version) return version.toString().trim(); } diff --git a/dist/server/helpers/uuid.js b/dist/server/helpers/uuid.js index 309cc218..a2c6bdf1 100644 --- a/dist/server/helpers/uuid.js +++ b/dist/server/helpers/uuid.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isShortUUID = exports.shortToUUID = exports.uuidToShort = exports.buildUUID = void 0; const tslib_1 = require("tslib"); -const short_uuid_1 = tslib_1.__importStar(require("short-uuid")); -const translator = short_uuid_1.default(); +const short_uuid_1 = (0, tslib_1.__importStar)(require("short-uuid")); +const translator = (0, short_uuid_1.default)(); function buildUUID() { - return short_uuid_1.uuid(); + return (0, short_uuid_1.uuid)(); } exports.buildUUID = buildUUID; function uuidToShort(uuid) { diff --git a/dist/server/helpers/video.js b/dist/server/helpers/video.js index b97d54fd..d1961553 100644 --- a/dist/server/helpers/video.js +++ b/dist/server/helpers/video.js @@ -8,7 +8,7 @@ function getVideoWithAttributes(res) { } exports.getVideoWithAttributes = getVideoWithAttributes; function extractVideo(videoOrPlaylist) { - return models_1.isStreamingPlaylist(videoOrPlaylist) + return (0, models_1.isStreamingPlaylist)(videoOrPlaylist) ? videoOrPlaylist.Video : videoOrPlaylist; } diff --git a/dist/server/helpers/webtorrent.js b/dist/server/helpers/webtorrent.js index d44951f6..74747d06 100644 --- a/dist/server/helpers/webtorrent.js +++ b/dist/server/helpers/webtorrent.js @@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.downloadWebTorrentVideo = exports.generateMagnetUri = exports.createTorrentAndSetInfoHash = exports.updateTorrentUrls = exports.createTorrentPromise = void 0; const tslib_1 = require("tslib"); const bencode_1 = require("bencode"); -const create_torrent_1 = tslib_1.__importDefault(require("create-torrent")); +const create_torrent_1 = (0, tslib_1.__importDefault)(require("create-torrent")); const fs_extra_1 = require("fs-extra"); -const magnet_uri_1 = tslib_1.__importDefault(require("magnet-uri")); -const parse_torrent_1 = tslib_1.__importDefault(require("parse-torrent")); +const magnet_uri_1 = (0, tslib_1.__importDefault)(require("magnet-uri")); +const parse_torrent_1 = (0, tslib_1.__importDefault)(require("parse-torrent")); const path_1 = require("path"); const stream_1 = require("stream"); -const webtorrent_1 = tslib_1.__importDefault(require("webtorrent")); +const webtorrent_1 = (0, tslib_1.__importDefault)(require("webtorrent")); const misc_1 = require("@server/helpers/custom-validators/misc"); const constants_1 = require("@server/initializers/constants"); const paths_1 = require("@server/lib/paths"); @@ -19,20 +19,20 @@ const core_utils_1 = require("./core-utils"); const logger_1 = require("./logger"); const utils_1 = require("./utils"); const video_1 = require("./video"); -const createTorrentPromise = core_utils_1.promisify2(create_torrent_1.default); +const createTorrentPromise = (0, core_utils_1.promisify2)(create_torrent_1.default); exports.createTorrentPromise = createTorrentPromise; function downloadWebTorrentVideo(target, timeout) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const id = target.uri || target.torrentName; let timer; - const path = utils_1.generateVideoImportTmpPath(id); + const path = (0, utils_1.generateVideoImportTmpPath)(id); logger_1.logger.info('Importing torrent video %s', id); - const directoryPath = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, 'webtorrent'); - yield fs_extra_1.ensureDir(directoryPath); + const directoryPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, 'webtorrent'); + yield (0, fs_extra_1.ensureDir)(directoryPath); return new Promise((res, rej) => { const webtorrent = new webtorrent_1.default(); let file; - const torrentId = target.uri || path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, target.torrentName); + const torrentId = target.uri || (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, target.torrentName); const options = { path: directoryPath }; const torrent = webtorrent.add(torrentId, options, torrent => { if (torrent.files.length !== 1) { @@ -46,7 +46,7 @@ function downloadWebTorrentVideo(target, timeout) { } logger_1.logger.debug('Got torrent from webtorrent %s.', id, { infoHash: torrent.infoHash }); file = torrent.files[0]; - const writeStream = fs_extra_1.createWriteStream(path); + const writeStream = (0, fs_extra_1.createWriteStream)(path); writeStream.on('finish', () => { if (timer) clearTimeout(timer); @@ -54,7 +54,7 @@ function downloadWebTorrentVideo(target, timeout) { .then(() => res(path)) .catch(err => logger_1.logger.error('Cannot destroy webtorrent.', { err })); }); - stream_1.pipeline(file.createReadStream(), writeStream, err => { + (0, stream_1.pipeline)(file.createReadStream(), writeStream, err => { if (err) rej(err); }); @@ -74,42 +74,42 @@ function downloadWebTorrentVideo(target, timeout) { } exports.downloadWebTorrentVideo = downloadWebTorrentVideo; function createTorrentAndSetInfoHash(videoOrPlaylist, videoFile) { - const video = video_1.extractVideo(videoOrPlaylist); + const video = (0, video_1.extractVideo)(videoOrPlaylist); const options = { name: `${video.name} ${videoFile.resolution}p${videoFile.extname}`, createdBy: 'PeerTube', announceList: buildAnnounceList(), urlList: buildUrlList(video, videoFile) }; - return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, videoFile, (videoPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, videoFile, (videoPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const torrentContent = yield createTorrentPromise(videoPath, options); - const torrentFilename = paths_1.generateTorrentFileName(videoOrPlaylist, videoFile.resolution); - const torrentPath = path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, torrentFilename); + const torrentFilename = (0, paths_1.generateTorrentFileName)(videoOrPlaylist, videoFile.resolution); + const torrentPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, torrentFilename); logger_1.logger.info('Creating torrent %s.', torrentPath); - yield fs_extra_1.writeFile(torrentPath, torrentContent); + yield (0, fs_extra_1.writeFile)(torrentPath, torrentContent); if (videoFile.hasTorrent()) { - yield fs_extra_1.remove(path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)); + yield (0, fs_extra_1.remove)((0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)); } - const parsedTorrent = parse_torrent_1.default(torrentContent); + const parsedTorrent = (0, parse_torrent_1.default)(torrentContent); videoFile.infoHash = parsedTorrent.infoHash; videoFile.torrentFilename = torrentFilename; })); } exports.createTorrentAndSetInfoHash = createTorrentAndSetInfoHash; function updateTorrentUrls(videoOrPlaylist, videoFile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const video = video_1.extractVideo(videoOrPlaylist); - const oldTorrentPath = path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename); - const torrentContent = yield fs_extra_1.readFile(oldTorrentPath); - const decoded = bencode_1.decode(torrentContent); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const video = (0, video_1.extractVideo)(videoOrPlaylist); + const oldTorrentPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename); + const torrentContent = yield (0, fs_extra_1.readFile)(oldTorrentPath); + const decoded = (0, bencode_1.decode)(torrentContent); decoded['announce-list'] = buildAnnounceList(); decoded.announce = decoded['announce-list'][0][0]; decoded['url-list'] = buildUrlList(video, videoFile); - const newTorrentFilename = paths_1.generateTorrentFileName(videoOrPlaylist, videoFile.resolution); - const newTorrentPath = path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, newTorrentFilename); + const newTorrentFilename = (0, paths_1.generateTorrentFileName)(videoOrPlaylist, videoFile.resolution); + const newTorrentPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, newTorrentFilename); logger_1.logger.info('Updating torrent URLs %s -> %s.', oldTorrentPath, newTorrentPath); - yield fs_extra_1.writeFile(newTorrentPath, bencode_1.encode(decoded)); - yield fs_extra_1.remove(path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)); + yield (0, fs_extra_1.writeFile)(newTorrentPath, (0, bencode_1.encode)(decoded)); + yield (0, fs_extra_1.remove)((0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)); videoFile.torrentFilename = newTorrentFilename; }); } @@ -119,7 +119,7 @@ function generateMagnetUri(video, videoFile, trackerUrls) { const announce = trackerUrls; let urlList = [videoFile.getFileUrl(video)]; const redundancies = videoFile.RedundancyVideos; - if (misc_1.isArray(redundancies)) + if ((0, misc_1.isArray)(redundancies)) urlList = urlList.concat(redundancies.map(r => r.fileUrl)); const magnetHash = { xs, @@ -136,7 +136,7 @@ function safeWebtorrentDestroy(webtorrent, torrentId, downloadedFile, torrentNam webtorrent.destroy(err => { if (torrentName) { logger_1.logger.debug('Removing %s torrent after webtorrent download.', torrentId); - fs_extra_1.remove(torrentId) + (0, fs_extra_1.remove)(torrentId) .catch(err => logger_1.logger.error('Cannot remove torrent %s in webtorrent download.', torrentId, { err })); } if (downloadedFile) @@ -148,12 +148,12 @@ function safeWebtorrentDestroy(webtorrent, torrentId, downloadedFile, torrentNam }); } function deleteDownloadedFile(downloadedFile) { - let pathToDelete = path_1.dirname(downloadedFile.filepath); + let pathToDelete = (0, path_1.dirname)(downloadedFile.filepath); if (pathToDelete === '.') pathToDelete = downloadedFile.filepath; - const toRemovePath = path_1.join(downloadedFile.directoryPath, pathToDelete); + const toRemovePath = (0, path_1.join)(downloadedFile.directoryPath, pathToDelete); logger_1.logger.debug('Removing %s after webtorrent download.', toRemovePath); - fs_extra_1.remove(toRemovePath) + (0, fs_extra_1.remove)(toRemovePath) .catch(err => logger_1.logger.error('Cannot remove torrent file %s in webtorrent download.', toRemovePath, { err })); } function buildAnnounceList() { diff --git a/dist/server/helpers/youtube-dl.js b/dist/server/helpers/youtube-dl.js index 5a50e90e..c4596562 100644 --- a/dist/server/helpers/youtube-dl.js +++ b/dist/server/helpers/youtube-dl.js @@ -4,7 +4,7 @@ exports.YoutubeDL = void 0; const tslib_1 = require("tslib"); const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); -const got_1 = tslib_1.__importDefault(require("got")); +const got_1 = (0, tslib_1.__importDefault)(require("got")); const path_1 = require("path"); const config_1 = require("@server/initializers/config"); const http_error_codes_1 = require("../../shared/models/http/http-error-codes"); @@ -65,7 +65,7 @@ class YoutubeDL { ...acc, { language: matched[1], - path: path_1.join(cwd, filename), + path: (0, path_1.join)(cwd, filename), filename } ]; @@ -90,7 +90,7 @@ class YoutubeDL { ].join('/'); } downloadYoutubeDLVideo(fileExt, timeout) { - const pathWithoutExtension = utils_1.generateVideoImportTmpPath(this.url, ''); + const pathWithoutExtension = (0, utils_1.generateVideoImportTmpPath)(this.url, ''); let timer; logger_1.logger.info('Importing youtubeDL video %s to %s', this.url, pathWithoutExtension); let options = ['-f', this.getYoutubeDLVideoFormat(), '-o', pathWithoutExtension]; @@ -102,15 +102,15 @@ class YoutubeDL { return new Promise((res, rej) => { YoutubeDL.safeGetYoutubeDL() .then(youtubeDL => { - youtubeDL.exec(this.url, options, processOptions, (err) => tslib_1.__awaiter(this, void 0, void 0, function* () { + youtubeDL.exec(this.url, options, processOptions, (err) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { clearTimeout(timer); try { - if (yield fs_extra_1.pathExists(pathWithoutExtension)) { - yield fs_extra_1.move(pathWithoutExtension, pathWithoutExtension + '.mp4'); + if (yield (0, fs_extra_1.pathExists)(pathWithoutExtension)) { + yield (0, fs_extra_1.move)(pathWithoutExtension, pathWithoutExtension + '.mp4'); } const path = yield this.guessVideoPathWithExtension(pathWithoutExtension, fileExt); if (err) { - fs_extra_1.remove(path) + (0, fs_extra_1.remove)(path) .catch(err => logger_1.logger.error('Cannot delete path on YoutubeDL error.', { err })); return rej(err); } @@ -123,7 +123,7 @@ class YoutubeDL { timer = setTimeout(() => { const err = new Error('YoutubeDL download timeout.'); this.guessVideoPathWithExtension(pathWithoutExtension, fileExt) - .then(path => fs_extra_1.remove(path)) + .then(path => (0, fs_extra_1.remove)(path)) .finally(() => rej(err)) .catch(err => { logger_1.logger.error('Cannot remove file in youtubeDL timeout.', { err }); @@ -148,14 +148,14 @@ class YoutubeDL { return originallyPublishedAt; } guessVideoPathWithExtension(tmpPath, sourceExt) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (!videos_1.isVideoFileExtnameValid(sourceExt)) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if (!(0, videos_1.isVideoFileExtnameValid)(sourceExt)) { throw new Error('Invalid video extension ' + sourceExt); } const extensions = [sourceExt, '.mp4', '.mkv', '.webm']; for (const extension of extensions) { const path = tmpPath + extension; - if (yield fs_extra_1.pathExists(path)) + if (yield (0, fs_extra_1.pathExists)(path)) return path; } throw new Error('Cannot guess path of ' + tmpPath); @@ -191,7 +191,7 @@ class YoutubeDL { }; } titleTruncation(title) { - return core_utils_1.peertubeTruncate(title, { + return (0, core_utils_1.peertubeTruncate)(title, { length: constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max, separator: /,? +/, omission: ' […]' @@ -200,7 +200,7 @@ class YoutubeDL { descriptionTruncation(description) { if (!description || description.length < constants_1.CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.min) return undefined; - return core_utils_1.peertubeTruncate(description, { + return (0, core_utils_1.peertubeTruncate)(description, { length: constants_1.CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max, separator: /,? +/, omission: ' […]' @@ -255,15 +255,15 @@ class YoutubeDL { return options; } static updateYoutubeDLBinary() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Updating youtubeDL binary.'); - const binDirectory = path_1.join(core_utils_1.root(), 'node_modules', 'youtube-dl', 'bin'); - const bin = path_1.join(binDirectory, 'youtube-dl'); - const detailsPath = path_1.join(binDirectory, 'details'); + const binDirectory = (0, path_1.join)((0, core_utils_1.root)(), 'node_modules', 'youtube-dl', 'bin'); + const bin = (0, path_1.join)(binDirectory, 'youtube-dl'); + const detailsPath = (0, path_1.join)(binDirectory, 'details'); const url = process.env.YOUTUBE_DL_DOWNLOAD_HOST || 'https://yt-dl.org/downloads/latest/youtube-dl'; - yield fs_extra_1.ensureDir(binDirectory); + yield (0, fs_extra_1.ensureDir)(binDirectory); try { - const result = yield got_1.default(url, { followRedirect: false }); + const result = yield (0, got_1.default)(url, { followRedirect: false }); if (result.statusCode !== http_error_codes_1.HttpStatusCode.FOUND_302) { logger_1.logger.error('youtube-dl update error: did not get redirect for the latest version link. Status %d', result.statusCode); return; @@ -271,10 +271,10 @@ class YoutubeDL { const newUrl = result.headers.location; const newVersion = /\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/youtube-dl$/.exec(newUrl)[1]; const downloadFileStream = got_1.default.stream(newUrl); - const writeStream = fs_1.createWriteStream(bin, { mode: 493 }); - yield core_utils_1.pipelinePromise(downloadFileStream, writeStream); + const writeStream = (0, fs_1.createWriteStream)(bin, { mode: 493 }); + yield (0, core_utils_1.pipelinePromise)(downloadFileStream, writeStream); const details = JSON.stringify({ version: newVersion, path: bin, exec: 'youtube-dl' }); - yield fs_extra_1.writeFile(detailsPath, details, { encoding: 'utf8' }); + yield (0, fs_extra_1.writeFile)(detailsPath, details, { encoding: 'utf8' }); logger_1.logger.info('youtube-dl updated to version %s.', newVersion); } catch (err) { @@ -283,7 +283,7 @@ class YoutubeDL { }); } static safeGetYoutubeDL() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let youtubeDL; try { youtubeDL = require('youtube-dl'); diff --git a/dist/server/initializers/checker-after-init.js b/dist/server/initializers/checker-after-init.js index 0927823e..e6e2c32c 100644 --- a/dist/server/initializers/checker-after-init.js +++ b/dist/server/initializers/checker-after-init.js @@ -15,8 +15,8 @@ const oauth_client_1 = require("../models/oauth/oauth-client"); const config_2 = require("./config"); const constants_1 = require("./constants"); function checkActivityPubUrls() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const parsed = new url_1.URL(actor.url); if (constants_1.WEBSERVER.HOST !== parsed.host) { const NODE_ENV = config_1.util.getEnv('NODE_ENV'); @@ -29,10 +29,10 @@ function checkActivityPubUrls() { } exports.checkActivityPubUrls = checkActivityPubUrls; function checkConfig() { - if (config_1.has('services.csp-logger')) { + if ((0, config_1.has)('services.csp-logger')) { logger_1.logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.'); } - if (!config_2.isEmailEnabled()) { + if (!(0, config_2.isEmailEnabled)()) { if (config_2.CONFIG.SIGNUP.ENABLED && config_2.CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { return 'Emailer is disabled but you require signup email verification.'; } @@ -48,17 +48,17 @@ function checkConfig() { } } const redundancyVideos = config_2.CONFIG.REDUNDANCY.VIDEOS.STRATEGIES; - if (misc_1.isArray(redundancyVideos)) { + if ((0, misc_1.isArray)(redundancyVideos)) { const available = ['most-views', 'trending', 'recently-added']; for (const r of redundancyVideos) { if (available.includes(r.strategy) === false) { return 'Videos redundancy should have ' + available.join(' or ') + ' strategy instead of ' + r.strategy; } - if (!core_utils_1.isTestInstance() && r.minLifetime < 1000 * 3600 * 10) { + if (!(0, core_utils_1.isTestInstance)() && r.minLifetime < 1000 * 3600 * 10) { r.minLifetime = 1000 * 3600 * 10; } } - const filtered = lodash_1.uniq(redundancyVideos.map(r => r.strategy)); + const filtered = (0, lodash_1.uniq)(redundancyVideos.map(r => r.strategy)); if (filtered.length !== redundancyVideos.length) { return 'Redundancy video entries should have unique strategies'; } @@ -75,8 +75,8 @@ function checkConfig() { if (acceptFromValues.has(acceptFrom) === false) { return 'remote_redundancy.videos.accept_from has an incorrect value'; } - if (core_utils_1.isProdInstance()) { - const configStorage = config_1.get('storage'); + if ((0, core_utils_1.isProdInstance)()) { + const configStorage = (0, config_1.get)('storage'); for (const key of Object.keys(configStorage)) { if (configStorage[key].startsWith('storage/')) { logger_1.logger.warn('Directory of %s should not be in the production directory of PeerTube. Please check your production configuration file.', key); @@ -137,30 +137,30 @@ function checkConfig() { } exports.checkConfig = checkConfig; function clientsExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalClients = yield oauth_client_1.OAuthClientModel.countTotal(); return totalClients !== 0; }); } exports.clientsExist = clientsExist; function usersExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalUsers = yield user_1.UserModel.countTotal(); return totalUsers !== 0; }); } exports.usersExist = usersExist; function applicationExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalApplication = yield application_1.ApplicationModel.countTotal(); return totalApplication !== 0; }); } exports.applicationExist = applicationExist; function checkFFmpegVersion() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const version = yield ffmpeg_utils_1.getFFmpegVersion(); - const { major, minor } = core_utils_1.parseSemVersion(version); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const version = yield (0, ffmpeg_utils_1.getFFmpegVersion)(); + const { major, minor } = (0, core_utils_1.parseSemVersion)(version); if (major < 4 || (major === 4 && minor < 1)) { logger_1.logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade.', version); } diff --git a/dist/server/initializers/checker-before-init.js b/dist/server/initializers/checker-before-init.js index e507571b..062dc950 100644 --- a/dist/server/initializers/checker-before-init.js +++ b/dist/server/initializers/checker-before-init.js @@ -75,11 +75,11 @@ function checkMissedConfig() { } exports.checkMissedConfig = checkMissedConfig; function checkFFmpeg(CONFIG) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (CONFIG.TRANSCODING.ENABLED === false) return undefined; const Ffmpeg = require('fluent-ffmpeg'); - const getAvailableCodecsPromise = core_utils_1.promisify0(Ffmpeg.getAvailableCodecs); + const getAvailableCodecsPromise = (0, core_utils_1.promisify0)(Ffmpeg.getAvailableCodecs); const codecs = yield getAvailableCodecsPromise(); const canEncode = ['libx264']; for (const codec of canEncode) { @@ -95,7 +95,7 @@ function checkFFmpeg(CONFIG) { exports.checkFFmpeg = checkFFmpeg; function checkNodeVersion() { const v = process.version; - const { major } = core_utils_1.parseSemVersion(v); + const { major } = (0, core_utils_1.parseSemVersion)(v); logger_1.logger.debug('Checking NodeJS version %s.', v); if (major <= 10) { logger_1.logger.warn('Your NodeJS version %s is deprecated. Please upgrade.', v); diff --git a/dist/server/initializers/config.js b/dist/server/initializers/config.js index c199dd46..da198743 100644 --- a/dist/server/initializers/config.js +++ b/dist/server/initializers/config.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.reloadConfig = exports.isEmailEnabled = exports.registerConfigChangedHandler = exports.CONFIG = void 0; const tslib_1 = require("tslib"); -const bytes_1 = tslib_1.__importDefault(require("bytes")); -const decache_1 = tslib_1.__importDefault(require("decache")); +const bytes_1 = (0, tslib_1.__importDefault)(require("bytes")); +const decache_1 = (0, tslib_1.__importDefault)(require("decache")); const path_1 = require("path"); const core_utils_1 = require("../helpers/core-utils"); let config = require('config'); @@ -53,19 +53,20 @@ const CONFIG = { } }, STORAGE: { - TMP_DIR: core_utils_1.buildPath(config.get('storage.tmp')), - ACTOR_IMAGES: core_utils_1.buildPath(config.get('storage.avatars')), - LOG_DIR: core_utils_1.buildPath(config.get('storage.logs')), - VIDEOS_DIR: core_utils_1.buildPath(config.get('storage.videos')), - STREAMING_PLAYLISTS_DIR: core_utils_1.buildPath(config.get('storage.streaming_playlists')), - REDUNDANCY_DIR: core_utils_1.buildPath(config.get('storage.redundancy')), - THUMBNAILS_DIR: core_utils_1.buildPath(config.get('storage.thumbnails')), - PREVIEWS_DIR: core_utils_1.buildPath(config.get('storage.previews')), - CAPTIONS_DIR: core_utils_1.buildPath(config.get('storage.captions')), - TORRENTS_DIR: core_utils_1.buildPath(config.get('storage.torrents')), - CACHE_DIR: core_utils_1.buildPath(config.get('storage.cache')), - PLUGINS_DIR: core_utils_1.buildPath(config.get('storage.plugins')), - CLIENT_OVERRIDES_DIR: core_utils_1.buildPath(config.get('storage.client_overrides')) + TMP_DIR: (0, core_utils_1.buildPath)(config.get('storage.tmp')), + ACTOR_IMAGES: (0, core_utils_1.buildPath)(config.get('storage.avatars')), + LOG_DIR: (0, core_utils_1.buildPath)(config.get('storage.logs')), + VIDEOS_DIR: (0, core_utils_1.buildPath)(config.get('storage.videos')), + IMAGES_DIR: (0, core_utils_1.buildPath)(config.get('storage.images')), + STREAMING_PLAYLISTS_DIR: (0, core_utils_1.buildPath)(config.get('storage.streaming_playlists')), + REDUNDANCY_DIR: (0, core_utils_1.buildPath)(config.get('storage.redundancy')), + THUMBNAILS_DIR: (0, core_utils_1.buildPath)(config.get('storage.thumbnails')), + PREVIEWS_DIR: (0, core_utils_1.buildPath)(config.get('storage.previews')), + CAPTIONS_DIR: (0, core_utils_1.buildPath)(config.get('storage.captions')), + TORRENTS_DIR: (0, core_utils_1.buildPath)(config.get('storage.torrents')), + CACHE_DIR: (0, core_utils_1.buildPath)(config.get('storage.cache')), + PLUGINS_DIR: (0, core_utils_1.buildPath)(config.get('storage.plugins')), + CLIENT_OVERRIDES_DIR: (0, core_utils_1.buildPath)(config.get('storage.client_overrides')) }, OBJECT_STORAGE: { ENABLED: config.get('object_storage.enabled'), @@ -95,19 +96,19 @@ const CONFIG = { }, RATES_LIMIT: { API: { - WINDOW_MS: core_utils_1.parseDurationToMs(config.get('rates_limit.api.window')), + WINDOW_MS: (0, core_utils_1.parseDurationToMs)(config.get('rates_limit.api.window')), MAX: config.get('rates_limit.api.max') }, SIGNUP: { - WINDOW_MS: core_utils_1.parseDurationToMs(config.get('rates_limit.signup.window')), + WINDOW_MS: (0, core_utils_1.parseDurationToMs)(config.get('rates_limit.signup.window')), MAX: config.get('rates_limit.signup.max') }, LOGIN: { - WINDOW_MS: core_utils_1.parseDurationToMs(config.get('rates_limit.login.window')), + WINDOW_MS: (0, core_utils_1.parseDurationToMs)(config.get('rates_limit.login.window')), MAX: config.get('rates_limit.login.max') }, ASK_SEND_EMAIL: { - WINDOW_MS: core_utils_1.parseDurationToMs(config.get('rates_limit.ask_send_email.window')), + WINDOW_MS: (0, core_utils_1.parseDurationToMs)(config.get('rates_limit.ask_send_email.window')), MAX: config.get('rates_limit.ask_send_email.max') } }, @@ -134,8 +135,12 @@ const CONFIG = { }, REDUNDANCY: { VIDEOS: { - CHECK_INTERVAL: core_utils_1.parseDurationToMs(config.get('redundancy.videos.check_interval')), + CHECK_INTERVAL: (0, core_utils_1.parseDurationToMs)(config.get('redundancy.videos.check_interval')), STRATEGIES: buildVideosRedundancy(config.get('redundancy.videos.strategies')) + }, + IMAGES: { + CHECK_INTERVAL: (0, core_utils_1.parseDurationToMs)(config.get('redundancy.images.check_interval')), + NB_IMAGES_PER_REQ: config.get('redundancy.images.nb_images_per_req') } }, REMOTE_REDUNDANCY: { @@ -160,20 +165,20 @@ const CONFIG = { }, HISTORY: { VIDEOS: { - MAX_AGE: core_utils_1.parseDurationToMs(config.get('history.videos.max_age')) + MAX_AGE: (0, core_utils_1.parseDurationToMs)(config.get('history.videos.max_age')) } }, VIEWS: { VIDEOS: { REMOTE: { - MAX_AGE: core_utils_1.parseDurationToMs(config.get('views.videos.remote.max_age')) + MAX_AGE: (0, core_utils_1.parseDurationToMs)(config.get('views.videos.remote.max_age')) } } }, PLUGINS: { INDEX: { ENABLED: config.get('plugins.index.enabled'), - CHECK_LATEST_VERSIONS_INTERVAL: core_utils_1.parseDurationToMs(config.get('plugins.index.check_latest_versions_interval')), + CHECK_LATEST_VERSIONS_INTERVAL: (0, core_utils_1.parseDurationToMs)(config.get('plugins.index.check_latest_versions_interval')), URL: config.get('plugins.index.url') } }, @@ -208,8 +213,8 @@ const CONFIG = { } }, USER: { - get VIDEO_QUOTA() { return core_utils_1.parseBytes(config.get('user.video_quota')); }, - get VIDEO_QUOTA_DAILY() { return core_utils_1.parseBytes(config.get('user.video_quota_daily')); } + get VIDEO_QUOTA() { return (0, core_utils_1.parseBytes)(config.get('user.video_quota')); }, + get VIDEO_QUOTA_DAILY() { return (0, core_utils_1.parseBytes)(config.get('user.video_quota_daily')); } }, TRANSCODING: { get ENABLED() { return config.get('transcoding.enabled'); }, @@ -226,7 +231,8 @@ const CONFIG = { get '720p'() { return config.get('transcoding.resolutions.720p'); }, get '1080p'() { return config.get('transcoding.resolutions.1080p'); }, get '1440p'() { return config.get('transcoding.resolutions.1440p'); }, - get '2160p'() { return config.get('transcoding.resolutions.2160p'); } + get '2160p'() { return config.get('transcoding.resolutions.2160p'); }, + '144p': true }, HLS: { get ENABLED() { return config.get('transcoding.hls.enabled'); } @@ -237,7 +243,7 @@ const CONFIG = { }, LIVE: { get ENABLED() { return config.get('live.enabled'); }, - get MAX_DURATION() { return core_utils_1.parseDurationToMs(config.get('live.max_duration')); }, + get MAX_DURATION() { return (0, core_utils_1.parseDurationToMs)(config.get('live.max_duration')); }, get MAX_INSTANCE_LIVES() { return config.get('live.max_instance_lives'); }, get MAX_USER_LIVES() { return config.get('live.max_user_lives'); }, get ALLOW_REPLAY() { return config.get('live.allow_replay'); }, @@ -391,7 +397,7 @@ function getLocalConfigFilePath() { filename += `-${process.env.NODE_ENV}`; if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`; - return path_1.join(path_1.dirname(configSources[0].name), filename + '.json'); + return (0, path_1.join)((0, path_1.dirname)(configSources[0].name), filename + '.json'); } function buildVideosRedundancy(objs) { if (!objs) @@ -400,7 +406,7 @@ function buildVideosRedundancy(objs) { return objs; return objs.map(obj => { return Object.assign({}, obj, { - minLifetime: core_utils_1.parseDurationToMs(obj.min_lifetime), + minLifetime: (0, core_utils_1.parseDurationToMs)(obj.min_lifetime), size: bytes_1.default.parse(obj.size), minViews: obj.min_views }); @@ -411,7 +417,7 @@ function reloadConfig() { if (process.env.NODE_CONFIG_DIR) { return process.env.NODE_CONFIG_DIR; } - return path_1.join(core_utils_1.root(), 'config'); + return (0, path_1.join)((0, core_utils_1.root)(), 'config'); } function purge() { const directory = getConfigDirectory(); @@ -421,7 +427,7 @@ function reloadConfig() { } delete require.cache[fileName]; } - decache_1.default('config'); + (0, decache_1.default)('config'); } purge(); config = require('config'); diff --git a/dist/server/initializers/constants.js b/dist/server/initializers/constants.js index cefcff37..8405595a 100644 --- a/dist/server/initializers/constants.js +++ b/dist/server/initializers/constants.js @@ -20,7 +20,7 @@ const LOGGER_ENDPOINT = 'https://rixtrema.net/api/uptime/Peertube/TranscodingErr exports.LOGGER_ENDPOINT = LOGGER_ENDPOINT; const API_VERSION = 'v1'; exports.API_VERSION = API_VERSION; -const PEERTUBE_VERSION = require(path_1.join(core_utils_1.root(), 'package.json')).version; +const PEERTUBE_VERSION = require((0, path_1.join)((0, core_utils_1.root)(), 'package.json')).version; exports.PEERTUBE_VERSION = PEERTUBE_VERSION; const PAGINATION = { GLOBAL: { @@ -162,10 +162,10 @@ const JOB_TTL = { exports.JOB_TTL = JOB_TTL; const REPEAT_JOBS = { 'videos-views': { - cron: miscs_1.randomInt(1, 20) + ' * * * *' + cron: (0, miscs_1.randomInt)(1, 20) + ' * * * *' }, 'activitypub-cleaner': { - cron: '30 5 * * ' + miscs_1.randomInt(0, 7) + cron: '30 5 * * ' + (0, miscs_1.randomInt)(0, 7) } }; exports.REPEAT_JOBS = REPEAT_JOBS; @@ -470,8 +470,8 @@ const MIMETYPES = { } }; exports.MIMETYPES = MIMETYPES; -MIMETYPES.AUDIO.EXT_MIMETYPE = lodash_1.invert(MIMETYPES.AUDIO.MIMETYPE_EXT); -MIMETYPES.IMAGE.EXT_MIMETYPE = lodash_1.invert(MIMETYPES.IMAGE.MIMETYPE_EXT); +MIMETYPES.AUDIO.EXT_MIMETYPE = (0, lodash_1.invert)(MIMETYPES.AUDIO.MIMETYPE_EXT); +MIMETYPES.IMAGE.EXT_MIMETYPE = (0, lodash_1.invert)(MIMETYPES.IMAGE.MIMETYPE_EXT); const OVERVIEWS = { VIDEOS: { SAMPLE_THRESHOLD: 6, @@ -544,6 +544,8 @@ exports.NSFW_POLICY_TYPES = NSFW_POLICY_TYPES; const STATIC_PATHS = { THUMBNAILS: '/static/thumbnails/', TORRENTS: '/static/torrents/', + IMAGES: '/static/images', + IMAGES_WEBSEED: '/static/images_webseed', WEBSEED: '/static/webseed/', REDUNDANCY: '/static/redundancy/', STREAMING_PLAYLISTS: { @@ -601,15 +603,15 @@ const EMBED_SIZE = { exports.EMBED_SIZE = EMBED_SIZE; const FILES_CACHE = { PREVIEWS: { - DIRECTORY: path_1.join(config_1.CONFIG.STORAGE.CACHE_DIR, 'previews'), + DIRECTORY: (0, path_1.join)(config_1.CONFIG.STORAGE.CACHE_DIR, 'previews'), MAX_AGE: 1000 * 3600 * 3 }, VIDEO_CAPTIONS: { - DIRECTORY: path_1.join(config_1.CONFIG.STORAGE.CACHE_DIR, 'video-captions'), + DIRECTORY: (0, path_1.join)(config_1.CONFIG.STORAGE.CACHE_DIR, 'video-captions'), MAX_AGE: 1000 * 3600 * 3 }, TORRENTS: { - DIRECTORY: path_1.join(config_1.CONFIG.STORAGE.CACHE_DIR, 'torrents'), + DIRECTORY: (0, path_1.join)(config_1.CONFIG.STORAGE.CACHE_DIR, 'torrents'), MAX_AGE: 1000 * 3600 * 3 } }; @@ -623,11 +625,11 @@ const LRU_CACHE = { } }; exports.LRU_CACHE = LRU_CACHE; -const RESUMABLE_UPLOAD_DIRECTORY = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, 'resumable-uploads'); +const RESUMABLE_UPLOAD_DIRECTORY = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, 'resumable-uploads'); exports.RESUMABLE_UPLOAD_DIRECTORY = RESUMABLE_UPLOAD_DIRECTORY; -const HLS_STREAMING_PLAYLIST_DIRECTORY = path_1.join(config_1.CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls'); +const HLS_STREAMING_PLAYLIST_DIRECTORY = (0, path_1.join)(config_1.CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls'); exports.HLS_STREAMING_PLAYLIST_DIRECTORY = HLS_STREAMING_PLAYLIST_DIRECTORY; -const HLS_REDUNDANCY_DIRECTORY = path_1.join(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, 'hls'); +const HLS_REDUNDANCY_DIRECTORY = (0, path_1.join)(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, 'hls'); exports.HLS_REDUNDANCY_DIRECTORY = HLS_REDUNDANCY_DIRECTORY; const VIDEO_LIVE = { EXTENSION: '.ts', @@ -670,8 +672,8 @@ exports.REDUNDANCY = REDUNDANCY; const ACCEPT_HEADERS = ['html', 'application/json'].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS); exports.ACCEPT_HEADERS = ACCEPT_HEADERS; const ASSETS_PATH = { - DEFAULT_AUDIO_BACKGROUND: path_1.join(core_utils_1.root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'), - DEFAULT_LIVE_BACKGROUND: path_1.join(core_utils_1.root(), 'dist', 'server', 'assets', 'default-live-background.jpg') + DEFAULT_AUDIO_BACKGROUND: (0, path_1.join)((0, core_utils_1.root)(), 'dist', 'server', 'assets', 'default-audio-background.jpg'), + DEFAULT_LIVE_BACKGROUND: (0, path_1.join)((0, core_utils_1.root)(), 'dist', 'server', 'assets', 'default-live-background.jpg') }; exports.ASSETS_PATH = ASSETS_PATH; const CUSTOM_HTML_TAG_COMMENTS = { @@ -703,7 +705,7 @@ const P2P_MEDIA_LOADER_PEER_VERSION = 2; exports.P2P_MEDIA_LOADER_PEER_VERSION = P2P_MEDIA_LOADER_PEER_VERSION; const PLUGIN_GLOBAL_CSS_FILE_NAME = 'plugins-global.css'; exports.PLUGIN_GLOBAL_CSS_FILE_NAME = PLUGIN_GLOBAL_CSS_FILE_NAME; -const PLUGIN_GLOBAL_CSS_PATH = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, PLUGIN_GLOBAL_CSS_FILE_NAME); +const PLUGIN_GLOBAL_CSS_PATH = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, PLUGIN_GLOBAL_CSS_FILE_NAME); exports.PLUGIN_GLOBAL_CSS_PATH = PLUGIN_GLOBAL_CSS_PATH; let PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 1000 * 60 * 5; exports.PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME; @@ -718,7 +720,7 @@ const SEARCH_INDEX = { } }; exports.SEARCH_INDEX = SEARCH_INDEX; -if (core_utils_1.isTestInstance() === true) { +if ((0, core_utils_1.isTestInstance)() === true) { exports.PRIVATE_RSA_KEY_SIZE = PRIVATE_RSA_KEY_SIZE = 1024; ACTOR_FOLLOW_SCORE.BASE = 20; REMOTE_SCHEME.HTTP = 'http'; @@ -756,7 +758,7 @@ if (core_utils_1.isTestInstance() === true) { } updateWebserverUrls(); updateWebserverConfig(); -config_1.registerConfigChangedHandler(() => { +(0, config_1.registerConfigChangedHandler)(() => { updateWebserverUrls(); updateWebserverConfig(); }); @@ -805,8 +807,8 @@ function buildVideoMimetypeExt() { return data; } function updateWebserverUrls() { - WEBSERVER.URL = core_utils_1.sanitizeUrl(config_1.CONFIG.WEBSERVER.SCHEME + '://' + config_1.CONFIG.WEBSERVER.HOSTNAME + ':' + config_1.CONFIG.WEBSERVER.PORT); - WEBSERVER.HOST = core_utils_1.sanitizeHost(config_1.CONFIG.WEBSERVER.HOSTNAME + ':' + config_1.CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP); + WEBSERVER.URL = (0, core_utils_1.sanitizeUrl)(config_1.CONFIG.WEBSERVER.SCHEME + '://' + config_1.CONFIG.WEBSERVER.HOSTNAME + ':' + config_1.CONFIG.WEBSERVER.PORT); + WEBSERVER.HOST = (0, core_utils_1.sanitizeHost)(config_1.CONFIG.WEBSERVER.HOSTNAME + ':' + config_1.CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP); WEBSERVER.WS = config_1.CONFIG.WEBSERVER.WS; WEBSERVER.SCHEME = config_1.CONFIG.WEBSERVER.SCHEME; WEBSERVER.HOSTNAME = config_1.CONFIG.WEBSERVER.HOSTNAME; @@ -880,6 +882,6 @@ function buildLanguages() { } exports.buildLanguages = buildLanguages; function generateContentHash() { - return crypto_1.randomBytes(20).toString('hex'); + return (0, crypto_1.randomBytes)(20).toString('hex'); } exports.generateContentHash = generateContentHash; diff --git a/dist/server/initializers/database.js b/dist/server/initializers/database.js index e77c5915..d774cf1a 100644 --- a/dist/server/initializers/database.js +++ b/dist/server/initializers/database.js @@ -50,6 +50,8 @@ const video_view_1 = require("../models/video/video-view"); const config_1 = require("./config"); const actor_custom_page_1 = require("@server/models/account/actor-custom-page"); const video_job_info_1 = require("@server/models/video/video-job-info"); +const image_1 = require("@server/models/image/image"); +const image_redundancy_1 = require("@server/models/image/image-redundancy"); require('pg').defaults.parseInt8 = true; const dbname = config_1.CONFIG.DATABASE.DBNAME; const username = config_1.CONFIG.DATABASE.USERNAME; @@ -76,13 +78,13 @@ const sequelizeTypescript = new sequelize_typescript_1.Sequelize({ pool: { max: poolMax }, - benchmark: core_utils_1.isTestInstance(), + benchmark: (0, core_utils_1.isTestInstance)(), isolationLevel: sequelize_1.Transaction.ISOLATION_LEVELS.SERIALIZABLE, logging: (message, benchmark) => { if (process.env.NODE_DB_LOG === 'false') return; let newMessage = 'Executed SQL request'; - if (core_utils_1.isTestInstance() === true && benchmark !== undefined) { + if ((0, core_utils_1.isTestInstance)() === true && benchmark !== undefined) { newMessage += ' in ' + benchmark + 'ms'; } logger_1.logger.debug(newMessage, { sql: message, tags: ['sql'] }); @@ -99,7 +101,7 @@ function checkDatabaseConnectionOrDie() { } exports.checkDatabaseConnectionOrDie = checkDatabaseConnectionOrDie; function initDatabaseModels(silent) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { sequelizeTypescript.addModels([ application_1.ApplicationModel, actor_1.ActorModel, @@ -143,7 +145,9 @@ function initDatabaseModels(silent) { video_tracker_1.VideoTrackerModel, plugin_1.PluginModel, actor_custom_page_1.ActorCustomPageModel, - video_job_info_1.VideoJobInfoModel + video_job_info_1.VideoJobInfoModel, + image_1.ImageModel, + image_redundancy_1.ImageRedundancyModel ]); yield checkPostgresExtensions(); yield createFunctions(); @@ -153,7 +157,7 @@ function initDatabaseModels(silent) { } exports.initDatabaseModels = initDatabaseModels; function checkPostgresExtensions() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const promises = [ checkPostgresExtension('pg_trgm'), checkPostgresExtension('unaccent') @@ -162,7 +166,7 @@ function checkPostgresExtensions() { }); } function checkPostgresExtension(extension) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = `SELECT 1 FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`; const options = { type: sequelize_1.QueryTypes.SELECT, diff --git a/dist/server/initializers/installer.js b/dist/server/initializers/installer.js index f1df32fe..dbb373f5 100644 --- a/dist/server/initializers/installer.js +++ b/dist/server/initializers/installer.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.installApplication = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); -const password_generator_1 = tslib_1.__importDefault(require("password-generator")); +const password_generator_1 = (0, tslib_1.__importDefault)(require("password-generator")); const shared_1 = require("../../shared"); const logger_1 = require("../helpers/logger"); const user_1 = require("../lib/user"); @@ -15,7 +15,7 @@ const config_1 = require("./config"); const constants_1 = require("./constants"); const database_1 = require("./database"); function installApplication() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield Promise.all([ database_1.sequelizeTypescript.sync() @@ -43,9 +43,9 @@ function removeCacheAndTmpDirectories() { const tasks = []; for (const key of Object.keys(cacheDirectories)) { const dir = cacheDirectories[key]; - tasks.push(fs_extra_1.remove(dir)); + tasks.push((0, fs_extra_1.remove)(dir)); } - tasks.push(fs_extra_1.remove(config_1.CONFIG.STORAGE.TMP_DIR)); + tasks.push((0, fs_extra_1.remove)(config_1.CONFIG.STORAGE.TMP_DIR)); return Promise.all(tasks); } function createDirectoriesIfNotExist() { @@ -55,24 +55,24 @@ function createDirectoriesIfNotExist() { const tasks = []; for (const key of Object.keys(storage)) { const dir = storage[key]; - tasks.push(fs_extra_1.ensureDir(dir)); + tasks.push((0, fs_extra_1.ensureDir)(dir)); } for (const key of Object.keys(cacheDirectories)) { const dir = cacheDirectories[key]; - tasks.push(fs_extra_1.ensureDir(dir)); + tasks.push((0, fs_extra_1.ensureDir)(dir)); } - tasks.push(fs_extra_1.ensureDir(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY)); - tasks.push(fs_extra_1.ensureDir(constants_1.RESUMABLE_UPLOAD_DIRECTORY)); + tasks.push((0, fs_extra_1.ensureDir)(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY)); + tasks.push((0, fs_extra_1.ensureDir)(constants_1.RESUMABLE_UPLOAD_DIRECTORY)); return Promise.all(tasks); } function createOAuthClientIfNotExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const exist = yield checker_after_init_1.clientsExist(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const exist = yield (0, checker_after_init_1.clientsExist)(); if (exist === true) return undefined; logger_1.logger.info('Creating a default OAuth Client.'); - const id = password_generator_1.default(32, false, /[a-z0-9]/); - const secret = password_generator_1.default(32, false, /[a-zA-Z0-9]/); + const id = (0, password_generator_1.default)(32, false, /[a-z0-9]/); + const secret = (0, password_generator_1.default)(32, false, /[a-zA-Z0-9]/); const client = new oauth_client_1.OAuthClientModel({ clientId: id, clientSecret: secret, @@ -86,8 +86,8 @@ function createOAuthClientIfNotExist() { }); } function createOAuthAdminIfNotExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const exist = yield checker_after_init_1.usersExist(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const exist = yield (0, checker_after_init_1.usersExist)(); if (exist === true) return undefined; logger_1.logger.info('Creating the administrator.'); @@ -107,7 +107,7 @@ function createOAuthAdminIfNotExist() { password = process.env.PT_INITIAL_ROOT_PASSWORD; } else { - password = password_generator_1.default(16, true); + password = (0, password_generator_1.default)(16, true); } const userData = { username, @@ -120,20 +120,20 @@ function createOAuthAdminIfNotExist() { videoQuotaDaily: -1 }; const user = new user_2.UserModel(userData); - yield user_1.createUserAccountAndChannelAndPlaylist({ userToCreate: user, channelNames: undefined, validateUser: validatePassword }); + yield (0, user_1.createUserAccountAndChannelAndPlaylist)({ userToCreate: user, channelNames: undefined, validateUser: validatePassword }); logger_1.logger.info('Username: ' + username); logger_1.logger.info('User password: ' + password); }); } function createApplicationIfNotExist() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const exist = yield checker_after_init_1.applicationExist(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const exist = yield (0, checker_after_init_1.applicationExist)(); if (exist === true) return undefined; logger_1.logger.info('Creating application account.'); const application = yield application_1.ApplicationModel.create({ migrationVersion: constants_1.LAST_MIGRATION_VERSION }); - return user_1.createApplicationActor(application.id); + return (0, user_1.createApplicationActor)(application.id); }); } diff --git a/dist/server/initializers/migrations/0005-email-pod.js b/dist/server/initializers/migrations/0005-email-pod.js index 20c43256..d5ca1be1 100644 --- a/dist/server/initializers/migrations/0005-email-pod.js +++ b/dist/server/initializers/migrations/0005-email-pod.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0010-email-user.js b/dist/server/initializers/migrations/0010-email-user.js index 0aec2efe..0f037e69 100644 --- a/dist/server/initializers/migrations/0010-email-user.js +++ b/dist/server/initializers/migrations/0010-email-user.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0015-video-views.js b/dist/server/initializers/migrations/0015-video-views.js index 212adac5..84cd1c65 100644 --- a/dist/server/initializers/migrations/0015-video-views.js +++ b/dist/server/initializers/migrations/0015-video-views.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0020-video-likes.js b/dist/server/initializers/migrations/0020-video-likes.js index 08f93e15..d3e49920 100644 --- a/dist/server/initializers/migrations/0020-video-likes.js +++ b/dist/server/initializers/migrations/0020-video-likes.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0025-video-dislikes.js b/dist/server/initializers/migrations/0025-video-dislikes.js index 4da7a2fb..7c38d8bd 100644 --- a/dist/server/initializers/migrations/0025-video-dislikes.js +++ b/dist/server/initializers/migrations/0025-video-dislikes.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0030-video-category.js b/dist/server/initializers/migrations/0030-video-category.js index f9da7ea4..19be569e 100644 --- a/dist/server/initializers/migrations/0030-video-category.js +++ b/dist/server/initializers/migrations/0030-video-category.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0035-video-licence.js b/dist/server/initializers/migrations/0035-video-licence.js index d65a92fd..edd37054 100644 --- a/dist/server/initializers/migrations/0035-video-licence.js +++ b/dist/server/initializers/migrations/0035-video-licence.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0040-video-nsfw.js b/dist/server/initializers/migrations/0040-video-nsfw.js index 7f8677c7..8f8e9274 100644 --- a/dist/server/initializers/migrations/0040-video-nsfw.js +++ b/dist/server/initializers/migrations/0040-video-nsfw.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0045-user-display-nsfw.js b/dist/server/initializers/migrations/0045-user-display-nsfw.js index 60d265ae..df14b942 100644 --- a/dist/server/initializers/migrations/0045-user-display-nsfw.js +++ b/dist/server/initializers/migrations/0045-user-display-nsfw.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0050-video-language.js b/dist/server/initializers/migrations/0050-video-language.js index e4d43439..c8202fc0 100644 --- a/dist/server/initializers/migrations/0050-video-language.js +++ b/dist/server/initializers/migrations/0050-video-language.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0055-video-uuid.js b/dist/server/initializers/migrations/0055-video-uuid.js index bc591689..d8b26593 100644 --- a/dist/server/initializers/migrations/0055-video-uuid.js +++ b/dist/server/initializers/migrations/0055-video-uuid.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const dataUUID = { diff --git a/dist/server/initializers/migrations/0070-user-video-quota.js b/dist/server/initializers/migrations/0070-user-video-quota.js index d7d71e14..b258da39 100644 --- a/dist/server/initializers/migrations/0070-user-video-quota.js +++ b/dist/server/initializers/migrations/0070-user-video-quota.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0075-video-resolutions.js b/dist/server/initializers/migrations/0075-video-resolutions.js index 0567095d..c4482707 100644 --- a/dist/server/initializers/migrations/0075-video-resolutions.js +++ b/dist/server/initializers/migrations/0075-video-resolutions.js @@ -9,7 +9,7 @@ const fs_extra_1 = require("fs-extra"); function up(utils) { const torrentDir = config_1.CONFIG.STORAGE.TORRENTS_DIR; const videoFileDir = config_1.CONFIG.STORAGE.VIDEOS_DIR; - return fs_extra_1.readdir(videoFileDir) + return (0, fs_extra_1.readdir)(videoFileDir) .then(videoFiles => { const tasks = []; for (const videoFile of videoFiles) { @@ -20,13 +20,13 @@ function up(utils) { } const uuid = matches[1]; const ext = matches[2]; - const p = ffprobe_utils_1.getVideoFileResolution(path_1.join(videoFileDir, videoFile)) - .then(({ resolution }) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const p = (0, ffprobe_utils_1.getVideoFileResolution)((0, path_1.join)(videoFileDir, videoFile)) + .then(({ resolution }) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldTorrentName = uuid + '.torrent'; const newTorrentName = uuid + '-' + resolution + '.torrent'; - yield fs_extra_1.rename(path_1.join(torrentDir, oldTorrentName), path_1.join(torrentDir, newTorrentName)).then(() => resolution); + yield (0, fs_extra_1.rename)((0, path_1.join)(torrentDir, oldTorrentName), (0, path_1.join)(torrentDir, newTorrentName)).then(() => resolution); const newVideoFileName = uuid + '-' + resolution + '.' + ext; - yield fs_extra_1.rename(path_1.join(videoFileDir, videoFile), path_1.join(videoFileDir, newVideoFileName)).then(() => resolution); + yield (0, fs_extra_1.rename)((0, path_1.join)(videoFileDir, videoFile), (0, path_1.join)(videoFileDir, newVideoFileName)).then(() => resolution); const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution + ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')'; return utils.sequelize.query(query); diff --git a/dist/server/initializers/migrations/0080-video-channels.js b/dist/server/initializers/migrations/0080-video-channels.js index d9d78cf5..5ec2afc4 100644 --- a/dist/server/initializers/migrations/0080-video-channels.js +++ b/dist/server/initializers/migrations/0080-video-channels.js @@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); const uuid_1 = require("@server/helpers/uuid"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; const dataAuthorUUID = { type: Sequelize.UUID, @@ -16,7 +16,7 @@ function up(utils) { { const authors = yield utils.db.Author.findAll(); for (const author of authors) { - author.uuid = uuid_1.buildUUID(); + author.uuid = (0, uuid_1.buildUUID)(); yield author.save(); } } diff --git a/dist/server/initializers/migrations/0085-user-role.js b/dist/server/initializers/migrations/0085-user-role.js index c376647d..f55b6d23 100644 --- a/dist/server/initializers/migrations/0085-user-role.js +++ b/dist/server/initializers/migrations/0085-user-role.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; yield q.renameColumn('Users', 'role', 'oldRole'); const data = { diff --git a/dist/server/initializers/migrations/0090-videos-description.js b/dist/server/initializers/migrations/0090-videos-description.js index 45d44094..803feddb 100644 --- a/dist/server/initializers/migrations/0090-videos-description.js +++ b/dist/server/initializers/migrations/0090-videos-description.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; const data = { type: Sequelize.STRING(3000), diff --git a/dist/server/initializers/migrations/0095-videos-privacy.js b/dist/server/initializers/migrations/0095-videos-privacy.js index a2cfcddc..12e23662 100644 --- a/dist/server/initializers/migrations/0095-videos-privacy.js +++ b/dist/server/initializers/migrations/0095-videos-privacy.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0100-activitypub.js b/dist/server/initializers/migrations/0100-activitypub.js index 61177775..aab72087 100644 --- a/dist/server/initializers/migrations/0100-activitypub.js +++ b/dist/server/initializers/migrations/0100-activitypub.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const peertube_crypto_1 = require("../../helpers/peertube-crypto"); const share_1 = require("../../lib/activitypub/share"); const url_1 = require("../../lib/activitypub/url"); @@ -10,7 +10,7 @@ const user_1 = require("../../lib/user"); const application_1 = require("../../models/application/application"); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; const db = utils.db; { @@ -47,13 +47,13 @@ function up(utils) { yield utils.queryInterface.dropTable('Requests'); { const applicationInstance = yield application_1.ApplicationModel.findOne(); - const accountCreated = yield user_1.createLocalAccountWithoutKeys({ + const accountCreated = yield (0, user_1.createLocalAccountWithoutKeys)({ name: constants_1.SERVER_ACTOR_NAME, userId: null, applicationId: applicationInstance.id, t: undefined }); - const { publicKey, privateKey } = yield peertube_crypto_1.createPrivateAndPublicKeys(); + const { publicKey, privateKey } = yield (0, peertube_crypto_1.createPrivateAndPublicKeys)(); accountCreated.Actor.publicKey = publicKey; accountCreated.Actor.privateKey = privateKey; yield accountCreated.save(); @@ -64,8 +64,8 @@ function up(utils) { } const users = yield db.User.findAll(); for (const user of users) { - const account = yield user_1.createLocalAccountWithoutKeys({ name: user.username, userId: user.id, applicationId: null, t: undefined }); - const { publicKey, privateKey } = yield peertube_crypto_1.createPrivateAndPublicKeys(); + const account = yield (0, user_1.createLocalAccountWithoutKeys)({ name: user.username, userId: user.id, applicationId: null, t: undefined }); + const { publicKey, privateKey } = yield (0, peertube_crypto_1.createPrivateAndPublicKeys)(); account.Actor.publicKey = publicKey; account.Actor.privateKey = privateKey; yield account.save(); @@ -100,7 +100,7 @@ function up(utils) { yield q.addColumn('Videos', 'url', data); const videos = yield db.Video.findAll(); for (const video of videos) { - video.url = url_1.getLocalVideoActivityPubUrl(video); + video.url = (0, url_1.getLocalVideoActivityPubUrl)(video); yield video.save(); } data.allowNull = false; @@ -115,7 +115,7 @@ function up(utils) { yield q.addColumn('VideoChannels', 'url', data); const videoChannels = yield db.VideoChannel.findAll(); for (const videoChannel of videoChannels) { - videoChannel.url = url_1.getLocalVideoChannelActivityPubUrl(videoChannel); + videoChannel.url = (0, url_1.getLocalVideoChannelActivityPubUrl)(videoChannel); yield videoChannel.save(); } data.allowNull = false; @@ -158,7 +158,7 @@ function up(utils) { ] }); for (const video of videos) { - yield share_1.shareVideoByServerAndChannel(video, undefined); + yield (0, share_1.shareVideoByServerAndChannel)(video, undefined); } } }); diff --git a/dist/server/initializers/migrations/0105-server-mail.js b/dist/server/initializers/migrations/0105-server-mail.js index e57b71b5..3c886c80 100644 --- a/dist/server/initializers/migrations/0105-server-mail.js +++ b/dist/server/initializers/migrations/0105-server-mail.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeColumn('Servers', 'email'); }); } diff --git a/dist/server/initializers/migrations/0110-server-key.js b/dist/server/initializers/migrations/0110-server-key.js index 5c51bcde..bd79061c 100644 --- a/dist/server/initializers/migrations/0110-server-key.js +++ b/dist/server/initializers/migrations/0110-server-key.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeColumn('Servers', 'publicKey'); }); } diff --git a/dist/server/initializers/migrations/0115-account-avatar.js b/dist/server/initializers/migrations/0115-account-avatar.js index ac0855aa..c032785d 100644 --- a/dist/server/initializers/migrations/0115-account-avatar.js +++ b/dist/server/initializers/migrations/0115-account-avatar.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.db.Avatar.sync(); const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0120-video-null.js b/dist/server/initializers/migrations/0120-video-null.js index 5a236ed8..87654486 100644 --- a/dist/server/initializers/migrations/0120-video-null.js +++ b/dist/server/initializers/migrations/0120-video-null.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0125-table-lowercase.js b/dist/server/initializers/migrations/0125-table-lowercase.js index 1dafefbf..399d435a 100644 --- a/dist/server/initializers/migrations/0125-table-lowercase.js +++ b/dist/server/initializers/migrations/0125-table-lowercase.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.renameTable('Applications', 'application'); yield utils.queryInterface.renameTable('AccountFollows', 'accountFollow'); yield utils.queryInterface.renameTable('AccountVideoRates', 'accountVideoRate'); diff --git a/dist/server/initializers/migrations/0130-user-autoplay-video.js b/dist/server/initializers/migrations/0130-user-autoplay-video.js index 6effebdd..46f91c89 100644 --- a/dist/server/initializers/migrations/0130-user-autoplay-video.js +++ b/dist/server/initializers/migrations/0130-user-autoplay-video.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrations/0135-video-channel-actor.js b/dist/server/initializers/migrations/0135-video-channel-actor.js index 212a85db..e7f9867e 100644 --- a/dist/server/initializers/migrations/0135-video-channel-actor.js +++ b/dist/server/initializers/migrations/0135-video-channel-actor.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const sequelize_typescript_1 = require("sequelize-typescript"); const peertube_crypto_1 = require("../../helpers/peertube-crypto"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const queries = [ `DROP TYPE IF EXISTS enum_actor_type`, @@ -215,7 +215,7 @@ function up(utils) { const options = { type: Sequelize.QueryTypes.SELECT }; const [res] = yield utils.sequelize.query(query, options); for (const actor of res) { - const { privateKey, publicKey } = yield peertube_crypto_1.createPrivateAndPublicKeys(); + const { privateKey, publicKey } = yield (0, peertube_crypto_1.createPrivateAndPublicKeys)(); const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}`; yield utils.sequelize.query(queryUpdate); } diff --git a/dist/server/initializers/migrations/0140-actor-url.js b/dist/server/initializers/migrations/0140-actor-url.js index ae7bd4f8..43538c36 100644 --- a/dist/server/initializers/migrations/0140-actor-url.js +++ b/dist/server/initializers/migrations/0140-actor-url.js @@ -4,7 +4,7 @@ exports.down = exports.up = void 0; const tslib_1 = require("tslib"); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const toReplace = constants_1.WEBSERVER.HOSTNAME + ':443'; const by = constants_1.WEBSERVER.HOST; const replacer = column => `replace("${column}", '${toReplace}', '${by}')`; diff --git a/dist/server/initializers/migrations/0145-delete-author.js b/dist/server/initializers/migrations/0145-delete-author.js index 4cc6fbcf..68ed48cd 100644 --- a/dist/server/initializers/migrations/0145-delete-author.js +++ b/dist/server/initializers/migrations/0145-delete-author.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.dropTable('Authors'); }); } diff --git a/dist/server/initializers/migrations/0150-avatar-cascade.js b/dist/server/initializers/migrations/0150-avatar-cascade.js index 2c6c61cb..5b77e035 100644 --- a/dist/server/initializers/migrations/0150-avatar-cascade.js +++ b/dist/server/initializers/migrations/0150-avatar-cascade.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey'); yield utils.queryInterface.addConstraint('actor', { fields: ['avatarId'], diff --git a/dist/server/initializers/migrations/0155-video-comments-enabled.js b/dist/server/initializers/migrations/0155-video-comments-enabled.js index 3d665a40..de454928 100644 --- a/dist/server/initializers/migrations/0155-video-comments-enabled.js +++ b/dist/server/initializers/migrations/0155-video-comments-enabled.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.BOOLEAN, allowNull: false, diff --git a/dist/server/initializers/migrations/0160-account-route.js b/dist/server/initializers/migrations/0160-account-route.js index 44d21ddb..683d0305 100644 --- a/dist/server/initializers/migrations/0160-account-route.js +++ b/dist/server/initializers/migrations/0160-account-route.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const toReplace = ':443'; const by = ''; diff --git a/dist/server/initializers/migrations/0165-video-route.js b/dist/server/initializers/migrations/0165-video-route.js index be404829..108e5b88 100644 --- a/dist/server/initializers/migrations/0165-video-route.js +++ b/dist/server/initializers/migrations/0165-video-route.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const toReplace = ':443'; const by = ''; diff --git a/dist/server/initializers/migrations/0170-actor-follow-score.js b/dist/server/initializers/migrations/0170-actor-follow-score.js index b7060708..f55fe623 100644 --- a/dist/server/initializers/migrations/0170-actor-follow-score.js +++ b/dist/server/initializers/migrations/0170-actor-follow-score.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeColumn('server', 'score'); const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0175-actor-follow-counts.js b/dist/server/initializers/migrations/0175-actor-follow-counts.js index 374e8641..89cb3682 100644 --- a/dist/server/initializers/migrations/0175-actor-follow-counts.js +++ b/dist/server/initializers/migrations/0175-actor-follow-counts.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = 'UPDATE "actor" SET ' + '"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' + '"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' + diff --git a/dist/server/initializers/migrations/0180-job-table-delete.js b/dist/server/initializers/migrations/0180-job-table-delete.js index 1e1f7b4b..f0c410b2 100644 --- a/dist/server/initializers/migrations/0180-job-table-delete.js +++ b/dist/server/initializers/migrations/0180-job-table-delete.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.dropTable('job'); }); } diff --git a/dist/server/initializers/migrations/0185-video-share-url.js b/dist/server/initializers/migrations/0185-video-share-url.js index f8fc1439..e5b3c800 100644 --- a/dist/server/initializers/migrations/0185-video-share-url.js +++ b/dist/server/initializers/migrations/0185-video-share-url.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "videoShare" s1 ' + 'USING (SELECT MIN(id) as id, "actorId", "videoId" FROM "videoShare" GROUP BY "actorId", "videoId" HAVING COUNT(*) > 1) s2 ' + diff --git a/dist/server/initializers/migrations/0190-video-comment-unique-url.js b/dist/server/initializers/migrations/0190-video-comment-unique-url.js index e92dd183..8e9911d7 100644 --- a/dist/server/initializers/migrations/0190-video-comment-unique-url.js +++ b/dist/server/initializers/migrations/0190-video-comment-unique-url.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "videoComment" s1 ' + 'USING (SELECT MIN(id) as id, url FROM "videoComment" GROUP BY "url" HAVING COUNT(*) > 1) s2 ' + diff --git a/dist/server/initializers/migrations/0195-support.js b/dist/server/initializers/migrations/0195-support.js index 4eecdb1d..ce495c41 100644 --- a/dist/server/initializers/migrations/0195-support.js +++ b/dist/server/initializers/migrations/0195-support.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(500), diff --git a/dist/server/initializers/migrations/0200-video-published-at.js b/dist/server/initializers/migrations/0200-video-published-at.js index 7a032408..0eaf0731 100644 --- a/dist/server/initializers/migrations/0200-video-published-at.js +++ b/dist/server/initializers/migrations/0200-video-published-at.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.DATE, diff --git a/dist/server/initializers/migrations/0205-user-nsfw-policy.js b/dist/server/initializers/migrations/0205-user-nsfw-policy.js index 5a14b918..469f3c20 100644 --- a/dist/server/initializers/migrations/0205-user-nsfw-policy.js +++ b/dist/server/initializers/migrations/0205-user-nsfw-policy.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.ENUM('do_not_list', 'blur', 'display'), diff --git a/dist/server/initializers/migrations/0210-video-language.js b/dist/server/initializers/migrations/0210-video-language.js index 11465dd1..228fd2c3 100644 --- a/dist/server/initializers/migrations/0210-video-language.js +++ b/dist/server/initializers/migrations/0210-video-language.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { yield utils.queryInterface.renameColumn('video', 'language', 'oldLanguage'); } diff --git a/dist/server/initializers/migrations/0215-video-support-length.js b/dist/server/initializers/migrations/0215-video-support-length.js index 39470d84..b0824f71 100644 --- a/dist/server/initializers/migrations/0215-video-support-length.js +++ b/dist/server/initializers/migrations/0215-video-support-length.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(500), diff --git a/dist/server/initializers/migrations/0220-video-state.js b/dist/server/initializers/migrations/0220-video-state.js index f51e67d1..9d57a45b 100644 --- a/dist/server/initializers/migrations/0220-video-state.js +++ b/dist/server/initializers/migrations/0220-video-state.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0225-video-fps.js b/dist/server/initializers/migrations/0225-video-fps.js index 9733ac6b..7a102dd9 100644 --- a/dist/server/initializers/migrations/0225-video-fps.js +++ b/dist/server/initializers/migrations/0225-video-fps.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0235-delete-some-video-indexes.js b/dist/server/initializers/migrations/0235-delete-some-video-indexes.js index fd3c01e0..40e5557e 100644 --- a/dist/server/initializers/migrations/0235-delete-some-video-indexes.js +++ b/dist/server/initializers/migrations/0235-delete-some-video-indexes.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;'); yield utils.sequelize.query('DROP INDEX IF EXISTS video_name;'); for (let i = 0; i < 5; i++) { diff --git a/dist/server/initializers/migrations/0240-drop-old-indexes.js b/dist/server/initializers/migrations/0240-drop-old-indexes.js index 66be8697..99a7b14a 100644 --- a/dist/server/initializers/migrations/0240-drop-old-indexes.js +++ b/dist/server/initializers/migrations/0240-drop-old-indexes.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const indexNames = [ 'accounts_application_id', 'accounts_user_id', diff --git a/dist/server/initializers/migrations/0245-user-blocked.js b/dist/server/initializers/migrations/0245-user-blocked.js index 6c4b9ffb..141c469b 100644 --- a/dist/server/initializers/migrations/0245-user-blocked.js +++ b/dist/server/initializers/migrations/0245-user-blocked.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0250-video-abuse-state.js b/dist/server/initializers/migrations/0250-video-abuse-state.js index eb7bbeec..fa603a06 100644 --- a/dist/server/initializers/migrations/0250-video-abuse-state.js +++ b/dist/server/initializers/migrations/0250-video-abuse-state.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0255-video-blacklist-reason.js b/dist/server/initializers/migrations/0255-video-blacklist-reason.js index 1578392a..79717a92 100644 --- a/dist/server/initializers/migrations/0255-video-blacklist-reason.js +++ b/dist/server/initializers/migrations/0255-video-blacklist-reason.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(300), diff --git a/dist/server/initializers/migrations/0260-upload-quota-daily.js b/dist/server/initializers/migrations/0260-upload-quota-daily.js index c7a7d40d..7b3a2f4e 100644 --- a/dist/server/initializers/migrations/0260-upload-quota-daily.js +++ b/dist/server/initializers/migrations/0260-upload-quota-daily.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BIGINT, diff --git a/dist/server/initializers/migrations/0265-user-email-verified.js b/dist/server/initializers/migrations/0265-user-email-verified.js index 529d06e6..3ff6d186 100644 --- a/dist/server/initializers/migrations/0265-user-email-verified.js +++ b/dist/server/initializers/migrations/0265-user-email-verified.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0270-server-redundancy.js b/dist/server/initializers/migrations/0270-server-redundancy.js index 6a592f23..4392c094 100644 --- a/dist/server/initializers/migrations/0270-server-redundancy.js +++ b/dist/server/initializers/migrations/0270-server-redundancy.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0275-video-file-unique.js b/dist/server/initializers/migrations/0275-video-file-unique.js index af887fb0..d7236795 100644 --- a/dist/server/initializers/migrations/0275-video-file-unique.js +++ b/dist/server/initializers/migrations/0275-video-file-unique.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "server" s1 USING "server" s2 WHERE s1.id < s2.id AND s1."host" = s2."host"'; yield utils.sequelize.query(query); diff --git a/dist/server/initializers/migrations/0280-webtorrent-policy-user.js b/dist/server/initializers/migrations/0280-webtorrent-policy-user.js index 339ef5d0..59b1303b 100644 --- a/dist/server/initializers/migrations/0280-webtorrent-policy-user.js +++ b/dist/server/initializers/migrations/0280-webtorrent-policy-user.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, @@ -17,7 +17,7 @@ function up(utils) { } exports.up = up; function down(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeColumn('user', 'webTorrentEnabled'); }); } diff --git a/dist/server/initializers/migrations/0285-description-support.js b/dist/server/initializers/migrations/0285-description-support.js index f6be74d8..01671409 100644 --- a/dist/server/initializers/migrations/0285-description-support.js +++ b/dist/server/initializers/migrations/0285-description-support.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(1000), diff --git a/dist/server/initializers/migrations/0290-account-video-rate-url.js b/dist/server/initializers/migrations/0290-account-video-rate-url.js index 2f8e9382..01996a73 100644 --- a/dist/server/initializers/migrations/0290-account-video-rate-url.js +++ b/dist/server/initializers/migrations/0290-account-video-rate-url.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(2000), diff --git a/dist/server/initializers/migrations/0295-video-file-extname.js b/dist/server/initializers/migrations/0295-video-file-extname.js index 944c25fc..a5efef1e 100644 --- a/dist/server/initializers/migrations/0295-video-file-extname.js +++ b/dist/server/initializers/migrations/0295-video-file-extname.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { yield utils.queryInterface.renameColumn('videoFile', 'extname', 'extname_old'); } diff --git a/dist/server/initializers/migrations/0300-user-videos-history-enabled.js b/dist/server/initializers/migrations/0300-user-videos-history-enabled.js index 3d21569a..46978414 100644 --- a/dist/server/initializers/migrations/0300-user-videos-history-enabled.js +++ b/dist/server/initializers/migrations/0300-user-videos-history-enabled.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0305-fix-unfederated-videos.js b/dist/server/initializers/migrations/0305-fix-unfederated-videos.js index dfcba847..17f41246 100644 --- a/dist/server/initializers/migrations/0305-fix-unfederated-videos.js +++ b/dist/server/initializers/migrations/0305-fix-unfederated-videos.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` + `(` + diff --git a/dist/server/initializers/migrations/0310-drop-unused-video-indexes.js b/dist/server/initializers/migrations/0310-drop-unused-video-indexes.js index 49d00482..a9e18b8d 100644 --- a/dist/server/initializers/migrations/0310-drop-unused-video-indexes.js +++ b/dist/server/initializers/migrations/0310-drop-unused-video-indexes.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const indexNames = [ 'video_category', 'video_licence', diff --git a/dist/server/initializers/migrations/0315-user-notifications.js b/dist/server/initializers/migrations/0315-user-notifications.js index fa925a01..41070649 100644 --- a/dist/server/initializers/migrations/0315-user-notifications.js +++ b/dist/server/initializers/migrations/0315-user-notifications.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL, diff --git a/dist/server/initializers/migrations/0320-blacklist-unfederate.js b/dist/server/initializers/migrations/0320-blacklist-unfederate.js index 2920d9bc..fb8b76cb 100644 --- a/dist/server/initializers/migrations/0320-blacklist-unfederate.js +++ b/dist/server/initializers/migrations/0320-blacklist-unfederate.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0325-video-abuse-fields.js b/dist/server/initializers/migrations/0325-video-abuse-fields.js index 3fc2c37d..e0953a54 100644 --- a/dist/server/initializers/migrations/0325-video-abuse-fields.js +++ b/dist/server/initializers/migrations/0325-video-abuse-fields.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(3000), diff --git a/dist/server/initializers/migrations/0330-video-streaming-playlist.js b/dist/server/initializers/migrations/0330-video-streaming-playlist.js index c02a4cb8..0df60659 100644 --- a/dist/server/initializers/migrations/0330-video-streaming-playlist.js +++ b/dist/server/initializers/migrations/0330-video-streaming-playlist.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist" diff --git a/dist/server/initializers/migrations/0335-video-downloading-enabled.js b/dist/server/initializers/migrations/0335-video-downloading-enabled.js index c7312a45..4cfe8f46 100644 --- a/dist/server/initializers/migrations/0335-video-downloading-enabled.js +++ b/dist/server/initializers/migrations/0335-video-downloading-enabled.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.BOOLEAN, allowNull: false, diff --git a/dist/server/initializers/migrations/0340-add-originally-published-at.js b/dist/server/initializers/migrations/0340-add-originally-published-at.js index 4c6ad520..59726e32 100644 --- a/dist/server/initializers/migrations/0340-add-originally-published-at.js +++ b/dist/server/initializers/migrations/0340-add-originally-published-at.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.DATE, allowNull: true, diff --git a/dist/server/initializers/migrations/0345-video-playlists.js b/dist/server/initializers/migrations/0345-video-playlists.js index 7751d897..a51af300 100644 --- a/dist/server/initializers/migrations/0345-video-playlists.js +++ b/dist/server/initializers/migrations/0345-video-playlists.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const uuid_1 = require("@server/helpers/uuid"); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const transaction = utils.transaction; { const query = ` @@ -50,7 +50,7 @@ CREATE TABLE IF NOT EXISTS "videoPlaylistElement" const userResult = yield utils.sequelize.query(userQuery, options); const usernames = userResult.map(r => r.username); for (const username of usernames) { - const uuid = uuid_1.buildUUID(); + const uuid = (0, uuid_1.buildUUID)(); const baseUrl = constants_1.WEBSERVER.URL + '/video-playlists/' + uuid; const query = ` INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt") diff --git a/dist/server/initializers/migrations/0350-video-blacklist-type.js b/dist/server/initializers/migrations/0350-video-blacklist-type.js index b587fc21..7bf692bf 100644 --- a/dist/server/initializers/migrations/0350-video-blacklist-type.js +++ b/dist/server/initializers/migrations/0350-video-blacklist-type.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0355-p2p-peer-version.js b/dist/server/initializers/migrations/0355-p2p-peer-version.js index 7dbc8e0a..112b3d62 100644 --- a/dist/server/initializers/migrations/0355-p2p-peer-version.js +++ b/dist/server/initializers/migrations/0355-p2p-peer-version.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0360-notification-instance-follower.js b/dist/server/initializers/migrations/0360-notification-instance-follower.js index ad0c31fa..1f03cd8a 100644 --- a/dist/server/initializers/migrations/0360-notification-instance-follower.js +++ b/dist/server/initializers/migrations/0360-notification-instance-follower.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0365-user-admin-flags.js b/dist/server/initializers/migrations/0365-user-admin-flags.js index f2734d24..da764f0d 100644 --- a/dist/server/initializers/migrations/0365-user-admin-flags.js +++ b/dist/server/initializers/migrations/0365-user-admin-flags.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0370-thumbnail.js b/dist/server/initializers/migrations/0370-thumbnail.js index 71164dab..92ab1158 100644 --- a/dist/server/initializers/migrations/0370-thumbnail.js +++ b/dist/server/initializers/migrations/0370-thumbnail.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "thumbnail" diff --git a/dist/server/initializers/migrations/0375-account-description.js b/dist/server/initializers/migrations/0375-account-description.js index a060ff56..4b089af9 100644 --- a/dist/server/initializers/migrations/0375-account-description.js +++ b/dist/server/initializers/migrations/0375-account-description.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.STRING(1000), allowNull: true, diff --git a/dist/server/initializers/migrations/0380-cleanup-timestamps.js b/dist/server/initializers/migrations/0380-cleanup-timestamps.js index 32a6651d..80e66e66 100644 --- a/dist/server/initializers/migrations/0380-cleanup-timestamps.js +++ b/dist/server/initializers/migrations/0380-cleanup-timestamps.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield utils.queryInterface.removeColumn('application', 'createdAt'); } diff --git a/dist/server/initializers/migrations/0385-remove-actor-uuid.js b/dist/server/initializers/migrations/0385-remove-actor-uuid.js index 086c6fe4..86a7a5fa 100644 --- a/dist/server/initializers/migrations/0385-remove-actor-uuid.js +++ b/dist/server/initializers/migrations/0385-remove-actor-uuid.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.removeColumn('actor', 'uuid'); }); } diff --git a/dist/server/initializers/migrations/0390-user-pending-email.js b/dist/server/initializers/migrations/0390-user-pending-email.js index d0d59945..fce66911 100644 --- a/dist/server/initializers/migrations/0390-user-pending-email.js +++ b/dist/server/initializers/migrations/0390-user-pending-email.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.STRING(400), allowNull: true, diff --git a/dist/server/initializers/migrations/0395-user-video-languages.js b/dist/server/initializers/migrations/0395-user-video-languages.js index e2600c2d..9e764082 100644 --- a/dist/server/initializers/migrations/0395-user-video-languages.js +++ b/dist/server/initializers/migrations/0395-user-video-languages.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.ARRAY(Sequelize.STRING), allowNull: true, diff --git a/dist/server/initializers/migrations/0400-user-theme.js b/dist/server/initializers/migrations/0400-user-theme.js index 3eb185ce..f0d026c9 100644 --- a/dist/server/initializers/migrations/0400-user-theme.js +++ b/dist/server/initializers/migrations/0400-user-theme.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.STRING, allowNull: false, diff --git a/dist/server/initializers/migrations/0405-plugin.js b/dist/server/initializers/migrations/0405-plugin.js index 037a7ca0..ecbac48a 100644 --- a/dist/server/initializers/migrations/0405-plugin.js +++ b/dist/server/initializers/migrations/0405-plugin.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "plugin" diff --git a/dist/server/initializers/migrations/0410-video-playlist-element.js b/dist/server/initializers/migrations/0410-video-playlist-element.js index b920a955..b63324fd 100644 --- a/dist/server/initializers/migrations/0410-video-playlist-element.js +++ b/dist/server/initializers/migrations/0410-video-playlist-element.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0415-thumbnail-auto-generated.js b/dist/server/initializers/migrations/0415-thumbnail-auto-generated.js index a17f7263..9df92f6e 100644 --- a/dist/server/initializers/migrations/0415-thumbnail-auto-generated.js +++ b/dist/server/initializers/migrations/0415-thumbnail-auto-generated.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0420-avatar-lazy.js b/dist/server/initializers/migrations/0420-avatar-lazy.js index 65099562..15051968 100644 --- a/dist/server/initializers/migrations/0420-avatar-lazy.js +++ b/dist/server/initializers/migrations/0420-avatar-lazy.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "avatar" s1 ' + 'USING (SELECT MIN(id) as id, filename FROM "avatar" GROUP BY "filename" HAVING COUNT(*) > 1) s2 ' + diff --git a/dist/server/initializers/migrations/0425-nullable-actor-fields.js b/dist/server/initializers/migrations/0425-nullable-actor-fields.js index db8b33d6..af3fdd4f 100644 --- a/dist/server/initializers/migrations/0425-nullable-actor-fields.js +++ b/dist/server/initializers/migrations/0425-nullable-actor-fields.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = { type: Sequelize.STRING, allowNull: true diff --git a/dist/server/initializers/migrations/0430-auto-follow-notification-setting.js b/dist/server/initializers/migrations/0430-auto-follow-notification-setting.js index 590cf6cc..340a6bcf 100644 --- a/dist/server/initializers/migrations/0430-auto-follow-notification-setting.js +++ b/dist/server/initializers/migrations/0430-auto-follow-notification-setting.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0435-user-modals.js b/dist/server/initializers/migrations/0435-user-modals.js index f4dcb2ad..67d3c5f8 100644 --- a/dist/server/initializers/migrations/0435-user-modals.js +++ b/dist/server/initializers/migrations/0435-user-modals.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0440-user-auto-play-next-video.js b/dist/server/initializers/migrations/0440-user-auto-play-next-video.js index 60add361..24e284d7 100644 --- a/dist/server/initializers/migrations/0440-user-auto-play-next-video.js +++ b/dist/server/initializers/migrations/0440-user-auto-play-next-video.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0445-shared-inbox-optional.js b/dist/server/initializers/migrations/0445-shared-inbox-optional.js index 7be65b84..a85dab8a 100644 --- a/dist/server/initializers/migrations/0445-shared-inbox-optional.js +++ b/dist/server/initializers/migrations/0445-shared-inbox-optional.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0450-streaming-playlist-files.js b/dist/server/initializers/migrations/0450-streaming-playlist-files.js index e9ac466f..d225050e 100644 --- a/dist/server/initializers/migrations/0450-streaming-playlist-files.js +++ b/dist/server/initializers/migrations/0450-streaming-playlist-files.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0455-soft-delete-video-comments.js b/dist/server/initializers/migrations/0455-soft-delete-video-comments.js index 49125d89..f8f344d3 100644 --- a/dist/server/initializers/migrations/0455-soft-delete-video-comments.js +++ b/dist/server/initializers/migrations/0455-soft-delete-video-comments.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0460-user-playlist-autoplay.js b/dist/server/initializers/migrations/0460-user-playlist-autoplay.js index 8b204446..f05f6488 100644 --- a/dist/server/initializers/migrations/0460-user-playlist-autoplay.js +++ b/dist/server/initializers/migrations/0460-user-playlist-autoplay.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0465-thumbnail-file-url-length.js b/dist/server/initializers/migrations/0465-thumbnail-file-url-length.js index e38cd976..e4b0eb25 100644 --- a/dist/server/initializers/migrations/0465-thumbnail-file-url-length.js +++ b/dist/server/initializers/migrations/0465-thumbnail-file-url-length.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(2000), diff --git a/dist/server/initializers/migrations/0470-cleanup-indexes.js b/dist/server/initializers/migrations/0470-cleanup-indexes.js index 9c9a2701..d6300ece 100644 --- a/dist/server/initializers/migrations/0470-cleanup-indexes.js +++ b/dist/server/initializers/migrations/0470-cleanup-indexes.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.sequelize.query('DROP INDEX IF EXISTS video_share_account_id;'); yield utils.sequelize.query('DROP INDEX IF EXISTS video_published_at;'); yield utils.sequelize.query('ALTER TABLE "avatar" DROP COLUMN IF EXISTS "avatarId"'); diff --git a/dist/server/initializers/migrations/0475-redundancy-expires-on.js b/dist/server/initializers/migrations/0475-redundancy-expires-on.js index 682536bd..e2a366c6 100644 --- a/dist/server/initializers/migrations/0475-redundancy-expires-on.js +++ b/dist/server/initializers/migrations/0475-redundancy-expires-on.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.DATE, diff --git a/dist/server/initializers/migrations/0480-caption-file-url.js b/dist/server/initializers/migrations/0480-caption-file-url.js index 15b89748..def4d184 100644 --- a/dist/server/initializers/migrations/0480-caption-file-url.js +++ b/dist/server/initializers/migrations/0480-caption-file-url.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0490-abuse-video.js b/dist/server/initializers/migrations/0490-abuse-video.js index 0b3d0ae5..cb6cb37b 100644 --- a/dist/server/initializers/migrations/0490-abuse-video.js +++ b/dist/server/initializers/migrations/0490-abuse-video.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const deletedVideo = { type: Sequelize.JSONB, allowNull: true diff --git a/dist/server/initializers/migrations/0495-plugin-auth.js b/dist/server/initializers/migrations/0495-plugin-auth.js index b4b2c7a2..2ffd22b4 100644 --- a/dist/server/initializers/migrations/0495-plugin-auth.js +++ b/dist/server/initializers/migrations/0495-plugin-auth.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const password = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0500-playlist-description-length.js b/dist/server/initializers/migrations/0500-playlist-description-length.js index 22fe88d9..85d4b871 100644 --- a/dist/server/initializers/migrations/0500-playlist-description-length.js +++ b/dist/server/initializers/migrations/0500-playlist-description-length.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const description = { type: Sequelize.STRING(1000), diff --git a/dist/server/initializers/migrations/0505-user-last-login-date.js b/dist/server/initializers/migrations/0505-user-last-login-date.js index 8f19ca4e..4a055bb7 100644 --- a/dist/server/initializers/migrations/0505-user-last-login-date.js +++ b/dist/server/initializers/migrations/0505-user-last-login-date.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const field = { type: Sequelize.DATE, diff --git a/dist/server/initializers/migrations/0510-video-file-metadata.js b/dist/server/initializers/migrations/0510-video-file-metadata.js index 11e314e6..1a4658d4 100644 --- a/dist/server/initializers/migrations/0510-video-file-metadata.js +++ b/dist/server/initializers/migrations/0510-video-file-metadata.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const tableDefinition = yield utils.queryInterface.describeTable('videoFile'); if (!tableDefinition['metadata']) { const metadata = { diff --git a/dist/server/initializers/migrations/0515-video-abuse-reason-timestamps.js b/dist/server/initializers/migrations/0515-video-abuse-reason-timestamps.js index a5d4ef3a..b4be6b34 100644 --- a/dist/server/initializers/migrations/0515-video-abuse-reason-timestamps.js +++ b/dist/server/initializers/migrations/0515-video-abuse-reason-timestamps.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.addColumn('videoAbuse', 'predefinedReasons', { type: Sequelize.ARRAY(Sequelize.INTEGER), allowNull: true diff --git a/dist/server/initializers/migrations/0520-abuses-split.js b/dist/server/initializers/migrations/0520-abuses-split.js index 7dbd49f6..8c60c16b 100644 --- a/dist/server/initializers/migrations/0520-abuses-split.js +++ b/dist/server/initializers/migrations/0520-abuses-split.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.queryInterface.renameTable('videoAbuse', 'abuse'); yield utils.sequelize.query(` ALTER TABLE "abuse" diff --git a/dist/server/initializers/migrations/0525-abuse-messages.js b/dist/server/initializers/migrations/0525-abuse-messages.js index 2bfc74e5..744bdf11 100644 --- a/dist/server/initializers/migrations/0525-abuse-messages.js +++ b/dist/server/initializers/migrations/0525-abuse-messages.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.sequelize.query(` CREATE TABLE IF NOT EXISTS "abuseMessage" ( "id" serial, diff --git a/dist/server/initializers/migrations/0530-playlist-multiple-video.js b/dist/server/initializers/migrations/0530-playlist-multiple-video.js index 48406475..61a20c54 100644 --- a/dist/server/initializers/migrations/0530-playlist-multiple-video.js +++ b/dist/server/initializers/migrations/0530-playlist-multiple-video.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const field = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0535-video-live.js b/dist/server/initializers/migrations/0535-video-live.js index 665aed16..d1a968b6 100644 --- a/dist/server/initializers/migrations/0535-video-live.js +++ b/dist/server/initializers/migrations/0535-video-live.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "videoLive" ( diff --git a/dist/server/initializers/migrations/0540-video-file-infohash.js b/dist/server/initializers/migrations/0540-video-file-infohash.js index 1b180fb4..81125e6f 100644 --- a/dist/server/initializers/migrations/0540-video-file-infohash.js +++ b/dist/server/initializers/migrations/0540-video-file-infohash.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0545-video-live-save-replay.js b/dist/server/initializers/migrations/0545-video-live-save-replay.js index d92e83fa..c4ec488a 100644 --- a/dist/server/initializers/migrations/0545-video-live-save-replay.js +++ b/dist/server/initializers/migrations/0545-video-live-save-replay.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0550-actor-follow-cleanup.js b/dist/server/initializers/migrations/0550-actor-follow-cleanup.js index 7379de90..a67bca61 100644 --- a/dist/server/initializers/migrations/0550-actor-follow-cleanup.js +++ b/dist/server/initializers/migrations/0550-actor-follow-cleanup.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = ` WITH t AS ( SELECT actor.id FROM actor diff --git a/dist/server/initializers/migrations/0555-actor-follow-url.js b/dist/server/initializers/migrations/0555-actor-follow-url.js index 867df33b..a61b92eb 100644 --- a/dist/server/initializers/migrations/0555-actor-follow-url.js +++ b/dist/server/initializers/migrations/0555-actor-follow-url.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING(2000), diff --git a/dist/server/initializers/migrations/0560-user-feed-token.js b/dist/server/initializers/migrations/0560-user-feed-token.js index 5211e1a8..3840f42e 100644 --- a/dist/server/initializers/migrations/0560-user-feed-token.js +++ b/dist/server/initializers/migrations/0560-user-feed-token.js @@ -2,10 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const uuid_1 = require("@server/helpers/uuid"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const q = utils.queryInterface; { const userFeedTokenUUID = { @@ -20,7 +20,7 @@ function up(utils) { const options = { type: Sequelize.QueryTypes.SELECT }; const users = yield utils.sequelize.query(query, options); for (const user of users) { - const queryUpdate = `UPDATE "user" SET "feedToken" = '${uuid_1.buildUUID()}' WHERE id = ${user.id}`; + const queryUpdate = `UPDATE "user" SET "feedToken" = '${(0, uuid_1.buildUUID)()}' WHERE id = ${user.id}`; yield utils.sequelize.query(queryUpdate); } } diff --git a/dist/server/initializers/migrations/0565-actor-follow-local-url.js b/dist/server/initializers/migrations/0565-actor-follow-local-url.js index bdbf681c..37b53fe7 100644 --- a/dist/server/initializers/migrations/0565-actor-follow-local-url.js +++ b/dist/server/initializers/migrations/0565-actor-follow-local-url.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` UPDATE "actorFollow" SET url = follower.url || '/follows/' || following.id diff --git a/dist/server/initializers/migrations/0570-permanent-live.js b/dist/server/initializers/migrations/0570-permanent-live.js index ef91bed0..808287be 100644 --- a/dist/server/initializers/migrations/0570-permanent-live.js +++ b/dist/server/initializers/migrations/0570-permanent-live.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0575-duplicate-thumbnail.js b/dist/server/initializers/migrations/0575-duplicate-thumbnail.js index c500ff35..46d14575 100644 --- a/dist/server/initializers/migrations/0575-duplicate-thumbnail.js +++ b/dist/server/initializers/migrations/0575-duplicate-thumbnail.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "thumbnail" s1 ' + 'USING (SELECT MIN(id) as id, "filename", "type" FROM "thumbnail" GROUP BY "filename", "type" HAVING COUNT(*) > 1) s2 ' + diff --git a/dist/server/initializers/migrations/0580-caption-filename.js b/dist/server/initializers/migrations/0580-caption-filename.js index 491c049d..4d561850 100644 --- a/dist/server/initializers/migrations/0580-caption-filename.js +++ b/dist/server/initializers/migrations/0580-caption-filename.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0585-video-file-names.js b/dist/server/initializers/migrations/0585-video-file-names.js index b9aabf59..7613e25f 100644 --- a/dist/server/initializers/migrations/0585-video-file-names.js +++ b/dist/server/initializers/migrations/0585-video-file-names.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const column of ['filename', 'fileUrl', 'torrentFilename', 'torrentUrl']) { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0590-trackers.js b/dist/server/initializers/migrations/0590-trackers.js index 5419b5b1..affbd894 100644 --- a/dist/server/initializers/migrations/0590-trackers.js +++ b/dist/server/initializers/migrations/0590-trackers.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = `CREATE TABLE IF NOT EXISTS "tracker" ( "id" serial, diff --git a/dist/server/initializers/migrations/0595-remote-url.js b/dist/server/initializers/migrations/0595-remote-url.js index 837847fc..fd2bee19 100644 --- a/dist/server/initializers/migrations/0595-remote-url.js +++ b/dist/server/initializers/migrations/0595-remote-url.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const fromQueryWebtorrent = `SELECT 'https://' || server.host AS "serverUrl", '/static/webseed/' AS "filePath", "videoFile".id ` + `FROM video ` + diff --git a/dist/server/initializers/migrations/0600-duplicate-video-files.js b/dist/server/initializers/migrations/0600-duplicate-video-files.js index c37937b6..e3822c8c 100644 --- a/dist/server/initializers/migrations/0600-duplicate-video-files.js +++ b/dist/server/initializers/migrations/0600-duplicate-video-files.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'DELETE FROM "videoFile" f1 ' + 'USING (SELECT MIN(id) as id, "torrentFilename" FROM "videoFile" GROUP BY "torrentFilename" HAVING COUNT(*) > 1) f2 ' + diff --git a/dist/server/initializers/migrations/0605-actor-missing-keys.js b/dist/server/initializers/migrations/0605-actor-missing-keys.js index c882889a..cc3187a1 100644 --- a/dist/server/initializers/migrations/0605-actor-missing-keys.js +++ b/dist/server/initializers/migrations/0605-actor-missing-keys.js @@ -2,18 +2,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); const core_utils_1 = require("../../helpers/core-utils"); const constants_1 = require("../constants"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL'; const options = { type: Sequelize.QueryTypes.SELECT }; const actors = yield utils.sequelize.query(query, options); for (const actor of actors) { - const { key } = yield core_utils_1.createPrivateKey(constants_1.PRIVATE_RSA_KEY_SIZE); - const { publicKey } = yield core_utils_1.getPublicKey(key); + const { key } = yield (0, core_utils_1.createPrivateKey)(constants_1.PRIVATE_RSA_KEY_SIZE); + const { publicKey } = yield (0, core_utils_1.getPublicKey)(key); const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${key}' WHERE id = ${actor.id}`; yield utils.sequelize.query(queryUpdate); } diff --git a/dist/server/initializers/migrations/0610-views-index copy.js b/dist/server/initializers/migrations/0610-views-index copy.js index e7c37fb1..d0a4f9c7 100644 --- a/dist/server/initializers/migrations/0610-views-index copy.js +++ b/dist/server/initializers/migrations/0610-views-index copy.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.sequelize.query('DROP INDEX IF EXISTS video_views;'); }); } diff --git a/dist/server/initializers/migrations/0612-captions-unique.js b/dist/server/initializers/migrations/0612-captions-unique.js index b724efec..5f18ae81 100644 --- a/dist/server/initializers/migrations/0612-captions-unique.js +++ b/dist/server/initializers/migrations/0612-captions-unique.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield utils.sequelize.query('DELETE FROM "videoCaption" v1 USING (SELECT MIN(id) as id, "filename" FROM "videoCaption" ' + 'GROUP BY "filename" HAVING COUNT(*) > 1) v2 WHERE v1."filename" = v2."filename" AND v1.id <> v2.id'); }); diff --git a/dist/server/initializers/migrations/0615-latest-versions-notification-settings.js b/dist/server/initializers/migrations/0615-latest-versions-notification-settings.js index 99dc4389..a34902b9 100644 --- a/dist/server/initializers/migrations/0615-latest-versions-notification-settings.js +++ b/dist/server/initializers/migrations/0615-latest-versions-notification-settings.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const notificationSettingColumns = ['newPeerTubeVersion', 'newPluginVersion']; for (const column of notificationSettingColumns) { diff --git a/dist/server/initializers/migrations/0620-latest-versions-application.js b/dist/server/initializers/migrations/0620-latest-versions-application.js index f5de1475..03a6fdaa 100644 --- a/dist/server/initializers/migrations/0620-latest-versions-application.js +++ b/dist/server/initializers/migrations/0620-latest-versions-application.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.STRING, diff --git a/dist/server/initializers/migrations/0625-latest-versions-notification.js b/dist/server/initializers/migrations/0625-latest-versions-notification.js index e70775a4..f93441d1 100644 --- a/dist/server/initializers/migrations/0625-latest-versions-notification.js +++ b/dist/server/initializers/migrations/0625-latest-versions-notification.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { yield utils.sequelize.query(` ALTER TABLE "userNotification" diff --git a/dist/server/initializers/migrations/0630-banner.js b/dist/server/initializers/migrations/0630-banner.js index 92eacc82..aeacea7d 100644 --- a/dist/server/initializers/migrations/0630-banner.js +++ b/dist/server/initializers/migrations/0630-banner.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { yield utils.sequelize.query(`ALTER TABLE "avatar" RENAME to "actorImage"`); } diff --git a/dist/server/initializers/migrations/0635-actor-image-size.js b/dist/server/initializers/migrations/0635-actor-image-size.js index 169c4cdd..143c29b5 100644 --- a/dist/server/initializers/migrations/0635-actor-image-size.js +++ b/dist/server/initializers/migrations/0635-actor-image-size.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0640-unique-keys.js b/dist/server/initializers/migrations/0640-unique-keys.js index a6cc019d..0858abd3 100644 --- a/dist/server/initializers/migrations/0640-unique-keys.js +++ b/dist/server/initializers/migrations/0640-unique-keys.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { yield utils.sequelize.query('DELETE FROM "actor" v1 USING (SELECT MIN(id) as id, "preferredUsername", "serverId" FROM "actor" ' + 'GROUP BY "preferredUsername", "serverId" HAVING COUNT(*) > 1 AND "serverId" IS NOT NULL) v2 ' + diff --git a/dist/server/initializers/migrations/0645-actor-remote-creation-date.js b/dist/server/initializers/migrations/0645-actor-remote-creation-date.js index 87e89b03..191c1d9f 100644 --- a/dist/server/initializers/migrations/0645-actor-remote-creation-date.js +++ b/dist/server/initializers/migrations/0645-actor-remote-creation-date.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.DATE, diff --git a/dist/server/initializers/migrations/0650-actor-custom-pages.js b/dist/server/initializers/migrations/0650-actor-custom-pages.js index a82bf77f..02cd4d2a 100644 --- a/dist/server/initializers/migrations/0650-actor-custom-pages.js +++ b/dist/server/initializers/migrations/0650-actor-custom-pages.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "actorCustomPage" ( diff --git a/dist/server/initializers/migrations/0655-streaming-playlist-filenames.js b/dist/server/initializers/migrations/0655-streaming-playlist-filenames.js index 96270693..1fea0e98 100644 --- a/dist/server/initializers/migrations/0655-streaming-playlist-filenames.js +++ b/dist/server/initializers/migrations/0655-streaming-playlist-filenames.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { for (const column of ['playlistUrl', 'segmentsSha256Url']) { const data = { diff --git a/dist/server/initializers/migrations/0660-object-storage.js b/dist/server/initializers/migrations/0660-object-storage.js index 11f4eeab..2aa45d3f 100644 --- a/dist/server/initializers/migrations/0660-object-storage.js +++ b/dist/server/initializers/migrations/0660-object-storage.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const query = ` CREATE TABLE IF NOT EXISTS "videoJobInfo" ( diff --git a/dist/server/initializers/migrations/0665-no-account-warning-modal.js b/dist/server/initializers/migrations/0665-no-account-warning-modal.js index 7a55245a..1b60e8cb 100644 --- a/dist/server/initializers/migrations/0665-no-account-warning-modal.js +++ b/dist/server/initializers/migrations/0665-no-account-warning-modal.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const data = { type: Sequelize.BOOLEAN, diff --git a/dist/server/initializers/migrations/0670-pending-job-default.js b/dist/server/initializers/migrations/0670-pending-job-default.js index f3b4bddc..54e91577 100644 --- a/dist/server/initializers/migrations/0670-pending-job-default.js +++ b/dist/server/initializers/migrations/0670-pending-job-default.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const column of ['pendingMove', 'pendingTranscode']) { const data = { type: Sequelize.INTEGER, diff --git a/dist/server/initializers/migrations/0671-video-size.js b/dist/server/initializers/migrations/0671-video-size.js index b3fd926e..27ee49be 100644 --- a/dist/server/initializers/migrations/0671-video-size.js +++ b/dist/server/initializers/migrations/0671-video-size.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.down = exports.up = void 0; const tslib_1 = require("tslib"); -const Sequelize = tslib_1.__importStar(require("sequelize")); +const Sequelize = (0, tslib_1.__importStar)(require("sequelize")); function up(utils) { const q = utils.queryInterface; const data = { diff --git a/dist/server/initializers/migrator.js b/dist/server/initializers/migrator.js index 2ac11d55..8963c2d9 100644 --- a/dist/server/initializers/migrator.js +++ b/dist/server/initializers/migrator.js @@ -10,7 +10,7 @@ const constants_1 = require("./constants"); const database_1 = require("./database"); function migrate() { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const tables = yield database_1.sequelizeTypescript.getQueryInterface().showAllTables(); if (tables.length === 0) return; @@ -45,8 +45,8 @@ function migrate() { } exports.migrate = migrate; function getMigrationScripts() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const files = yield fs_extra_1.readdir(path_1.join(__dirname, 'migrations')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const files = yield (0, fs_extra_1.readdir)((0, path_1.join)(__dirname, 'migrations')); const filesToMigrate = []; files .filter(file => file.endsWith('.js.map') === false) @@ -61,14 +61,14 @@ function getMigrationScripts() { }); } function executeMigration(actualVersion, entity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const versionScript = parseInt(entity.version, 10); if (versionScript <= actualVersion) return undefined; const migrationScriptName = entity.script; logger_1.logger.info('Executing %s migration script.', migrationScriptName); - const migrationScript = require(path_1.join(__dirname, 'migrations', migrationScriptName)); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const migrationScript = require((0, path_1.join)(__dirname, 'migrations', migrationScriptName)); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { transaction: t, queryInterface: database_1.sequelizeTypescript.getQueryInterface(), diff --git a/dist/server/lib/activitypub/actors/get.js b/dist/server/lib/activitypub/actors/get.js index 3dca307c..5e845207 100644 --- a/dist/server/lib/activitypub/actors/get.js +++ b/dist/server/lib/activitypub/actors/get.js @@ -10,13 +10,13 @@ const model_loaders_1 = require("@server/lib/model-loaders"); const refresh_1 = require("./refresh"); const shared_1 = require("./shared"); function getOrCreateAPActor(activityActor, fetchType = 'association-ids', recurseIfNeeded = true, updateCollections = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actorUrl = activitypub_1.getAPId(activityActor); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actorUrl = (0, activitypub_1.getAPId)(activityActor); let actor = yield loadActorFromDB(actorUrl, fetchType); let created = false; let accountPlaylistsUrl; if (!actor) { - const { actorObject } = yield shared_1.fetchRemoteActor(actorUrl); + const { actorObject } = yield (0, shared_1.fetchRemoteActor)(actorUrl); if (actorObject === undefined) throw new Error('Cannot fetch remote actor ' + actorUrl); if (actorObject.id !== actorUrl) @@ -26,7 +26,7 @@ function getOrCreateAPActor(activityActor, fetchType = 'association-ids', recurs ownerActor = yield getOrCreateAPOwner(actorObject, actorUrl); } const creator = new shared_1.APActorCreator(actorObject, ownerActor); - actor = yield database_utils_1.retryTransactionWrapper(creator.create.bind(creator)); + actor = yield (0, database_utils_1.retryTransactionWrapper)(creator.create.bind(creator)); created = true; accountPlaylistsUrl = actorObject.playlists; } @@ -34,7 +34,7 @@ function getOrCreateAPActor(activityActor, fetchType = 'association-ids', recurs actor.Account.Actor = actor; if (actor.VideoChannel) actor.VideoChannel.Actor = actor; - const { actor: actorRefreshed, refreshed } = yield refresh_1.refreshActorIfNeeded({ actor, fetchedType: fetchType }); + const { actor: actorRefreshed, refreshed } = yield (0, refresh_1.refreshActorIfNeeded)({ actor, fetchedType: fetchType }); if (!actorRefreshed) throw new Error('Actor ' + actor.url + ' does not exist anymore.'); yield scheduleOutboxFetchIfNeeded(actor, created, refreshed, updateCollections); @@ -44,8 +44,8 @@ function getOrCreateAPActor(activityActor, fetchType = 'association-ids', recurs } exports.getOrCreateAPActor = getOrCreateAPActor; function loadActorFromDB(actorUrl, fetchType) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - let actor = yield model_loaders_1.loadActorByUrl(actorUrl, fetchType); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + let actor = yield (0, model_loaders_1.loadActorByUrl)(actorUrl, fetchType); if (actor && (!actor.Account && !actor.VideoChannel)) { yield actor.destroy(); actor = null; @@ -57,7 +57,7 @@ function getOrCreateAPOwner(actorObject, actorUrl) { const accountAttributedTo = actorObject.attributedTo.find(a => a.type === 'Person'); if (!accountAttributedTo) throw new Error('Cannot find account attributed to video channel ' + actorUrl); - if (activitypub_1.checkUrlsSameHost(accountAttributedTo.id, actorUrl) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(accountAttributedTo.id, actorUrl) !== true) { throw new Error(`Account attributed to ${accountAttributedTo.id} does not have the same host than actor url ${actorUrl}`); } try { @@ -70,7 +70,7 @@ function getOrCreateAPOwner(actorObject, actorUrl) { } } function scheduleOutboxFetchIfNeeded(actor, created, refreshed, updateCollections) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if ((created === true || refreshed === true) && updateCollections === true) { const payload = { uri: actor.outboxUrl, type: 'activity' }; yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'activitypub-http-fetcher', payload }); @@ -78,7 +78,7 @@ function scheduleOutboxFetchIfNeeded(actor, created, refreshed, updateCollection }); } function schedulePlaylistFetchIfNeeded(actor, created, accountPlaylistsUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (created === true && actor.Account && accountPlaylistsUrl) { const payload = { uri: accountPlaylistsUrl, type: 'account-playlists' }; yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'activitypub-http-fetcher', payload }); diff --git a/dist/server/lib/activitypub/actors/image.js b/dist/server/lib/activitypub/actors/image.js index 8ea2ef49..a6817127 100644 --- a/dist/server/lib/activitypub/actors/image.js +++ b/dist/server/lib/activitypub/actors/image.js @@ -6,7 +6,7 @@ const logger_1 = require("@server/helpers/logger"); const actor_image_1 = require("@server/models/actor/actor-image"); function updateActorImageInstance(actor, type, imageInfo, t) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldImageModel = type === 1 ? actor.Avatar : actor.Banner; @@ -37,7 +37,7 @@ function updateActorImageInstance(actor, type, imageInfo, t) { } exports.updateActorImageInstance = updateActorImageInstance; function deleteActorImageInstance(actor, type, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { if (type === 1) { yield actor.Avatar.destroy({ transaction: t }); diff --git a/dist/server/lib/activitypub/actors/index.js b/dist/server/lib/activitypub/actors/index.js index 2491fad1..0db1b98d 100644 --- a/dist/server/lib/activitypub/actors/index.js +++ b/dist/server/lib/activitypub/actors/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./get"), exports); -tslib_1.__exportStar(require("./image"), exports); -tslib_1.__exportStar(require("./keys"), exports); -tslib_1.__exportStar(require("./refresh"), exports); -tslib_1.__exportStar(require("./updater"), exports); -tslib_1.__exportStar(require("./webfinger"), exports); +(0, tslib_1.__exportStar)(require("./get"), exports); +(0, tslib_1.__exportStar)(require("./image"), exports); +(0, tslib_1.__exportStar)(require("./keys"), exports); +(0, tslib_1.__exportStar)(require("./refresh"), exports); +(0, tslib_1.__exportStar)(require("./updater"), exports); +(0, tslib_1.__exportStar)(require("./webfinger"), exports); diff --git a/dist/server/lib/activitypub/actors/keys.js b/dist/server/lib/activitypub/actors/keys.js index eacfdc1c..ddba3c61 100644 --- a/dist/server/lib/activitypub/actors/keys.js +++ b/dist/server/lib/activitypub/actors/keys.js @@ -4,8 +4,8 @@ exports.generateAndSaveActorKeys = void 0; const tslib_1 = require("tslib"); const peertube_crypto_1 = require("@server/helpers/peertube-crypto"); function generateAndSaveActorKeys(actor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { publicKey, privateKey } = yield peertube_crypto_1.createPrivateAndPublicKeys(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { publicKey, privateKey } = yield (0, peertube_crypto_1.createPrivateAndPublicKeys)(); actor.publicKey = publicKey; actor.privateKey = privateKey; return actor.save(); diff --git a/dist/server/lib/activitypub/actors/refresh.js b/dist/server/lib/activitypub/actors/refresh.js index ca195a13..70678591 100644 --- a/dist/server/lib/activitypub/actors/refresh.js +++ b/dist/server/lib/activitypub/actors/refresh.js @@ -18,16 +18,16 @@ function refreshActorIfNeeded(options) { } exports.refreshActorIfNeeded = refreshActorIfNeeded; function doRefresh(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { actor: actorArg, fetchedType } = options; const actor = fetchedType === 'all' ? actorArg : yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(actorArg.url); - const lTags = logger_1.loggerTagsFactory('ap', 'actor', 'refresh', actor.url); + const lTags = (0, logger_1.loggerTagsFactory)('ap', 'actor', 'refresh', actor.url); logger_1.logger.info('Refreshing actor %s.', actor.url, lTags()); try { const actorUrl = yield getActorUrl(actor); - const { actorObject } = yield shared_1.fetchRemoteActor(actorUrl); + const { actorObject } = yield (0, shared_1.fetchRemoteActor)(actorUrl); if (actorObject === undefined) { logger_1.logger.warn('Cannot fetch remote actor in refresh actor.'); return { actor, refreshed: false }; @@ -50,7 +50,7 @@ function doRefresh(options) { }); } function getActorUrl(actor) { - return webfinger_1.getUrlFromWebfinger(actor.preferredUsername + '@' + actor.getHost()) + return (0, webfinger_1.getUrlFromWebfinger)(actor.preferredUsername + '@' + actor.getHost()) .catch(err => { logger_1.logger.warn('Cannot get actor URL from webfinger, keeping the old one.', err); return actor.url; diff --git a/dist/server/lib/activitypub/actors/shared/creator.js b/dist/server/lib/activitypub/actors/shared/creator.js index e70fbf68..1dfee578 100644 --- a/dist/server/lib/activitypub/actors/shared/creator.js +++ b/dist/server/lib/activitypub/actors/shared/creator.js @@ -17,10 +17,10 @@ class APActorCreator { this.ownerActor = ownerActor; } create() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { followersCount, followingCount } = yield url_to_object_1.fetchActorFollowsCount(this.actorObject); - const actorInstance = new actor_1.ActorModel(object_to_model_attributes_1.getActorAttributesFromObject(this.actorObject, followersCount, followingCount)); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { followersCount, followingCount } = yield (0, url_to_object_1.fetchActorFollowsCount)(this.actorObject); + const actorInstance = new actor_1.ActorModel((0, object_to_model_attributes_1.getActorAttributesFromObject)(this.actorObject, followersCount, followingCount)); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = yield this.setServer(actorInstance, t); yield this.setImageIfNeeded(actorInstance, 1, t); yield this.setImageIfNeeded(actorInstance, 2, t); @@ -40,7 +40,7 @@ class APActorCreator { }); } setServer(actor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actorHost = new URL(actor.url).host; const serverOptions = { where: { @@ -57,15 +57,15 @@ class APActorCreator { }); } setImageIfNeeded(actor, type, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const imageInfo = object_to_model_attributes_1.getImageInfoFromObject(this.actorObject, type); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const imageInfo = (0, object_to_model_attributes_1.getImageInfoFromObject)(this.actorObject, type); if (!imageInfo) return; - return image_1.updateActorImageInstance(actor, type, imageInfo, t); + return (0, image_1.updateActorImageInstance)(actor, type, imageInfo, t); }); } saveActor(actor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [actorCreated, created] = yield actor_1.ActorModel.findOrCreate({ defaults: actor.toJSON(), where: { @@ -85,7 +85,7 @@ class APActorCreator { }); } tryToFixActorUrlIfNeeded(actorCreated, newActor, created, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (created !== true && actorCreated.url !== newActor.url) { if (actorCreated.url.replace(/^http:\/\//, '') !== newActor.url.replace(/^https:\/\//, '')) { throw new Error(`Actor from DB with URL ${actorCreated.url} does not correspond to actor ${newActor.url}`); @@ -96,10 +96,10 @@ class APActorCreator { }); } saveAccount(actor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [accountCreated] = yield account_1.AccountModel.findOrCreate({ defaults: { - name: object_to_model_attributes_1.getActorDisplayNameFromObject(this.actorObject), + name: (0, object_to_model_attributes_1.getActorDisplayNameFromObject)(this.actorObject), description: this.actorObject.summary, actorId: actor.id }, @@ -112,10 +112,10 @@ class APActorCreator { }); } saveVideoChannel(actor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [videoChannelCreated] = yield video_channel_1.VideoChannelModel.findOrCreate({ defaults: { - name: object_to_model_attributes_1.getActorDisplayNameFromObject(this.actorObject), + name: (0, object_to_model_attributes_1.getActorDisplayNameFromObject)(this.actorObject), description: this.actorObject.summary, support: this.actorObject.support, actorId: actor.id, diff --git a/dist/server/lib/activitypub/actors/shared/index.js b/dist/server/lib/activitypub/actors/shared/index.js index f642291a..628b6419 100644 --- a/dist/server/lib/activitypub/actors/shared/index.js +++ b/dist/server/lib/activitypub/actors/shared/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./creator"), exports); -tslib_1.__exportStar(require("./object-to-model-attributes"), exports); -tslib_1.__exportStar(require("./url-to-object"), exports); +(0, tslib_1.__exportStar)(require("./creator"), exports); +(0, tslib_1.__exportStar)(require("./object-to-model-attributes"), exports); +(0, tslib_1.__exportStar)(require("./url-to-object"), exports); diff --git a/dist/server/lib/activitypub/actors/shared/object-to-model-attributes.js b/dist/server/lib/activitypub/actors/shared/object-to-model-attributes.js index 5888c431..defbe1b0 100644 --- a/dist/server/lib/activitypub/actors/shared/object-to-model-attributes.js +++ b/dist/server/lib/activitypub/actors/shared/object-to-model-attributes.js @@ -30,21 +30,21 @@ function getImageInfoFromObject(actorObject, type) { const icon = type === 1 ? actorObject.icon : actorObject.image; - if (!icon || icon.type !== 'Image' || !misc_1.isActivityPubUrlValid(icon.url)) + if (!icon || icon.type !== 'Image' || !(0, misc_1.isActivityPubUrlValid)(icon.url)) return undefined; let extension; if (icon.mediaType) { extension = mimetypes.MIMETYPE_EXT[icon.mediaType]; } else { - const tmp = core_utils_1.getLowercaseExtension(icon.url); + const tmp = (0, core_utils_1.getLowercaseExtension)(icon.url); if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp; } if (!extension) return undefined; return { - name: uuid_1.buildUUID() + extension, + name: (0, uuid_1.buildUUID)() + extension, fileUrl: icon.url, height: icon.height, width: icon.width, diff --git a/dist/server/lib/activitypub/actors/shared/url-to-object.js b/dist/server/lib/activitypub/actors/shared/url-to-object.js index 67568f79..2166e217 100644 --- a/dist/server/lib/activitypub/actors/shared/url-to-object.js +++ b/dist/server/lib/activitypub/actors/shared/url-to-object.js @@ -7,14 +7,14 @@ const actor_1 = require("@server/helpers/custom-validators/activitypub/actor"); const logger_1 = require("@server/helpers/logger"); const requests_1 = require("@server/helpers/requests"); function fetchRemoteActor(actorUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Fetching remote actor %s.', actorUrl); - const { body, statusCode } = yield requests_1.doJSONRequest(actorUrl, { activityPub: true }); - if (actor_1.sanitizeAndCheckActorObject(body) === false) { + const { body, statusCode } = yield (0, requests_1.doJSONRequest)(actorUrl, { activityPub: true }); + if ((0, actor_1.sanitizeAndCheckActorObject)(body) === false) { logger_1.logger.debug('Remote actor JSON is not valid.', { actorJSON: body }); return { actorObject: undefined, statusCode: statusCode }; } - if (activitypub_1.checkUrlsSameHost(body.id, actorUrl) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(body.id, actorUrl) !== true) { logger_1.logger.warn('Actor url %s has not the same host than its AP id %s', actorUrl, body.id); return { actorObject: undefined, statusCode: statusCode }; } @@ -26,7 +26,7 @@ function fetchRemoteActor(actorUrl) { } exports.fetchRemoteActor = fetchRemoteActor; function fetchActorFollowsCount(actorObject) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const followersCount = yield fetchActorTotalItems(actorObject.followers); const followingCount = yield fetchActorTotalItems(actorObject.following); return { followersCount, followingCount }; @@ -34,9 +34,9 @@ function fetchActorFollowsCount(actorObject) { } exports.fetchActorFollowsCount = fetchActorFollowsCount; function fetchActorTotalItems(url) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - const { body } = yield requests_1.doJSONRequest(url, { activityPub: true }); + const { body } = yield (0, requests_1.doJSONRequest)(url, { activityPub: true }); return body.totalItems || 0; } catch (err) { diff --git a/dist/server/lib/activitypub/actors/updater.js b/dist/server/lib/activitypub/actors/updater.js index a08978ae..ce85c2e3 100644 --- a/dist/server/lib/activitypub/actors/updater.js +++ b/dist/server/lib/activitypub/actors/updater.js @@ -20,20 +20,20 @@ class APActorUpdater { this.accountOrChannelFieldsSave = this.accountOrChannel.toJSON(); } update() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const avatarInfo = object_to_model_attributes_1.getImageInfoFromObject(this.actorObject, 1); - const bannerInfo = object_to_model_attributes_1.getImageInfoFromObject(this.actorObject, 2); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const avatarInfo = (0, object_to_model_attributes_1.getImageInfoFromObject)(this.actorObject, 1); + const bannerInfo = (0, object_to_model_attributes_1.getImageInfoFromObject)(this.actorObject, 2); try { yield this.updateActorInstance(this.actor, this.actorObject); this.accountOrChannel.name = this.actorObject.name || this.actorObject.preferredUsername; this.accountOrChannel.description = this.actorObject.summary; if (this.accountOrChannel instanceof video_channel_1.VideoChannelModel) this.accountOrChannel.support = this.actorObject.support; - yield database_utils_1.runInReadCommittedTransaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { - yield image_1.updateActorImageInstance(this.actor, 1, avatarInfo, t); - yield image_1.updateActorImageInstance(this.actor, 2, bannerInfo, t); + yield (0, database_utils_1.runInReadCommittedTransaction)((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, image_1.updateActorImageInstance)(this.actor, 1, avatarInfo, t); + yield (0, image_1.updateActorImageInstance)(this.actor, 2, bannerInfo, t); })); - yield database_utils_1.runInReadCommittedTransaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, database_utils_1.runInReadCommittedTransaction)((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.actor.save({ transaction: t }); yield this.accountOrChannel.save({ transaction: t }); })); @@ -41,10 +41,10 @@ class APActorUpdater { } catch (err) { if (this.actor !== undefined && this.actorFieldsSave !== undefined) { - database_utils_1.resetSequelizeInstance(this.actor, this.actorFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(this.actor, this.actorFieldsSave); } if (this.accountOrChannel !== undefined && this.accountOrChannelFieldsSave !== undefined) { - database_utils_1.resetSequelizeInstance(this.accountOrChannel, this.accountOrChannelFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(this.accountOrChannel, this.accountOrChannelFieldsSave); } logger_1.logger.debug('Cannot update the remote account.', { err }); throw err; @@ -53,8 +53,8 @@ class APActorUpdater { } updateActorInstance(actorInstance, actorObject) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { followersCount, followingCount } = yield shared_1.fetchActorFollowsCount(actorObject); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { followersCount, followingCount } = yield (0, shared_1.fetchActorFollowsCount)(actorObject); actorInstance.type = actorObject.type; actorInstance.preferredUsername = actorObject.preferredUsername; actorInstance.url = actorObject.id; diff --git a/dist/server/lib/activitypub/actors/webfinger.js b/dist/server/lib/activitypub/actors/webfinger.js index c09f7d50..aa17b49a 100644 --- a/dist/server/lib/activitypub/actors/webfinger.js +++ b/dist/server/lib/activitypub/actors/webfinger.js @@ -2,19 +2,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.loadActorUrlOrGetFromWebfinger = exports.getUrlFromWebfinger = void 0; const tslib_1 = require("tslib"); -const webfinger_js_1 = tslib_1.__importDefault(require("webfinger.js")); +const webfinger_js_1 = (0, tslib_1.__importDefault)(require("webfinger.js")); const core_utils_1 = require("@server/helpers/core-utils"); const misc_1 = require("@server/helpers/custom-validators/activitypub/misc"); const constants_1 = require("@server/initializers/constants"); const actor_1 = require("@server/models/actor/actor"); const webfinger = new webfinger_js_1.default({ webfist_fallback: false, - tls_only: core_utils_1.isProdInstance(), + tls_only: (0, core_utils_1.isProdInstance)(), uri_fallback: false, request_timeout: constants_1.REQUEST_TIMEOUT }); function loadActorUrlOrGetFromWebfinger(uriArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uri = uriArg.startsWith('@') ? uriArg.slice(1) : uriArg; const [name, host] = uri.split('@'); let actor; @@ -31,7 +31,7 @@ function loadActorUrlOrGetFromWebfinger(uriArg) { } exports.loadActorUrlOrGetFromWebfinger = loadActorUrlOrGetFromWebfinger; function getUrlFromWebfinger(uri) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const webfingerData = yield webfingerLookup(uri); return getLinkOrThrow(webfingerData); }); @@ -41,7 +41,7 @@ function getLinkOrThrow(webfingerData) { if (Array.isArray(webfingerData.links) === false) throw new Error('WebFinger links is not an array.'); const selfLink = webfingerData.links.find(l => l.rel === 'self'); - if (selfLink === undefined || misc_1.isActivityPubUrlValid(selfLink.href) === false) { + if (selfLink === undefined || (0, misc_1.isActivityPubUrlValid)(selfLink.href) === false) { throw new Error('Cannot find self link or href is not a valid URL.'); } return selfLink.href; diff --git a/dist/server/lib/activitypub/audience.js b/dist/server/lib/activitypub/audience.js index 3cfc5eed..8d58e8d7 100644 --- a/dist/server/lib/activitypub/audience.js +++ b/dist/server/lib/activitypub/audience.js @@ -39,7 +39,7 @@ function getAudienceFromFollowersOf(actorsInvolvedInObject) { exports.getAudienceFromFollowersOf = getAudienceFromFollowersOf; function getActorsInvolvedInVideo(video, t) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actors = yield video_share_1.VideoShareModel.loadActorsByShare(video.id, t); const videoAll = video; const videoActor = ((_a = videoAll.VideoChannel) === null || _a === void 0 ? void 0 : _a.Account) diff --git a/dist/server/lib/activitypub/cache-file.js b/dist/server/lib/activitypub/cache-file.js index 5d9a16b6..fb5ebed9 100644 --- a/dist/server/lib/activitypub/cache-file.js +++ b/dist/server/lib/activitypub/cache-file.js @@ -4,7 +4,7 @@ exports.createOrUpdateCacheFile = void 0; const tslib_1 = require("tslib"); const video_redundancy_1 = require("../../models/redundancy/video-redundancy"); function createOrUpdateCacheFile(cacheFileObject, video, byActor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const redundancyModel = yield video_redundancy_1.VideoRedundancyModel.loadByUrl(cacheFileObject.id, t); if (redundancyModel) { return updateCacheFile(cacheFileObject, redundancyModel, video, byActor, t); diff --git a/dist/server/lib/activitypub/crawl.js b/dist/server/lib/activitypub/crawl.js index 1f45f6b2..4d329f95 100644 --- a/dist/server/lib/activitypub/crawl.js +++ b/dist/server/lib/activitypub/crawl.js @@ -8,12 +8,12 @@ const logger_1 = require("../../helpers/logger"); const requests_1 = require("../../helpers/requests"); const constants_1 = require("../../initializers/constants"); function crawlCollectionPage(argUrl, handler, cleaner) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let url = argUrl; logger_1.logger.info('Crawling ActivityPub data on %s.', url); const options = { activityPub: true }; const startDate = new Date(); - const response = yield requests_1.doJSONRequest(url, options); + const response = yield (0, requests_1.doJSONRequest)(url, options); const firstBody = response.body; const limit = constants_1.ACTIVITY_PUB.FETCH_PAGE_LIMIT; let i = 0; @@ -25,7 +25,7 @@ function crawlCollectionPage(argUrl, handler, cleaner) { if (remoteHost === constants_1.WEBSERVER.HOST) continue; url = nextLink; - const res = yield requests_1.doJSONRequest(url, options); + const res = yield (0, requests_1.doJSONRequest)(url, options); body = res.body; } else { @@ -40,7 +40,7 @@ function crawlCollectionPage(argUrl, handler, cleaner) { } } if (cleaner) - yield database_utils_1.retryTransactionWrapper(cleaner, startDate); + yield (0, database_utils_1.retryTransactionWrapper)(cleaner, startDate); }); } exports.crawlCollectionPage = crawlCollectionPage; diff --git a/dist/server/lib/activitypub/follow.js b/dist/server/lib/activitypub/follow.js index e87b9329..7519bbcc 100644 --- a/dist/server/lib/activitypub/follow.js +++ b/dist/server/lib/activitypub/follow.js @@ -9,13 +9,13 @@ const constants_1 = require("../../initializers/constants"); const server_1 = require("../../models/server/server"); const job_queue_1 = require("../job-queue"); function autoFollowBackIfNeeded(actorFollow, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!config_1.CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_BACK.ENABLED) return; const follower = actorFollow.ActorFollower; if (follower.type === 'Application' && follower.preferredUsername === constants_1.SERVER_ACTOR_NAME) { logger_1.logger.info('Auto follow back %s.', follower.url); - const me = yield application_1.getServerActor(); + const me = yield (0, application_1.getServerActor)(); const server = yield server_1.ServerModel.load(follower.serverId, transaction); const host = server.host; const payload = { diff --git a/dist/server/lib/activitypub/inbox-manager.js b/dist/server/lib/activitypub/inbox-manager.js index 74fb1e04..f9e3fe74 100644 --- a/dist/server/lib/activitypub/inbox-manager.js +++ b/dist/server/lib/activitypub/inbox-manager.js @@ -8,9 +8,9 @@ const stat_manager_1 = require("../stat-manager"); const process_1 = require("./process"); class InboxManager { constructor() { - this.inboxQueue = async_1.queue((task, cb) => { + this.inboxQueue = (0, async_1.queue)((task, cb) => { const options = { signatureActor: task.signatureActor, inboxActor: task.inboxActor }; - process_1.processActivities(task.activities, options) + (0, process_1.processActivities)(task.activities, options) .then(() => cb()) .catch(err => { logger_1.logger.error('Error in process activities.', { err }); diff --git a/dist/server/lib/activitypub/outbox.js b/dist/server/lib/activitypub/outbox.js index ceed91b7..70b90a2d 100644 --- a/dist/server/lib/activitypub/outbox.js +++ b/dist/server/lib/activitypub/outbox.js @@ -6,8 +6,8 @@ const logger_1 = require("@server/helpers/logger"); const application_1 = require("@server/models/application/application"); const job_queue_1 = require("../job-queue"); function addFetchOutboxJob(actor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); if (serverActor.id === actor.id) { logger_1.logger.error('Cannot fetch our own outbox!'); return undefined; diff --git a/dist/server/lib/activitypub/playlists/create-update.js b/dist/server/lib/activitypub/playlists/create-update.js index 1fb02a03..adebf64e 100644 --- a/dist/server/lib/activitypub/playlists/create-update.js +++ b/dist/server/lib/activitypub/playlists/create-update.js @@ -15,15 +15,15 @@ const actors_1 = require("../actors"); const crawl_1 = require("../crawl"); const videos_1 = require("../videos"); const shared_1 = require("./shared"); -const lTags = logger_1.loggerTagsFactory('ap', 'video-playlist'); +const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video-playlist'); function createAccountPlaylists(playlistUrls) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield bluebird_1.map(playlistUrls, (playlistUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(playlistUrls, (playlistUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const exists = yield video_playlist_1.VideoPlaylistModel.doesPlaylistExist(playlistUrl); if (exists === true) return; - const { playlistObject } = yield shared_1.fetchRemoteVideoPlaylist(playlistUrl); + const { playlistObject } = yield (0, shared_1.fetchRemoteVideoPlaylist)(playlistUrl); if (playlistObject === undefined) { throw new Error(`Cannot refresh remote playlist ${playlistUrl}: invalid body.`); } @@ -37,8 +37,8 @@ function createAccountPlaylists(playlistUrls) { } exports.createAccountPlaylists = createAccountPlaylists; function createOrUpdateVideoPlaylist(playlistObject, to) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const playlistAttributes = shared_1.playlistObjectToDBAttributes(playlistObject, to || playlistObject.to); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const playlistAttributes = (0, shared_1.playlistObjectToDBAttributes)(playlistObject, to || playlistObject.to); yield setVideoChannel(playlistObject, playlistAttributes); const [upsertPlaylist] = yield video_playlist_1.VideoPlaylistModel.upsert(playlistAttributes, { returning: true }); const playlistElementUrls = yield fetchElementUrls(playlistObject); @@ -51,11 +51,11 @@ function createOrUpdateVideoPlaylist(playlistObject, to) { } exports.createOrUpdateVideoPlaylist = createOrUpdateVideoPlaylist; function setVideoChannel(playlistObject, playlistAttributes) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (!misc_1.isArray(playlistObject.attributedTo) || playlistObject.attributedTo.length !== 1) { - throw new Error('Not attributed to for playlist object ' + activitypub_1.getAPId(playlistObject)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if (!(0, misc_1.isArray)(playlistObject.attributedTo) || playlistObject.attributedTo.length !== 1) { + throw new Error('Not attributed to for playlist object ' + (0, activitypub_1.getAPId)(playlistObject)); } - const actor = yield actors_1.getOrCreateAPActor(playlistObject.attributedTo[0], 'all'); + const actor = yield (0, actors_1.getOrCreateAPActor)(playlistObject.attributedTo[0], 'all'); if (!actor.VideoChannel) { logger_1.logger.warn('Playlist "attributedTo" %s is not a video channel.', playlistObject.id, Object.assign({ playlistObject }, lTags(playlistObject.id))); return; @@ -65,9 +65,9 @@ function setVideoChannel(playlistObject, playlistAttributes) { }); } function fetchElementUrls(playlistObject) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let accItems = []; - yield crawl_1.crawlCollectionPage(playlistObject.id, items => { + yield (0, crawl_1.crawlCollectionPage)(playlistObject.id, items => { accItems = accItems.concat(items); return Promise.resolve(); }); @@ -75,11 +75,11 @@ function fetchElementUrls(playlistObject) { }); } function updatePlaylistThumbnail(playlistObject, playlist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (playlistObject.icon) { let thumbnailModel; try { - thumbnailModel = yield thumbnail_1.updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist }); + thumbnailModel = yield (0, thumbnail_1.updatePlaylistMiniatureFromUrl)({ downloadUrl: playlistObject.icon.url, playlist }); yield playlist.setAndSaveThumbnail(thumbnailModel, undefined); } catch (err) { @@ -96,9 +96,9 @@ function updatePlaylistThumbnail(playlistObject, playlist) { }); } function rebuildVideoPlaylistElements(elementUrls, playlist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const elementsToCreate = yield buildElementsDBAttributes(elementUrls, playlist); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_playlist_element_1.VideoPlaylistElementModel.deleteAllOf(playlist.id, t); for (const element of elementsToCreate) { yield video_playlist_element_1.VideoPlaylistElementModel.create(element, { transaction: t }); @@ -109,13 +109,13 @@ function rebuildVideoPlaylistElements(elementUrls, playlist) { }); } function buildElementsDBAttributes(elementUrls, playlist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const elementsToCreate = []; - yield bluebird_1.map(elementUrls, (elementUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(elementUrls, (elementUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - const { elementObject } = yield shared_1.fetchRemotePlaylistElement(elementUrl); - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: { id: elementObject.url }, fetchType: 'only-video' }); - elementsToCreate.push(shared_1.playlistElementObjectToDBAttributes(elementObject, playlist, video)); + const { elementObject } = yield (0, shared_1.fetchRemotePlaylistElement)(elementUrl); + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: { id: elementObject.url }, fetchType: 'only-video' }); + elementsToCreate.push((0, shared_1.playlistElementObjectToDBAttributes)(elementObject, playlist, video)); } catch (err) { logger_1.logger.warn('Cannot add playlist element %s.', elementUrl, Object.assign({ err }, lTags(playlist.uuid, playlist.url))); diff --git a/dist/server/lib/activitypub/playlists/get.js b/dist/server/lib/activitypub/playlists/get.js index 54760128..a174f794 100644 --- a/dist/server/lib/activitypub/playlists/get.js +++ b/dist/server/lib/activitypub/playlists/get.js @@ -8,19 +8,19 @@ const create_update_1 = require("./create-update"); const refresh_1 = require("./refresh"); const shared_1 = require("./shared"); function getOrCreateAPVideoPlaylist(playlistObjectArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const playlistUrl = activitypub_1.getAPId(playlistObjectArg); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const playlistUrl = (0, activitypub_1.getAPId)(playlistObjectArg); const playlistFromDatabase = yield video_playlist_1.VideoPlaylistModel.loadByUrlWithAccountAndChannelSummary(playlistUrl); if (playlistFromDatabase) { - refresh_1.scheduleRefreshIfNeeded(playlistFromDatabase); + (0, refresh_1.scheduleRefreshIfNeeded)(playlistFromDatabase); return playlistFromDatabase; } - const { playlistObject } = yield shared_1.fetchRemoteVideoPlaylist(playlistUrl); + const { playlistObject } = yield (0, shared_1.fetchRemoteVideoPlaylist)(playlistUrl); if (!playlistObject) throw new Error('Cannot fetch remote playlist with url: ' + playlistUrl); if (playlistObject.id !== playlistUrl) return getOrCreateAPVideoPlaylist(playlistObject); - const playlistCreated = yield create_update_1.createOrUpdateVideoPlaylist(playlistObject); + const playlistCreated = yield (0, create_update_1.createOrUpdateVideoPlaylist)(playlistObject); return playlistCreated; }); } diff --git a/dist/server/lib/activitypub/playlists/index.js b/dist/server/lib/activitypub/playlists/index.js index 521c46f4..58406e19 100644 --- a/dist/server/lib/activitypub/playlists/index.js +++ b/dist/server/lib/activitypub/playlists/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./get"), exports); -tslib_1.__exportStar(require("./create-update"), exports); -tslib_1.__exportStar(require("./refresh"), exports); +(0, tslib_1.__exportStar)(require("./get"), exports); +(0, tslib_1.__exportStar)(require("./create-update"), exports); +(0, tslib_1.__exportStar)(require("./refresh"), exports); diff --git a/dist/server/lib/activitypub/playlists/refresh.js b/dist/server/lib/activitypub/playlists/refresh.js index 4557f4bf..d14316c4 100644 --- a/dist/server/lib/activitypub/playlists/refresh.js +++ b/dist/server/lib/activitypub/playlists/refresh.js @@ -14,19 +14,19 @@ function scheduleRefreshIfNeeded(playlist) { } exports.scheduleRefreshIfNeeded = scheduleRefreshIfNeeded; function refreshVideoPlaylistIfNeeded(videoPlaylist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!videoPlaylist.isOutdated()) return videoPlaylist; - const lTags = logger_1.loggerTagsFactory('ap', 'video-playlist', 'refresh', videoPlaylist.uuid, videoPlaylist.url); + const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video-playlist', 'refresh', videoPlaylist.uuid, videoPlaylist.url); logger_1.logger.info('Refreshing playlist %s.', videoPlaylist.url, lTags()); try { - const { playlistObject } = yield shared_1.fetchRemoteVideoPlaylist(videoPlaylist.url); + const { playlistObject } = yield (0, shared_1.fetchRemoteVideoPlaylist)(videoPlaylist.url); if (playlistObject === undefined) { logger_1.logger.warn('Cannot refresh remote playlist %s: invalid body.', videoPlaylist.url, lTags()); yield videoPlaylist.setAsRefreshed(); return videoPlaylist; } - yield create_update_1.createOrUpdateVideoPlaylist(playlistObject); + yield (0, create_update_1.createOrUpdateVideoPlaylist)(playlistObject); return videoPlaylist; } catch (err) { diff --git a/dist/server/lib/activitypub/playlists/shared/index.js b/dist/server/lib/activitypub/playlists/shared/index.js index 470a7a42..54080828 100644 --- a/dist/server/lib/activitypub/playlists/shared/index.js +++ b/dist/server/lib/activitypub/playlists/shared/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./object-to-model-attributes"), exports); -tslib_1.__exportStar(require("./url-to-object"), exports); +(0, tslib_1.__exportStar)(require("./object-to-model-attributes"), exports); +(0, tslib_1.__exportStar)(require("./url-to-object"), exports); diff --git a/dist/server/lib/activitypub/playlists/shared/url-to-object.js b/dist/server/lib/activitypub/playlists/shared/url-to-object.js index e3d1cf3e..0877ab94 100644 --- a/dist/server/lib/activitypub/playlists/shared/url-to-object.js +++ b/dist/server/lib/activitypub/playlists/shared/url-to-object.js @@ -8,15 +8,15 @@ const playlist_1 = require("@server/helpers/custom-validators/activitypub/playli const logger_1 = require("@server/helpers/logger"); const requests_1 = require("@server/helpers/requests"); function fetchRemoteVideoPlaylist(playlistUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const lTags = logger_1.loggerTagsFactory('ap', 'video-playlist', playlistUrl); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video-playlist', playlistUrl); logger_1.logger.info('Fetching remote playlist %s.', playlistUrl, lTags()); - const { body, statusCode } = yield requests_1.doJSONRequest(playlistUrl, { activityPub: true }); - if (playlist_1.isPlaylistObjectValid(body) === false || activitypub_1.checkUrlsSameHost(body.id, playlistUrl) !== true) { + const { body, statusCode } = yield (0, requests_1.doJSONRequest)(playlistUrl, { activityPub: true }); + if ((0, playlist_1.isPlaylistObjectValid)(body) === false || (0, activitypub_1.checkUrlsSameHost)(body.id, playlistUrl) !== true) { logger_1.logger.debug('Remote video playlist JSON is not valid.', Object.assign({ body }, lTags())); return { statusCode, playlistObject: undefined }; } - if (!lodash_1.isArray(body.to)) { + if (!(0, lodash_1.isArray)(body.to)) { logger_1.logger.debug('Remote video playlist JSON does not have a valid audience.', Object.assign({ body }, lTags())); return { statusCode, playlistObject: undefined }; } @@ -25,13 +25,13 @@ function fetchRemoteVideoPlaylist(playlistUrl) { } exports.fetchRemoteVideoPlaylist = fetchRemoteVideoPlaylist; function fetchRemotePlaylistElement(elementUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const lTags = logger_1.loggerTagsFactory('ap', 'video-playlist', 'element', elementUrl); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video-playlist', 'element', elementUrl); logger_1.logger.debug('Fetching remote playlist element %s.', elementUrl, lTags()); - const { body, statusCode } = yield requests_1.doJSONRequest(elementUrl, { activityPub: true }); - if (!playlist_1.isPlaylistElementObjectValid(body)) + const { body, statusCode } = yield (0, requests_1.doJSONRequest)(elementUrl, { activityPub: true }); + if (!(0, playlist_1.isPlaylistElementObjectValid)(body)) throw new Error(`Invalid body in fetch playlist element ${elementUrl}`); - if (activitypub_1.checkUrlsSameHost(body.id, elementUrl) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(body.id, elementUrl) !== true) { throw new Error(`Playlist element url ${elementUrl} host is different from the AP object id ${body.id}`); } return { statusCode, elementObject: body }; diff --git a/dist/server/lib/activitypub/process/index.js b/dist/server/lib/activitypub/process/index.js index e615536a..561013da 100644 --- a/dist/server/lib/activitypub/process/index.js +++ b/dist/server/lib/activitypub/process/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./process"), exports); +(0, tslib_1.__exportStar)(require("./process"), exports); diff --git a/dist/server/lib/activitypub/process/process-accept.js b/dist/server/lib/activitypub/process/process-accept.js index 66abf5d7..0bd7b5f3 100644 --- a/dist/server/lib/activitypub/process/process-accept.js +++ b/dist/server/lib/activitypub/process/process-accept.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const actor_follow_1 = require("../../../models/actor/actor-follow"); const outbox_1 = require("../outbox"); function processAcceptActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { byActor: targetActor, inboxActor } = options; if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.'); @@ -14,14 +14,14 @@ function processAcceptActivity(options) { } exports.processAcceptActivity = processAcceptActivity; function processAccept(actor, targetActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const follow = yield actor_follow_1.ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id); if (!follow) throw new Error('Cannot find associated follow.'); if (follow.state !== 'accepted') { follow.state = 'accepted'; yield follow.save(); - yield outbox_1.addFetchOutboxJob(targetActor); + yield (0, outbox_1.addFetchOutboxJob)(targetActor); } }); } diff --git a/dist/server/lib/activitypub/process/process-announce.js b/dist/server/lib/activitypub/process/process-announce.js index 62a3c4cd..8e520035 100644 --- a/dist/server/lib/activitypub/process/process-announce.js +++ b/dist/server/lib/activitypub/process/process-announce.js @@ -10,20 +10,20 @@ const videos_1 = require("../videos"); const notifier_1 = require("../../notifier"); const logger_1 = require("../../../helpers/logger"); function processAnnounceActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor: actorAnnouncer } = options; const notify = options.fromFetch !== true; - return database_utils_1.retryTransactionWrapper(processVideoShare, actorAnnouncer, activity, notify); + return (0, database_utils_1.retryTransactionWrapper)(processVideoShare, actorAnnouncer, activity, notify); }); } exports.processAnnounceActivity = processAnnounceActivity; function processVideoShare(actorAnnouncer, activity, notify) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id; let video; let videoCreated; try { - const result = yield videos_1.getOrCreateAPVideo({ videoObject: objectUri }); + const result = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: objectUri }); video = result.video; videoCreated = result.created; } @@ -31,7 +31,7 @@ function processVideoShare(actorAnnouncer, activity, notify) { logger_1.logger.debug('Cannot process share of %s. Maybe this is not a video object, so just skipping.', objectUri, { err }); return; } - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const share = { actorId: actorAnnouncer.id, videoId: video.id, @@ -46,7 +46,7 @@ function processVideoShare(actorAnnouncer, activity, notify) { }); if (video.isOwned() && created === true) { const exceptions = [actorAnnouncer]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } return undefined; })); diff --git a/dist/server/lib/activitypub/process/process-create.js b/dist/server/lib/activitypub/process/process-create.js index 9284473d..9265f681 100644 --- a/dist/server/lib/activitypub/process/process-create.js +++ b/dist/server/lib/activitypub/process/process-create.js @@ -14,7 +14,7 @@ const utils_1 = require("../send/utils"); const video_comments_1 = require("../video-comments"); const videos_1 = require("../videos"); function processCreateActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; const notify = options.fromFetch !== true; const activityObject = activity.object; @@ -23,13 +23,13 @@ function processCreateActivity(options) { return processCreateVideo(activity, notify); } if (activityType === 'Note') { - return database_utils_1.retryTransactionWrapper(processCreateVideoComment, activity, byActor, notify); + return (0, database_utils_1.retryTransactionWrapper)(processCreateVideoComment, activity, byActor, notify); } if (activityType === 'CacheFile') { - return database_utils_1.retryTransactionWrapper(processCreateCacheFile, activity, byActor); + return (0, database_utils_1.retryTransactionWrapper)(processCreateCacheFile, activity, byActor); } if (activityType === 'Playlist') { - return database_utils_1.retryTransactionWrapper(processCreatePlaylist, activity, byActor); + return (0, database_utils_1.retryTransactionWrapper)(processCreatePlaylist, activity, byActor); } logger_1.logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }); return Promise.resolve(undefined); @@ -37,32 +37,32 @@ function processCreateActivity(options) { } exports.processCreateActivity = processCreateActivity; function processCreateVideo(activity, notify) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoToCreateData = activity.object; const syncParam = { likes: false, dislikes: false, shares: false, comments: false, thumbnail: true, refreshVideo: false }; - const { video, created } = yield videos_1.getOrCreateAPVideo({ videoObject: videoToCreateData, syncParam }); + const { video, created } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: videoToCreateData, syncParam }); if (created && notify) notifier_1.Notifier.Instance.notifyOnNewVideoIfNeeded(video); return video; }); } function processCreateCacheFile(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if ((yield redundancy_1.isRedundancyAccepted(activity, byActor)) !== true) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if ((yield (0, redundancy_1.isRedundancyAccepted)(activity, byActor)) !== true) return; const cacheFile = activity.object; - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: cacheFile.object }); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { - return cache_file_1.createOrUpdateCacheFile(cacheFile, video, byActor, t); + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: cacheFile.object }); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return (0, cache_file_1.createOrUpdateCacheFile)(cacheFile, video, byActor, t); })); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, undefined, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, undefined, exceptions, video); } }); } function processCreateVideoComment(activity, byActor, notify) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const commentObject = activity.object; const byAccount = byActor.Account; if (!byAccount) @@ -71,7 +71,7 @@ function processCreateVideoComment(activity, byActor, notify) { let created; let comment; try { - const resolveThreadResult = yield video_comments_1.resolveThread({ url: commentObject.id, isVideo: false }); + const resolveThreadResult = yield (0, video_comments_1.resolveThread)({ url: commentObject.id, isVideo: false }); video = resolveThreadResult.video; created = resolveThreadResult.commentCreated; comment = resolveThreadResult.comment; @@ -81,13 +81,13 @@ function processCreateVideoComment(activity, byActor, notify) { return; } if (video.isOwned()) { - if (yield blocklist_1.isBlockedByServerOrAccount(comment.Account, video.VideoChannel.Account)) { + if (yield (0, blocklist_1.isBlockedByServerOrAccount)(comment.Account, video.VideoChannel.Account)) { logger_1.logger.info('Skip comment forward from blocked account or server %s.', comment.Account.Actor.url); return; } if (created === true) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, undefined, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, undefined, exceptions, video); } } if (created && notify) @@ -95,11 +95,11 @@ function processCreateVideoComment(activity, byActor, notify) { }); } function processCreatePlaylist(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlistObject = activity.object; const byAccount = byActor.Account; if (!byAccount) throw new Error('Cannot create video playlist with the non account actor ' + byActor.url); - yield playlists_1.createOrUpdateVideoPlaylist(playlistObject, activity.to); + yield (0, playlists_1.createOrUpdateVideoPlaylist)(playlistObject, activity.to); }); } diff --git a/dist/server/lib/activitypub/process/process-delete.js b/dist/server/lib/activitypub/process/process-delete.js index fa3be47d..7a8d1be7 100644 --- a/dist/server/lib/activitypub/process/process-delete.js +++ b/dist/server/lib/activitypub/process/process-delete.js @@ -11,7 +11,7 @@ const video_comment_1 = require("../../../models/video/video-comment"); const video_playlist_1 = require("../../../models/video/video-playlist"); const utils_1 = require("../send/utils"); function processDeleteActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id; if (activity.actor === objectUrl) { @@ -21,20 +21,20 @@ function processDeleteActivity(options) { throw new Error('Actor ' + byActorFull.url + ' is a person but we cannot find it in database.'); const accountToDelete = byActorFull.Account; accountToDelete.Actor = byActorFull; - return database_utils_1.retryTransactionWrapper(processDeleteAccount, accountToDelete); + return (0, database_utils_1.retryTransactionWrapper)(processDeleteAccount, accountToDelete); } else if (byActorFull.type === 'Group') { if (!byActorFull.VideoChannel) throw new Error('Actor ' + byActorFull.url + ' is a group but we cannot find it in database.'); const channelToDelete = byActorFull.VideoChannel; channelToDelete.Actor = byActorFull; - return database_utils_1.retryTransactionWrapper(processDeleteVideoChannel, channelToDelete); + return (0, database_utils_1.retryTransactionWrapper)(processDeleteVideoChannel, channelToDelete); } } { const videoCommentInstance = yield video_comment_1.VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(objectUrl); if (videoCommentInstance) { - return database_utils_1.retryTransactionWrapper(processDeleteVideoComment, byActor, videoCommentInstance, activity); + return (0, database_utils_1.retryTransactionWrapper)(processDeleteVideoComment, byActor, videoCommentInstance, activity); } } { @@ -42,7 +42,7 @@ function processDeleteActivity(options) { if (videoInstance) { if (videoInstance.isOwned()) throw new Error(`Remote instance cannot delete owned video ${videoInstance.url}.`); - return database_utils_1.retryTransactionWrapper(processDeleteVideo, byActor, videoInstance); + return (0, database_utils_1.retryTransactionWrapper)(processDeleteVideo, byActor, videoInstance); } } { @@ -50,7 +50,7 @@ function processDeleteActivity(options) { if (videoPlaylist) { if (videoPlaylist.isOwned()) throw new Error(`Remote instance cannot delete owned playlist ${videoPlaylist.url}.`); - return database_utils_1.retryTransactionWrapper(processDeleteVideoPlaylist, byActor, videoPlaylist); + return (0, database_utils_1.retryTransactionWrapper)(processDeleteVideoPlaylist, byActor, videoPlaylist); } } return undefined; @@ -58,9 +58,9 @@ function processDeleteActivity(options) { } exports.processDeleteActivity = processDeleteActivity; function processDeleteVideo(actor, videoToDelete) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Removing remote video "%s".', videoToDelete.uuid); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (videoToDelete.VideoChannel.Account.Actor.id !== actor.id) { throw new Error('Account ' + actor.url + ' does not own video channel ' + videoToDelete.VideoChannel.Actor.url); } @@ -70,9 +70,9 @@ function processDeleteVideo(actor, videoToDelete) { }); } function processDeleteVideoPlaylist(actor, playlistToDelete) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Removing remote video playlist "%s".', playlistToDelete.uuid); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (playlistToDelete.OwnerAccount.Actor.id !== actor.id) { throw new Error('Account ' + actor.url + ' does not own video playlist ' + playlistToDelete.url); } @@ -82,18 +82,18 @@ function processDeleteVideoPlaylist(actor, playlistToDelete) { }); } function processDeleteAccount(accountToRemove) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Removing remote account "%s".', accountToRemove.Actor.url); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield accountToRemove.destroy({ transaction: t }); })); logger_1.logger.info('Remote account %s removed.', accountToRemove.Actor.url); }); } function processDeleteVideoChannel(videoChannelToRemove) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.url); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield videoChannelToRemove.destroy({ transaction: t }); })); logger_1.logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url); @@ -103,7 +103,7 @@ function processDeleteVideoComment(byActor, videoComment, activity) { if (videoComment.isDeleted()) return Promise.resolve(); logger_1.logger.debug('Removing remote video comment "%s".', videoComment.url); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (byActor.Account.id !== videoComment.Account.id && byActor.Account.id !== videoComment.Video.VideoChannel.accountId) { throw new Error(`Account ${byActor.url} does not own video comment ${videoComment.url} or video ${videoComment.Video.url}`); } @@ -111,7 +111,7 @@ function processDeleteVideoComment(byActor, videoComment, activity) { yield videoComment.save({ transaction: t }); if (videoComment.Video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, videoComment.Video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, videoComment.Video); } logger_1.logger.info('Remote video comment %s removed.', videoComment.url); })); diff --git a/dist/server/lib/activitypub/process/process-dislike.js b/dist/server/lib/activitypub/process/process-dislike.js index c05b8883..c0bbae0d 100644 --- a/dist/server/lib/activitypub/process/process-dislike.js +++ b/dist/server/lib/activitypub/process/process-dislike.js @@ -8,22 +8,22 @@ const account_video_rate_1 = require("../../../models/account/account-video-rate const utils_1 = require("../send/utils"); const videos_1 = require("../videos"); function processDislikeActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; - return database_utils_1.retryTransactionWrapper(processDislike, activity, byActor); + return (0, database_utils_1.retryTransactionWrapper)(processDislike, activity, byActor); }); } exports.processDislikeActivity = processDislikeActivity; function processDislike(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const dislikeObject = activity.type === 'Dislike' ? activity.object : activity.object.object; const byAccount = byActor.Account; if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url); - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: dislikeObject }); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: dislikeObject }); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const existingRate = yield account_video_rate_1.AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t); if (existingRate && existingRate.type === 'dislike') return; @@ -39,7 +39,7 @@ function processDislike(activity, byActor) { yield rate.save({ transaction: t }); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } })); }); diff --git a/dist/server/lib/activitypub/process/process-flag.js b/dist/server/lib/activitypub/process/process-flag.js index 79ce93a4..9ec039c4 100644 --- a/dist/server/lib/activitypub/process/process-flag.js +++ b/dist/server/lib/activitypub/process/process-flag.js @@ -12,14 +12,14 @@ const database_utils_1 = require("../../../helpers/database-utils"); const logger_1 = require("../../../helpers/logger"); const database_1 = require("../../../initializers/database"); function processFlagActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; - return database_utils_1.retryTransactionWrapper(processCreateAbuse, activity, byActor); + return (0, database_utils_1.retryTransactionWrapper)(processCreateAbuse, activity, byActor); }); } exports.processFlagActivity = processFlagActivity; function processCreateAbuse(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const flag = activity.type === 'Flag' ? activity : activity.object; const account = byActor.Account; if (!account) @@ -33,9 +33,9 @@ function processCreateAbuse(activity, byActor) { const endAt = flag.endAt; for (const object of objects) { try { - const uri = activitypub_1.getAPId(object); + const uri = (0, activitypub_1.getAPId)(object); logger_1.logger.debug('Reporting remote abuse for object %s.', uri); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadByUrlAndPopulateAccount(uri, t); let videoComment; let flaggedAccount; @@ -54,7 +54,7 @@ function processCreateAbuse(activity, byActor) { predefinedReasons }; if (video) { - return moderation_1.createVideoAbuse({ + return (0, moderation_1.createVideoAbuse)({ baseAbuse, startAt, endAt, @@ -64,14 +64,14 @@ function processCreateAbuse(activity, byActor) { }); } if (videoComment) { - return moderation_1.createVideoCommentAbuse({ + return (0, moderation_1.createVideoCommentAbuse)({ baseAbuse, reporterAccount, transaction: t, commentInstance: videoComment }); } - return yield moderation_1.createAccountAbuse({ + return yield (0, moderation_1.createAccountAbuse)({ baseAbuse, reporterAccount, transaction: t, @@ -80,7 +80,7 @@ function processCreateAbuse(activity, byActor) { })); } catch (err) { - logger_1.logger.debug('Cannot process report of %s', activitypub_1.getAPId(object), { err }); + logger_1.logger.debug('Cannot process report of %s', (0, activitypub_1.getAPId)(object), { err }); } } }); diff --git a/dist/server/lib/activitypub/process/process-follow.js b/dist/server/lib/activitypub/process/process-follow.js index ec5d2d10..9b7c484a 100644 --- a/dist/server/lib/activitypub/process/process-follow.js +++ b/dist/server/lib/activitypub/process/process-follow.js @@ -14,27 +14,27 @@ const notifier_1 = require("../../notifier"); const follow_1 = require("../follow"); const send_1 = require("../send"); function processFollowActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; const activityId = activity.id; - const objectId = activitypub_1.getAPId(activity.object); - return database_utils_1.retryTransactionWrapper(processFollow, byActor, activityId, objectId); + const objectId = (0, activitypub_1.getAPId)(activity.object); + return (0, database_utils_1.retryTransactionWrapper)(processFollow, byActor, activityId, objectId); }); } exports.processFollowActivity = processFollowActivity; function processFollow(byActor, activityId, targetActorURL) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { actorFollow, created, isFollowingInstance, targetActor } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { actorFollow, created, isFollowingInstance, targetActor } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const targetActor = yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(targetActorURL, t); if (!targetActor) throw new Error('Unknown actor'); if (targetActor.isOwned() === false) throw new Error('This is not a local actor.'); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const isFollowingInstance = targetActor.id === serverActor.id; if (isFollowingInstance && config_1.CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { logger_1.logger.info('Rejecting %s because instance followers are disabled.', targetActor.url); - send_1.sendReject(activityId, byActor, targetActor); + (0, send_1.sendReject)(activityId, byActor, targetActor); return { actorFollow: undefined }; } const [actorFollow, created] = yield actor_follow_1.ActorFollowModel.findOrCreate({ @@ -63,8 +63,8 @@ function processFollow(byActor, activityId, targetActorURL) { actorFollow.ActorFollower = byActor; actorFollow.ActorFollowing = targetActor; if (actorFollow.state === 'accepted') { - send_1.sendAccept(actorFollow); - yield follow_1.autoFollowBackIfNeeded(actorFollow, t); + (0, send_1.sendAccept)(actorFollow); + yield (0, follow_1.autoFollowBackIfNeeded)(actorFollow, t); } return { actorFollow, created, isFollowingInstance, targetActor }; })); diff --git a/dist/server/lib/activitypub/process/process-like.js b/dist/server/lib/activitypub/process/process-like.js index 71cc9e50..5c2af20e 100644 --- a/dist/server/lib/activitypub/process/process-like.js +++ b/dist/server/lib/activitypub/process/process-like.js @@ -9,20 +9,20 @@ const account_video_rate_1 = require("../../../models/account/account-video-rate const utils_1 = require("../send/utils"); const videos_1 = require("../videos"); function processLikeActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; - return database_utils_1.retryTransactionWrapper(processLikeVideo, byActor, activity); + return (0, database_utils_1.retryTransactionWrapper)(processLikeVideo, byActor, activity); }); } exports.processLikeActivity = processLikeActivity; function processLikeVideo(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoUrl = activitypub_1.getAPId(activity.object); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoUrl = (0, activitypub_1.getAPId)(activity.object); const byAccount = byActor.Account; if (!byAccount) throw new Error('Cannot create like with the non account actor ' + byActor.url); - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: videoUrl }); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: videoUrl }); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const existingRate = yield account_video_rate_1.AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t); if (existingRate && existingRate.type === 'like') return; @@ -38,7 +38,7 @@ function processLikeVideo(byActor, activity) { yield rate.save({ transaction: t }); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } })); }); diff --git a/dist/server/lib/activitypub/process/process-reject.js b/dist/server/lib/activitypub/process/process-reject.js index 9f834cf7..e80f8cf1 100644 --- a/dist/server/lib/activitypub/process/process-reject.js +++ b/dist/server/lib/activitypub/process/process-reject.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const database_1 = require("../../../initializers/database"); const actor_follow_1 = require("../../../models/actor/actor-follow"); function processRejectActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { byActor: targetActor, inboxActor } = options; if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.'); @@ -14,8 +14,8 @@ function processRejectActivity(options) { } exports.processRejectActivity = processRejectActivity; function processReject(follower, targetActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actorFollow = yield actor_follow_1.ActorFollowModel.loadByActorAndTarget(follower.id, targetActor.id, t); if (!actorFollow) throw new Error(`'Unknown actor follow ${follower.id} -> ${targetActor.id}.`); diff --git a/dist/server/lib/activitypub/process/process-undo.js b/dist/server/lib/activitypub/process/process-undo.js index 501ff48b..e9d1fd26 100644 --- a/dist/server/lib/activitypub/process/process-undo.js +++ b/dist/server/lib/activitypub/process/process-undo.js @@ -13,25 +13,25 @@ const video_share_1 = require("../../../models/video/video-share"); const utils_1 = require("../send/utils"); const videos_1 = require("../videos"); function processUndoActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; const activityToUndo = activity.object; if (activityToUndo.type === 'Like') { - return database_utils_1.retryTransactionWrapper(processUndoLike, byActor, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUndoLike, byActor, activity); } if (activityToUndo.type === 'Create') { if (activityToUndo.object.type === 'CacheFile') { - return database_utils_1.retryTransactionWrapper(processUndoCacheFile, byActor, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUndoCacheFile, byActor, activity); } } if (activityToUndo.type === 'Dislike') { - return database_utils_1.retryTransactionWrapper(processUndoDislike, byActor, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUndoDislike, byActor, activity); } if (activityToUndo.type === 'Follow') { - return database_utils_1.retryTransactionWrapper(processUndoFollow, byActor, activityToUndo); + return (0, database_utils_1.retryTransactionWrapper)(processUndoFollow, byActor, activityToUndo); } if (activityToUndo.type === 'Announce') { - return database_utils_1.retryTransactionWrapper(processUndoAnnounce, byActor, activityToUndo); + return (0, database_utils_1.retryTransactionWrapper)(processUndoAnnounce, byActor, activityToUndo); } logger_1.logger.warn('Unknown activity object type %s -> %s when undo activity.', activityToUndo.type, { activity: activity.id }); return undefined; @@ -39,10 +39,10 @@ function processUndoActivity(options) { } exports.processUndoActivity = processUndoActivity; function processUndoLike(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const likeActivity = activity.object; - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: likeActivity.object }); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: likeActivity.object }); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!byActor.Account) throw new Error('Unknown account ' + byActor.url); const rate = yield account_video_rate_1.AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, likeActivity.id, t); @@ -52,18 +52,18 @@ function processUndoLike(byActor, activity) { yield video.decrement('likes', { transaction: t }); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } })); }); } function processUndoDislike(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const dislike = activity.object.type === 'Dislike' ? activity.object : activity.object.object; - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: dislike.object }); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: dislike.object }); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!byActor.Account) throw new Error('Unknown account ' + byActor.url); const rate = yield account_video_rate_1.AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, dislike.id, t); @@ -73,16 +73,16 @@ function processUndoDislike(byActor, activity) { yield video.decrement('dislikes', { transaction: t }); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } })); }); } function processUndoCacheFile(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const cacheFileObject = activity.object.object; - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: cacheFileObject.object }); - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: cacheFileObject.object }); + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const cacheFile = yield video_redundancy_1.VideoRedundancyModel.loadByUrl(cacheFileObject.id, t); if (!cacheFile) { logger_1.logger.debug('Cannot undo unknown video cache %s.', cacheFileObject.id); @@ -93,13 +93,13 @@ function processUndoCacheFile(byActor, activity) { yield cacheFile.destroy({ transaction: t }); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, t, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, t, exceptions, video); } })); }); } function processUndoFollow(follower, followActivity) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const following = yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(followActivity.object, t); const actorFollow = yield actor_follow_1.ActorFollowModel.loadByActorAndTarget(follower.id, following.id, t); if (!actorFollow) @@ -109,7 +109,7 @@ function processUndoFollow(follower, followActivity) { })); } function processUndoAnnounce(byActor, announceActivity) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const share = yield video_share_1.VideoShareModel.loadByUrl(announceActivity.id, t); if (!share) throw new Error(`Unknown video share ${announceActivity.id}.`); @@ -118,7 +118,7 @@ function processUndoAnnounce(byActor, announceActivity) { yield share.destroy({ transaction: t }); if (share.Video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(announceActivity, t, exceptions, share.Video); + yield (0, utils_1.forwardVideoRelatedActivity)(announceActivity, t, exceptions, share.Video); } })); } diff --git a/dist/server/lib/activitypub/process/process-update.js b/dist/server/lib/activitypub/process/process-update.js index 1fcdaff1..817d9cbc 100644 --- a/dist/server/lib/activitypub/process/process-update.js +++ b/dist/server/lib/activitypub/process/process-update.js @@ -15,35 +15,35 @@ const playlists_1 = require("../playlists"); const utils_1 = require("../send/utils"); const videos_2 = require("../videos"); function processUpdateActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; const objectType = activity.object.type; if (objectType === 'Video') { - return database_utils_1.retryTransactionWrapper(processUpdateVideo, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUpdateVideo, activity); } if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') { const byActorFull = yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(byActor.url); - return database_utils_1.retryTransactionWrapper(processUpdateActor, byActorFull, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUpdateActor, byActorFull, activity); } if (objectType === 'CacheFile') { const byActorFull = yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(byActor.url); - return database_utils_1.retryTransactionWrapper(processUpdateCacheFile, byActorFull, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUpdateCacheFile, byActorFull, activity); } if (objectType === 'Playlist') { - return database_utils_1.retryTransactionWrapper(processUpdatePlaylist, byActor, activity); + return (0, database_utils_1.retryTransactionWrapper)(processUpdatePlaylist, byActor, activity); } return undefined; }); } exports.processUpdateActivity = processUpdateActivity; function processUpdateVideo(activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoObject = activity.object; - if (videos_1.sanitizeAndCheckVideoTorrentObject(videoObject) === false) { + if ((0, videos_1.sanitizeAndCheckVideoTorrentObject)(videoObject) === false) { logger_1.logger.debug('Video sent by update is not valid.', { videoObject }); return undefined; } - const { video, created } = yield videos_2.getOrCreateAPVideo({ + const { video, created } = yield (0, videos_2.getOrCreateAPVideo)({ videoObject: videoObject.id, allowRefresh: false, fetchType: 'all' @@ -55,26 +55,26 @@ function processUpdateVideo(activity) { }); } function processUpdateCacheFile(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if ((yield redundancy_1.isRedundancyAccepted(activity, byActor)) !== true) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if ((yield (0, redundancy_1.isRedundancyAccepted)(activity, byActor)) !== true) return; const cacheFileObject = activity.object; - if (!cache_file_1.isCacheFileObjectValid(cacheFileObject)) { + if (!(0, cache_file_1.isCacheFileObjectValid)(cacheFileObject)) { logger_1.logger.debug('Cache file object sent by update is not valid.', { cacheFileObject }); return undefined; } - const { video } = yield videos_2.getOrCreateAPVideo({ videoObject: cacheFileObject.object }); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { - yield cache_file_2.createOrUpdateCacheFile(cacheFileObject, video, byActor, t); + const { video } = yield (0, videos_2.getOrCreateAPVideo)({ videoObject: cacheFileObject.object }); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, cache_file_2.createOrUpdateCacheFile)(cacheFileObject, video, byActor, t); })); if (video.isOwned()) { const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, undefined, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, undefined, exceptions, video); } }); } function processUpdateActor(actor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actorObject = activity.object; logger_1.logger.debug('Updating remote account "%s".', actorObject.url); const updater = new updater_1.APActorUpdater(actorObject, actor); @@ -82,11 +82,11 @@ function processUpdateActor(actor, activity) { }); } function processUpdatePlaylist(byActor, activity) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlistObject = activity.object; const byAccount = byActor.Account; if (!byAccount) throw new Error('Cannot update video playlist with the non account actor ' + byActor.url); - yield playlists_1.createOrUpdateVideoPlaylist(playlistObject, activity.to); + yield (0, playlists_1.createOrUpdateVideoPlaylist)(playlistObject, activity.to); }); } diff --git a/dist/server/lib/activitypub/process/process-view.js b/dist/server/lib/activitypub/process/process-view.js index c0a1292d..e54e1307 100644 --- a/dist/server/lib/activitypub/process/process-view.js +++ b/dist/server/lib/activitypub/process/process-view.js @@ -7,18 +7,18 @@ const utils_1 = require("../send/utils"); const redis_1 = require("../../redis"); const live_manager_1 = require("@server/lib/live/live-manager"); function processViewActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, byActor } = options; return processCreateView(activity, byActor); }); } exports.processViewActivity = processViewActivity; function processCreateView(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoObject = activity.type === 'View' ? activity.object : activity.object.object; - const { video } = yield videos_1.getOrCreateAPVideo({ + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject, fetchType: 'only-video', allowRefresh: false @@ -32,7 +32,7 @@ function processCreateView(activity, byActor) { return; } const exceptions = [byActor]; - yield utils_1.forwardVideoRelatedActivity(activity, undefined, exceptions, video); + yield (0, utils_1.forwardVideoRelatedActivity)(activity, undefined, exceptions, video); } }); } diff --git a/dist/server/lib/activitypub/process/process.js b/dist/server/lib/activitypub/process/process.js index 7ffd6085..db9ad757 100644 --- a/dist/server/lib/activitypub/process/process.js +++ b/dist/server/lib/activitypub/process/process.js @@ -33,7 +33,7 @@ const processActivity = { View: process_view_1.processViewActivity }; function processActivities(activities, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { outboxUrl, signatureActor, inboxActor, fromFetch = false } = options; const actorsCache = {}; for (const activity of activities) { @@ -41,16 +41,16 @@ function processActivities(activities, options = {}) { logger_1.logger.error('Cannot process activity %s (type: %s) without the actor signature.', activity.id, activity.type); continue; } - const actorUrl = activitypub_1.getAPId(activity.actor); + const actorUrl = (0, activitypub_1.getAPId)(activity.actor); if (signatureActor && actorUrl !== signatureActor.url) { logger_1.logger.warn('Signature mismatch between %s and %s, skipping.', actorUrl, signatureActor.url); continue; } - if (outboxUrl && activitypub_1.checkUrlsSameHost(outboxUrl, actorUrl) !== true) { + if (outboxUrl && (0, activitypub_1.checkUrlsSameHost)(outboxUrl, actorUrl) !== true) { logger_1.logger.warn('Host mismatch between outbox URL %s and actor URL %s, skipping.', outboxUrl, actorUrl); continue; } - const byActor = signatureActor || actorsCache[actorUrl] || (yield actors_1.getOrCreateAPActor(actorUrl)); + const byActor = signatureActor || actorsCache[actorUrl] || (yield (0, actors_1.getOrCreateAPActor)(actorUrl)); actorsCache[actorUrl] = byActor; const activityProcessor = processActivity[activity.type]; if (activityProcessor === undefined) { diff --git a/dist/server/lib/activitypub/send/index.js b/dist/server/lib/activitypub/send/index.js index be8eee92..94fc3a3b 100644 --- a/dist/server/lib/activitypub/send/index.js +++ b/dist/server/lib/activitypub/send/index.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./send-accept"), exports); -tslib_1.__exportStar(require("./send-accept"), exports); -tslib_1.__exportStar(require("./send-announce"), exports); -tslib_1.__exportStar(require("./send-create"), exports); -tslib_1.__exportStar(require("./send-delete"), exports); -tslib_1.__exportStar(require("./send-follow"), exports); -tslib_1.__exportStar(require("./send-like"), exports); -tslib_1.__exportStar(require("./send-reject"), exports); -tslib_1.__exportStar(require("./send-undo"), exports); -tslib_1.__exportStar(require("./send-update"), exports); +(0, tslib_1.__exportStar)(require("./send-accept"), exports); +(0, tslib_1.__exportStar)(require("./send-accept"), exports); +(0, tslib_1.__exportStar)(require("./send-announce"), exports); +(0, tslib_1.__exportStar)(require("./send-create"), exports); +(0, tslib_1.__exportStar)(require("./send-delete"), exports); +(0, tslib_1.__exportStar)(require("./send-follow"), exports); +(0, tslib_1.__exportStar)(require("./send-like"), exports); +(0, tslib_1.__exportStar)(require("./send-reject"), exports); +(0, tslib_1.__exportStar)(require("./send-undo"), exports); +(0, tslib_1.__exportStar)(require("./send-update"), exports); diff --git a/dist/server/lib/activitypub/send/send-accept.js b/dist/server/lib/activitypub/send/send-accept.js index c2cd7f80..df2a82a7 100644 --- a/dist/server/lib/activitypub/send/send-accept.js +++ b/dist/server/lib/activitypub/send/send-accept.js @@ -13,10 +13,10 @@ function sendAccept(actorFollow) { return; } logger_1.logger.info('Creating job to accept follower %s.', follower.url); - const followData = send_follow_1.buildFollowActivity(actorFollow.url, follower, me); - const url = url_1.getLocalActorFollowAcceptActivityPubUrl(actorFollow); + const followData = (0, send_follow_1.buildFollowActivity)(actorFollow.url, follower, me); + const url = (0, url_1.getLocalActorFollowAcceptActivityPubUrl)(actorFollow); const data = buildAcceptActivity(url, me, followData); - return utils_1.unicastTo(data, me, follower.inboxUrl); + return (0, utils_1.unicastTo)(data, me, follower.inboxUrl); } exports.sendAccept = sendAccept; function buildAcceptActivity(url, byActor, followActivityData) { diff --git a/dist/server/lib/activitypub/send/send-announce.js b/dist/server/lib/activitypub/send/send-announce.js index b3790d7e..b722d694 100644 --- a/dist/server/lib/activitypub/send/send-announce.js +++ b/dist/server/lib/activitypub/send/send-announce.js @@ -6,28 +6,28 @@ const utils_1 = require("./utils"); const audience_1 = require("../audience"); const logger_1 = require("../../../helpers/logger"); function buildAnnounceWithVideoAudience(byActor, videoShare, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const announcedObject = video.url; - const actorsInvolvedInVideo = yield audience_1.getActorsInvolvedInVideo(video, t); - const audience = audience_1.getAudienceFromFollowersOf(actorsInvolvedInVideo); + const actorsInvolvedInVideo = yield (0, audience_1.getActorsInvolvedInVideo)(video, t); + const audience = (0, audience_1.getAudienceFromFollowersOf)(actorsInvolvedInVideo); const activity = buildAnnounceActivity(videoShare.url, byActor, announcedObject, audience); return { activity, actorsInvolvedInVideo }; }); } exports.buildAnnounceWithVideoAudience = buildAnnounceWithVideoAudience; function sendVideoAnnounce(byActor, videoShare, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { activity, actorsInvolvedInVideo } = yield buildAnnounceWithVideoAudience(byActor, videoShare, video, t); logger_1.logger.info('Creating job to send announce %s.', videoShare.url); const followersException = [byActor]; - return utils_1.broadcastToFollowers(activity, byActor, actorsInvolvedInVideo, t, followersException, 'Announce'); + return (0, utils_1.broadcastToFollowers)(activity, byActor, actorsInvolvedInVideo, t, followersException, 'Announce'); }); } exports.sendVideoAnnounce = sendVideoAnnounce; function buildAnnounceActivity(url, byActor, object, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ type: 'Announce', id: url, actor: byActor.url, diff --git a/dist/server/lib/activitypub/send/send-create.js b/dist/server/lib/activitypub/send/send-create.js index a262fbe3..f9c44f71 100644 --- a/dist/server/lib/activitypub/send/send-create.js +++ b/dist/server/lib/activitypub/send/send-create.js @@ -7,22 +7,22 @@ const utils_1 = require("./utils"); const audience_1 = require("../audience"); const logger_1 = require("../../../helpers/logger"); const application_1 = require("@server/models/application/application"); -const lTags = logger_1.loggerTagsFactory('ap', 'create'); +const lTags = (0, logger_1.loggerTagsFactory)('ap', 'create'); function sendCreateVideo(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!video.hasPrivacyForFederation()) return undefined; logger_1.logger.info('Creating job to send video creation of %s.', video.url, lTags(video.uuid)); const byActor = video.VideoChannel.Account.Actor; const videoObject = video.toActivityPubObject(); - const audience = audience_1.getAudience(byActor, video.privacy === 1); + const audience = (0, audience_1.getAudience)(byActor, video.privacy === 1); const createActivity = buildCreateActivity(video.url, byActor, videoObject, audience); - return utils_1.broadcastToFollowers(createActivity, byActor, [byActor], t); + return (0, utils_1.broadcastToFollowers)(createActivity, byActor, [byActor], t); }); } exports.sendCreateVideo = sendCreateVideo; function sendCreateCacheFile(byActor, video, fileRedundancy) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to send file cache of %s.', fileRedundancy.url, lTags(video.uuid)); return sendVideoRelatedCreateActivity({ byActor, @@ -35,66 +35,66 @@ function sendCreateCacheFile(byActor, video, fileRedundancy) { } exports.sendCreateCacheFile = sendCreateCacheFile; function sendCreateVideoPlaylist(playlist, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (playlist.privacy === 3) return undefined; logger_1.logger.info('Creating job to send create video playlist of %s.', playlist.url, lTags(playlist.uuid)); const byActor = playlist.OwnerAccount.Actor; - const audience = audience_1.getAudience(byActor, playlist.privacy === 1); + const audience = (0, audience_1.getAudience)(byActor, playlist.privacy === 1); const object = yield playlist.toActivityPubObject(null, t); const createActivity = buildCreateActivity(playlist.url, byActor, object, audience); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const toFollowersOf = [byActor, serverActor]; if (playlist.VideoChannel) toFollowersOf.push(playlist.VideoChannel.Actor); - return utils_1.broadcastToFollowers(createActivity, byActor, toFollowersOf, t); + return (0, utils_1.broadcastToFollowers)(createActivity, byActor, toFollowersOf, t); }); } exports.sendCreateVideoPlaylist = sendCreateVideoPlaylist; function sendCreateVideoComment(comment, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to send comment %s.', comment.url); const isOrigin = comment.Video.isOwned(); const byActor = comment.Account.Actor; const threadParentComments = yield video_comment_1.VideoCommentModel.listThreadParentComments(comment, t); const commentObject = comment.toActivityPubObject(threadParentComments); - const actorsInvolvedInComment = yield audience_1.getActorsInvolvedInVideo(comment.Video, t); + const actorsInvolvedInComment = yield (0, audience_1.getActorsInvolvedInVideo)(comment.Video, t); actorsInvolvedInComment.push(byActor); const parentsCommentActors = threadParentComments.filter(c => !c.isDeleted()) .map(c => c.Account.Actor); let audience; if (isOrigin) { - audience = audience_1.getVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment, isOrigin); + audience = (0, audience_1.getVideoCommentAudience)(comment, threadParentComments, actorsInvolvedInComment, isOrigin); } else { - audience = audience_1.getAudienceFromFollowersOf(actorsInvolvedInComment.concat(parentsCommentActors)); + audience = (0, audience_1.getAudienceFromFollowersOf)(actorsInvolvedInComment.concat(parentsCommentActors)); } const createActivity = buildCreateActivity(comment.url, byActor, commentObject, audience); const actorsException = [byActor]; - yield utils_1.broadcastToActors(createActivity, byActor, parentsCommentActors, t, actorsException); - yield utils_1.broadcastToFollowers(createActivity, byActor, [byActor], t); + yield (0, utils_1.broadcastToActors)(createActivity, byActor, parentsCommentActors, t, actorsException); + yield (0, utils_1.broadcastToFollowers)(createActivity, byActor, [byActor], t); if (isOrigin) - return utils_1.broadcastToFollowers(createActivity, byActor, actorsInvolvedInComment, t, actorsException); - t.afterCommit(() => utils_1.unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.getSharedInbox())); + return (0, utils_1.broadcastToFollowers)(createActivity, byActor, actorsInvolvedInComment, t, actorsException); + t.afterCommit(() => (0, utils_1.unicastTo)(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.getSharedInbox())); }); } exports.sendCreateVideoComment = sendCreateVideoComment; function buildCreateActivity(url, byActor, object, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ type: 'Create', id: url + '/activity', actor: byActor.url, - object: audience_1.audiencify(object, audience) + object: (0, audience_1.audiencify)(object, audience) }, audience); } exports.buildCreateActivity = buildCreateActivity; function sendVideoRelatedCreateActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const activityBuilder = (audience) => { return buildCreateActivity(options.url, options.byActor, options.object, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, options); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, options); }); } diff --git a/dist/server/lib/activitypub/send/send-delete.js b/dist/server/lib/activitypub/send/send-delete.js index cbefd2d4..46c4868b 100644 --- a/dist/server/lib/activitypub/send/send-delete.js +++ b/dist/server/lib/activitypub/send/send-delete.js @@ -10,64 +10,64 @@ const audience_1 = require("../audience"); const url_1 = require("../url"); const utils_1 = require("./utils"); function sendDeleteVideo(video, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to broadcast delete of video %s.', video.url); const byActor = video.VideoChannel.Account.Actor; const activityBuilder = (audience) => { - const url = url_1.getDeleteActivityPubUrl(video.url); + const url = (0, url_1.getDeleteActivityPubUrl)(video.url); return buildDeleteActivity(url, video.url, byActor, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction }); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, { byActor, video, transaction }); }); } exports.sendDeleteVideo = sendDeleteVideo; function sendDeleteActor(byActor, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to broadcast delete of actor %s.', byActor.url); - const url = url_1.getDeleteActivityPubUrl(byActor.url); + const url = (0, url_1.getDeleteActivityPubUrl)(byActor.url); const activity = buildDeleteActivity(url, byActor.url, byActor); const actorsInvolved = yield video_share_1.VideoShareModel.loadActorsWhoSharedVideosOf(byActor.id, t); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); actorsInvolved.push(serverActor); actorsInvolved.push(byActor); - return utils_1.broadcastToFollowers(activity, byActor, actorsInvolved, t); + return (0, utils_1.broadcastToFollowers)(activity, byActor, actorsInvolved, t); }); } exports.sendDeleteActor = sendDeleteActor; function sendDeleteVideoComment(videoComment, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to send delete of comment %s.', videoComment.url); const isVideoOrigin = videoComment.Video.isOwned(); - const url = url_1.getDeleteActivityPubUrl(videoComment.url); + const url = (0, url_1.getDeleteActivityPubUrl)(videoComment.url); const byActor = videoComment.isOwned() ? videoComment.Account.Actor : videoComment.Video.VideoChannel.Account.Actor; const threadParentComments = yield video_comment_1.VideoCommentModel.listThreadParentComments(videoComment, t); const threadParentCommentsFiltered = threadParentComments.filter(c => !c.isDeleted()); - const actorsInvolvedInComment = yield audience_1.getActorsInvolvedInVideo(videoComment.Video, t); + const actorsInvolvedInComment = yield (0, audience_1.getActorsInvolvedInVideo)(videoComment.Video, t); actorsInvolvedInComment.push(byActor); - const audience = audience_1.getVideoCommentAudience(videoComment, threadParentCommentsFiltered, actorsInvolvedInComment, isVideoOrigin); + const audience = (0, audience_1.getVideoCommentAudience)(videoComment, threadParentCommentsFiltered, actorsInvolvedInComment, isVideoOrigin); const activity = buildDeleteActivity(url, videoComment.url, byActor, audience); const actorsException = [byActor]; - yield utils_1.broadcastToActors(activity, byActor, threadParentCommentsFiltered.map(c => c.Account.Actor), t, actorsException); - yield utils_1.broadcastToFollowers(activity, byActor, [byActor], t); + yield (0, utils_1.broadcastToActors)(activity, byActor, threadParentCommentsFiltered.map(c => c.Account.Actor), t, actorsException); + yield (0, utils_1.broadcastToFollowers)(activity, byActor, [byActor], t); if (isVideoOrigin) - return utils_1.broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException); - t.afterCommit(() => utils_1.unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.getSharedInbox())); + return (0, utils_1.broadcastToFollowers)(activity, byActor, actorsInvolvedInComment, t, actorsException); + t.afterCommit(() => (0, utils_1.unicastTo)(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.getSharedInbox())); }); } exports.sendDeleteVideoComment = sendDeleteVideoComment; function sendDeleteVideoPlaylist(videoPlaylist, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to send delete of playlist %s.', videoPlaylist.url); const byActor = videoPlaylist.OwnerAccount.Actor; - const url = url_1.getDeleteActivityPubUrl(videoPlaylist.url); + const url = (0, url_1.getDeleteActivityPubUrl)(videoPlaylist.url); const activity = buildDeleteActivity(url, videoPlaylist.url, byActor); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const toFollowersOf = [byActor, serverActor]; if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor); - return utils_1.broadcastToFollowers(activity, byActor, toFollowersOf, t); + return (0, utils_1.broadcastToFollowers)(activity, byActor, toFollowersOf, t); }); } exports.sendDeleteVideoPlaylist = sendDeleteVideoPlaylist; @@ -79,6 +79,6 @@ function buildDeleteActivity(url, object, byActor, audience) { object }; if (audience) - return audience_1.audiencify(activity, audience); + return (0, audience_1.audiencify)(activity, audience); return activity; } diff --git a/dist/server/lib/activitypub/send/send-dislike.js b/dist/server/lib/activitypub/send/send-dislike.js index a3f8ef7d..3cef1559 100644 --- a/dist/server/lib/activitypub/send/send-dislike.js +++ b/dist/server/lib/activitypub/send/send-dislike.js @@ -8,16 +8,16 @@ const audience_1 = require("../audience"); function sendDislike(byActor, video, t) { logger_1.logger.info('Creating job to dislike %s.', video.url); const activityBuilder = (audience) => { - const url = url_1.getVideoDislikeActivityPubUrlByLocalActor(byActor, video); + const url = (0, url_1.getVideoDislikeActivityPubUrlByLocalActor)(byActor, video); return buildDislikeActivity(url, byActor, video, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction: t }); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, { byActor, video, transaction: t }); } exports.sendDislike = sendDislike; function buildDislikeActivity(url, byActor, video, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ id: url, type: 'Dislike', actor: byActor.url, diff --git a/dist/server/lib/activitypub/send/send-flag.js b/dist/server/lib/activitypub/send/send-flag.js index 87ee8b3a..4aba0195 100644 --- a/dist/server/lib/activitypub/send/send-flag.js +++ b/dist/server/lib/activitypub/send/send-flag.js @@ -8,16 +8,16 @@ const utils_1 = require("./utils"); function sendAbuse(byActor, abuse, flaggedAccount, t) { if (!flaggedAccount.Actor.serverId) return; - const url = url_1.getLocalAbuseActivityPubUrl(abuse); + const url = (0, url_1.getLocalAbuseActivityPubUrl)(abuse); logger_1.logger.info('Creating job to send abuse %s.', url); const audience = { to: [flaggedAccount.Actor.url], cc: [] }; const flagActivity = buildFlagActivity(url, byActor, abuse, audience); - t.afterCommit(() => utils_1.unicastTo(flagActivity, byActor, flaggedAccount.Actor.getSharedInbox())); + t.afterCommit(() => (0, utils_1.unicastTo)(flagActivity, byActor, flaggedAccount.Actor.getSharedInbox())); } exports.sendAbuse = sendAbuse; function buildFlagActivity(url, byActor, abuse, audience) { if (!audience) - audience = audience_1.getAudience(byActor); + audience = (0, audience_1.getAudience)(byActor); const activity = Object.assign({ id: url, actor: byActor.url }, abuse.toActivityPubObject()); - return audience_1.audiencify(activity, audience); + return (0, audience_1.audiencify)(activity, audience); } diff --git a/dist/server/lib/activitypub/send/send-follow.js b/dist/server/lib/activitypub/send/send-follow.js index b73ef62c..77127c6c 100644 --- a/dist/server/lib/activitypub/send/send-follow.js +++ b/dist/server/lib/activitypub/send/send-follow.js @@ -10,7 +10,7 @@ function sendFollow(actorFollow, t) { return; logger_1.logger.info('Creating job to send follow request to %s.', following.url); const data = buildFollowActivity(actorFollow.url, me, following); - t.afterCommit(() => utils_1.unicastTo(data, me, following.inboxUrl)); + t.afterCommit(() => (0, utils_1.unicastTo)(data, me, following.inboxUrl)); } exports.sendFollow = sendFollow; function buildFollowActivity(url, byActor, targetActor) { diff --git a/dist/server/lib/activitypub/send/send-like.js b/dist/server/lib/activitypub/send/send-like.js index e4f447bb..aca2f84d 100644 --- a/dist/server/lib/activitypub/send/send-like.js +++ b/dist/server/lib/activitypub/send/send-like.js @@ -8,16 +8,16 @@ const logger_1 = require("../../../helpers/logger"); function sendLike(byActor, video, t) { logger_1.logger.info('Creating job to like %s.', video.url); const activityBuilder = (audience) => { - const url = url_1.getVideoLikeActivityPubUrlByLocalActor(byActor, video); + const url = (0, url_1.getVideoLikeActivityPubUrlByLocalActor)(byActor, video); return buildLikeActivity(url, byActor, video, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction: t }); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, { byActor, video, transaction: t }); } exports.sendLike = sendLike; function buildLikeActivity(url, byActor, video, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ id: url, type: 'Like', actor: byActor.url, diff --git a/dist/server/lib/activitypub/send/send-reject.js b/dist/server/lib/activitypub/send/send-reject.js index eb59ce96..a2440ee8 100644 --- a/dist/server/lib/activitypub/send/send-reject.js +++ b/dist/server/lib/activitypub/send/send-reject.js @@ -11,10 +11,10 @@ function sendReject(followUrl, follower, following) { return; } logger_1.logger.info('Creating job to reject follower %s.', follower.url); - const followData = send_follow_1.buildFollowActivity(followUrl, follower, following); - const url = url_1.getLocalActorFollowRejectActivityPubUrl(follower, following); + const followData = (0, send_follow_1.buildFollowActivity)(followUrl, follower, following); + const url = (0, url_1.getLocalActorFollowRejectActivityPubUrl)(follower, following); const data = buildRejectActivity(url, following, followData); - return utils_1.unicastTo(data, following, follower.inboxUrl); + return (0, utils_1.unicastTo)(data, following, follower.inboxUrl); } exports.sendReject = sendReject; function buildRejectActivity(url, byActor, followActivityData) { diff --git a/dist/server/lib/activitypub/send/send-undo.js b/dist/server/lib/activitypub/send/send-undo.js index 60c41778..644e58f2 100644 --- a/dist/server/lib/activitypub/send/send-undo.js +++ b/dist/server/lib/activitypub/send/send-undo.js @@ -18,43 +18,43 @@ function sendUndoFollow(actorFollow, t) { if (!following.serverId) return; logger_1.logger.info('Creating job to send an unfollow request to %s.', following.url); - const undoUrl = url_1.getUndoActivityPubUrl(actorFollow.url); - const followActivity = send_follow_1.buildFollowActivity(actorFollow.url, me, following); + const undoUrl = (0, url_1.getUndoActivityPubUrl)(actorFollow.url); + const followActivity = (0, send_follow_1.buildFollowActivity)(actorFollow.url, me, following); const undoActivity = undoActivityData(undoUrl, me, followActivity); - t.afterCommit(() => utils_1.unicastTo(undoActivity, me, following.inboxUrl)); + t.afterCommit(() => (0, utils_1.unicastTo)(undoActivity, me, following.inboxUrl)); } exports.sendUndoFollow = sendUndoFollow; function sendUndoAnnounce(byActor, videoShare, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to undo announce %s.', videoShare.url); - const undoUrl = url_1.getUndoActivityPubUrl(videoShare.url); - const { activity: announceActivity, actorsInvolvedInVideo } = yield send_announce_1.buildAnnounceWithVideoAudience(byActor, videoShare, video, t); + const undoUrl = (0, url_1.getUndoActivityPubUrl)(videoShare.url); + const { activity: announceActivity, actorsInvolvedInVideo } = yield (0, send_announce_1.buildAnnounceWithVideoAudience)(byActor, videoShare, video, t); const undoActivity = undoActivityData(undoUrl, byActor, announceActivity); const followersException = [byActor]; - return utils_1.broadcastToFollowers(undoActivity, byActor, actorsInvolvedInVideo, t, followersException); + return (0, utils_1.broadcastToFollowers)(undoActivity, byActor, actorsInvolvedInVideo, t, followersException); }); } exports.sendUndoAnnounce = sendUndoAnnounce; function sendUndoLike(byActor, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to undo a like of video %s.', video.url); - const likeUrl = url_1.getVideoLikeActivityPubUrlByLocalActor(byActor, video); - const likeActivity = send_like_1.buildLikeActivity(likeUrl, byActor, video); + const likeUrl = (0, url_1.getVideoLikeActivityPubUrlByLocalActor)(byActor, video); + const likeActivity = (0, send_like_1.buildLikeActivity)(likeUrl, byActor, video); return sendUndoVideoRelatedActivity({ byActor, video, url: likeUrl, activity: likeActivity, transaction: t }); }); } exports.sendUndoLike = sendUndoLike; function sendUndoDislike(byActor, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to undo a dislike of video %s.', video.url); - const dislikeUrl = url_1.getVideoDislikeActivityPubUrlByLocalActor(byActor, video); - const dislikeActivity = send_dislike_1.buildDislikeActivity(dislikeUrl, byActor, video); + const dislikeUrl = (0, url_1.getVideoDislikeActivityPubUrlByLocalActor)(byActor, video); + const dislikeActivity = (0, send_dislike_1.buildDislikeActivity)(dislikeUrl, byActor, video); return sendUndoVideoRelatedActivity({ byActor, video, url: dislikeUrl, activity: dislikeActivity, transaction: t }); }); } exports.sendUndoDislike = sendUndoDislike; function sendUndoCacheFile(byActor, redundancyModel, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to undo cache file %s.', redundancyModel.url); const associatedVideo = redundancyModel.getVideo(); if (!associatedVideo) { @@ -62,15 +62,15 @@ function sendUndoCacheFile(byActor, redundancyModel, t) { return; } const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id); - const createActivity = send_create_1.buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject()); + const createActivity = (0, send_create_1.buildCreateActivity)(redundancyModel.url, byActor, redundancyModel.toActivityPubObject()); return sendUndoVideoRelatedActivity({ byActor, video, url: redundancyModel.url, activity: createActivity, transaction: t }); }); } exports.sendUndoCacheFile = sendUndoCacheFile; function undoActivityData(url, byActor, object, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ type: 'Undo', id: url, actor: byActor.url, @@ -78,11 +78,11 @@ function undoActivityData(url, byActor, object, audience) { }, audience); } function sendUndoVideoRelatedActivity(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const activityBuilder = (audience) => { - const undoUrl = url_1.getUndoActivityPubUrl(options.url); + const undoUrl = (0, url_1.getUndoActivityPubUrl)(options.url); return undoActivityData(undoUrl, options.byActor, options.activity, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, options); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, options); }); } diff --git a/dist/server/lib/activitypub/send/send-update.js b/dist/server/lib/activitypub/send/send-update.js index bab46ea1..8d913957 100644 --- a/dist/server/lib/activitypub/send/send-update.js +++ b/dist/server/lib/activitypub/send/send-update.js @@ -11,33 +11,33 @@ const audience_1 = require("../audience"); const logger_1 = require("../../../helpers/logger"); const application_1 = require("@server/models/application/application"); function sendUpdateVideo(videoArg, t, overrodeByActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = videoArg; if (!video.hasPrivacyForFederation()) return undefined; logger_1.logger.info('Creating job to update video %s.', video.url); const byActor = overrodeByActor || video.VideoChannel.Account.Actor; - const url = url_1.getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString()); + const url = (0, url_1.getUpdateActivityPubUrl)(video.url, video.updatedAt.toISOString()); if (!video.VideoCaptions) { video.VideoCaptions = yield video.$get('VideoCaptions', { transaction: t }); } const videoObject = video.toActivityPubObject(); - const audience = audience_1.getAudience(byActor, video.privacy === 1); + const audience = (0, audience_1.getAudience)(byActor, video.privacy === 1); const updateActivity = buildUpdateActivity(url, byActor, videoObject, audience); - const actorsInvolved = yield audience_1.getActorsInvolvedInVideo(video, t); + const actorsInvolved = yield (0, audience_1.getActorsInvolvedInVideo)(video, t); if (overrodeByActor) actorsInvolved.push(overrodeByActor); - return utils_1.broadcastToFollowers(updateActivity, byActor, actorsInvolved, t); + return (0, utils_1.broadcastToFollowers)(updateActivity, byActor, actorsInvolved, t); }); } exports.sendUpdateVideo = sendUpdateVideo; function sendUpdateActor(accountOrChannel, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const byActor = accountOrChannel.Actor; logger_1.logger.info('Creating job to update actor %s.', byActor.url); - const url = url_1.getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()); + const url = (0, url_1.getUpdateActivityPubUrl)(byActor.url, byActor.updatedAt.toISOString()); const accountOrChannelObject = accountOrChannel.toActivityPubObject(); - const audience = audience_1.getAudience(byActor); + const audience = (0, audience_1.getAudience)(byActor); const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience); let actorsInvolved; if (accountOrChannel instanceof account_1.AccountModel) { @@ -47,12 +47,12 @@ function sendUpdateActor(accountOrChannel, t) { actorsInvolved = yield video_share_1.VideoShareModel.loadActorsByVideoChannel(accountOrChannel.id, t); } actorsInvolved.push(byActor); - return utils_1.broadcastToFollowers(updateActivity, byActor, actorsInvolved, t); + return (0, utils_1.broadcastToFollowers)(updateActivity, byActor, actorsInvolved, t); }); } exports.sendUpdateActor = sendUpdateActor; function sendUpdateCacheFile(byActor, redundancyModel) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to update cache file %s.', redundancyModel.url); const associatedVideo = redundancyModel.getVideo(); if (!associatedVideo) { @@ -62,38 +62,38 @@ function sendUpdateCacheFile(byActor, redundancyModel) { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id); const activityBuilder = (audience) => { const redundancyObject = redundancyModel.toActivityPubObject(); - const url = url_1.getUpdateActivityPubUrl(redundancyModel.url, redundancyModel.updatedAt.toISOString()); + const url = (0, url_1.getUpdateActivityPubUrl)(redundancyModel.url, redundancyModel.updatedAt.toISOString()); return buildUpdateActivity(url, byActor, redundancyObject, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, { byActor, video, contextType: 'CacheFile' }); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, { byActor, video, contextType: 'CacheFile' }); }); } exports.sendUpdateCacheFile = sendUpdateCacheFile; function sendUpdateVideoPlaylist(videoPlaylist, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (videoPlaylist.privacy === 3) return undefined; const byActor = videoPlaylist.OwnerAccount.Actor; logger_1.logger.info('Creating job to update video playlist %s.', videoPlaylist.url); - const url = url_1.getUpdateActivityPubUrl(videoPlaylist.url, videoPlaylist.updatedAt.toISOString()); + const url = (0, url_1.getUpdateActivityPubUrl)(videoPlaylist.url, videoPlaylist.updatedAt.toISOString()); const object = yield videoPlaylist.toActivityPubObject(null, t); - const audience = audience_1.getAudience(byActor, videoPlaylist.privacy === 1); + const audience = (0, audience_1.getAudience)(byActor, videoPlaylist.privacy === 1); const updateActivity = buildUpdateActivity(url, byActor, object, audience); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const toFollowersOf = [byActor, serverActor]; if (videoPlaylist.VideoChannel) toFollowersOf.push(videoPlaylist.VideoChannel.Actor); - return utils_1.broadcastToFollowers(updateActivity, byActor, toFollowersOf, t); + return (0, utils_1.broadcastToFollowers)(updateActivity, byActor, toFollowersOf, t); }); } exports.sendUpdateVideoPlaylist = sendUpdateVideoPlaylist; function buildUpdateActivity(url, byActor, object, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ type: 'Update', id: url, actor: byActor.url, - object: audience_1.audiencify(object, audience) + object: (0, audience_1.audiencify)(object, audience) }, audience); } diff --git a/dist/server/lib/activitypub/send/send-view.js b/dist/server/lib/activitypub/send/send-view.js index 02b9e03b..e77f00a6 100644 --- a/dist/server/lib/activitypub/send/send-view.js +++ b/dist/server/lib/activitypub/send/send-view.js @@ -7,20 +7,20 @@ const audience_1 = require("../audience"); const url_1 = require("../url"); const utils_1 = require("./utils"); function sendView(byActor, video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Creating job to send view of %s.', video.url); const activityBuilder = (audience) => { - const url = url_1.getLocalVideoViewActivityPubUrl(byActor, video); + const url = (0, url_1.getLocalVideoViewActivityPubUrl)(byActor, video); return buildViewActivity(url, byActor, video, audience); }; - return utils_1.sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction: t, contextType: 'View' }); + return (0, utils_1.sendVideoRelatedActivity)(activityBuilder, { byActor, video, transaction: t, contextType: 'View' }); }); } exports.sendView = sendView; function buildViewActivity(url, byActor, video, audience) { if (!audience) - audience = audience_1.getAudience(byActor); - return audience_1.audiencify({ + audience = (0, audience_1.getAudience)(byActor); + return (0, audience_1.audiencify)({ id: url, type: 'View', actor: byActor.url, diff --git a/dist/server/lib/activitypub/send/utils.js b/dist/server/lib/activitypub/send/utils.js index e1f1b482..63520fd2 100644 --- a/dist/server/lib/activitypub/send/utils.js +++ b/dist/server/lib/activitypub/send/utils.js @@ -11,20 +11,20 @@ const job_queue_1 = require("../../job-queue"); const audience_1 = require("../audience"); function sendVideoRelatedActivity(activityBuilder, options) { var _a, _b; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { byActor, video, transaction, contextType } = options; - const actorsInvolvedInVideo = yield audience_1.getActorsInvolvedInVideo(video, transaction); + const actorsInvolvedInVideo = yield (0, audience_1.getActorsInvolvedInVideo)(video, transaction); if (video.isOwned() === false) { let accountActor = (_b = (_a = video.VideoChannel) === null || _a === void 0 ? void 0 : _a.Account) === null || _b === void 0 ? void 0 : _b.Actor; if (!accountActor) accountActor = yield actor_1.ActorModel.loadAccountActorByVideoId(video.id, transaction); - const audience = audience_1.getRemoteVideoAudience(accountActor, actorsInvolvedInVideo); + const audience = (0, audience_1.getRemoteVideoAudience)(accountActor, actorsInvolvedInVideo); const activity = activityBuilder(audience); - return database_utils_1.afterCommitIfTransaction(transaction, () => { + return (0, database_utils_1.afterCommitIfTransaction)(transaction, () => { return unicastTo(activity, byActor, accountActor.getSharedInbox(), contextType); }); } - const audience = audience_1.getAudienceFromFollowersOf(actorsInvolvedInVideo); + const audience = (0, audience_1.getAudienceFromFollowersOf)(actorsInvolvedInVideo); const activity = activityBuilder(audience); const actorsException = [byActor]; return broadcastToFollowers(activity, byActor, actorsInvolvedInVideo, transaction, actorsException, contextType); @@ -32,15 +32,15 @@ function sendVideoRelatedActivity(activityBuilder, options) { } exports.sendVideoRelatedActivity = sendVideoRelatedActivity; function forwardVideoRelatedActivity(activity, t, followersException, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const additionalActors = yield audience_1.getActorsInvolvedInVideo(video, t); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const additionalActors = yield (0, audience_1.getActorsInvolvedInVideo)(video, t); const additionalFollowerUrls = additionalActors.map(a => a.followersUrl); return forwardActivity(activity, t, followersException, additionalFollowerUrls); }); } exports.forwardVideoRelatedActivity = forwardVideoRelatedActivity; function forwardActivity(activity, t, followersException = [], additionalFollowerUrls = []) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Forwarding activity %s.', activity.id); const to = activity.to || []; const cc = activity.cc || []; @@ -61,21 +61,21 @@ function forwardActivity(activity, t, followersException = [], additionalFollowe uris, body: activity }; - return database_utils_1.afterCommitIfTransaction(t, () => job_queue_1.JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload })); + return (0, database_utils_1.afterCommitIfTransaction)(t, () => job_queue_1.JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload })); }); } exports.forwardActivity = forwardActivity; function broadcastToFollowers(data, byActor, toFollowersOf, t, actorsException = [], contextType) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uris = yield computeFollowerUris(toFollowersOf, actorsException, t); - return database_utils_1.afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor, contextType)); + return (0, database_utils_1.afterCommitIfTransaction)(t, () => broadcastTo(uris, data, byActor, contextType)); }); } exports.broadcastToFollowers = broadcastToFollowers; function broadcastToActors(data, byActor, toActors, t, actorsException = [], contextType) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uris = yield computeUris(toActors, actorsException); - return database_utils_1.afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor, contextType)); + return (0, database_utils_1.afterCommitIfTransaction)(t, () => broadcastTo(uris, data, byActor, contextType)); }); } exports.broadcastToActors = broadcastToActors; @@ -103,7 +103,7 @@ function unicastTo(data, byActor, toActorUrl, contextType) { } exports.unicastTo = unicastTo; function computeFollowerUris(toFollowersOf, actorsException, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const toActorFollowerIds = toFollowersOf.map(a => a.id); const result = yield actor_follow_1.ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t); const sharedInboxesException = yield buildSharedInboxesException(actorsException); @@ -111,8 +111,8 @@ function computeFollowerUris(toFollowersOf, actorsException, t) { }); } function computeUris(toActors, actorsException = []) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const targetUrls = toActors .filter(a => a.id !== serverActor.id) .map(a => a.getSharedInbox()); @@ -123,8 +123,8 @@ function computeUris(toActors, actorsException = []) { }); } function buildSharedInboxesException(actorsException) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); return actorsException .map(f => f.getSharedInbox()) .concat([serverActor.sharedInboxUrl]); diff --git a/dist/server/lib/activitypub/share.js b/dist/server/lib/activitypub/share.js index 5b5929f3..2cd6b130 100644 --- a/dist/server/lib/activitypub/share.js +++ b/dist/server/lib/activitypub/share.js @@ -12,9 +12,9 @@ const video_share_1 = require("../../models/video/video-share"); const actors_1 = require("./actors"); const send_1 = require("./send"); const url_1 = require("./url"); -const lTags = logger_1.loggerTagsFactory('share'); +const lTags = (0, logger_1.loggerTagsFactory)('share'); function shareVideoByServerAndChannel(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!video.hasPrivacyForFederation()) return undefined; return Promise.all([ @@ -25,7 +25,7 @@ function shareVideoByServerAndChannel(video, t) { } exports.shareVideoByServerAndChannel = shareVideoByServerAndChannel; function changeVideoChannelShare(video, oldVideoChannel, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Updating video channel of video %s: %s -> %s.', video.uuid, oldVideoChannel.name, video.VideoChannel.name, lTags(video.uuid)); yield undoShareByVideoChannel(video, oldVideoChannel, t); yield shareByVideoChannel(video, t); @@ -33,8 +33,8 @@ function changeVideoChannelShare(video, oldVideoChannel, t) { } exports.changeVideoChannelShare = changeVideoChannelShare; function addVideoShares(shareUrls, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield bluebird_1.map(shareUrls, (shareUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(shareUrls, (shareUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield addVideoShare(shareUrl, video); } @@ -46,15 +46,15 @@ function addVideoShares(shareUrls, video) { } exports.addVideoShares = addVideoShares; function addVideoShare(shareUrl, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { body } = yield requests_1.doJSONRequest(shareUrl, { activityPub: true }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { body } = yield (0, requests_1.doJSONRequest)(shareUrl, { activityPub: true }); if (!body || !body.actor) throw new Error('Body or body actor is invalid'); - const actorUrl = activitypub_1.getAPId(body.actor); - if (activitypub_1.checkUrlsSameHost(shareUrl, actorUrl) !== true) { + const actorUrl = (0, activitypub_1.getAPId)(body.actor); + if ((0, activitypub_1.checkUrlsSameHost)(shareUrl, actorUrl) !== true) { throw new Error(`Actor url ${actorUrl} has not the same host than the share url ${shareUrl}`); } - const actor = yield actors_1.getOrCreateAPActor(actorUrl); + const actor = yield (0, actors_1.getOrCreateAPActor)(actorUrl); const entry = { actorId: actor.id, videoId: video.id, @@ -64,9 +64,9 @@ function addVideoShare(shareUrl, video) { }); } function shareByServer(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); - const serverShareUrl = url_1.getLocalVideoAnnounceActivityPubUrl(serverActor, video); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); + const serverShareUrl = (0, url_1.getLocalVideoAnnounceActivityPubUrl)(serverActor, video); const [serverShare] = yield video_share_1.VideoShareModel.findOrCreate({ defaults: { actorId: serverActor.id, @@ -78,12 +78,12 @@ function shareByServer(video, t) { }, transaction: t }); - return send_1.sendVideoAnnounce(serverActor, serverShare, video, t); + return (0, send_1.sendVideoAnnounce)(serverActor, serverShare, video, t); }); } function shareByVideoChannel(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoChannelShareUrl = url_1.getLocalVideoAnnounceActivityPubUrl(video.VideoChannel.Actor, video); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoChannelShareUrl = (0, url_1.getLocalVideoAnnounceActivityPubUrl)(video.VideoChannel.Actor, video); const [videoChannelShare] = yield video_share_1.VideoShareModel.findOrCreate({ defaults: { actorId: video.VideoChannel.actorId, @@ -95,15 +95,15 @@ function shareByVideoChannel(video, t) { }, transaction: t }); - return send_1.sendVideoAnnounce(video.VideoChannel.Actor, videoChannelShare, video, t); + return (0, send_1.sendVideoAnnounce)(video.VideoChannel.Actor, videoChannelShare, video, t); }); } function undoShareByVideoChannel(video, oldVideoChannel, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldShare = yield video_share_1.VideoShareModel.load(oldVideoChannel.actorId, video.id, t); if (!oldShare) return new Error('Cannot find old video channel share ' + oldVideoChannel.actorId + ' for video ' + video.id); - yield send_1.sendUndoAnnounce(oldVideoChannel.Actor, oldShare, video, t); + yield (0, send_1.sendUndoAnnounce)(oldVideoChannel.Actor, oldShare, video, t); yield oldShare.destroy({ transaction: t }); }); } diff --git a/dist/server/lib/activitypub/video-comments.js b/dist/server/lib/activitypub/video-comments.js index 0c49de1a..f1860fd3 100644 --- a/dist/server/lib/activitypub/video-comments.js +++ b/dist/server/lib/activitypub/video-comments.js @@ -12,8 +12,8 @@ const video_comment_1 = require("../../models/video/video-comment"); const actors_1 = require("./actors"); const videos_1 = require("./videos"); function addVideoComments(commentUrls) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - return bluebird_1.map(commentUrls, (commentUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return (0, bluebird_1.map)(commentUrls, (commentUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield resolveThread({ url: commentUrl, isVideo: false }); } @@ -25,7 +25,7 @@ function addVideoComments(commentUrls) { } exports.addVideoComments = addVideoComments; function resolveThread(params) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { url, isVideo } = params; if (params.commentCreated === undefined) params.commentCreated = false; @@ -49,7 +49,7 @@ function resolveThread(params) { } exports.resolveThread = resolveThread; function resolveCommentFromDB(params) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { url, comments, commentCreated } = params; const commentFromDatabase = yield video_comment_1.VideoCommentModel.loadByUrlAndPopulateReplyAndVideoUrlAndAccount(url); if (!commentFromDatabase) @@ -68,10 +68,10 @@ function resolveCommentFromDB(params) { }); } function tryToResolveThreadFromVideo(params) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { url, comments, commentCreated } = params; const syncParam = { likes: true, dislikes: true, shares: true, comments: false, thumbnail: true, refreshVideo: false }; - const { video } = yield videos_1.getOrCreateAPVideo({ videoObject: url, syncParam }); + const { video } = yield (0, videos_1.getOrCreateAPVideo)({ videoObject: url, syncParam }); if (video.isOwned() && !video.hasPrivacyForFederation()) { throw new Error('Cannot resolve thread of video with privacy that is not compatible with federation'); } @@ -99,26 +99,26 @@ function tryToResolveThreadFromVideo(params) { }); } function resolveRemoteParentComment(params) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { url, comments } = params; if (comments.length > constants_1.ACTIVITY_PUB.MAX_RECURSION_COMMENTS) { throw new Error('Recursion limit reached when resolving a thread'); } - const { body } = yield requests_1.doJSONRequest(url, { activityPub: true }); - if (video_comments_1.sanitizeAndCheckVideoCommentObject(body) === false) { + const { body } = yield (0, requests_1.doJSONRequest)(url, { activityPub: true }); + if ((0, video_comments_1.sanitizeAndCheckVideoCommentObject)(body) === false) { throw new Error(`Remote video comment JSON ${url} is not valid:` + JSON.stringify(body)); } const actorUrl = body.attributedTo; if (!actorUrl && body.type !== 'Tombstone') throw new Error('Miss attributed to in comment'); - if (actorUrl && activitypub_1.checkUrlsSameHost(url, actorUrl) !== true) { + if (actorUrl && (0, activitypub_1.checkUrlsSameHost)(url, actorUrl) !== true) { throw new Error(`Actor url ${actorUrl} has not the same host than the comment url ${url}`); } - if (activitypub_1.checkUrlsSameHost(body.id, url) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(body.id, url) !== true) { throw new Error(`Comment url ${url} host is different from the AP object id ${body.id}`); } const actor = actorUrl - ? yield actors_1.getOrCreateAPActor(actorUrl, 'all') + ? yield (0, actors_1.getOrCreateAPActor)(actorUrl, 'all') : null; const comment = new video_comment_1.VideoCommentModel({ url: body.id, diff --git a/dist/server/lib/activitypub/video-rates.js b/dist/server/lib/activitypub/video-rates.js index d9b2e9a7..0d7ac9ed 100644 --- a/dist/server/lib/activitypub/video-rates.js +++ b/dist/server/lib/activitypub/video-rates.js @@ -12,10 +12,10 @@ const actors_1 = require("./actors"); const send_1 = require("./send"); const send_dislike_1 = require("./send/send-dislike"); const url_1 = require("./url"); -const lTags = logger_1.loggerTagsFactory('ap', 'video-rate', 'create'); +const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video-rate', 'create'); function createRates(ratesUrl, video, rate) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield bluebird_1.map(ratesUrl, (rateUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(ratesUrl, (rateUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield createRate(rateUrl, video, rate); } @@ -27,38 +27,38 @@ function createRates(ratesUrl, video, rate) { } exports.createRates = createRates; function sendVideoRateChange(account, video, likes, dislikes, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actor = account.Actor; if (likes < 0) - yield send_1.sendUndoLike(actor, video, t); + yield (0, send_1.sendUndoLike)(actor, video, t); if (dislikes < 0) - yield send_1.sendUndoDislike(actor, video, t); + yield (0, send_1.sendUndoDislike)(actor, video, t); if (likes > 0) - yield send_1.sendLike(actor, video, t); + yield (0, send_1.sendLike)(actor, video, t); if (dislikes > 0) - yield send_dislike_1.sendDislike(actor, video, t); + yield (0, send_dislike_1.sendDislike)(actor, video, t); }); } exports.sendVideoRateChange = sendVideoRateChange; function getLocalRateUrl(rateType, actor, video) { return rateType === 'like' - ? url_1.getVideoLikeActivityPubUrlByLocalActor(actor, video) - : url_1.getVideoDislikeActivityPubUrlByLocalActor(actor, video); + ? (0, url_1.getVideoLikeActivityPubUrlByLocalActor)(actor, video) + : (0, url_1.getVideoDislikeActivityPubUrlByLocalActor)(actor, video); } exports.getLocalRateUrl = getLocalRateUrl; function createRate(rateUrl, video, rate) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { body } = yield requests_1.doJSONRequest(rateUrl, { activityPub: true }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { body } = yield (0, requests_1.doJSONRequest)(rateUrl, { activityPub: true }); if (!body || !body.actor) throw new Error('Body or body actor is invalid'); - const actorUrl = activitypub_1.getAPId(body.actor); - if (activitypub_1.checkUrlsSameHost(actorUrl, rateUrl) !== true) { + const actorUrl = (0, activitypub_1.getAPId)(body.actor); + if ((0, activitypub_1.checkUrlsSameHost)(actorUrl, rateUrl) !== true) { throw new Error(`Rate url ${rateUrl} has not the same host than actor url ${actorUrl}`); } - if (activitypub_1.checkUrlsSameHost(body.id, rateUrl) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(body.id, rateUrl) !== true) { throw new Error(`Rate url ${rateUrl} host is different from the AP object id ${body.id}`); } - const actor = yield actors_1.getOrCreateAPActor(actorUrl); + const actor = yield (0, actors_1.getOrCreateAPActor)(actorUrl); const entry = { videoId: video.id, accountId: actor.Account.id, diff --git a/dist/server/lib/activitypub/videos/federate.js b/dist/server/lib/activitypub/videos/federate.js index c592bcf6..dab3f765 100644 --- a/dist/server/lib/activitypub/videos/federate.js +++ b/dist/server/lib/activitypub/videos/federate.js @@ -6,22 +6,22 @@ const misc_1 = require("@server/helpers/custom-validators/misc"); const send_1 = require("../send"); const share_1 = require("../share"); function federateVideoIfNeeded(videoArg, isNewVideo, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = videoArg; if ((video.isBlacklisted() === false || (isNewVideo === false && video.VideoBlacklist.unfederated === false)) && video.hasPrivacyForFederation() && video.hasStateForFederation()) { - if (misc_1.isArray(video.VideoCaptions) === false) { + if ((0, misc_1.isArray)(video.VideoCaptions) === false) { video.VideoCaptions = yield video.$get('VideoCaptions', { attributes: ['filename', 'language'], transaction }); } if (isNewVideo) { - yield send_1.sendCreateVideo(video, transaction); - yield share_1.shareVideoByServerAndChannel(video, transaction); + yield (0, send_1.sendCreateVideo)(video, transaction); + yield (0, share_1.shareVideoByServerAndChannel)(video, transaction); } else { - yield send_1.sendUpdateVideo(video, transaction); + yield (0, send_1.sendUpdateVideo)(video, transaction); } } }); diff --git a/dist/server/lib/activitypub/videos/get.js b/dist/server/lib/activitypub/videos/get.js index fdbbd12f..33002a2a 100644 --- a/dist/server/lib/activitypub/videos/get.js +++ b/dist/server/lib/activitypub/videos/get.js @@ -9,32 +9,32 @@ const model_loaders_1 = require("@server/lib/model-loaders"); const refresh_1 = require("./refresh"); const shared_1 = require("./shared"); function getOrCreateAPVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }; const fetchType = options.fetchType || 'all'; const allowRefresh = options.allowRefresh !== false; - const videoUrl = activitypub_1.getAPId(options.videoObject); - let videoFromDatabase = yield model_loaders_1.loadVideoByUrl(videoUrl, fetchType); + const videoUrl = (0, activitypub_1.getAPId)(options.videoObject); + let videoFromDatabase = yield (0, model_loaders_1.loadVideoByUrl)(videoUrl, fetchType); if (videoFromDatabase) { if (allowRefresh === true) { videoFromDatabase = yield scheduleRefresh(videoFromDatabase, fetchType, syncParam); } return { video: videoFromDatabase, created: false }; } - const { videoObject } = yield shared_1.fetchRemoteVideo(videoUrl); + const { videoObject } = yield (0, shared_1.fetchRemoteVideo)(videoUrl); if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl); if (videoObject.id !== videoUrl) return getOrCreateAPVideo(Object.assign(Object.assign({}, options), { fetchType: 'all', videoObject })); try { const creator = new shared_1.APVideoCreator(videoObject); - const { autoBlacklisted, videoCreated } = yield database_utils_1.retryTransactionWrapper(creator.create.bind(creator), syncParam.thumbnail); - yield shared_1.syncVideoExternalAttributes(videoCreated, videoObject, syncParam); + const { autoBlacklisted, videoCreated } = yield (0, database_utils_1.retryTransactionWrapper)(creator.create.bind(creator), syncParam.thumbnail); + yield (0, shared_1.syncVideoExternalAttributes)(videoCreated, videoObject, syncParam); return { video: videoCreated, created: true, autoBlacklisted }; } catch (err) { if (err.name === 'SequelizeUniqueConstraintError') { - const alreadyCreatedVideo = yield model_loaders_1.loadVideoByUrl(videoUrl, fetchType); + const alreadyCreatedVideo = yield (0, model_loaders_1.loadVideoByUrl)(videoUrl, fetchType); if (alreadyCreatedVideo) return { video: alreadyCreatedVideo, created: false }; } @@ -44,7 +44,7 @@ function getOrCreateAPVideo(options) { } exports.getOrCreateAPVideo = getOrCreateAPVideo; function scheduleRefresh(video, fetchType, syncParam) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!video.isOutdated()) return video; const refreshOptions = { @@ -53,7 +53,7 @@ function scheduleRefresh(video, fetchType, syncParam) { syncParam }; if (syncParam.refreshVideo === true) { - return refresh_1.refreshVideoIfNeeded(refreshOptions); + return (0, refresh_1.refreshVideoIfNeeded)(refreshOptions); } yield job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'activitypub-refresher', diff --git a/dist/server/lib/activitypub/videos/index.js b/dist/server/lib/activitypub/videos/index.js index 5de93f75..b617ef57 100644 --- a/dist/server/lib/activitypub/videos/index.js +++ b/dist/server/lib/activitypub/videos/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./federate"), exports); -tslib_1.__exportStar(require("./get"), exports); -tslib_1.__exportStar(require("./refresh"), exports); -tslib_1.__exportStar(require("./updater"), exports); +(0, tslib_1.__exportStar)(require("./federate"), exports); +(0, tslib_1.__exportStar)(require("./get"), exports); +(0, tslib_1.__exportStar)(require("./refresh"), exports); +(0, tslib_1.__exportStar)(require("./updater"), exports); diff --git a/dist/server/lib/activitypub/videos/refresh.js b/dist/server/lib/activitypub/videos/refresh.js index 5f0bf11a..65587a06 100644 --- a/dist/server/lib/activitypub/videos/refresh.js +++ b/dist/server/lib/activitypub/videos/refresh.js @@ -9,16 +9,16 @@ const models_1 = require("@shared/models"); const shared_1 = require("./shared"); const updater_1 = require("./updater"); function refreshVideoIfNeeded(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!options.video.isOutdated()) return options.video; const video = options.fetchedType === 'all' ? options.video : yield video_1.VideoModel.loadByUrlAndPopulateAccount(options.video.url); - const lTags = logger_1.loggerTagsFactory('ap', 'video', 'refresh', video.uuid, video.url); + const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video', 'refresh', video.uuid, video.url); logger_1.logger.info('Refreshing video %s.', video.url, lTags()); try { - const { videoObject } = yield shared_1.fetchRemoteVideo(video.url); + const { videoObject } = yield (0, shared_1.fetchRemoteVideo)(video.url); if (videoObject === undefined) { logger_1.logger.warn('Cannot refresh remote video %s: invalid body.', video.url, lTags()); yield video.setAsRefreshed(); @@ -26,7 +26,7 @@ function refreshVideoIfNeeded(options) { } const videoUpdater = new updater_1.APVideoUpdater(videoObject, video); yield videoUpdater.update(); - yield shared_1.syncVideoExternalAttributes(video, videoObject, options.syncParam); + yield (0, shared_1.syncVideoExternalAttributes)(video, videoObject, options.syncParam); files_cache_1.ActorFollowScoreCache.Instance.addGoodServerId(video.VideoChannel.Actor.serverId); return video; } diff --git a/dist/server/lib/activitypub/videos/shared/abstract-builder.js b/dist/server/lib/activitypub/videos/shared/abstract-builder.js index 2cf7be94..a495a794 100644 --- a/dist/server/lib/activitypub/videos/shared/abstract-builder.js +++ b/dist/server/lib/activitypub/videos/shared/abstract-builder.js @@ -16,19 +16,19 @@ const object_to_model_attributes_1 = require("./object-to-model-attributes"); const trackers_1 = require("./trackers"); class APVideoAbstractBuilder { getOrCreateVideoChannelFromVideoObject() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const channel = this.videoObject.attributedTo.find(a => a.type === 'Group'); if (!channel) throw new Error('Cannot find associated video channel to video ' + this.videoObject.url); - if (activitypub_1.checkUrlsSameHost(channel.id, this.videoObject.id) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(channel.id, this.videoObject.id) !== true) { throw new Error(`Video channel url ${channel.id} does not have the same host than video object id ${this.videoObject.id}`); } - return actors_1.getOrCreateAPActor(channel.id, 'all'); + return (0, actors_1.getOrCreateAPActor)(channel.id, 'all'); }); } tryToGenerateThumbnail(video) { - return thumbnail_1.updateVideoMiniatureFromUrl({ - downloadUrl: object_to_model_attributes_1.getThumbnailFromIcons(this.videoObject).url, + return (0, thumbnail_1.updateVideoMiniatureFromUrl)({ + downloadUrl: (0, object_to_model_attributes_1.getThumbnailFromIcons)(this.videoObject).url, video, type: 1 }).catch(err => { @@ -37,11 +37,11 @@ class APVideoAbstractBuilder { }); } setPreview(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const previewIcon = object_to_model_attributes_1.getPreviewFromIcons(this.videoObject); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const previewIcon = (0, object_to_model_attributes_1.getPreviewFromIcons)(this.videoObject); if (!previewIcon) return; - const previewModel = thumbnail_1.updatePlaceholderThumbnail({ + const previewModel = (0, thumbnail_1.updatePlaceholderThumbnail)({ fileUrl: previewIcon.url, video, type: 2, @@ -51,21 +51,21 @@ class APVideoAbstractBuilder { }); } setTags(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const tags = object_to_model_attributes_1.getTagsFromObject(this.videoObject); - yield video_1.setVideoTags({ video, tags, transaction: t }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const tags = (0, object_to_model_attributes_1.getTagsFromObject)(this.videoObject); + yield (0, video_1.setVideoTags)({ video, tags, transaction: t }); }); } setTrackers(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const trackers = trackers_1.getTrackerUrls(this.videoObject, video); - yield trackers_1.setVideoTrackers({ video, trackers, transaction: t }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const trackers = (0, trackers_1.getTrackerUrls)(this.videoObject, video); + yield (0, trackers_1.setVideoTrackers)({ video, trackers, transaction: t }); }); } insertOrReplaceCaptions(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const existingCaptions = yield video_caption_1.VideoCaptionModel.listVideoCaptions(video.id, t); - let captionsToCreate = object_to_model_attributes_1.getCaptionAttributesFromObject(video, this.videoObject) + let captionsToCreate = (0, object_to_model_attributes_1.getCaptionAttributesFromObject)(video, this.videoObject) .map(a => new video_caption_1.VideoCaptionModel(a)); for (const existingCaption of existingCaptions) { const filtered = captionsToCreate.filter(c => !c.isEqual(existingCaption)); @@ -81,26 +81,26 @@ class APVideoAbstractBuilder { }); } insertOrReplaceLive(video, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const attributes = object_to_model_attributes_1.getLiveAttributesFromObject(video, this.videoObject); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const attributes = (0, object_to_model_attributes_1.getLiveAttributesFromObject)(video, this.videoObject); const [videoLive] = yield video_live_1.VideoLiveModel.upsert(attributes, { transaction, returning: true }); video.VideoLive = videoLive; }); } setWebTorrentFiles(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoFileAttributes = object_to_model_attributes_1.getFileAttributesFromUrl(video, this.videoObject.url); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoFileAttributes = (0, object_to_model_attributes_1.getFileAttributesFromUrl)(video, this.videoObject.url); const newVideoFiles = videoFileAttributes.map(a => new video_file_1.VideoFileModel(a)); - yield database_utils_1.deleteAllModels(database_utils_1.filterNonExistingModels(video.VideoFiles || [], newVideoFiles), t); + yield (0, database_utils_1.deleteAllModels)((0, database_utils_1.filterNonExistingModels)(video.VideoFiles || [], newVideoFiles), t); const upsertTasks = newVideoFiles.map(f => video_file_1.VideoFileModel.customUpsert(f, 'video', t)); video.VideoFiles = yield Promise.all(upsertTasks); }); } setStreamingPlaylists(video, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const streamingPlaylistAttributes = object_to_model_attributes_1.getStreamingPlaylistAttributesFromObject(video, this.videoObject, video.VideoFiles || []); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const streamingPlaylistAttributes = (0, object_to_model_attributes_1.getStreamingPlaylistAttributesFromObject)(video, this.videoObject, video.VideoFiles || []); const newStreamingPlaylists = streamingPlaylistAttributes.map(a => new video_streaming_playlist_1.VideoStreamingPlaylistModel(a)); - yield database_utils_1.deleteAllModels(database_utils_1.filterNonExistingModels(video.VideoStreamingPlaylists || [], newStreamingPlaylists), t); + yield (0, database_utils_1.deleteAllModels)((0, database_utils_1.filterNonExistingModels)(video.VideoStreamingPlaylists || [], newStreamingPlaylists), t); video.VideoStreamingPlaylists = []; for (const playlistAttributes of streamingPlaylistAttributes) { const streamingPlaylistModel = yield this.insertOrReplaceStreamingPlaylist(playlistAttributes, t); @@ -111,7 +111,7 @@ class APVideoAbstractBuilder { }); } insertOrReplaceStreamingPlaylist(attributes, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [streamingPlaylist] = yield video_streaming_playlist_1.VideoStreamingPlaylistModel.upsert(attributes, { returning: true, transaction: t }); return streamingPlaylist; }); @@ -123,10 +123,10 @@ class APVideoAbstractBuilder { return playlist.VideoFiles; } setStreamingPlaylistFiles(video, playlistModel, tagObjects, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const oldStreamingPlaylistFiles = this.getStreamingPlaylistFiles(video, playlistModel.type); - const newVideoFiles = object_to_model_attributes_1.getFileAttributesFromUrl(playlistModel, tagObjects).map(a => new video_file_1.VideoFileModel(a)); - yield database_utils_1.deleteAllModels(database_utils_1.filterNonExistingModels(oldStreamingPlaylistFiles, newVideoFiles), t); + const newVideoFiles = (0, object_to_model_attributes_1.getFileAttributesFromUrl)(playlistModel, tagObjects).map(a => new video_file_1.VideoFileModel(a)); + yield (0, database_utils_1.deleteAllModels)((0, database_utils_1.filterNonExistingModels)(oldStreamingPlaylistFiles, newVideoFiles), t); const upsertTasks = newVideoFiles.map(f => video_file_1.VideoFileModel.customUpsert(f, 'streaming-playlist', t)); playlistModel.VideoFiles = yield Promise.all(upsertTasks); }); diff --git a/dist/server/lib/activitypub/videos/shared/creator.js b/dist/server/lib/activitypub/videos/shared/creator.js index c49d4cf7..1867367c 100644 --- a/dist/server/lib/activitypub/videos/shared/creator.js +++ b/dist/server/lib/activitypub/videos/shared/creator.js @@ -12,21 +12,21 @@ class APVideoCreator extends abstract_builder_1.APVideoAbstractBuilder { constructor(videoObject) { super(); this.videoObject = videoObject; - this.lTags = logger_1.loggerTagsFactory('ap', 'video', 'create', this.videoObject.uuid, this.videoObject.id); + this.lTags = (0, logger_1.loggerTagsFactory)('ap', 'video', 'create', this.videoObject.uuid, this.videoObject.id); } create(waitThumbnail = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags()); const channelActor = yield this.getOrCreateVideoChannelFromVideoObject(); const channel = channelActor.VideoChannel; - const videoData = object_to_model_attributes_1.getVideoAttributesFromObject(channel, this.videoObject, this.videoObject.to); + const videoData = (0, object_to_model_attributes_1.getVideoAttributesFromObject)(channel, this.videoObject, this.videoObject.to); const video = video_1.VideoModel.build(videoData); const promiseThumbnail = this.tryToGenerateThumbnail(video); let thumbnailModel; if (waitThumbnail === true) { thumbnailModel = yield promiseThumbnail; } - const { autoBlacklisted, videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { autoBlacklisted, videoCreated } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const videoCreated = yield video.save({ transaction: t }); videoCreated.VideoChannel = channel; @@ -40,7 +40,7 @@ class APVideoCreator extends abstract_builder_1.APVideoAbstractBuilder { yield this.insertOrReplaceCaptions(videoCreated, t); yield this.insertOrReplaceLive(videoCreated, t); yield channel.setAsUpdated(t); - const autoBlacklisted = yield video_blacklist_1.autoBlacklistVideoIfNeeded({ + const autoBlacklisted = yield (0, video_blacklist_1.autoBlacklistVideoIfNeeded)({ video: videoCreated, user: undefined, isRemote: true, diff --git a/dist/server/lib/activitypub/videos/shared/index.js b/dist/server/lib/activitypub/videos/shared/index.js index c70e8963..22be5cb0 100644 --- a/dist/server/lib/activitypub/videos/shared/index.js +++ b/dist/server/lib/activitypub/videos/shared/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abstract-builder"), exports); -tslib_1.__exportStar(require("./creator"), exports); -tslib_1.__exportStar(require("./object-to-model-attributes"), exports); -tslib_1.__exportStar(require("./trackers"), exports); -tslib_1.__exportStar(require("./url-to-object"), exports); -tslib_1.__exportStar(require("./video-sync-attributes"), exports); +(0, tslib_1.__exportStar)(require("./abstract-builder"), exports); +(0, tslib_1.__exportStar)(require("./creator"), exports); +(0, tslib_1.__exportStar)(require("./object-to-model-attributes"), exports); +(0, tslib_1.__exportStar)(require("./trackers"), exports); +(0, tslib_1.__exportStar)(require("./url-to-object"), exports); +(0, tslib_1.__exportStar)(require("./video-sync-attributes"), exports); diff --git a/dist/server/lib/activitypub/videos/shared/object-to-model-attributes.js b/dist/server/lib/activitypub/videos/shared/object-to-model-attributes.js index 6857d022..9a6791c9 100644 --- a/dist/server/lib/activitypub/videos/shared/object-to-model-attributes.js +++ b/dist/server/lib/activitypub/videos/shared/object-to-model-attributes.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getVideoAttributesFromObject = exports.getCaptionAttributesFromObject = exports.getLiveAttributesFromObject = exports.getStreamingPlaylistAttributesFromObject = exports.getFileAttributesFromUrl = exports.getTagsFromObject = exports.getPreviewFromIcons = exports.getThumbnailFromIcons = void 0; const tslib_1 = require("tslib"); const lodash_1 = require("lodash"); -const magnet_uri_1 = tslib_1.__importDefault(require("magnet-uri")); +const magnet_uri_1 = (0, tslib_1.__importDefault)(require("magnet-uri")); const path_1 = require("path"); const videos_1 = require("@server/helpers/custom-validators/activitypub/videos"); const videos_2 = require("@server/helpers/custom-validators/videos"); @@ -18,12 +18,12 @@ function getThumbnailFromIcons(videoObject) { let validIcons = videoObject.icon.filter(i => i.width > constants_1.THUMBNAILS_SIZE.minWidth); if (validIcons.length === 0) validIcons = videoObject.icon; - return lodash_1.minBy(validIcons, 'width'); + return (0, lodash_1.minBy)(validIcons, 'width'); } exports.getThumbnailFromIcons = getThumbnailFromIcons; function getPreviewFromIcons(videoObject) { const validIcons = videoObject.icon.filter(i => i.width > constants_1.PREVIEWS_SIZE.minWidth); - return lodash_1.maxBy(validIcons, 'width'); + return (0, lodash_1.maxBy)(validIcons, 'width'); } exports.getPreviewFromIcons = getPreviewFromIcons; function getTagsFromObject(videoObject) { @@ -43,7 +43,7 @@ function getFileAttributesFromUrl(videoOrPlaylist, urls) { if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href); const parsed = magnet_uri_1.default.decode(magnet.href); - if (!parsed || videos_2.isVideoFileInfoHashValid(parsed.infoHash) === false) { + if (!parsed || (0, videos_2.isVideoFileInfoHashValid)(parsed.infoHash) === false) { throw new Error('Cannot parse magnet URI ' + magnet.href); } const torrentUrl = Array.isArray(parsed.xs) @@ -55,10 +55,10 @@ function getFileAttributesFromUrl(videoOrPlaylist, urls) { u.fps === fileUrl.fps && u.rel.includes(fileUrl.mediaType); }); - const extname = video_1.getExtFromMimetype(constants_1.MIMETYPES.VIDEO.MIMETYPE_EXT, fileUrl.mediaType); + const extname = (0, video_1.getExtFromMimetype)(constants_1.MIMETYPES.VIDEO.MIMETYPE_EXT, fileUrl.mediaType); const resolution = fileUrl.height; - const videoId = models_1.isStreamingPlaylist(videoOrPlaylist) ? null : videoOrPlaylist.id; - const videoStreamingPlaylistId = models_1.isStreamingPlaylist(videoOrPlaylist) ? videoOrPlaylist.id : null; + const videoId = (0, models_1.isStreamingPlaylist)(videoOrPlaylist) ? null : videoOrPlaylist.id; + const videoStreamingPlaylistId = (0, models_1.isStreamingPlaylist)(videoOrPlaylist) ? videoOrPlaylist.id : null; const attribute = { extname, infoHash: parsed.infoHash, @@ -66,10 +66,10 @@ function getFileAttributesFromUrl(videoOrPlaylist, urls) { size: fileUrl.size, fps: fileUrl.fps || -1, metadataUrl: metadata === null || metadata === void 0 ? void 0 : metadata.href, - filename: path_1.basename(fileUrl.href), + filename: (0, path_1.basename)(fileUrl.href), fileUrl: fileUrl.href, torrentUrl, - torrentFilename: paths_1.generateTorrentFileName(videoOrPlaylist, resolution), + torrentFilename: (0, paths_1.generateTorrentFileName)(videoOrPlaylist, resolution), videoId, videoStreamingPlaylistId }; @@ -94,9 +94,9 @@ function getStreamingPlaylistAttributesFromObject(video, videoObject, videoFiles } const attribute = { type: 1, - playlistFilename: path_1.basename(playlistUrlObject.href), + playlistFilename: (0, path_1.basename)(playlistUrlObject.href), playlistUrl: playlistUrlObject.href, - segmentsSha256Filename: path_1.basename(segmentsSha256UrlObject.href), + segmentsSha256Filename: (0, path_1.basename)(segmentsSha256UrlObject.href), segmentsSha256Url: segmentsSha256UrlObject.href, p2pMediaLoaderInfohashes: video_streaming_playlist_1.VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrlObject.href, files), p2pMediaLoaderPeerVersion: constants_1.P2P_MEDIA_LOADER_PEER_VERSION, diff --git a/dist/server/lib/activitypub/videos/shared/trackers.js b/dist/server/lib/activitypub/videos/shared/trackers.js index d514de48..2768a6a2 100644 --- a/dist/server/lib/activitypub/videos/shared/trackers.js +++ b/dist/server/lib/activitypub/videos/shared/trackers.js @@ -9,22 +9,22 @@ const constants_1 = require("@server/initializers/constants"); const tracker_1 = require("@server/models/server/tracker"); function getTrackerUrls(object, video) { let wsFound = false; - const trackers = object.url.filter(u => videos_1.isAPVideoTrackerUrlObject(u)) + const trackers = object.url.filter(u => (0, videos_1.isAPVideoTrackerUrlObject)(u)) .map((u) => { - if (misc_1.isArray(u.rel) && u.rel.includes('websocket')) + if ((0, misc_1.isArray)(u.rel) && u.rel.includes('websocket')) wsFound = true; return u.href; }); if (wsFound) return trackers; return [ - activitypub_1.buildRemoteVideoBaseUrl(video, '/tracker/socket', constants_1.REMOTE_SCHEME.WS), - activitypub_1.buildRemoteVideoBaseUrl(video, '/tracker/announce') + (0, activitypub_1.buildRemoteVideoBaseUrl)(video, '/tracker/socket', constants_1.REMOTE_SCHEME.WS), + (0, activitypub_1.buildRemoteVideoBaseUrl)(video, '/tracker/announce') ]; } exports.getTrackerUrls = getTrackerUrls; function setVideoTrackers(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, trackers, transaction } = options; const trackerInstances = yield tracker_1.TrackerModel.findOrCreateTrackers(trackers, transaction); yield video.$set('Trackers', trackerInstances, { transaction }); diff --git a/dist/server/lib/activitypub/videos/shared/url-to-object.js b/dist/server/lib/activitypub/videos/shared/url-to-object.js index 9609606e..c59bd8a1 100644 --- a/dist/server/lib/activitypub/videos/shared/url-to-object.js +++ b/dist/server/lib/activitypub/videos/shared/url-to-object.js @@ -6,12 +6,12 @@ const activitypub_1 = require("@server/helpers/activitypub"); const videos_1 = require("@server/helpers/custom-validators/activitypub/videos"); const logger_1 = require("@server/helpers/logger"); const requests_1 = require("@server/helpers/requests"); -const lTags = logger_1.loggerTagsFactory('ap', 'video'); +const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video'); function fetchRemoteVideo(videoUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Fetching remote video %s.', videoUrl, lTags(videoUrl)); - const { statusCode, body } = yield requests_1.doJSONRequest(videoUrl, { activityPub: true }); - if (videos_1.sanitizeAndCheckVideoTorrentObject(body) === false || activitypub_1.checkUrlsSameHost(body.id, videoUrl) !== true) { + const { statusCode, body } = yield (0, requests_1.doJSONRequest)(videoUrl, { activityPub: true }); + if ((0, videos_1.sanitizeAndCheckVideoTorrentObject)(body) === false || (0, activitypub_1.checkUrlsSameHost)(body.id, videoUrl) !== true) { logger_1.logger.debug('Remote video JSON is not valid.', Object.assign({ body }, lTags(videoUrl))); return { statusCode, videoObject: undefined }; } diff --git a/dist/server/lib/activitypub/videos/shared/video-sync-attributes.js b/dist/server/lib/activitypub/videos/shared/video-sync-attributes.js index fc710d26..bac4945e 100644 --- a/dist/server/lib/activitypub/videos/shared/video-sync-attributes.js +++ b/dist/server/lib/activitypub/videos/shared/video-sync-attributes.js @@ -11,9 +11,9 @@ const crawl_1 = require("../../crawl"); const share_1 = require("../../share"); const video_comments_1 = require("../../video-comments"); const video_rates_1 = require("../../video-rates"); -const lTags = logger_1.loggerTagsFactory('ap', 'video'); +const lTags = (0, logger_1.loggerTagsFactory)('ap', 'video'); function syncVideoExternalAttributes(video, fetchedVideo, syncParam) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Adding likes/dislikes/shares/comments of video %s.', video.uuid); yield syncRates('like', video, fetchedVideo, syncParam.likes); yield syncRates('dislike', video, fetchedVideo, syncParam.dislikes); @@ -35,9 +35,9 @@ function syncRates(type, video, fetchedVideo, isSync) { : 'video-dislikes'; return createJob({ uri, videoId: video.id, type: jobType }); } - const handler = items => video_rates_1.createRates(items, video, type); + const handler = items => (0, video_rates_1.createRates)(items, video, type); const cleaner = crawlStartDate => account_video_rate_1.AccountVideoRateModel.cleanOldRatesOf(video.id, type, crawlStartDate); - return crawl_1.crawlCollectionPage(uri, handler, cleaner) + return (0, crawl_1.crawlCollectionPage)(uri, handler, cleaner) .catch(err => logger_1.logger.error('Cannot add rate of video %s.', video.uuid, Object.assign({ err, rootUrl: uri }, lTags(video.uuid, video.url)))); } function syncShares(video, fetchedVideo, isSync) { @@ -45,9 +45,9 @@ function syncShares(video, fetchedVideo, isSync) { if (!isSync) { return createJob({ uri, videoId: video.id, type: 'video-shares' }); } - const handler = items => share_1.addVideoShares(items, video); + const handler = items => (0, share_1.addVideoShares)(items, video); const cleaner = crawlStartDate => video_share_1.VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate); - return crawl_1.crawlCollectionPage(uri, handler, cleaner) + return (0, crawl_1.crawlCollectionPage)(uri, handler, cleaner) .catch(err => logger_1.logger.error('Cannot add shares of video %s.', video.uuid, Object.assign({ err, rootUrl: uri }, lTags(video.uuid, video.url)))); } function syncComments(video, fetchedVideo, isSync) { @@ -55,8 +55,8 @@ function syncComments(video, fetchedVideo, isSync) { if (!isSync) { return createJob({ uri, videoId: video.id, type: 'video-comments' }); } - const handler = items => video_comments_1.addVideoComments(items); + const handler = items => (0, video_comments_1.addVideoComments)(items); const cleaner = crawlStartDate => video_comment_1.VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate); - return crawl_1.crawlCollectionPage(uri, handler, cleaner) + return (0, crawl_1.crawlCollectionPage)(uri, handler, cleaner) .catch(err => logger_1.logger.error('Cannot add comments of video %s.', video.uuid, Object.assign({ err, rootUrl: uri }, lTags(video.uuid, video.url)))); } diff --git a/dist/server/lib/activitypub/videos/updater.js b/dist/server/lib/activitypub/videos/updater.js index cfc24e72..ebc6c7f7 100644 --- a/dist/server/lib/activitypub/videos/updater.js +++ b/dist/server/lib/activitypub/videos/updater.js @@ -18,10 +18,10 @@ class APVideoUpdater extends shared_1.APVideoAbstractBuilder { this.wasUnlistedVideo = this.video.privacy === 2; this.oldVideoChannel = this.video.VideoChannel; this.videoFieldsSave = this.video.toJSON(); - this.lTags = logger_1.loggerTagsFactory('ap', 'video', 'update', video.uuid, video.url); + this.lTags = (0, logger_1.loggerTagsFactory)('ap', 'video', 'update', video.uuid, video.url); } update(overrideTo) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Updating remote video "%s".', this.videoObject.uuid, Object.assign({ videoObject: this.videoObject }, this.lTags())); try { const channelActor = yield this.getOrCreateVideoChannelFromVideoObject(); @@ -30,18 +30,18 @@ class APVideoUpdater extends shared_1.APVideoAbstractBuilder { const videoUpdated = yield this.updateVideo(channelActor.VideoChannel, undefined, overrideTo); if (thumbnailModel) yield videoUpdated.addAndSaveThumbnail(thumbnailModel); - yield database_utils_1.runInReadCommittedTransaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, database_utils_1.runInReadCommittedTransaction)((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.setWebTorrentFiles(videoUpdated, t); yield this.setStreamingPlaylists(videoUpdated, t); })); yield Promise.all([ - database_utils_1.runInReadCommittedTransaction(t => this.setTags(videoUpdated, t)), - database_utils_1.runInReadCommittedTransaction(t => this.setTrackers(videoUpdated, t)), + (0, database_utils_1.runInReadCommittedTransaction)(t => this.setTags(videoUpdated, t)), + (0, database_utils_1.runInReadCommittedTransaction)(t => this.setTrackers(videoUpdated, t)), this.setOrDeleteLive(videoUpdated), this.setPreview(videoUpdated) ]); - yield database_utils_1.runInReadCommittedTransaction(t => this.setCaptions(videoUpdated, t)); - yield video_blacklist_1.autoBlacklistVideoIfNeeded({ + yield (0, database_utils_1.runInReadCommittedTransaction)(t => this.setCaptions(videoUpdated, t)); + yield (0, video_blacklist_1.autoBlacklistVideoIfNeeded)({ video: videoUpdated, user: undefined, isRemote: true, @@ -73,7 +73,7 @@ class APVideoUpdater extends shared_1.APVideoAbstractBuilder { } updateVideo(channel, transaction, overrideTo) { const to = overrideTo || this.videoObject.to; - const videoData = shared_1.getVideoAttributesFromObject(channel, this.videoObject, to); + const videoData = (0, shared_1.getVideoAttributesFromObject)(channel, this.videoObject, to); this.video.name = videoData.name; this.video.uuid = videoData.uuid; this.video.url = videoData.url; @@ -100,12 +100,12 @@ class APVideoUpdater extends shared_1.APVideoAbstractBuilder { return this.video.save({ transaction }); } setCaptions(videoUpdated, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.insertOrReplaceCaptions(videoUpdated, t); }); } setOrDeleteLive(videoUpdated, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.video.isLive) return; if (this.video.isLive) @@ -121,7 +121,7 @@ class APVideoUpdater extends shared_1.APVideoAbstractBuilder { } catchUpdateError(err) { if (this.video !== undefined && this.videoFieldsSave !== undefined) { - database_utils_1.resetSequelizeInstance(this.video, this.videoFieldsSave); + (0, database_utils_1.resetSequelizeInstance)(this.video, this.videoFieldsSave); } logger_1.logger.debug('Cannot update the remote video.', Object.assign({ err }, this.lTags())); throw err; diff --git a/dist/server/lib/auth/external-auth.js b/dist/server/lib/auth/external-auth.js index f207d9e5..924e2e50 100644 --- a/dist/server/lib/auth/external-auth.js +++ b/dist/server/lib/auth/external-auth.js @@ -11,7 +11,7 @@ const oauth_token_1 = require("@server/models/oauth/oauth-token"); const models_1 = require("@shared/models"); const authBypassTokens = new Map(); function onExternalUserAuthenticated(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { npmName, authName, authResult } = options; if (!authResult.req || !authResult.res) { logger_1.logger.error('Cannot authenticate external user for auth %s of plugin %s: no req or res are provided.', authName, npmName); @@ -23,7 +23,7 @@ function onExternalUserAuthenticated(options) { return; } logger_1.logger.info('Generating auth bypass token for %s in auth %s of plugin %s.', authResult.username, authName, npmName); - const bypassToken = yield utils_1.generateRandomString(32); + const bypassToken = yield (0, utils_1.generateRandomString)(32); const expires = new Date(); expires.setTime(expires.getTime() + constants_1.PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME); const user = buildUserResult(authResult); @@ -44,7 +44,7 @@ function onExternalUserAuthenticated(options) { } exports.onExternalUserAuthenticated = onExternalUserAuthenticated; function getAuthNameFromRefreshGrant(refreshToken) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!refreshToken) return undefined; const tokenModel = yield oauth_token_1.OAuthTokenModel.loadByRefreshToken(refreshToken); @@ -53,7 +53,7 @@ function getAuthNameFromRefreshGrant(refreshToken) { } exports.getAuthNameFromRefreshGrant = getAuthNameFromRefreshGrant; function getBypassFromPasswordGrant(username, password) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const plugins = plugin_manager_1.PluginManager.Instance.getIdAndPassAuths(); const pluginAuths = []; for (const plugin of plugins) { @@ -127,7 +127,7 @@ function getBypassFromExternalAuth(username, externalAuthToken) { } exports.getBypassFromExternalAuth = getBypassFromExternalAuth; function isAuthResultValid(npmName, authName, result) { - if (!users_1.isUserUsernameValid(result.username)) { + if (!(0, users_1.isUserUsernameValid)(result.username)) { logger_1.logger.error('Auth method %s of plugin %s did not provide a valid username.', authName, npmName, { username: result.username }); return false; } @@ -135,11 +135,11 @@ function isAuthResultValid(npmName, authName, result) { logger_1.logger.error('Auth method %s of plugin %s did not provide a valid email.', authName, npmName, { email: result.email }); return false; } - if (result.role && !users_1.isUserRoleValid(result.role)) { + if (result.role && !(0, users_1.isUserRoleValid)(result.role)) { logger_1.logger.error('Auth method %s of plugin %s did not provide a valid role.', authName, npmName, { role: result.role }); return false; } - if (result.displayName && !users_1.isUserDisplayNameValid(result.displayName)) { + if (result.displayName && !(0, users_1.isUserDisplayNameValid)(result.displayName)) { logger_1.logger.error('Auth method %s of plugin %s did not provide a valid display name.', authName, npmName, { displayName: result.displayName }); return false; } diff --git a/dist/server/lib/auth/oauth-model.js b/dist/server/lib/auth/oauth-model.js index be37e641..a0bea451 100644 --- a/dist/server/lib/auth/oauth-model.js +++ b/dist/server/lib/auth/oauth-model.js @@ -13,7 +13,7 @@ const oauth_token_1 = require("../../models/oauth/oauth-token"); const user_2 = require("../user"); const tokens_cache_1 = require("./tokens-cache"); function getAccessToken(bearerToken) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Getting access token (bearerToken: ' + bearerToken + ').'); if (!bearerToken) return undefined; @@ -43,7 +43,7 @@ function getClient(clientId, clientSecret) { } exports.getClient = getClient; function getRefreshToken(refreshToken) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').'); const tokenInfo = yield oauth_token_1.OAuthTokenModel.getByRefreshTokenAndPopulateClient(refreshToken); if (!tokenInfo) @@ -59,7 +59,7 @@ function getRefreshToken(refreshToken) { } exports.getRefreshToken = getRefreshToken; function getUser(usernameOrEmail, password, bypassLogin) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (bypassLogin && bypassLogin.bypass === true) { logger_1.logger.info('Bypassing oauth login by plugin %s.', bypassLogin.pluginName); let user = yield user_1.UserModel.loadByEmail(bypassLogin.user.email); @@ -94,7 +94,7 @@ function getUser(usernameOrEmail, password, bypassLogin) { } exports.getUser = getUser; function revokeToken(tokenInfo, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { req, explicitLogout } = options; const token = yield oauth_token_1.OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken); if (token) { @@ -112,7 +112,7 @@ function revokeToken(tokenInfo, options = {}) { } exports.revokeToken = revokeToken; function saveToken(token, client, user, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { refreshTokenAuthName, bypassLogin } = options; let authName = null; if ((bypassLogin === null || bypassLogin === void 0 ? void 0 : bypassLogin.bypass) === true) { @@ -148,7 +148,7 @@ function saveToken(token, client, user, options = {}) { } exports.saveToken = saveToken; function createUserFromExternal(pluginAuth, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actor = yield actor_1.ActorModel.loadLocalByName(options.username); if (actor) return null; @@ -164,7 +164,7 @@ function createUserFromExternal(pluginAuth, options) { adminFlags: 0, pluginAuth }); - const { user } = yield user_2.createUserAccountAndChannelAndPlaylist({ + const { user } = yield (0, user_2.createUserAccountAndChannelAndPlaylist)({ userToCreate, userDisplayName: options.displayName }); diff --git a/dist/server/lib/auth/oauth.js b/dist/server/lib/auth/oauth.js index c65200b5..7de22940 100644 --- a/dist/server/lib/auth/oauth.js +++ b/dist/server/lib/auth/oauth.js @@ -12,7 +12,7 @@ const oAuthServer = new (require('oauth2-server'))({ model: require('./oauth-model') }); function handleOAuthToken(req, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const request = new oauth2_server_1.Request(req); const { refreshTokenAuthName, bypassLogin } = options; if (request.method !== 'POST') { @@ -26,7 +26,7 @@ function handleOAuthToken(req, options) { if (!clientId || !clientSecret) { throw new oauth2_server_1.InvalidClientError('Invalid client: cannot retrieve client credentials'); } - const client = yield oauth_model_1.getClient(clientId, clientSecret); + const client = yield (0, oauth_model_1.getClient)(clientId, clientSecret); if (!client) { throw new oauth2_server_1.InvalidClientError('Invalid client: client is invalid'); } @@ -63,7 +63,7 @@ function handleOAuthAuthenticate(req, res, authenticateInQuery = false) { } exports.handleOAuthAuthenticate = handleOAuthAuthenticate; function handlePasswordGrant(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { request, client, bypassLogin } = options; if (!request.body.username) { throw new oauth2_server_1.InvalidRequestError('Missing parameter: `username`'); @@ -71,20 +71,20 @@ function handlePasswordGrant(options) { if (!bypassLogin && !request.body.password) { throw new oauth2_server_1.InvalidRequestError('Missing parameter: `password`'); } - const user = yield oauth_model_1.getUser(request.body.username, request.body.password, bypassLogin); + const user = yield (0, oauth_model_1.getUser)(request.body.username, request.body.password, bypassLogin); if (!user) throw new oauth2_server_1.InvalidGrantError('Invalid grant: user credentials are invalid'); const token = yield buildToken(); - return oauth_model_1.saveToken(token, client, user, { bypassLogin }); + return (0, oauth_model_1.saveToken)(token, client, user, { bypassLogin }); }); } function handleRefreshGrant(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { request, client, refreshTokenAuthName } = options; if (!request.body.refresh_token) { throw new oauth2_server_1.InvalidRequestError('Missing parameter: `refresh_token`'); } - const refreshToken = yield oauth_model_1.getRefreshToken(request.body.refresh_token); + const refreshToken = yield (0, oauth_model_1.getRefreshToken)(request.body.refresh_token); if (!refreshToken) { throw new oauth2_server_1.InvalidGrantError('Invalid grant: refresh token is invalid'); } @@ -94,14 +94,14 @@ function handleRefreshGrant(options) { if (refreshToken.refreshTokenExpiresAt && refreshToken.refreshTokenExpiresAt < new Date()) { throw new oauth2_server_1.InvalidGrantError('Invalid grant: refresh token has expired'); } - yield oauth_model_1.revokeToken({ refreshToken: refreshToken.refreshToken }); + yield (0, oauth_model_1.revokeToken)({ refreshToken: refreshToken.refreshToken }); const token = yield buildToken(); - return oauth_model_1.saveToken(token, client, refreshToken.user, { refreshTokenAuthName }); + return (0, oauth_model_1.saveToken)(token, client, refreshToken.user, { refreshTokenAuthName }); }); } function generateRandomToken() { - return core_utils_1.randomBytesPromise(256) - .then(buffer => core_utils_1.sha1(buffer)); + return (0, core_utils_1.randomBytesPromise)(256) + .then(buffer => (0, core_utils_1.sha1)(buffer)); } function getTokenExpiresAt(type) { const lifetime = type === 'access' @@ -110,7 +110,7 @@ function getTokenExpiresAt(type) { return new Date(Date.now() + lifetime * 1000); } function buildToken() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [accessToken, refreshToken] = yield Promise.all([generateRandomToken(), generateRandomToken()]); return { accessToken, diff --git a/dist/server/lib/auth/tokens-cache.js b/dist/server/lib/auth/tokens-cache.js index 428c47c0..2e3a52ef 100644 --- a/dist/server/lib/auth/tokens-cache.js +++ b/dist/server/lib/auth/tokens-cache.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.TokensCache = void 0; const tslib_1 = require("tslib"); -const lru_cache_1 = tslib_1.__importDefault(require("lru-cache")); +const lru_cache_1 = (0, tslib_1.__importDefault)(require("lru-cache")); const constants_1 = require("../../initializers/constants"); class TokensCache { constructor() { diff --git a/dist/server/lib/blocklist.js b/dist/server/lib/blocklist.js index 53ff9217..4df9bab6 100644 --- a/dist/server/lib/blocklist.js +++ b/dist/server/lib/blocklist.js @@ -7,7 +7,7 @@ const application_1 = require("@server/models/application/application"); const account_blocklist_1 = require("../models/account/account-blocklist"); const server_blocklist_1 = require("../models/server/server-blocklist"); function addAccountInBlocklist(byAccountId, targetAccountId) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return account_blocklist_1.AccountBlocklistModel.upsert({ accountId: byAccountId, targetAccountId: targetAccountId @@ -16,7 +16,7 @@ function addAccountInBlocklist(byAccountId, targetAccountId) { } exports.addAccountInBlocklist = addAccountInBlocklist; function addServerInBlocklist(byAccountId, targetServerId) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return server_blocklist_1.ServerBlocklistModel.upsert({ accountId: byAccountId, targetServerId @@ -25,20 +25,20 @@ function addServerInBlocklist(byAccountId, targetServerId) { } exports.addServerInBlocklist = addServerInBlocklist; function removeAccountFromBlocklist(accountBlock) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return accountBlock.destroy({ transaction: t }); })); } exports.removeAccountFromBlocklist = removeAccountFromBlocklist; function removeServerFromBlocklist(serverBlock) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return serverBlock.destroy({ transaction: t }); })); } exports.removeServerFromBlocklist = removeServerFromBlocklist; function isBlockedByServerOrAccount(targetAccount, userAccount) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverAccountId = (yield application_1.getServerActor()).Account.id; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverAccountId = (yield (0, application_1.getServerActor)()).Account.id; const sourceAccounts = [serverAccountId]; if (userAccount) sourceAccounts.push(userAccount.id); diff --git a/dist/server/lib/client-html.js b/dist/server/lib/client-html.js index 6c13eca0..75b2f31d 100644 --- a/dist/server/lib/client-html.js +++ b/dist/server/lib/client-html.js @@ -4,7 +4,7 @@ exports.serveIndexHTML = exports.sendHTML = exports.ClientHtml = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const renderer_1 = require("@shared/core-utils/renderer"); const i18n_1 = require("../../shared/core-utils/i18n/i18n"); const http_error_codes_1 = require("../../shared/models/http/http-error-codes"); @@ -26,7 +26,7 @@ class ClientHtml { ClientHtml.htmlCache = {}; } static getDefaultHTMLPage(req, res, paramLang) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = paramLang ? yield ClientHtml.getIndexHTML(req, res, paramLang) : yield ClientHtml.getIndexHTML(req, res); @@ -36,8 +36,8 @@ class ClientHtml { }); } static getWatchHTMLPage(videoIdArg, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoId = misc_1.toCompleteUUID(videoIdArg); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoId = (0, misc_1.toCompleteUUID)(videoIdArg); if (!validator_1.default.isInt(videoId) && !validator_1.default.isUUID(videoId, 4)) { res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404); return ClientHtml.getIndexHTML(req, res); @@ -50,20 +50,20 @@ class ClientHtml { res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404); return html; } - let customHtml = ClientHtml.addTitleTag(html, renderer_1.escapeHTML(video.name)); - customHtml = ClientHtml.addDescriptionTag(customHtml, markdown_1.mdToPlainText(video.description)); + let customHtml = ClientHtml.addTitleTag(html, (0, renderer_1.escapeHTML)(video.name)); + customHtml = ClientHtml.addDescriptionTag(customHtml, (0, markdown_1.mdToPlainText)(video.description)); const url = constants_1.WEBSERVER.URL + video.getWatchStaticPath(); const originUrl = video.url; - const title = renderer_1.escapeHTML(video.name); - const siteName = renderer_1.escapeHTML(config_1.CONFIG.INSTANCE.NAME); - const description = markdown_1.mdToPlainText(video.description); + const title = (0, renderer_1.escapeHTML)(video.name); + const siteName = (0, renderer_1.escapeHTML)(config_1.CONFIG.INSTANCE.NAME); + const description = (0, markdown_1.mdToPlainText)(video.description); const image = { url: constants_1.WEBSERVER.URL + video.getPreviewStaticPath() }; const embed = { url: constants_1.WEBSERVER.URL + video.getEmbedStaticPath(), createdAt: video.createdAt.toISOString(), - duration: video_format_utils_1.getActivityStreamDuration(video.duration), + duration: (0, video_format_utils_1.getActivityStreamDuration)(video.duration), views: video.views }; const ogType = 'video'; @@ -85,8 +85,8 @@ class ClientHtml { }); } static getWatchPlaylistHTMLPage(videoPlaylistIdArg, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoPlaylistId = misc_1.toCompleteUUID(videoPlaylistIdArg); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoPlaylistId = (0, misc_1.toCompleteUUID)(videoPlaylistIdArg); if (!validator_1.default.isInt(videoPlaylistId) && !validator_1.default.isUUID(videoPlaylistId, 4)) { res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404); return ClientHtml.getIndexHTML(req, res); @@ -99,13 +99,13 @@ class ClientHtml { res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404); return html; } - let customHtml = ClientHtml.addTitleTag(html, renderer_1.escapeHTML(videoPlaylist.name)); - customHtml = ClientHtml.addDescriptionTag(customHtml, markdown_1.mdToPlainText(videoPlaylist.description)); + let customHtml = ClientHtml.addTitleTag(html, (0, renderer_1.escapeHTML)(videoPlaylist.name)); + customHtml = ClientHtml.addDescriptionTag(customHtml, (0, markdown_1.mdToPlainText)(videoPlaylist.description)); const url = constants_1.WEBSERVER.URL + videoPlaylist.getWatchStaticPath(); const originUrl = videoPlaylist.url; - const title = renderer_1.escapeHTML(videoPlaylist.name); - const siteName = renderer_1.escapeHTML(config_1.CONFIG.INSTANCE.NAME); - const description = markdown_1.mdToPlainText(videoPlaylist.description); + const title = (0, renderer_1.escapeHTML)(videoPlaylist.name); + const siteName = (0, renderer_1.escapeHTML)(config_1.CONFIG.INSTANCE.NAME); + const description = (0, markdown_1.mdToPlainText)(videoPlaylist.description); const image = { url: videoPlaylist.getThumbnailUrl() }; @@ -136,19 +136,19 @@ class ClientHtml { }); } static getAccountHTMLPage(nameWithHost, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountModelPromise = account_1.AccountModel.loadByNameWithHost(nameWithHost); return this.getAccountOrChannelHTMLPage(() => accountModelPromise, req, res); }); } static getVideoChannelHTMLPage(nameWithHost, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannelModelPromise = video_channel_1.VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost); return this.getAccountOrChannelHTMLPage(() => videoChannelModelPromise, req, res); }); } static getActorHTMLPage(nameWithHost, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [account, channel] = yield Promise.all([ account_1.AccountModel.loadByNameWithHost(nameWithHost), video_channel_1.VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost) @@ -157,11 +157,11 @@ class ClientHtml { }); } static getEmbedHTML() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = ClientHtml.getEmbedPath(); - if (!core_utils_1.isTestInstance() && ClientHtml.htmlCache[path]) + if (!(0, core_utils_1.isTestInstance)() && ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path]; - const buffer = yield fs_extra_1.readFile(path); + const buffer = yield (0, fs_extra_1.readFile)(path); const serverConfig = yield server_config_manager_1.ServerConfigManager.Instance.getHTMLServerConfig(); let html = buffer.toString(); html = yield ClientHtml.addAsyncPluginCSS(html); @@ -174,7 +174,7 @@ class ClientHtml { }); } static getAccountOrChannelHTMLPage(loader, req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [html, entity] = yield Promise.all([ ClientHtml.getIndexHTML(req, res), loader() @@ -183,13 +183,13 @@ class ClientHtml { res.status(http_error_codes_1.HttpStatusCode.NOT_FOUND_404); return ClientHtml.getIndexHTML(req, res); } - let customHtml = ClientHtml.addTitleTag(html, renderer_1.escapeHTML(entity.getDisplayName())); - customHtml = ClientHtml.addDescriptionTag(customHtml, markdown_1.mdToPlainText(entity.description)); + let customHtml = ClientHtml.addTitleTag(html, (0, renderer_1.escapeHTML)(entity.getDisplayName())); + customHtml = ClientHtml.addDescriptionTag(customHtml, (0, markdown_1.mdToPlainText)(entity.description)); const url = entity.getLocalUrl(); const originUrl = entity.Actor.url; - const siteName = renderer_1.escapeHTML(config_1.CONFIG.INSTANCE.NAME); - const title = renderer_1.escapeHTML(entity.getDisplayName()); - const description = markdown_1.mdToPlainText(entity.description); + const siteName = (0, renderer_1.escapeHTML)(config_1.CONFIG.INSTANCE.NAME); + const title = (0, renderer_1.escapeHTML)(entity.getDisplayName()); + const description = (0, markdown_1.mdToPlainText)(entity.description); const image = { url: entity.Actor.getAvatarUrl(), width: constants_1.ACTOR_IMAGES_SIZE.AVATARS.width, @@ -214,11 +214,11 @@ class ClientHtml { }); } static getIndexHTML(req, res, paramLang) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = ClientHtml.getIndexPath(req, res, paramLang); - if (!core_utils_1.isTestInstance() && ClientHtml.htmlCache[path]) + if (!(0, core_utils_1.isTestInstance)() && ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path]; - const buffer = yield fs_extra_1.readFile(path); + const buffer = yield (0, fs_extra_1.readFile)(path); const serverConfig = yield server_config_manager_1.ServerConfigManager.Instance.getHTMLServerConfig(); let html = buffer.toString(); if (paramLang) @@ -235,7 +235,7 @@ class ClientHtml { } static getIndexPath(req, res, paramLang) { let lang; - if (paramLang && i18n_1.is18nLocale(paramLang)) { + if (paramLang && (0, i18n_1.is18nLocale)(paramLang)) { lang = paramLang; res.cookie('clientLanguage', lang, { secure: constants_1.WEBSERVER.SCHEME === 'https', @@ -243,16 +243,16 @@ class ClientHtml { maxAge: 1000 * 3600 * 24 * 90 }); } - else if (req.cookies.clientLanguage && i18n_1.is18nLocale(req.cookies.clientLanguage)) { + else if (req.cookies.clientLanguage && (0, i18n_1.is18nLocale)(req.cookies.clientLanguage)) { lang = req.cookies.clientLanguage; } else { - lang = req.acceptsLanguages(i18n_1.POSSIBLE_LOCALES) || i18n_1.getDefaultLocale(); + lang = req.acceptsLanguages(i18n_1.POSSIBLE_LOCALES) || (0, i18n_1.getDefaultLocale)(); } - return path_1.join(__dirname, '../../../client/dist/' + i18n_1.buildFileLocale(lang) + '/index.html'); + return (0, path_1.join)(__dirname, '../../../client/dist/' + (0, i18n_1.buildFileLocale)(lang) + '/index.html'); } static getEmbedPath() { - return path_1.join(__dirname, '../../../client/dist/standalone/videos/embed.html'); + return (0, path_1.join)(__dirname, '../../../client/dist/standalone/videos/embed.html'); } static addHtmlLang(htmlStringPage, paramLang) { return htmlStringPage.replace('', ``); @@ -288,11 +288,11 @@ class ClientHtml { return htmlStringPage.replace(constants_1.CUSTOM_HTML_TAG_COMMENTS.SERVER_CONFIG, configScriptTag); } static addAsyncPluginCSS(htmlStringPage) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const globalCSSContent = yield fs_extra_1.readFile(constants_1.PLUGIN_GLOBAL_CSS_PATH); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const globalCSSContent = yield (0, fs_extra_1.readFile)(constants_1.PLUGIN_GLOBAL_CSS_PATH); if (globalCSSContent.byteLength === 0) return htmlStringPage; - const fileHash = core_utils_1.sha256(globalCSSContent); + const fileHash = (0, core_utils_1.sha256)(globalCSSContent); const linkTag = ``; return htmlStringPage.replace('', linkTag + ''); }); @@ -309,7 +309,7 @@ class ClientHtml { metaTags['og:image:height'] = tags.image.height; } metaTags['og:url'] = tags.url; - metaTags['og:description'] = markdown_1.mdToPlainText(tags.description); + metaTags['og:description'] = (0, markdown_1.mdToPlainText)(tags.description); if (tags.embed) { metaTags['og:video:url'] = tags.embed.url; metaTags['og:video:secure_url'] = tags.embed.url; @@ -322,7 +322,7 @@ class ClientHtml { static generateStandardMetaTags(tags) { return { name: tags.title, - description: markdown_1.mdToPlainText(tags.description), + description: (0, markdown_1.mdToPlainText)(tags.description), image: tags.image.url }; } @@ -418,7 +418,7 @@ function sendHTML(html, res) { } exports.sendHTML = sendHTML; function serveIndexHTML(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (req.accepts(constants_1.ACCEPT_HEADERS) === 'html' || !req.headers.accept) { try { @@ -435,7 +435,7 @@ function serveIndexHTML(req, res) { } exports.serveIndexHTML = serveIndexHTML; function generateHTMLPage(req, res, paramLang) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const html = yield ClientHtml.getDefaultHTMLPage(req, res, paramLang); return sendHTML(html, res); }); diff --git a/dist/server/lib/emailer.js b/dist/server/lib/emailer.js index 7e286487..7e4283ce 100644 --- a/dist/server/lib/emailer.js +++ b/dist/server/lib/emailer.js @@ -20,8 +20,8 @@ class Emailer { if (this.initialized === true) return; this.initialized = true; - if (!config_1.isEmailEnabled()) { - if (!core_utils_1.isTestInstance()) { + if (!(0, config_1.isEmailEnabled)()) { + if (!(0, core_utils_1.isTestInstance)()) { logger_1.logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!'); } return; @@ -32,7 +32,7 @@ class Emailer { this.initSendmailTransport(); } checkConnection() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.transporter || config_1.CONFIG.SMTP.TRANSPORT !== 'smtp') return; logger_1.logger.info('Testing SMTP server...'); @@ -110,8 +110,8 @@ class Emailer { return job_queue_1.JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }); } sendMail(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (!config_1.isEmailEnabled()) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if (!(0, config_1.isEmailEnabled)()) { throw new Error('Cannot send mail because SMTP is not configured.'); } const fromDisplayName = options.from @@ -124,11 +124,11 @@ class Emailer { }, transport: this.transporter, views: { - root: path_1.join(core_utils_1.root(), 'dist', 'server', 'lib', 'emails') + root: (0, path_1.join)((0, core_utils_1.root)(), 'dist', 'server', 'lib', 'emails') }, subjectPrefix: config_1.CONFIG.EMAIL.SUBJECT.PREFIX }); - const toEmails = lodash_1.isArray(options.to) + const toEmails = (0, lodash_1.isArray)(options.to) ? options.to : [options.to]; for (const to of toEmails) { @@ -148,7 +148,7 @@ class Emailer { subject: options.subject } }; - const sendOptions = lodash_1.merge(baseOptions, options); + const sendOptions = (0, lodash_1.merge)(baseOptions, options); yield email.send(sendOptions) .then(res => logger_1.logger.debug('Sent email.', { res })) .catch(err => logger_1.logger.error('Error in email sender.', { err })); @@ -163,7 +163,7 @@ class Emailer { let tls; if (config_1.CONFIG.SMTP.CA_FILE) { tls = { - ca: [fs_extra_1.readFileSync(config_1.CONFIG.SMTP.CA_FILE)] + ca: [(0, fs_extra_1.readFileSync)(config_1.CONFIG.SMTP.CA_FILE)] }; } let auth; @@ -173,7 +173,7 @@ class Emailer { pass: config_1.CONFIG.SMTP.PASSWORD }; } - this.transporter = nodemailer_1.createTransport({ + this.transporter = (0, nodemailer_1.createTransport)({ host: config_1.CONFIG.SMTP.HOSTNAME, port: config_1.CONFIG.SMTP.PORT, secure: config_1.CONFIG.SMTP.TLS, @@ -186,7 +186,7 @@ class Emailer { } initSendmailTransport() { logger_1.logger.info('Using sendmail to send emails'); - this.transporter = nodemailer_1.createTransport({ + this.transporter = (0, nodemailer_1.createTransport)({ sendmail: true, newline: 'unix', path: config_1.CONFIG.SMTP.SENDMAIL, diff --git a/dist/server/lib/files-cache/abstract-video-static-file-cache.js b/dist/server/lib/files-cache/abstract-video-static-file-cache.js index cda9ea14..d61ca9f2 100644 --- a/dist/server/lib/files-cache/abstract-video-static-file-cache.js +++ b/dist/server/lib/files-cache/abstract-video-static-file-cache.js @@ -4,16 +4,16 @@ exports.AbstractVideoStaticFileCache = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); const logger_1 = require("../../helpers/logger"); -const memoizee_1 = tslib_1.__importDefault(require("memoizee")); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); class AbstractVideoStaticFileCache { init(max, maxAge) { - this.getFilePath = memoizee_1.default(this.getFilePathImpl, { + this.getFilePath = (0, memoizee_1.default)(this.getFilePathImpl, { maxAge, max, promise: true, dispose: (result) => { if (result && result.isOwned !== true) { - fs_extra_1.remove(result.path) + (0, fs_extra_1.remove)(result.path) .then(() => logger_1.logger.debug('%s removed from %s', result.path, this.constructor.name)) .catch(err => logger_1.logger.error('Cannot remove %s from cache %s.', result.path, this.constructor.name, { err })); } diff --git a/dist/server/lib/files-cache/index.js b/dist/server/lib/files-cache/index.js index 1a11ec54..45c80528 100644 --- a/dist/server/lib/files-cache/index.js +++ b/dist/server/lib/files-cache/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./actor-follow-score-cache"), exports); -tslib_1.__exportStar(require("./videos-preview-cache"), exports); -tslib_1.__exportStar(require("./videos-caption-cache"), exports); +(0, tslib_1.__exportStar)(require("./actor-follow-score-cache"), exports); +(0, tslib_1.__exportStar)(require("./videos-preview-cache"), exports); +(0, tslib_1.__exportStar)(require("./videos-caption-cache"), exports); diff --git a/dist/server/lib/files-cache/videos-caption-cache.js b/dist/server/lib/files-cache/videos-caption-cache.js index 83ebd697..96415696 100644 --- a/dist/server/lib/files-cache/videos-caption-cache.js +++ b/dist/server/lib/files-cache/videos-caption-cache.js @@ -17,17 +17,17 @@ class VideosCaptionCache extends abstract_video_static_file_cache_1.AbstractVide return this.instance || (this.instance = new this()); } getFilePathImpl(filename) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCaption = yield video_caption_1.VideoCaptionModel.loadWithVideoByFilename(filename); if (!videoCaption) return undefined; if (videoCaption.isOwned()) - return { isOwned: true, path: path_1.join(config_1.CONFIG.STORAGE.CAPTIONS_DIR, videoCaption.filename) }; + return { isOwned: true, path: (0, path_1.join)(config_1.CONFIG.STORAGE.CAPTIONS_DIR, videoCaption.filename) }; return this.loadRemoteFile(filename); }); } loadRemoteFile(key) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCaption = yield video_caption_1.VideoCaptionModel.loadWithVideoByFilename(key); if (!videoCaption) return undefined; @@ -37,8 +37,8 @@ class VideosCaptionCache extends abstract_video_static_file_cache_1.AbstractVide if (!video) return undefined; const remoteUrl = videoCaption.getFileUrl(video); - const destPath = path_1.join(constants_1.FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename); - yield requests_1.doRequestAndSaveToFile(remoteUrl, destPath); + const destPath = (0, path_1.join)(constants_1.FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename); + yield (0, requests_1.doRequestAndSaveToFile)(remoteUrl, destPath); return { isOwned: false, path: destPath }; }); } diff --git a/dist/server/lib/files-cache/videos-preview-cache.js b/dist/server/lib/files-cache/videos-preview-cache.js index b6c8de26..d5d22938 100644 --- a/dist/server/lib/files-cache/videos-preview-cache.js +++ b/dist/server/lib/files-cache/videos-preview-cache.js @@ -17,7 +17,7 @@ class VideosPreviewCache extends abstract_video_static_file_cache_1.AbstractVide return this.instance || (this.instance = new this()); } getFilePathImpl(filename) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const thumbnail = yield thumbnail_1.ThumbnailModel.loadWithVideoByFilename(filename, 2); if (!thumbnail) return undefined; @@ -27,16 +27,16 @@ class VideosPreviewCache extends abstract_video_static_file_cache_1.AbstractVide }); } loadRemoteFile(key) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(key); if (!video) return undefined; if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.'); const preview = video.getPreview(); - const destPath = path_1.join(constants_1.FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename); + const destPath = (0, path_1.join)(constants_1.FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename); const remoteUrl = preview.getFileUrl(video); - yield requests_1.doRequestAndSaveToFile(remoteUrl, destPath); + yield (0, requests_1.doRequestAndSaveToFile)(remoteUrl, destPath); logger_1.logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath); return { isOwned: false, path: destPath }; }); diff --git a/dist/server/lib/files-cache/videos-torrent-cache.js b/dist/server/lib/files-cache/videos-torrent-cache.js index f2a288da..74ac7aee 100644 --- a/dist/server/lib/files-cache/videos-torrent-cache.js +++ b/dist/server/lib/files-cache/videos-torrent-cache.js @@ -17,19 +17,19 @@ class VideosTorrentCache extends abstract_video_static_file_cache_1.AbstractVide return this.instance || (this.instance = new this()); } getFilePathImpl(filename) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const file = yield video_file_1.VideoFileModel.loadWithVideoOrPlaylistByTorrentFilename(filename); if (!file) return undefined; if (file.getVideo().isOwned()) { const downloadName = this.buildDownloadName(file.getVideo(), file); - return { isOwned: true, path: path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, file.torrentFilename), downloadName }; + return { isOwned: true, path: (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, file.torrentFilename), downloadName }; } return this.loadRemoteFile(filename); }); } loadRemoteFile(key) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const file = yield video_file_1.VideoFileModel.loadWithVideoOrPlaylistByTorrentFilename(key); if (!file) return undefined; @@ -39,8 +39,8 @@ class VideosTorrentCache extends abstract_video_static_file_cache_1.AbstractVide if (!video) return undefined; const remoteUrl = file.getRemoteTorrentUrl(video); - const destPath = path_1.join(constants_1.FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename); - yield requests_1.doRequestAndSaveToFile(remoteUrl, destPath); + const destPath = (0, path_1.join)(constants_1.FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename); + yield (0, requests_1.doRequestAndSaveToFile)(remoteUrl, destPath); const downloadName = this.buildDownloadName(video, file); return { isOwned: false, path: destPath, downloadName }; }); diff --git a/dist/server/lib/hls.js b/dist/server/lib/hls.js index 53a61710..9a94316f 100644 --- a/dist/server/lib/hls.js +++ b/dist/server/lib/hls.js @@ -18,10 +18,10 @@ const video_streaming_playlist_1 = require("../models/video/video-streaming-play const paths_1 = require("./paths"); const video_path_manager_1 = require("./video-path-manager"); function updateStreamingPlaylistsInfohashesIfNeeded() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlistsToUpdate = yield video_streaming_playlist_1.VideoStreamingPlaylistModel.listByIncorrectPeerVersion(); for (const playlist of playlistsToUpdate) { - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoFiles = yield video_file_1.VideoFileModel.listByStreamingPlaylist(playlist.id, t); playlist.assignP2PMediaLoaderInfoHashes(playlist.Video, videoFiles); playlist.p2pMediaLoaderPeerVersion = constants_1.P2P_MEDIA_LOADER_PEER_VERSION; @@ -32,20 +32,20 @@ function updateStreamingPlaylistsInfohashesIfNeeded() { } exports.updateStreamingPlaylistsInfohashesIfNeeded = updateStreamingPlaylistsInfohashesIfNeeded; function updateMasterHLSPlaylist(video, playlist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const masterPlaylists = ['#EXTM3U', '#EXT-X-VERSION:3']; for (const file of playlist.VideoFiles) { - const playlistFilename = paths_1.getHlsResolutionPlaylistFilename(file.filename); - yield video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(playlist, file, (videoFilePath) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const size = yield ffprobe_utils_1.getVideoStreamSize(videoFilePath); + const playlistFilename = (0, paths_1.getHlsResolutionPlaylistFilename)(file.filename); + yield video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(playlist, file, (videoFilePath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const size = yield (0, ffprobe_utils_1.getVideoStreamSize)(videoFilePath); const bandwidth = 'BANDWIDTH=' + video.getBandwidthBits(file); const resolution = `RESOLUTION=${size.width}x${size.height}`; let line = `#EXT-X-STREAM-INF:${bandwidth},${resolution}`; if (file.fps) line += ',FRAME-RATE=' + file.fps; const codecs = yield Promise.all([ - ffprobe_utils_1.getVideoStreamCodec(videoFilePath), - ffprobe_utils_1.getAudioStreamCodec(videoFilePath) + (0, ffprobe_utils_1.getVideoStreamCodec)(videoFilePath), + (0, ffprobe_utils_1.getAudioStreamCodec)(videoFilePath) ]); line += `,CODECS="${codecs.filter(c => !!c).join(',')}"`; masterPlaylists.push(line); @@ -53,41 +53,41 @@ function updateMasterHLSPlaylist(video, playlist) { })); } yield video_path_manager_1.VideoPathManager.Instance.makeAvailablePlaylistFile(playlist, playlist.playlistFilename, masterPlaylistPath => { - return fs_extra_1.writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n'); + return (0, fs_extra_1.writeFile)(masterPlaylistPath, masterPlaylists.join('\n') + '\n'); }); }); } exports.updateMasterHLSPlaylist = updateMasterHLSPlaylist; function updateSha256VODSegments(video, playlist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const json = {}; for (const file of playlist.VideoFiles) { const rangeHashes = {}; yield video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(playlist, file, videoPath => { - return video_path_manager_1.VideoPathManager.Instance.makeAvailableResolutionPlaylistFile(playlist, file, (resolutionPlaylistPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const playlistContent = yield fs_extra_1.readFile(resolutionPlaylistPath); + return video_path_manager_1.VideoPathManager.Instance.makeAvailableResolutionPlaylistFile(playlist, file, (resolutionPlaylistPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const playlistContent = yield (0, fs_extra_1.readFile)(resolutionPlaylistPath); const ranges = getRangesFromPlaylist(playlistContent.toString()); - const fd = yield fs_extra_1.open(videoPath, 'r'); + const fd = yield (0, fs_extra_1.open)(videoPath, 'r'); for (const range of ranges) { const buf = Buffer.alloc(range.length); - yield fs_extra_1.read(fd, buf, 0, range.length, range.offset); - rangeHashes[`${range.offset}-${range.offset + range.length - 1}`] = core_utils_1.sha256(buf); + yield (0, fs_extra_1.read)(fd, buf, 0, range.length, range.offset); + rangeHashes[`${range.offset}-${range.offset + range.length - 1}`] = (0, core_utils_1.sha256)(buf); } - yield fs_extra_1.close(fd); + yield (0, fs_extra_1.close)(fd); const videoFilename = file.filename; json[videoFilename] = rangeHashes; })); }); } const outputPath = video_path_manager_1.VideoPathManager.Instance.getFSHLSOutputPath(video, playlist.segmentsSha256Filename); - yield fs_extra_1.outputJSON(outputPath, json); + yield (0, fs_extra_1.outputJSON)(outputPath, json); }); } exports.updateSha256VODSegments = updateSha256VODSegments; function buildSha256Segment(segmentPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const buf = yield fs_extra_1.readFile(segmentPath); - return core_utils_1.sha256(buf); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const buf = yield (0, fs_extra_1.readFile)(segmentPath); + return (0, core_utils_1.sha256)(buf); }); } exports.buildSha256Segment = buildSha256Segment; @@ -95,9 +95,9 @@ function downloadPlaylistSegments(playlistUrl, destinationDir, timeout, bodyKBLi let timer; let remainingBodyKBLimit = bodyKBLimit; logger_1.logger.info('Importing HLS playlist %s', playlistUrl); - return new Promise((res, rej) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const tmpDirectory = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, yield utils_1.generateRandomString(10)); - yield fs_extra_1.ensureDir(tmpDirectory); + return new Promise((res, rej) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const tmpDirectory = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, yield (0, utils_1.generateRandomString)(10)); + yield (0, fs_extra_1.ensureDir)(tmpDirectory); timer = setTimeout(() => { deleteTmpDirectory(tmpDirectory); return rej(new Error('HLS download timeout.')); @@ -105,17 +105,17 @@ function downloadPlaylistSegments(playlistUrl, destinationDir, timeout, bodyKBLi try { const subPlaylistUrls = yield fetchUniqUrls(playlistUrl); const subRequests = subPlaylistUrls.map(u => fetchUniqUrls(u)); - const fileUrls = lodash_1.uniq(lodash_1.flatten(yield Promise.all(subRequests))); + const fileUrls = (0, lodash_1.uniq)((0, lodash_1.flatten)(yield Promise.all(subRequests))); logger_1.logger.debug('Will download %d HLS files.', fileUrls.length, { fileUrls }); for (const fileUrl of fileUrls) { - const destPath = path_1.join(tmpDirectory, path_1.basename(fileUrl)); - yield requests_1.doRequestAndSaveToFile(fileUrl, destPath, { bodyKBLimit: remainingBodyKBLimit }); - const { size } = yield fs_extra_1.stat(destPath); + const destPath = (0, path_1.join)(tmpDirectory, (0, path_1.basename)(fileUrl)); + yield (0, requests_1.doRequestAndSaveToFile)(fileUrl, destPath, { bodyKBLimit: remainingBodyKBLimit }); + const { size } = yield (0, fs_extra_1.stat)(destPath); remainingBodyKBLimit -= (size / 1000); logger_1.logger.debug('Downloaded HLS playlist file %s with %d kB remained limit.', fileUrl, Math.floor(remainingBodyKBLimit)); } clearTimeout(timer); - yield fs_extra_1.move(tmpDirectory, destinationDir, { overwrite: true }); + yield (0, fs_extra_1.move)(tmpDirectory, destinationDir, { overwrite: true }); return res(); } catch (err) { @@ -124,12 +124,12 @@ function downloadPlaylistSegments(playlistUrl, destinationDir, timeout, bodyKBLi } })); function deleteTmpDirectory(directory) { - fs_extra_1.remove(directory) + (0, fs_extra_1.remove)(directory) .catch(err => logger_1.logger.error('Cannot delete path on HLS download error.', { err })); } function fetchUniqUrls(playlistUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { body } = yield requests_1.doRequest(playlistUrl); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { body } = yield (0, requests_1.doRequest)(playlistUrl); if (!body) return []; const urls = body.split('\n') @@ -137,9 +137,9 @@ function downloadPlaylistSegments(playlistUrl, destinationDir, timeout, bodyKBLi .map(url => { if (url.startsWith('http://') || url.startsWith('https://')) return url; - return `${path_1.dirname(playlistUrl)}/${url}`; + return `${(0, path_1.dirname)(playlistUrl)}/${url}`; }); - return lodash_1.uniq(urls); + return (0, lodash_1.uniq)(urls); }); } } diff --git a/dist/server/lib/job-queue/handlers/activitypub-cleaner.js b/dist/server/lib/job-queue/handlers/activitypub-cleaner.js index 8ec1d771..d5171169 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-cleaner.js +++ b/dist/server/lib/job-queue/handlers/activitypub-cleaner.js @@ -15,12 +15,12 @@ const models_1 = require("@shared/models"); const logger_1 = require("../../../helpers/logger"); const account_video_rate_1 = require("../../../models/account/account-video-rate"); function processActivityPubCleaner(_job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing ActivityPub cleaner.'); { const rateUrls = yield account_video_rate_1.AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos(); const { bodyValidator, deleter, updater } = rateOptionsFactory(); - yield bluebird_1.map(rateUrls, (rateUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(rateUrls, (rateUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const result = yield updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter); if ((result === null || result === void 0 ? void 0 : result.status) === 'deleted') { @@ -36,7 +36,7 @@ function processActivityPubCleaner(_job) { { const shareUrls = yield video_share_1.VideoShareModel.listRemoteShareUrlsOfLocalVideos(); const { bodyValidator, deleter, updater } = shareOptionsFactory(); - yield bluebird_1.map(shareUrls, (shareUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(shareUrls, (shareUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter); } @@ -48,7 +48,7 @@ function processActivityPubCleaner(_job) { { const commentUrls = yield video_comment_1.VideoCommentModel.listRemoteCommentUrlsOfLocalVideos(); const { bodyValidator, deleter, updater } = commentOptionsFactory(); - yield bluebird_1.map(commentUrls, (commentUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield (0, bluebird_1.map)(commentUrls, (commentUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter); } @@ -61,14 +61,14 @@ function processActivityPubCleaner(_job) { } exports.processActivityPubCleaner = processActivityPubCleaner; function updateObjectIfNeeded(url, bodyValidator, updater, deleter) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const on404OrTombstone = () => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const on404OrTombstone = () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Removing remote AP object %s.', url); const data = yield deleter(url); return { status: 'deleted', data }; }); try { - const { body } = yield requests_1.doJSONRequest(url, { activityPub: true }); + const { body } = yield (0, requests_1.doJSONRequest)(url, { activityPub: true }); if (!body || !body.id || !bodyValidator(body)) throw new Error(`Body or body id of ${url} is invalid`); if (body.type === 'Tombstone') { @@ -76,7 +76,7 @@ function updateObjectIfNeeded(url, bodyValidator, updater, deleter) { } const newUrl = body.id; if (newUrl !== url) { - if (activitypub_1.checkUrlsSameHost(newUrl, url) !== true) { + if ((0, activitypub_1.checkUrlsSameHost)(newUrl, url) !== true) { throw new Error(`New url ${newUrl} has not the same host than old url ${url}`); } logger_1.logger.info('Updating remote AP object %s.', url); @@ -95,8 +95,8 @@ function updateObjectIfNeeded(url, bodyValidator, updater, deleter) { } function rateOptionsFactory() { return { - bodyValidator: (body) => activity_1.isLikeActivityValid(body) || activity_1.isDislikeActivityValid(body), - updater: (url, newUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + bodyValidator: (body) => (0, activity_1.isLikeActivityValid)(body) || (0, activity_1.isDislikeActivityValid)(body), + updater: (url, newUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const rate = yield account_video_rate_1.AccountVideoRateModel.loadByUrl(url, undefined); rate.url = newUrl; const videoId = rate.videoId; @@ -104,7 +104,7 @@ function rateOptionsFactory() { yield rate.save(); return { videoId, type }; }), - deleter: (url) => tslib_1.__awaiter(this, void 0, void 0, function* () { + deleter: (url) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const rate = yield account_video_rate_1.AccountVideoRateModel.loadByUrl(url, undefined); const videoId = rate.videoId; const type = rate.type; @@ -115,14 +115,14 @@ function rateOptionsFactory() { } function shareOptionsFactory() { return { - bodyValidator: (body) => activity_1.isAnnounceActivityValid(body), - updater: (url, newUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + bodyValidator: (body) => (0, activity_1.isAnnounceActivityValid)(body), + updater: (url, newUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const share = yield video_share_1.VideoShareModel.loadByUrl(url, undefined); share.url = newUrl; yield share.save(); return undefined; }), - deleter: (url) => tslib_1.__awaiter(this, void 0, void 0, function* () { + deleter: (url) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const share = yield video_share_1.VideoShareModel.loadByUrl(url, undefined); yield share.destroy(); return undefined; @@ -131,14 +131,14 @@ function shareOptionsFactory() { } function commentOptionsFactory() { return { - bodyValidator: (body) => video_comments_1.sanitizeAndCheckVideoCommentObject(body), - updater: (url, newUrl) => tslib_1.__awaiter(this, void 0, void 0, function* () { + bodyValidator: (body) => (0, video_comments_1.sanitizeAndCheckVideoCommentObject)(body), + updater: (url, newUrl) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const comment = yield video_comment_1.VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(url); comment.url = newUrl; yield comment.save(); return undefined; }), - deleter: (url) => tslib_1.__awaiter(this, void 0, void 0, function* () { + deleter: (url) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const comment = yield video_comment_1.VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(url); yield comment.destroy(); return undefined; diff --git a/dist/server/lib/job-queue/handlers/activitypub-follow.js b/dist/server/lib/job-queue/handlers/activitypub-follow.js index be50e857..7f616464 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-follow.js +++ b/dist/server/lib/job-queue/handlers/activitypub-follow.js @@ -14,7 +14,7 @@ const actors_1 = require("../../activitypub/actors"); const send_1 = require("../../activitypub/send"); const notifier_1 = require("../../notifier"); function processActivityPubFollow(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; const host = payload.host; logger_1.logger.info('Processing ActivityPub follow in job %d.', job.id); @@ -23,26 +23,26 @@ function processActivityPubFollow(job) { targetActor = yield actor_1.ActorModel.loadLocalByName(payload.name); } else { - const sanitizedHost = core_utils_1.sanitizeHost(host, constants_1.REMOTE_SCHEME.HTTP); - const actorUrl = yield actors_1.loadActorUrlOrGetFromWebfinger(payload.name + '@' + sanitizedHost); - targetActor = yield actors_1.getOrCreateAPActor(actorUrl, 'all'); + const sanitizedHost = (0, core_utils_1.sanitizeHost)(host, constants_1.REMOTE_SCHEME.HTTP); + const actorUrl = yield (0, actors_1.loadActorUrlOrGetFromWebfinger)(payload.name + '@' + sanitizedHost); + targetActor = yield (0, actors_1.getOrCreateAPActor)(actorUrl, 'all'); } if (payload.assertIsChannel && !targetActor.VideoChannel) { logger_1.logger.warn('Do not follow %s@%s because it is not a channel.', payload.name, host); return; } const fromActor = yield actor_1.ActorModel.load(payload.followerActorId); - return database_utils_1.retryTransactionWrapper(follow, fromActor, targetActor, payload.isAutoFollow); + return (0, database_utils_1.retryTransactionWrapper)(follow, fromActor, targetActor, payload.isAutoFollow); }); } exports.processActivityPubFollow = processActivityPubFollow; function follow(fromActor, targetActor, isAutoFollow = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (fromActor.id === targetActor.id) { throw new Error('Follower is the same as target actor.'); } const state = !fromActor.serverId && !targetActor.serverId ? 'accepted' : 'pending'; - const actorFollow = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const actorFollow = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [actorFollow] = yield actor_follow_1.ActorFollowModel.findOrCreate({ where: { actorId: fromActor.id, @@ -50,7 +50,7 @@ function follow(fromActor, targetActor, isAutoFollow = false) { }, defaults: { state, - url: url_1.getLocalActorFollowActivityPubUrl(fromActor, targetActor), + url: (0, url_1.getLocalActorFollowActivityPubUrl)(fromActor, targetActor), actorId: fromActor.id, targetActorId: targetActor.id }, @@ -59,7 +59,7 @@ function follow(fromActor, targetActor, isAutoFollow = false) { actorFollow.ActorFollowing = targetActor; actorFollow.ActorFollower = fromActor; if (actorFollow.state !== 'accepted') - send_1.sendFollow(actorFollow, t); + (0, send_1.sendFollow)(actorFollow, t); return actorFollow; })); const followerFull = yield actor_1.ActorModel.loadFull(fromActor.id); diff --git a/dist/server/lib/job-queue/handlers/activitypub-http-broadcast.js b/dist/server/lib/job-queue/handlers/activitypub-http-broadcast.js index d33d5a38..1eb400a8 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-http-broadcast.js +++ b/dist/server/lib/job-queue/handlers/activitypub-http-broadcast.js @@ -9,21 +9,21 @@ const constants_1 = require("../../../initializers/constants"); const files_cache_1 = require("../../files-cache"); const activitypub_http_utils_1 = require("./utils/activitypub-http-utils"); function processActivityPubHttpBroadcast(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing ActivityPub broadcast in job %d.', job.id); const payload = job.data; - const body = yield activitypub_http_utils_1.computeBody(payload); - const httpSignatureOptions = yield activitypub_http_utils_1.buildSignedRequestOptions(payload); + const body = yield (0, activitypub_http_utils_1.computeBody)(payload); + const httpSignatureOptions = yield (0, activitypub_http_utils_1.buildSignedRequestOptions)(payload); const options = { method: 'POST', json: body, httpSignature: httpSignatureOptions, - headers: activitypub_http_utils_1.buildGlobalHeaders(body) + headers: (0, activitypub_http_utils_1.buildGlobalHeaders)(body) }; const badUrls = []; const goodUrls = []; - yield bluebird_1.map(payload.uris, uri => { - return requests_1.doRequest(uri, options) + yield (0, bluebird_1.map)(payload.uris, uri => { + return (0, requests_1.doRequest)(uri, options) .then(() => goodUrls.push(uri)) .catch(() => badUrls.push(uri)); }, { concurrency: constants_1.BROADCAST_CONCURRENCY }); diff --git a/dist/server/lib/job-queue/handlers/activitypub-http-fetcher.js b/dist/server/lib/job-queue/handlers/activitypub-http-fetcher.js index ea91aa07..1ba4a8e8 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-http-fetcher.js +++ b/dist/server/lib/job-queue/handlers/activitypub-http-fetcher.js @@ -14,19 +14,19 @@ const share_1 = require("../../activitypub/share"); const video_comments_1 = require("../../activitypub/video-comments"); const video_rates_1 = require("../../activitypub/video-rates"); function processActivityPubHttpFetcher(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing ActivityPub fetcher in job %d.', job.id); const payload = job.data; let video; if (payload.videoId) video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId); const fetcherType = { - 'activity': items => process_1.processActivities(items, { outboxUrl: payload.uri, fromFetch: true }), - 'video-likes': items => video_rates_1.createRates(items, video, 'like'), - 'video-dislikes': items => video_rates_1.createRates(items, video, 'dislike'), - 'video-shares': items => share_1.addVideoShares(items, video), - 'video-comments': items => video_comments_1.addVideoComments(items), - 'account-playlists': items => playlists_1.createAccountPlaylists(items) + 'activity': items => (0, process_1.processActivities)(items, { outboxUrl: payload.uri, fromFetch: true }), + 'video-likes': items => (0, video_rates_1.createRates)(items, video, 'like'), + 'video-dislikes': items => (0, video_rates_1.createRates)(items, video, 'dislike'), + 'video-shares': items => (0, share_1.addVideoShares)(items, video), + 'video-comments': items => (0, video_comments_1.addVideoComments)(items), + 'account-playlists': items => (0, playlists_1.createAccountPlaylists)(items) }; const cleanerType = { 'video-likes': crawlStartDate => account_video_rate_1.AccountVideoRateModel.cleanOldRatesOf(video.id, 'like', crawlStartDate), @@ -34,7 +34,7 @@ function processActivityPubHttpFetcher(job) { 'video-shares': crawlStartDate => video_share_1.VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate), 'video-comments': crawlStartDate => video_comment_1.VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate) }; - return crawl_1.crawlCollectionPage(payload.uri, fetcherType[payload.type], cleanerType[payload.type]); + return (0, crawl_1.crawlCollectionPage)(payload.uri, fetcherType[payload.type], cleanerType[payload.type]); }); } exports.processActivityPubHttpFetcher = processActivityPubHttpFetcher; diff --git a/dist/server/lib/job-queue/handlers/activitypub-http-unicast.js b/dist/server/lib/job-queue/handlers/activitypub-http-unicast.js index 1e89068c..0197b987 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-http-unicast.js +++ b/dist/server/lib/job-queue/handlers/activitypub-http-unicast.js @@ -7,20 +7,20 @@ const requests_1 = require("../../../helpers/requests"); const files_cache_1 = require("../../files-cache"); const activitypub_http_utils_1 = require("./utils/activitypub-http-utils"); function processActivityPubHttpUnicast(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing ActivityPub unicast in job %d.', job.id); const payload = job.data; const uri = payload.uri; - const body = yield activitypub_http_utils_1.computeBody(payload); - const httpSignatureOptions = yield activitypub_http_utils_1.buildSignedRequestOptions(payload); + const body = yield (0, activitypub_http_utils_1.computeBody)(payload); + const httpSignatureOptions = yield (0, activitypub_http_utils_1.buildSignedRequestOptions)(payload); const options = { method: 'POST', json: body, httpSignature: httpSignatureOptions, - headers: activitypub_http_utils_1.buildGlobalHeaders(body) + headers: (0, activitypub_http_utils_1.buildGlobalHeaders)(body) }; try { - yield requests_1.doRequest(uri, options); + yield (0, requests_1.doRequest)(uri, options); files_cache_1.ActorFollowScoreCache.Instance.updateActorFollowsScore([uri], []); } catch (err) { diff --git a/dist/server/lib/job-queue/handlers/activitypub-refresher.js b/dist/server/lib/job-queue/handlers/activitypub-refresher.js index a36b48ca..a5bebd9a 100644 --- a/dist/server/lib/job-queue/handlers/activitypub-refresher.js +++ b/dist/server/lib/job-queue/handlers/activitypub-refresher.js @@ -10,7 +10,7 @@ const actor_1 = require("../../../models/actor/actor"); const video_playlist_1 = require("../../../models/video/video-playlist"); const actors_1 = require("../../activitypub/actors"); function refreshAPObject(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url); if (payload.type === 'video') @@ -23,34 +23,34 @@ function refreshAPObject(job) { } exports.refreshAPObject = refreshAPObject; function refreshVideo(videoUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fetchType = 'all'; const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true }; - const videoFromDatabase = yield model_loaders_1.loadVideoByUrl(videoUrl, fetchType); + const videoFromDatabase = yield (0, model_loaders_1.loadVideoByUrl)(videoUrl, fetchType); if (videoFromDatabase) { const refreshOptions = { video: videoFromDatabase, fetchedType: fetchType, syncParam }; - yield videos_1.refreshVideoIfNeeded(refreshOptions); + yield (0, videos_1.refreshVideoIfNeeded)(refreshOptions); } }); } function refreshActor(actorUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fetchType = 'all'; const actor = yield actor_1.ActorModel.loadByUrlAndPopulateAccountAndChannel(actorUrl); if (actor) { - yield actors_1.refreshActorIfNeeded({ actor, fetchedType: fetchType }); + yield (0, actors_1.refreshActorIfNeeded)({ actor, fetchedType: fetchType }); } }); } function refreshVideoPlaylist(playlistUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlist = yield video_playlist_1.VideoPlaylistModel.loadByUrlAndPopulateAccount(playlistUrl); if (playlist) { - yield playlists_1.refreshVideoPlaylistIfNeeded(playlist); + yield (0, playlists_1.refreshVideoPlaylistIfNeeded)(playlist); } }); } diff --git a/dist/server/lib/job-queue/handlers/actor-keys.js b/dist/server/lib/job-queue/handlers/actor-keys.js index 57cf0a87..026d8161 100644 --- a/dist/server/lib/job-queue/handlers/actor-keys.js +++ b/dist/server/lib/job-queue/handlers/actor-keys.js @@ -6,11 +6,11 @@ const actors_1 = require("@server/lib/activitypub/actors"); const actor_1 = require("@server/models/actor/actor"); const logger_1 = require("../../../helpers/logger"); function processActorKeys(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing actor keys in job %d.', job.id); const actor = yield actor_1.ActorModel.load(payload.actorId); - yield actors_1.generateAndSaveActorKeys(actor); + yield (0, actors_1.generateAndSaveActorKeys)(actor); }); } exports.processActorKeys = processActorKeys; diff --git a/dist/server/lib/job-queue/handlers/email.js b/dist/server/lib/job-queue/handlers/email.js index b5e2198c..3369bf17 100644 --- a/dist/server/lib/job-queue/handlers/email.js +++ b/dist/server/lib/job-queue/handlers/email.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const logger_1 = require("../../../helpers/logger"); const emailer_1 = require("../../emailer"); function processEmail(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing email in job %d.', job.id); return emailer_1.Emailer.Instance.sendMail(payload); diff --git a/dist/server/lib/job-queue/handlers/move-to-object-storage.js b/dist/server/lib/job-queue/handlers/move-to-object-storage.js index a23062eb..1bfecf6c 100644 --- a/dist/server/lib/job-queue/handlers/move-to-object-storage.js +++ b/dist/server/lib/job-queue/handlers/move-to-object-storage.js @@ -14,7 +14,7 @@ const video_state_1 = require("@server/lib/video-state"); const video_1 = require("@server/models/video/video"); const video_job_info_1 = require("@server/models/video/video-job-info"); function processMoveToObjectStorage(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Moving video %s in job %d.', payload.videoUUID, job.id); const video = yield video_1.VideoModel.loadWithFiles(payload.videoUUID); @@ -38,57 +38,57 @@ function processMoveToObjectStorage(job) { } exports.processMoveToObjectStorage = processMoveToObjectStorage; function moveWebTorrentFiles(video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const file of video.VideoFiles) { if (file.storage !== 0) continue; - const fileUrl = yield object_storage_1.storeWebTorrentFile(file.filename); - const oldPath = path_1.join(config_1.CONFIG.STORAGE.VIDEOS_DIR, file.filename); + const fileUrl = yield (0, object_storage_1.storeWebTorrentFile)(file.filename); + const oldPath = (0, path_1.join)(config_1.CONFIG.STORAGE.VIDEOS_DIR, file.filename); yield onFileMoved({ videoOrPlaylist: video, file, fileUrl, oldPath }); } }); } function moveHLSFiles(video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const playlist of video.VideoStreamingPlaylists) { for (const file of playlist.VideoFiles) { if (file.storage !== 0) continue; - const playlistFilename = paths_1.getHlsResolutionPlaylistFilename(file.filename); - yield object_storage_1.storeHLSFile(playlist, video, playlistFilename); - const fileUrl = yield object_storage_1.storeHLSFile(playlist, video, file.filename); - const oldPath = path_1.join(paths_1.getHLSDirectory(video), file.filename); + const playlistFilename = (0, paths_1.getHlsResolutionPlaylistFilename)(file.filename); + yield (0, object_storage_1.storeHLSFile)(playlist, video, playlistFilename); + const fileUrl = yield (0, object_storage_1.storeHLSFile)(playlist, video, file.filename); + const oldPath = (0, path_1.join)((0, paths_1.getHLSDirectory)(video), file.filename); yield onFileMoved({ videoOrPlaylist: Object.assign(playlist, { Video: video }), file, fileUrl, oldPath }); } } }); } function doAfterLastJob(video, isNewVideo) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const playlist of video.VideoStreamingPlaylists) { if (playlist.storage === 1) continue; - playlist.playlistUrl = yield object_storage_1.storeHLSFile(playlist, video, playlist.playlistFilename); - playlist.segmentsSha256Url = yield object_storage_1.storeHLSFile(playlist, video, playlist.segmentsSha256Filename); + playlist.playlistUrl = yield (0, object_storage_1.storeHLSFile)(playlist, video, playlist.playlistFilename); + playlist.segmentsSha256Url = yield (0, object_storage_1.storeHLSFile)(playlist, video, playlist.segmentsSha256Filename); playlist.storage = 1; playlist.assignP2PMediaLoaderInfoHashes(video, playlist.VideoFiles); playlist.p2pMediaLoaderPeerVersion = constants_1.P2P_MEDIA_LOADER_PEER_VERSION; yield playlist.save(); } if (video.VideoStreamingPlaylists) { - yield fs_extra_1.remove(paths_1.getHLSDirectory(video)); + yield (0, fs_extra_1.remove)((0, paths_1.getHLSDirectory)(video)); } - yield video_state_1.moveToNextState(video, isNewVideo); + yield (0, video_state_1.moveToNextState)(video, isNewVideo); }); } function onFileMoved(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoOrPlaylist, file, fileUrl, oldPath } = options; file.fileUrl = fileUrl; file.storage = 1; - yield webtorrent_1.updateTorrentUrls(videoOrPlaylist, file); + yield (0, webtorrent_1.updateTorrentUrls)(videoOrPlaylist, file); yield file.save(); logger_1.logger.debug('Removing %s because it\'s now on object storage', oldPath); - yield fs_extra_1.remove(oldPath); + yield (0, fs_extra_1.remove)(oldPath); }); } diff --git a/dist/server/lib/job-queue/handlers/utils/activitypub-http-utils.js b/dist/server/lib/job-queue/handlers/utils/activitypub-http-utils.js index 140c4500..1aa6749d 100644 --- a/dist/server/lib/job-queue/handlers/utils/activitypub-http-utils.js +++ b/dist/server/lib/job-queue/handlers/utils/activitypub-http-utils.js @@ -8,20 +8,20 @@ const activitypub_1 = require("../../../../helpers/activitypub"); const constants_1 = require("../../../../initializers/constants"); const actor_1 = require("../../../../models/actor/actor"); function computeBody(payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let body = payload.body; if (payload.signatureActorId) { const actorSignature = yield actor_1.ActorModel.load(payload.signatureActorId); if (!actorSignature) throw new Error('Unknown signature actor id.'); - body = yield activitypub_1.buildSignedActivity(actorSignature, payload.body, payload.contextType); + body = yield (0, activitypub_1.buildSignedActivity)(actorSignature, payload.body, payload.contextType); } return body; }); } exports.computeBody = computeBody; function buildSignedRequestOptions(payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let actor; if (payload.signatureActorId) { actor = yield actor_1.ActorModel.load(payload.signatureActorId); @@ -29,7 +29,7 @@ function buildSignedRequestOptions(payload) { throw new Error('Unknown signature actor id.'); } else { - actor = yield application_1.getServerActor(); + actor = yield (0, application_1.getServerActor)(); } const keyId = actor.url; return { @@ -44,7 +44,7 @@ function buildSignedRequestOptions(payload) { exports.buildSignedRequestOptions = buildSignedRequestOptions; function buildGlobalHeaders(body) { return { - 'digest': peertube_crypto_1.buildDigest(body), + 'digest': (0, peertube_crypto_1.buildDigest)(body), 'content-type': 'application/activity+json', 'accept': constants_1.ACTIVITY_PUB.ACCEPT_HEADER }; diff --git a/dist/server/lib/job-queue/handlers/video-file-import.js b/dist/server/lib/job-queue/handlers/video-file-import.js index 068e0f43..4300c2c8 100644 --- a/dist/server/lib/job-queue/handlers/video-file-import.js +++ b/dist/server/lib/job-queue/handlers/video-file-import.js @@ -17,7 +17,7 @@ const video_2 = require("../../../models/video/video"); const video_file_1 = require("../../../models/video/video-file"); const video_transcoding_1 = require("./video-transcoding"); function processVideoFileImport(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing video file import in job %d.', job.id); const video = yield video_2.VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID); @@ -25,10 +25,10 @@ function processVideoFileImport(job) { logger_1.logger.info('Do not process job %d, video does not exist.', job.id); return undefined; } - const data = yield ffprobe_utils_1.getVideoFileResolution(payload.filePath); + const data = yield (0, ffprobe_utils_1.getVideoFileResolution)(payload.filePath); yield updateVideoFile(video, payload.filePath); const user = yield user_1.UserModel.loadByChannelActorId(video.VideoChannel.actorId); - yield video_transcoding_1.createHlsJobIfEnabled(user, { + yield (0, video_transcoding_1.createHlsJobIfEnabled)(user, { videoUUID: video.uuid, resolution: data.resolution, isPortraitMode: data.isPortraitMode, @@ -36,21 +36,21 @@ function processVideoFileImport(job) { isMaxQuality: false }); if (config_1.CONFIG.OBJECT_STORAGE.ENABLED) { - yield video_1.addMoveToObjectStorageJob(video); + yield (0, video_1.addMoveToObjectStorageJob)(video); } else { - yield videos_1.federateVideoIfNeeded(video, false); + yield (0, videos_1.federateVideoIfNeeded)(video, false); } return video; }); } exports.processVideoFileImport = processVideoFileImport; function updateVideoFile(video, inputFilePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { resolution } = yield ffprobe_utils_1.getVideoFileResolution(inputFilePath); - const { size } = yield fs_extra_1.stat(inputFilePath); - const fps = yield ffprobe_utils_1.getVideoFileFPS(inputFilePath); - const fileExt = core_utils_1.getLowercaseExtension(inputFilePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { resolution } = yield (0, ffprobe_utils_1.getVideoFileResolution)(inputFilePath); + const { size } = yield (0, fs_extra_1.stat)(inputFilePath); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(inputFilePath); + const fileExt = (0, core_utils_1.getLowercaseExtension)(inputFilePath); const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === resolution); if (currentVideoFile) { yield video.removeFileAndTorrent(currentVideoFile); @@ -60,16 +60,16 @@ function updateVideoFile(video, inputFilePath) { const newVideoFile = new video_file_1.VideoFileModel({ resolution, extname: fileExt, - filename: paths_1.generateWebTorrentVideoFilename(resolution, fileExt), + filename: (0, paths_1.generateWebTorrentVideoFilename)(resolution, fileExt), storage: 0, size, fps, videoId: video.id }); const outputPath = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(video, newVideoFile); - yield fs_extra_1.copy(inputFilePath, outputPath); + yield (0, fs_extra_1.copy)(inputFilePath, outputPath); video.VideoFiles.push(newVideoFile); - yield webtorrent_1.createTorrentAndSetInfoHash(video, newVideoFile); + yield (0, webtorrent_1.createTorrentAndSetInfoHash)(video, newVideoFile); yield newVideoFile.save(); }); } diff --git a/dist/server/lib/job-queue/handlers/video-import.js b/dist/server/lib/job-queue/handlers/video-import.js index 6be06298..eb49bda1 100644 --- a/dist/server/lib/job-queue/handlers/video-import.js +++ b/dist/server/lib/job-queue/handlers/video-import.js @@ -28,7 +28,7 @@ const videos_1 = require("../../activitypub/videos"); const notifier_1 = require("../../notifier"); const thumbnail_2 = require("../../thumbnail"); function processVideoImport(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload); @@ -38,7 +38,7 @@ function processVideoImport(job) { } exports.processVideoImport = processVideoImport; function processTorrentImport(job, payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing torrent video import in job %d.', job.id); const videoImport = yield getVideoImportOrDie(payload.videoImportId); const options = { @@ -46,14 +46,14 @@ function processTorrentImport(job, payload) { videoImportId: payload.videoImportId }; const target = { - torrentName: videoImport.torrentName ? utils_1.getSecureTorrentName(videoImport.torrentName) : undefined, + torrentName: videoImport.torrentName ? (0, utils_1.getSecureTorrentName)(videoImport.torrentName) : undefined, uri: videoImport.magnetUri }; - return processFile(() => webtorrent_1.downloadWebTorrentVideo(target, constants_1.VIDEO_IMPORT_TIMEOUT), videoImport, options); + return processFile(() => (0, webtorrent_1.downloadWebTorrentVideo)(target, constants_1.VIDEO_IMPORT_TIMEOUT), videoImport, options); }); } function processYoutubeDLImport(job, payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Processing youtubeDL video import in job %d.', job.id); const videoImport = yield getVideoImportOrDie(payload.videoImportId); const options = { @@ -65,7 +65,7 @@ function processYoutubeDLImport(job, payload) { }); } function getVideoImportOrDie(videoImportId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoImport = yield video_import_1.VideoImportModel.loadAndPopulateVideo(videoImportId); if (!videoImport || !videoImport.Video) { throw new Error('Cannot import video %s: the video import or video linked to this import does not exist anymore.'); @@ -74,25 +74,25 @@ function getVideoImportOrDie(videoImportId) { }); } function processFile(downloader, videoImport, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let tempVideoPath; let videoFile; try { tempVideoPath = yield downloader(); - const stats = yield fs_extra_1.stat(tempVideoPath); - const isAble = yield user_1.isAbleToUploadVideo(videoImport.User.id, stats.size); + const stats = yield (0, fs_extra_1.stat)(tempVideoPath); + const isAble = yield (0, user_1.isAbleToUploadVideo)(videoImport.User.id, stats.size); if (isAble === false) { throw new Error('The user video quota is exceeded with this video to import.'); } - const { resolution } = yield ffprobe_utils_1.getVideoFileResolution(tempVideoPath); - const fps = yield ffprobe_utils_1.getVideoFileFPS(tempVideoPath); - const duration = yield ffprobe_utils_1.getDurationFromVideoFile(tempVideoPath); - const fileExt = core_utils_1.getLowercaseExtension(tempVideoPath); + const { resolution } = yield (0, ffprobe_utils_1.getVideoFileResolution)(tempVideoPath); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(tempVideoPath); + const duration = yield (0, ffprobe_utils_1.getDurationFromVideoFile)(tempVideoPath); + const fileExt = (0, core_utils_1.getLowercaseExtension)(tempVideoPath); const videoFileData = { extname: fileExt, resolution, size: stats.size, - filename: paths_1.generateWebTorrentVideoFilename(resolution, fileExt), + filename: (0, paths_1.generateWebTorrentVideoFilename)(resolution, fileExt), fps, videoId: videoImport.videoId }; @@ -117,12 +117,12 @@ function processFile(downloader, videoImport, options) { const videoWithFiles = Object.assign(videoImport.Video, { VideoFiles: [videoFile], VideoStreamingPlaylists: [] }); const videoImportWithFiles = Object.assign(videoImport, { Video: videoWithFiles }); const videoDestFile = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(videoImportWithFiles.Video, videoFile); - yield fs_extra_1.move(tempVideoPath, videoDestFile); + yield (0, fs_extra_1.move)(tempVideoPath, videoDestFile); tempVideoPath = null; let thumbnailModel; let thumbnailSave; if (!videoImportWithFiles.Video.getMiniature()) { - thumbnailModel = yield thumbnail_2.generateVideoMiniature({ + thumbnailModel = yield (0, thumbnail_2.generateVideoMiniature)({ video: videoImportWithFiles.Video, videoFile, type: 1 @@ -132,31 +132,31 @@ function processFile(downloader, videoImport, options) { let previewModel; let previewSave; if (!videoImportWithFiles.Video.getPreview()) { - previewModel = yield thumbnail_2.generateVideoMiniature({ + previewModel = yield (0, thumbnail_2.generateVideoMiniature)({ video: videoImportWithFiles.Video, videoFile, type: 2 }); previewSave = previewModel.toJSON(); } - yield webtorrent_1.createTorrentAndSetInfoHash(videoImportWithFiles.Video, videoFile); + yield (0, webtorrent_1.createTorrentAndSetInfoHash)(videoImportWithFiles.Video, videoFile); const videoFileSave = videoFile.toJSON(); - const { videoImportUpdated, video } = yield database_utils_1.retryTransactionWrapper(() => { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { videoImportUpdated, video } = yield (0, database_utils_1.retryTransactionWrapper)(() => { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoImportToUpdate = videoImportWithFiles; const video = yield video_2.VideoModel.load(videoImportToUpdate.videoId, t); if (!video) throw new Error('Video linked to import ' + videoImportToUpdate.videoId + ' does not exist anymore.'); const videoFileCreated = yield videoFile.save({ transaction: t }); video.duration = duration; - video.state = video_state_1.buildNextVideoState(video.state); + video.state = (0, video_state_1.buildNextVideoState)(video.state); yield video.save({ transaction: t }); if (thumbnailModel) yield video.addAndSaveThumbnail(thumbnailModel, t); if (previewModel) yield video.addAndSaveThumbnail(previewModel, t); const videoForFederation = yield video_2.VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t); - yield videos_1.federateVideoIfNeeded(videoForFederation, true, t); + yield (0, videos_1.federateVideoIfNeeded)(videoForFederation, true, t); videoImportToUpdate.state = 2; const videoImportUpdated = yield videoImportToUpdate.save({ transaction: t }); videoImportUpdated.Video = video; @@ -181,16 +181,16 @@ function processFile(downloader, videoImport, options) { notifier_1.Notifier.Instance.notifyOnNewVideoIfNeeded(video); } if (video.state === 6) { - return video_1.addMoveToObjectStorageJob(videoImportUpdated.Video); + return (0, video_1.addMoveToObjectStorageJob)(videoImportUpdated.Video); } if (video.state === 2) { - yield video_1.addOptimizeOrMergeAudioJob(videoImportUpdated.Video, videoFile, videoImport.User); + yield (0, video_1.addOptimizeOrMergeAudioJob)(videoImportUpdated.Video, videoFile, videoImport.User); } } catch (err) { try { if (tempVideoPath) - yield fs_extra_1.remove(tempVideoPath); + yield (0, fs_extra_1.remove)(tempVideoPath); } catch (errUnlink) { logger_1.logger.warn('Cannot cleanup files after a video import error.', { err: errUnlink }); diff --git a/dist/server/lib/job-queue/handlers/video-live-ending.js b/dist/server/lib/job-queue/handlers/video-live-ending.js index 2d804643..9a4fdc1c 100644 --- a/dist/server/lib/job-queue/handlers/video-live-ending.js +++ b/dist/server/lib/job-queue/handlers/video-live-ending.js @@ -18,7 +18,7 @@ const video_live_1 = require("@server/models/video/video-live"); const video_streaming_playlist_1 = require("@server/models/video/video-streaming-playlist"); const logger_1 = require("../../../helpers/logger"); function processVideoLiveEnding(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; function logError() { logger_1.logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId); @@ -36,20 +36,20 @@ function processVideoLiveEnding(job) { } live_1.LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid); if (live.saveReplay !== true) { - return live_1.cleanupLive(video, streamingPlaylist); + return (0, live_1.cleanupLive)(video, streamingPlaylist); } return saveLive(video, live, streamingPlaylist); }); } exports.processVideoLiveEnding = processVideoLiveEnding; function saveLive(video, live, streamingPlaylist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const replayDirectory = video_path_manager_1.VideoPathManager.Instance.getFSHLSOutputPath(video, constants_1.VIDEO_LIVE.REPLAY_DIRECTORY); - const rootFiles = yield fs_extra_1.readdir(paths_1.getLiveDirectory(video)); + const rootFiles = yield (0, fs_extra_1.readdir)((0, paths_1.getLiveDirectory)(video)); const playlistFiles = rootFiles.filter(file => { return file.endsWith('.m3u8') && file !== streamingPlaylist.playlistFilename; }); - yield cleanupTMPLiveFiles(paths_1.getLiveDirectory(video)); + yield cleanupTMPLiveFiles((0, paths_1.getLiveDirectory)(video)); yield live.destroy(); video.isLive = false; video.views = 0; @@ -59,17 +59,17 @@ function saveLive(video, live, streamingPlaylist) { const hlsPlaylist = videoWithFiles.getHLSPlaylist(); yield video_file_1.VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id); hlsPlaylist.VideoFiles = []; - hlsPlaylist.playlistFilename = paths_1.generateHLSMasterPlaylistFilename(); - hlsPlaylist.segmentsSha256Filename = paths_1.generateHlsSha256SegmentsFilename(); + hlsPlaylist.playlistFilename = (0, paths_1.generateHLSMasterPlaylistFilename)(); + hlsPlaylist.segmentsSha256Filename = (0, paths_1.generateHlsSha256SegmentsFilename)(); yield hlsPlaylist.save(); let durationDone = false; for (const playlistFile of playlistFiles) { - const concatenatedTsFile = live_1.buildConcatenatedName(playlistFile); - const concatenatedTsFilePath = path_1.join(replayDirectory, concatenatedTsFile); - const probe = yield ffprobe_utils_1.ffprobePromise(concatenatedTsFilePath); - const { audioStream } = yield ffprobe_utils_1.getAudioStream(concatenatedTsFilePath, probe); - const { resolution, isPortraitMode } = yield ffprobe_utils_1.getVideoFileResolution(concatenatedTsFilePath, probe); - const { resolutionPlaylistPath: outputPath } = yield video_transcoding_1.generateHlsPlaylistResolutionFromTS({ + const concatenatedTsFile = (0, live_1.buildConcatenatedName)(playlistFile); + const concatenatedTsFilePath = (0, path_1.join)(replayDirectory, concatenatedTsFile); + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(concatenatedTsFilePath); + const { audioStream } = yield (0, ffprobe_utils_1.getAudioStream)(concatenatedTsFilePath, probe); + const { resolution, isPortraitMode } = yield (0, ffprobe_utils_1.getVideoFileResolution)(concatenatedTsFilePath, probe); + const { resolutionPlaylistPath: outputPath } = yield (0, video_transcoding_1.generateHlsPlaylistResolutionFromTS)({ video: videoWithFiles, concatenatedTsFilePath, resolution, @@ -77,42 +77,42 @@ function saveLive(video, live, streamingPlaylist) { isAAC: (audioStream === null || audioStream === void 0 ? void 0 : audioStream.codec_name) === 'aac' }); if (!durationDone) { - videoWithFiles.duration = yield ffprobe_utils_1.getDurationFromVideoFile(outputPath); + videoWithFiles.duration = yield (0, ffprobe_utils_1.getDurationFromVideoFile)(outputPath); yield videoWithFiles.save(); durationDone = true; } } - yield fs_extra_1.remove(replayDirectory); + yield (0, fs_extra_1.remove)(replayDirectory); if (videoWithFiles.getMiniature().automaticallyGenerated === true) { - yield thumbnail_1.generateVideoMiniature({ + yield (0, thumbnail_1.generateVideoMiniature)({ video: videoWithFiles, videoFile: videoWithFiles.getMaxQualityFile(), type: 1 }); } if (videoWithFiles.getPreview().automaticallyGenerated === true) { - yield thumbnail_1.generateVideoMiniature({ + yield (0, thumbnail_1.generateVideoMiniature)({ video: videoWithFiles, videoFile: videoWithFiles.getMaxQualityFile(), type: 2 }); } - yield video_state_1.moveToNextState(videoWithFiles, false); + yield (0, video_state_1.moveToNextState)(videoWithFiles, false); }); } function cleanupTMPLiveFiles(hlsDirectory) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (!(yield fs_extra_1.pathExists(hlsDirectory))) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if (!(yield (0, fs_extra_1.pathExists)(hlsDirectory))) return; - const files = yield fs_extra_1.readdir(hlsDirectory); + const files = yield (0, fs_extra_1.readdir)(hlsDirectory); for (const filename of files) { if (filename.endsWith('.ts') || filename.endsWith('.m3u8') || filename.endsWith('.mpd') || filename.endsWith('.m4s') || filename.endsWith('.tmp')) { - const p = path_1.join(hlsDirectory, filename); - fs_extra_1.remove(p) + const p = (0, path_1.join)(hlsDirectory, filename); + (0, fs_extra_1.remove)(p) .catch(err => logger_1.logger.error('Cannot remove %s.', p, { err })); } } diff --git a/dist/server/lib/job-queue/handlers/video-redundancy.js b/dist/server/lib/job-queue/handlers/video-redundancy.js index 3cda2eb8..adf04c56 100644 --- a/dist/server/lib/job-queue/handlers/video-redundancy.js +++ b/dist/server/lib/job-queue/handlers/video-redundancy.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const videos_redundancy_scheduler_1 = require("@server/lib/schedulers/videos-redundancy-scheduler"); const logger_1 = require("../../../helpers/logger"); function processVideoRedundancy(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing video redundancy in job %d.', job.id); return videos_redundancy_scheduler_1.VideosRedundancyScheduler.Instance.createManualRedundancy(payload.videoId); diff --git a/dist/server/lib/job-queue/handlers/video-transcoding.js b/dist/server/lib/job-queue/handlers/video-transcoding.js index e35c50b9..db9c7f73 100644 --- a/dist/server/lib/job-queue/handlers/video-transcoding.js +++ b/dist/server/lib/job-queue/handlers/video-transcoding.js @@ -20,9 +20,9 @@ const handlers = { 'merge-audio-to-webtorrent': handleWebTorrentMergeAudioJob, 'optimize-to-webtorrent': handleWebTorrentOptimizeJob }; -const lTags = logger_1.loggerTagsFactory('transcoding'); +const lTags = (0, logger_1.loggerTagsFactory)('transcoding'); function processVideoTranscoding(job) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const payload = job.data; logger_1.logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)); const video = yield video_2.VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID); @@ -41,14 +41,14 @@ function processVideoTranscoding(job) { } exports.processVideoTranscoding = processVideoTranscoding; function handleHLSJob(job, payload, video, user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)); const videoFileInput = payload.copyCodecs ? (video.getWebTorrentFile(payload.resolution) || video.getMaxQualityFile()) : video.getMaxQualityFile(); const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist(); yield video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(videoOrStreamingPlaylist, videoFileInput, videoInputPath => { - return video_transcoding_1.generateHlsPlaylistResolution({ + return (0, video_transcoding_1.generateHlsPlaylistResolution)({ video, videoInputPath, resolution: payload.resolution, @@ -58,36 +58,36 @@ function handleHLSJob(job, payload, video, user) { }); }); logger_1.logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid)); - yield database_utils_1.retryTransactionWrapper(onHlsPlaylistGeneration, video, user, payload); + yield (0, database_utils_1.retryTransactionWrapper)(onHlsPlaylistGeneration, video, user, payload); }); } function handleNewWebTorrentResolutionJob(job, payload, video, user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid)); - yield video_transcoding_1.transcodeNewWebTorrentResolution(video, payload.resolution, payload.isPortraitMode || false, job); + yield (0, video_transcoding_1.transcodeNewWebTorrentResolution)(video, payload.resolution, payload.isPortraitMode || false, job); logger_1.logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid)); - yield database_utils_1.retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload); + yield (0, database_utils_1.retryTransactionWrapper)(onNewWebTorrentFileResolution, video, user, payload); }); } function handleWebTorrentMergeAudioJob(job, payload, video, user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)); - yield video_transcoding_1.mergeAudioVideofile(video, payload.resolution, job); + yield (0, video_transcoding_1.mergeAudioVideofile)(video, payload.resolution, job); logger_1.logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid)); - yield database_utils_1.retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user); + yield (0, database_utils_1.retryTransactionWrapper)(onVideoFileOptimizer, video, payload, 'video', user); }); } function handleWebTorrentOptimizeJob(job, payload, video, user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)); - const { transcodeType } = yield video_transcoding_1.optimizeOriginalVideofile(video, video.getMaxQualityFile(), job); + const { transcodeType } = yield (0, video_transcoding_1.optimizeOriginalVideofile)(video, video.getMaxQualityFile(), job); logger_1.logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid)); - yield database_utils_1.retryTransactionWrapper(onVideoFileOptimizer, video, payload, transcodeType, user); + yield (0, database_utils_1.retryTransactionWrapper)(onVideoFileOptimizer, video, payload, transcodeType, user); }); } function onHlsPlaylistGeneration(video, user, payload) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (payload.isMaxQuality && config_1.CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { for (const file of video.VideoFiles) { yield video.removeFileAndTorrent(file); @@ -104,12 +104,12 @@ function onHlsPlaylistGeneration(video, user, payload) { }); } yield video_job_info_1.VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode'); - yield video_state_1.moveToNextState(video, payload.isNewVideo); + yield (0, video_state_1.moveToNextState)(video, payload.isNewVideo); }); } function onVideoFileOptimizer(videoArg, payload, transcodeType, user) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { resolution, isPortraitMode } = yield videoArg.getMaxQualityResolution(); const videoDatabase = yield video_2.VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid); if (!videoDatabase) @@ -128,24 +128,24 @@ function onVideoFileOptimizer(videoArg, payload, transcodeType, user) { }); yield video_job_info_1.VideoJobInfoModel.decrease(videoDatabase.uuid, 'pendingTranscode'); if (!hasHls && !hasNewResolutions) { - yield video_state_1.moveToNextState(videoDatabase, payload.isNewVideo); + yield (0, video_state_1.moveToNextState)(videoDatabase, payload.isNewVideo); } }); } function onNewWebTorrentFileResolution(video, user, payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield createHlsJobIfEnabled(user, Object.assign(Object.assign({}, payload), { copyCodecs: true, isMaxQuality: false })); yield video_job_info_1.VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode'); - yield video_state_1.moveToNextState(video, payload.isNewVideo); + yield (0, video_state_1.moveToNextState)(video, payload.isNewVideo); }); } exports.onNewWebTorrentFileResolution = onNewWebTorrentFileResolution; function createHlsJobIfEnabled(user, payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!payload || config_1.CONFIG.TRANSCODING.ENABLED !== true || config_1.CONFIG.TRANSCODING.HLS.ENABLED !== true) return false; const jobOptions = { - priority: yield video_1.getTranscodingJobPriority(user) + priority: yield (0, video_1.getTranscodingJobPriority)(user) }; const hlsTranscodingPayload = { type: 'new-resolution-to-hls', @@ -156,15 +156,15 @@ function createHlsJobIfEnabled(user, payload) { isMaxQuality: payload.isMaxQuality, isNewVideo: payload.isNewVideo }; - yield video_1.addTranscodingJob(hlsTranscodingPayload, jobOptions); + yield (0, video_1.addTranscodingJob)(hlsTranscodingPayload, jobOptions); return true; }); } exports.createHlsJobIfEnabled = createHlsJobIfEnabled; function createLowerResolutionsJobs(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, user, videoFileResolution, isPortraitMode, isNewVideo, type } = options; - const resolutionsEnabled = ffprobe_utils_1.computeResolutionsToTranscode(videoFileResolution, 'vod'); + const resolutionsEnabled = (0, ffprobe_utils_1.computeResolutionsToTranscode)(videoFileResolution, 'vod'); const resolutionCreated = []; for (const resolution of resolutionsEnabled) { let dataInput; @@ -193,9 +193,9 @@ function createLowerResolutionsJobs(options) { if (!dataInput) continue; const jobOptions = { - priority: yield video_1.getTranscodingJobPriority(user) + priority: yield (0, video_1.getTranscodingJobPriority)(user) }; - yield video_1.addTranscodingJob(dataInput, jobOptions); + yield (0, video_1.addTranscodingJob)(dataInput, jobOptions); } if (resolutionCreated.length === 0) { logger_1.logger.info('No transcoding jobs created for video %s (no resolutions).', video.uuid, lTags(video.uuid)); diff --git a/dist/server/lib/job-queue/handlers/video-views.js b/dist/server/lib/job-queue/handlers/video-views.js index 9252fccf..10f14be7 100644 --- a/dist/server/lib/job-queue/handlers/video-views.js +++ b/dist/server/lib/job-queue/handlers/video-views.js @@ -9,9 +9,9 @@ const video_view_1 = require("../../../models/video/video-view"); const core_utils_1 = require("../../../helpers/core-utils"); const videos_1 = require("../../activitypub/videos"); function processVideosViews() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const lastHour = new Date(); - if (!core_utils_1.isTestInstance()) + if (!(0, core_utils_1.isTestInstance)()) lastHour.setHours(lastHour.getHours() - 1); const hour = lastHour.getHours(); const startDate = lastHour.setMinutes(0, 0, 0); @@ -41,7 +41,7 @@ function processVideosViews() { if (video.isOwned()) { yield video_1.VideoModel.incrementViews(videoId, views); video.views += views; - yield videos_1.federateVideoIfNeeded(video, false); + yield (0, videos_1.federateVideoIfNeeded)(video, false); } } catch (err) { diff --git a/dist/server/lib/job-queue/index.js b/dist/server/lib/job-queue/index.js index dc12b19a..e080cbce 100644 --- a/dist/server/lib/job-queue/index.js +++ b/dist/server/lib/job-queue/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./job-queue"), exports); +(0, tslib_1.__exportStar)(require("./job-queue"), exports); diff --git a/dist/server/lib/job-queue/job-queue.js b/dist/server/lib/job-queue/job-queue.js index 370d43ca..20e5c4bc 100644 --- a/dist/server/lib/job-queue/job-queue.js +++ b/dist/server/lib/job-queue/job-queue.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.JobQueue = exports.jobTypes = void 0; const tslib_1 = require("tslib"); -const bull_1 = tslib_1.__importDefault(require("bull")); +const bull_1 = (0, tslib_1.__importDefault)(require("bull")); const jobs_1 = require("@server/helpers/custom-validators/jobs"); const config_1 = require("@server/initializers/config"); const video_redundancy_1 = require("@server/lib/job-queue/handlers/video-redundancy"); @@ -23,7 +23,7 @@ const video_import_1 = require("./handlers/video-import"); const video_live_ending_1 = require("./handlers/video-live-ending"); const video_transcoding_1 = require("./handlers/video-transcoding"); const video_views_1 = require("./handlers/video-views"); -const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); +const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch")); const handlers = { 'activitypub-http-broadcast': activitypub_http_broadcast_1.processActivityPubHttpBroadcast, 'activitypub-http-unicast': activitypub_http_unicast_1.processActivityPubHttpUnicast, @@ -87,7 +87,7 @@ class JobQueue { info: job.data, errText: err }; - return node_fetch_1.default(constants_1.LOGGER_ENDPOINT, { + return (0, node_fetch_1.default)(constants_1.LOGGER_ENDPOINT, { body: Object.assign({}, errorData) }); }); @@ -124,7 +124,7 @@ class JobQueue { return queue.add(obj.payload, jobArgs); } listForApi(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { state, start, count, asc, jobType } = options; const states = state ? [state] : jobs_1.jobStates; let results = []; @@ -151,7 +151,7 @@ class JobQueue { }); } count(state, jobType) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const states = state ? [state] : jobs_1.jobStates; let total = 0; const filteredJobTypes = this.filterJobTypes(jobType); @@ -170,7 +170,7 @@ class JobQueue { }); } removeOldJobs() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const key of Object.keys(this.queues)) { const queue = this.queues[key]; yield queue.clean(constants_1.JOB_COMPLETED_LIFETIME, 'completed'); diff --git a/dist/server/lib/live/index.js b/dist/server/lib/live/index.js index cdf94785..33d94a3a 100644 --- a/dist/server/lib/live/index.js +++ b/dist/server/lib/live/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./live-manager"), exports); -tslib_1.__exportStar(require("./live-quota-store"), exports); -tslib_1.__exportStar(require("./live-segment-sha-store"), exports); -tslib_1.__exportStar(require("./live-utils"), exports); +(0, tslib_1.__exportStar)(require("./live-manager"), exports); +(0, tslib_1.__exportStar)(require("./live-quota-store"), exports); +(0, tslib_1.__exportStar)(require("./live-segment-sha-store"), exports); +(0, tslib_1.__exportStar)(require("./live-utils"), exports); diff --git a/dist/server/lib/live/live-manager.js b/dist/server/lib/live/live-manager.js index 5a652195..30d3b056 100644 --- a/dist/server/lib/live/live-manager.js +++ b/dist/server/lib/live/live-manager.js @@ -35,7 +35,7 @@ const config = { ffmpeg: 'ffmpeg' } }; -const lTags = logger_1.loggerTagsFactory('live'); +const lTags = (0, logger_1.loggerTagsFactory)('live'); class LiveManager { constructor() { this.muxingSessions = new Map(); @@ -57,7 +57,7 @@ class LiveManager { events.on('donePublish', sessionId => { logger_1.logger.info('Live session ended.', Object.assign({ sessionId }, lTags(sessionId))); }); - config_1.registerConfigChangedHandler(() => { + (0, config_1.registerConfigChangedHandler)(() => { if (!this.rtmpServer && config_1.CONFIG.LIVE.ENABLED === true) { this.run(); return; @@ -72,7 +72,7 @@ class LiveManager { } run() { logger_1.logger.info('Running RTMP server on port %d', config.rtmp.port, lTags()); - this.rtmpServer = net_1.createServer(socket => { + this.rtmpServer = (0, net_1.createServer)(socket => { const session = new NodeRtmpSession(config, socket); session.run(); }); @@ -127,7 +127,7 @@ class LiveManager { } } handleSession(sessionId, streamPath, streamKey) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const pendingStreamJobs = yield job_queue_1.JobQueue.Instance.getQueues('video-live-ending', ['delayed']); const currentSessionJob = pendingStreamJobs.find((job) => job.data.name === streamKey); const videoLive = currentSessionJob @@ -150,11 +150,11 @@ class LiveManager { this.videoSessions.set(video.id, sessionId); const rtmpUrl = 'rtmp://127.0.0.1:' + config.rtmp.port + streamPath; const now = Date.now(); - const probe = yield ffprobe_utils_1.ffprobePromise(rtmpUrl); + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(rtmpUrl); const [{ resolution, ratio }, fps, bitrate] = yield Promise.all([ - ffprobe_utils_1.getVideoFileResolution(rtmpUrl, probe), - ffprobe_utils_1.getVideoFileFPS(rtmpUrl, probe), - ffprobe_utils_1.getVideoFileBitrate(rtmpUrl, probe) + (0, ffprobe_utils_1.getVideoFileResolution)(rtmpUrl, probe), + (0, ffprobe_utils_1.getVideoFileFPS)(rtmpUrl, probe), + (0, ffprobe_utils_1.getVideoFileBitrate)(rtmpUrl, probe) ]); logger_1.logger.info('%s probing took %d ms (bitrate: %d, fps: %d, resolution: %d)', rtmpUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid)); const allResolutions = this.buildAllResolutionsToTranscode(resolution); @@ -180,7 +180,7 @@ class LiveManager { }); } runMuxingSession(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { sessionId, videoLive, streamingPlaylist, allResolutions, fps, bitrate, ratio, rtmpUrl } = options; const videoUUID = videoLive.Video.uuid; const localLTags = lTags(sessionId, videoUUID); @@ -231,7 +231,7 @@ class LiveManager { }); } publishAndFederateLive(live, localLTags) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoId = live.videoId; try { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(videoId); @@ -240,7 +240,7 @@ class LiveManager { yield video.save(); live.Video = video; setTimeout(() => { - videos_1.federateVideoIfNeeded(video, false) + (0, videos_1.federateVideoIfNeeded)(video, false) .catch(err => logger_1.logger.error('Cannot federate live video %s.', video.url, Object.assign({ err }, localLTags))); peertube_socket_1.PeerTubeSocket.Instance.sendVideoLiveNewState(video); }, constants_1.VIDEO_LIVE.SEGMENT_TIME_SECONDS * 1000 * constants_1.VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION); @@ -255,7 +255,7 @@ class LiveManager { this.videoSessions.delete(videoId); } onAfterMuxingCleanup(videoUUID, cleanupNow = false, jobName) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const fullVideo = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(videoUUID); if (!fullVideo) @@ -276,7 +276,7 @@ class LiveManager { } yield fullVideo.save(); peertube_socket_1.PeerTubeSocket.Instance.sendVideoLiveNewState(fullVideo); - yield videos_1.federateVideoIfNeeded(fullVideo, false); + yield (0, videos_1.federateVideoIfNeeded)(fullVideo, false); } catch (err) { logger_1.logger.error('Cannot save/federate new video state of live streaming of video %d.', videoUUID, Object.assign({ err }, lTags(videoUUID))); @@ -284,10 +284,10 @@ class LiveManager { }); } updateLiveViews() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.isRunning()) return; - if (!core_utils_1.isTestInstance()) + if (!(0, core_utils_1.isTestInstance)()) logger_1.logger.info('Updating live video views.', lTags()); for (const videoId of this.watchersPerVideo.keys()) { const notBefore = new Date().getTime() - constants_1.VIEW_LIFETIME.LIVE; @@ -296,7 +296,7 @@ class LiveManager { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(videoId); video.views = numWatchers; yield video.save(); - yield videos_1.federateVideoIfNeeded(video, false); + yield (0, videos_1.federateVideoIfNeeded)(video, false); peertube_socket_1.PeerTubeSocket.Instance.sendVideoViewsUpdate(video); const newWatchers = watchers.filter(w => w > notBefore); this.watchersPerVideo.set(videoId, newWatchers); @@ -305,7 +305,7 @@ class LiveManager { }); } handleBrokenLives() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoUUIDs = yield video_1.VideoModel.listPublishedLiveUUIDs(); for (const uuid of videoUUIDs) { yield this.onAfterMuxingCleanup(uuid, true); @@ -314,15 +314,15 @@ class LiveManager { } buildAllResolutionsToTranscode(originResolution) { const resolutionsEnabled = config_1.CONFIG.LIVE.TRANSCODING.ENABLED - ? ffprobe_utils_1.computeResolutionsToTranscode(originResolution, 'live') + ? (0, ffprobe_utils_1.computeResolutionsToTranscode)(originResolution, 'live') : []; return resolutionsEnabled.concat([originResolution]); } createLivePlaylist(video, allResolutions) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlist = yield video_streaming_playlist_1.VideoStreamingPlaylistModel.loadOrGenerate(video); - playlist.playlistFilename = paths_1.generateHLSMasterPlaylistFilename(true); - playlist.segmentsSha256Filename = paths_1.generateHlsSha256SegmentsFilename(true); + playlist.playlistFilename = (0, paths_1.generateHLSMasterPlaylistFilename)(true); + playlist.segmentsSha256Filename = (0, paths_1.generateHlsSha256SegmentsFilename)(true); playlist.p2pMediaLoaderPeerVersion = constants_1.P2P_MEDIA_LOADER_PEER_VERSION; playlist.type = 1; playlist.assignP2PMediaLoaderInfoHashes(video, allResolutions); diff --git a/dist/server/lib/live/live-segment-sha-store.js b/dist/server/lib/live/live-segment-sha-store.js index 8948e695..cd1da809 100644 --- a/dist/server/lib/live/live-segment-sha-store.js +++ b/dist/server/lib/live/live-segment-sha-store.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const path_1 = require("path"); const logger_1 = require("@server/helpers/logger"); const hls_1 = require("../hls"); -const lTags = logger_1.loggerTagsFactory('live'); +const lTags = (0, logger_1.loggerTagsFactory)('live'); class LiveSegmentShaStore { constructor() { this.segmentsSha256 = new Map(); @@ -14,10 +14,10 @@ class LiveSegmentShaStore { return this.segmentsSha256.get(videoUUID); } addSegmentSha(videoUUID, segmentPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const segmentName = path_1.basename(segmentPath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const segmentName = (0, path_1.basename)(segmentPath); logger_1.logger.debug('Adding live sha segment %s.', segmentPath, lTags(videoUUID)); - const shaResult = yield hls_1.buildSha256Segment(segmentPath); + const shaResult = yield (0, hls_1.buildSha256Segment)(segmentPath); if (!this.segmentsSha256.has(videoUUID)) { this.segmentsSha256.set(videoUUID, new Map()); } @@ -26,7 +26,7 @@ class LiveSegmentShaStore { }); } removeSegmentSha(videoUUID, segmentPath) { - const segmentName = path_1.basename(segmentPath); + const segmentName = (0, path_1.basename)(segmentPath); logger_1.logger.debug('Removing live sha segment %s.', segmentPath, lTags(videoUUID)); const filesMap = this.segmentsSha256.get(videoUUID); if (!filesMap) { diff --git a/dist/server/lib/live/live-utils.js b/dist/server/lib/live/live-utils.js index 85f8d2be..1782926c 100644 --- a/dist/server/lib/live/live-utils.js +++ b/dist/server/lib/live/live-utils.js @@ -6,14 +6,14 @@ const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const paths_1 = require("../paths"); function buildConcatenatedName(segmentOrPlaylistPath) { - const num = path_1.basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/); + const num = (0, path_1.basename)(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/); return 'concat-' + num[1] + '.ts'; } exports.buildConcatenatedName = buildConcatenatedName; function cleanupLive(video, streamingPlaylist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const hlsDirectory = paths_1.getLiveDirectory(video); - yield fs_extra_1.remove(hlsDirectory); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const hlsDirectory = (0, paths_1.getLiveDirectory)(video); + yield (0, fs_extra_1.remove)(hlsDirectory); yield streamingPlaylist.destroy(); }); } diff --git a/dist/server/lib/live/shared/index.js b/dist/server/lib/live/shared/index.js index f3f3e015..0079ec69 100644 --- a/dist/server/lib/live/shared/index.js +++ b/dist/server/lib/live/shared/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./muxing-session"), exports); +(0, tslib_1.__exportStar)(require("./muxing-session"), exports); diff --git a/dist/server/lib/live/shared/muxing-session.js b/dist/server/lib/live/shared/muxing-session.js index 9b620adb..74625e0d 100644 --- a/dist/server/lib/live/shared/muxing-session.js +++ b/dist/server/lib/live/shared/muxing-session.js @@ -24,7 +24,7 @@ class MuxingSession extends stream_1.EventEmitter { super(); this.segmentsToProcessPerPlaylist = {}; this.isAbleToUploadVideoWithCache = memoizee((userId) => { - return user_1.isAbleToUploadVideo(userId, 1000); + return (0, user_1.isAbleToUploadVideo)(userId, 1000); }, { maxAge: constants_1.MEMOIZE_TTL.LIVE_ABLE_TO_UPLOAD }); this.hasClientSocketInBadHealthWithCache = memoizee((sessionId) => { return this.hasClientSocketInBadHealth(sessionId); @@ -42,14 +42,14 @@ class MuxingSession extends stream_1.EventEmitter { this.videoId = this.videoLive.Video.id; this.videoUUID = this.videoLive.Video.uuid; this.saveReplay = this.videoLive.saveReplay; - this.lTags = logger_1.loggerTagsFactory('live', this.sessionId, this.videoUUID); + this.lTags = (0, logger_1.loggerTagsFactory)('live', this.sessionId, this.videoUUID); } runMuxing() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.createFiles(); const outPath = yield this.prepareDirectories(); this.ffmpegCommand = config_1.CONFIG.LIVE.TRANSCODING.ENABLED - ? yield ffmpeg_utils_1.getLiveTranscodingCommand({ + ? yield (0, ffmpeg_utils_1.getLiveTranscodingCommand)({ rtmpUrl: this.rtmpUrl, outPath, masterPlaylistName: this.streamingPlaylist.playlistFilename, @@ -60,7 +60,7 @@ class MuxingSession extends stream_1.EventEmitter { availableEncoders: video_transcoding_profiles_1.VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), profile: config_1.CONFIG.LIVE.TRANSCODING.PROFILE }) - : ffmpeg_utils_1.getLiveMuxingCommand(this.rtmpUrl, outPath, this.streamingPlaylist.playlistFilename); + : (0, ffmpeg_utils_1.getLiveMuxingCommand)(this.rtmpUrl, outPath, this.streamingPlaylist.playlistFilename); logger_1.logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags); yield this.watchTSFiles(outPath); this.watchMasterFile(outPath); @@ -105,7 +105,7 @@ class MuxingSession extends stream_1.EventEmitter { }, 1000); } watchMasterFile(outPath) { - this.masterWatcher = chokidar_1.watch(outPath + '/' + this.streamingPlaylist.playlistFilename); + this.masterWatcher = (0, chokidar_1.watch)(outPath + '/' + this.streamingPlaylist.playlistFilename); this.masterWatcher.on('add', () => { this.emit('master-playlist-created', { videoId: this.videoId }); this.masterWatcher.close() @@ -113,15 +113,15 @@ class MuxingSession extends stream_1.EventEmitter { }); } watchTSFiles(outPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startStreamDateTime = new Date().getTime(); - this.tsWatcher = chokidar_1.watch(outPath + '/*.ts'); + this.tsWatcher = (0, chokidar_1.watch)(outPath + '/*.ts'); const playlistIdMatcher = /^([\d+])-/; - const existingFiles = yield fs_extra_1.readdir(outPath); - yield Promise.all(existingFiles.map(fileName => fileName.includes('.ts') ? fs_extra_1.unlink(path_1.join(outPath, fileName)) : Promise.resolve())); - const addHandler = (segmentPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const existingFiles = yield (0, fs_extra_1.readdir)(outPath); + yield Promise.all(existingFiles.map(fileName => fileName.includes('.ts') ? (0, fs_extra_1.unlink)((0, path_1.join)(outPath, fileName)) : Promise.resolve())); + const addHandler = (segmentPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Live add handler of %s.', segmentPath, this.lTags); - const playlistId = path_1.basename(segmentPath).match(playlistIdMatcher)[0]; + const playlistId = (0, path_1.basename)(segmentPath).match(playlistIdMatcher)[0]; const segmentsToProcess = this.segmentsToProcessPerPlaylist[playlistId] || []; this.processSegments(outPath, segmentsToProcess); this.segmentsToProcessPerPlaylist[playlistId] = [segmentPath]; @@ -143,11 +143,11 @@ class MuxingSession extends stream_1.EventEmitter { }); } isQuotaExceeded(segmentPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.saveReplay !== true) return false; try { - const segmentStat = yield fs_extra_1.stat(segmentPath); + const segmentStat = yield (0, fs_extra_1.stat)(segmentPath); live_quota_store_1.LiveQuotaStore.Instance.addQuotaTo(this.user.id, this.videoLive.id, segmentStat.size); const canUpload = yield this.isAbleToUploadVideoWithCache(this.user.id); return canUpload !== true; @@ -158,7 +158,7 @@ class MuxingSession extends stream_1.EventEmitter { }); } createFiles() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (let i = 0; i < this.allResolutions.length; i++) { const resolution = this.allResolutions[i]; const existingFile = yield video_file_1.VideoFileModel.loadByPlaylistId(this.streamingPlaylist.id, resolution); @@ -178,12 +178,12 @@ class MuxingSession extends stream_1.EventEmitter { }); } prepareDirectories() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const outPath = paths_1.getLiveDirectory(this.videoLive.Video); - yield fs_extra_1.ensureDir(outPath); - const replayDirectory = path_1.join(outPath, constants_1.VIDEO_LIVE.REPLAY_DIRECTORY); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const outPath = (0, paths_1.getLiveDirectory)(this.videoLive.Video); + yield (0, fs_extra_1.ensureDir)(outPath); + const replayDirectory = (0, path_1.join)(outPath, constants_1.VIDEO_LIVE.REPLAY_DIRECTORY); if (this.videoLive.saveReplay === true) { - yield fs_extra_1.ensureDir(replayDirectory); + yield (0, fs_extra_1.ensureDir)(replayDirectory); } return outPath; }); @@ -197,7 +197,7 @@ class MuxingSession extends stream_1.EventEmitter { return now <= max; } processSegments(hlsVideoPath, segmentPaths) { - bluebird_1.mapSeries(segmentPaths, (previousSegment) => tslib_1.__awaiter(this, void 0, void 0, function* () { + (0, bluebird_1.mapSeries)(segmentPaths, (previousSegment) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield live_segment_sha_store_1.LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment); if (this.saveReplay) { yield this.addSegmentToReplay(hlsVideoPath, previousSegment); @@ -223,12 +223,12 @@ class MuxingSession extends stream_1.EventEmitter { return false; } addSegmentToReplay(hlsVideoPath, segmentPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const segmentName = path_1.basename(segmentPath); - const dest = path_1.join(hlsVideoPath, constants_1.VIDEO_LIVE.REPLAY_DIRECTORY, live_utils_1.buildConcatenatedName(segmentName)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const segmentName = (0, path_1.basename)(segmentPath); + const dest = (0, path_1.join)(hlsVideoPath, constants_1.VIDEO_LIVE.REPLAY_DIRECTORY, (0, live_utils_1.buildConcatenatedName)(segmentName)); try { - const data = yield fs_extra_1.readFile(segmentPath); - yield fs_extra_1.appendFile(dest, data); + const data = yield (0, fs_extra_1.readFile)(segmentPath); + yield (0, fs_extra_1.appendFile)(dest, data); } catch (err) { logger_1.logger.error('Cannot copy segment %s to replay directory.', segmentPath, Object.assign({ err }, this.lTags)); diff --git a/dist/server/lib/local-actor.js b/dist/server/lib/local-actor.js index 3f322f12..8d88c588 100644 --- a/dist/server/lib/local-actor.js +++ b/dist/server/lib/local-actor.js @@ -4,7 +4,7 @@ exports.buildActorInstance = exports.pushActorImageProcessInQueue = exports.dele const tslib_1 = require("tslib"); require("multer"); const async_1 = require("async"); -const lru_cache_1 = tslib_1.__importDefault(require("lru-cache")); +const lru_cache_1 = (0, tslib_1.__importDefault)(require("lru-cache")); const path_1 = require("path"); const core_utils_1 = require("@server/helpers/core-utils"); const uuid_1 = require("@server/helpers/uuid"); @@ -35,16 +35,16 @@ function buildActorInstance(type, url, preferredUsername) { } exports.buildActorInstance = buildActorInstance; function updateLocalActorImageFile(accountOrChannel, imagePhysicalFile, type) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const imageSize = type === 1 ? constants_1.ACTOR_IMAGES_SIZE.AVATARS : constants_1.ACTOR_IMAGES_SIZE.BANNERS; - const extension = core_utils_1.getLowercaseExtension(imagePhysicalFile.filename); - const imageName = uuid_1.buildUUID() + extension; - const destination = path_1.join(config_1.CONFIG.STORAGE.ACTOR_IMAGES, imageName); - yield image_utils_1.processImage(imagePhysicalFile.path, destination, imageSize); - return database_utils_1.retryTransactionWrapper(() => { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const extension = (0, core_utils_1.getLowercaseExtension)(imagePhysicalFile.filename); + const imageName = (0, uuid_1.buildUUID)() + extension; + const destination = (0, path_1.join)(config_1.CONFIG.STORAGE.ACTOR_IMAGES, imageName); + yield (0, image_utils_1.processImage)(imagePhysicalFile.path, destination, imageSize); + return (0, database_utils_1.retryTransactionWrapper)(() => { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actorImageInfo = { name: imageName, fileUrl: null, @@ -52,9 +52,9 @@ function updateLocalActorImageFile(accountOrChannel, imagePhysicalFile, type) { width: imageSize.width, onDisk: true }; - const updatedActor = yield actors_1.updateActorImageInstance(accountOrChannel.Actor, type, actorImageInfo, t); + const updatedActor = yield (0, actors_1.updateActorImageInstance)(accountOrChannel.Actor, type, actorImageInfo, t); yield updatedActor.save({ transaction: t }); - yield send_1.sendUpdateActor(accountOrChannel, t); + yield (0, send_1.sendUpdateActor)(accountOrChannel, t); return type === 1 ? updatedActor.Avatar : updatedActor.Banner; @@ -64,23 +64,23 @@ function updateLocalActorImageFile(accountOrChannel, imagePhysicalFile, type) { } exports.updateLocalActorImageFile = updateLocalActorImageFile; function deleteLocalActorImageFile(accountOrChannel, type) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - return database_utils_1.retryTransactionWrapper(() => { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const updatedActor = yield actors_1.deleteActorImageInstance(accountOrChannel.Actor, type, t); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return (0, database_utils_1.retryTransactionWrapper)(() => { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const updatedActor = yield (0, actors_1.deleteActorImageInstance)(accountOrChannel.Actor, type, t); yield updatedActor.save({ transaction: t }); - yield send_1.sendUpdateActor(accountOrChannel, t); + yield (0, send_1.sendUpdateActor)(accountOrChannel, t); return updatedActor.Avatar; })); }); }); } exports.deleteLocalActorImageFile = deleteLocalActorImageFile; -const downloadImageQueue = async_1.queue((task, cb) => { +const downloadImageQueue = (0, async_1.queue)((task, cb) => { const size = task.type === 1 ? constants_1.ACTOR_IMAGES_SIZE.AVATARS : constants_1.ACTOR_IMAGES_SIZE.BANNERS; - requests_1.downloadImage(task.fileUrl, config_1.CONFIG.STORAGE.ACTOR_IMAGES, task.filename, size) + (0, requests_1.downloadImage)(task.fileUrl, config_1.CONFIG.STORAGE.ACTOR_IMAGES, task.filename, size) .then(() => cb()) .catch(err => cb(err)); }, constants_1.QUEUE_CONCURRENCY.ACTOR_PROCESS_IMAGE); diff --git a/dist/server/lib/model-loaders/index.js b/dist/server/lib/model-loaders/index.js index 944f48f0..dc9017a9 100644 --- a/dist/server/lib/model-loaders/index.js +++ b/dist/server/lib/model-loaders/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./actor"), exports); -tslib_1.__exportStar(require("./video"), exports); +(0, tslib_1.__exportStar)(require("./actor"), exports); +(0, tslib_1.__exportStar)(require("./video"), exports); diff --git a/dist/server/lib/moderation.js b/dist/server/lib/moderation.js index 352e34ad..04423168 100644 --- a/dist/server/lib/moderation.js +++ b/dist/server/lib/moderation.js @@ -43,9 +43,9 @@ function isPostImportVideoAccepted(object) { } exports.isPostImportVideoAccepted = isPostImportVideoAccepted; function createVideoAbuse(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount } = options; - const associateFun = (abuseInstance) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const associateFun = (abuseInstance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoAbuseInstance = yield video_abuse_1.VideoAbuseModel.create({ abuseId: abuseInstance.id, videoId: videoInstance.id, @@ -68,7 +68,7 @@ function createVideoAbuse(options) { exports.createVideoAbuse = createVideoAbuse; function createVideoCommentAbuse(options) { const { baseAbuse, commentInstance, transaction, reporterAccount } = options; - const associateFun = (abuseInstance) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const associateFun = (abuseInstance) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const commentAbuseInstance = yield video_comment_abuse_1.VideoCommentAbuseModel.create({ abuseId: abuseInstance.id, videoCommentId: commentInstance.id @@ -101,20 +101,20 @@ function createAccountAbuse(options) { } exports.createAccountAbuse = createAccountAbuse; function createAbuse(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { base, reporterAccount, flaggedAccount, associateFun, transaction } = options; - const auditLogger = audit_logger_1.auditLoggerFactory('abuse'); + const auditLogger = (0, audit_logger_1.auditLoggerFactory)('abuse'); const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id }); const abuseInstance = yield abuse_1.AbuseModel.create(abuseAttributes, { transaction }); abuseInstance.ReporterAccount = reporterAccount; abuseInstance.FlaggedAccount = flaggedAccount; const { isOwned } = yield associateFun(abuseInstance); if (isOwned === false) { - send_flag_1.sendAbuse(reporterAccount.Actor, abuseInstance, abuseInstance.FlaggedAccount, transaction); + (0, send_flag_1.sendAbuse)(reporterAccount.Actor, abuseInstance, abuseInstance.FlaggedAccount, transaction); } const abuseJSON = abuseInstance.toFormattedAdminJSON(); auditLogger.create(reporterAccount.Actor.getIdentifier(), new audit_logger_1.AbuseAuditView(abuseJSON)); - database_utils_1.afterCommitIfTransaction(transaction, () => { + (0, database_utils_1.afterCommitIfTransaction)(transaction, () => { notifier_1.Notifier.Instance.notifyOnNewAbuse({ abuse: abuseJSON, abuseInstance, diff --git a/dist/server/lib/notifier/index.js b/dist/server/lib/notifier/index.js index 234912c1..32607fd5 100644 --- a/dist/server/lib/notifier/index.js +++ b/dist/server/lib/notifier/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./notifier"), exports); +(0, tslib_1.__exportStar)(require("./notifier"), exports); diff --git a/dist/server/lib/notifier/notifier.js b/dist/server/lib/notifier/notifier.js index e5fc1b21..edb33746 100644 --- a/dist/server/lib/notifier/notifier.js +++ b/dist/server/lib/notifier/notifier.js @@ -127,7 +127,7 @@ class Notifier { .catch(err => logger_1.logger.error('Cannot notify on new plugin version %s.', plugin.name, { err })); } notify(object) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield object.prepare(); const users = object.getTargetUsers(); if (users.length === 0) @@ -161,7 +161,7 @@ class Notifier { return value & 1; } sendNotifications(models, payload) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const model of models) { yield this.notify(new model(payload)); } diff --git a/dist/server/lib/notifier/shared/abuse/abstract-new-abuse-message.js b/dist/server/lib/notifier/shared/abuse/abstract-new-abuse-message.js index d0d57bf8..36f97b00 100644 --- a/dist/server/lib/notifier/shared/abuse/abstract-new-abuse-message.js +++ b/dist/server/lib/notifier/shared/abuse/abstract-new-abuse-message.js @@ -8,7 +8,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class AbstractNewAbuseMessage extends abstract_notification_1.AbstractNotification { loadMessageAccount() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.messageAccount = yield account_1.AccountModel.load(this.message.accountId); }); } @@ -16,7 +16,7 @@ class AbstractNewAbuseMessage extends abstract_notification_1.AbstractNotificati return user.NotificationSetting.abuseNewMessage; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 16, userId: user.id, diff --git a/dist/server/lib/notifier/shared/abuse/abuse-state-change-for-reporter.js b/dist/server/lib/notifier/shared/abuse/abuse-state-change-for-reporter.js index 6e599f0d..578c6bcf 100644 --- a/dist/server/lib/notifier/shared/abuse/abuse-state-change-for-reporter.js +++ b/dist/server/lib/notifier/shared/abuse/abuse-state-change-for-reporter.js @@ -10,7 +10,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class AbuseStateChangeForReporter extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const reporter = this.abuse.ReporterAccount; if (reporter.isOwned() !== true) return; @@ -18,7 +18,7 @@ class AbuseStateChangeForReporter extends abstract_notification_1.AbstractNotifi }); } log() { - logger_1.logger.info('Notifying reporter of abuse % of state change.', url_1.getAbuseTargetUrl(this.abuse)); + logger_1.logger.info('Notifying reporter of abuse % of state change.', (0, url_1.getAbuseTargetUrl)(this.abuse)); } getSetting(user) { return user.NotificationSetting.abuseStateChange; @@ -29,7 +29,7 @@ class AbuseStateChangeForReporter extends abstract_notification_1.AbstractNotifi return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 15, userId: user.id, diff --git a/dist/server/lib/notifier/shared/abuse/index.js b/dist/server/lib/notifier/shared/abuse/index.js index 88037966..08c3279a 100644 --- a/dist/server/lib/notifier/shared/abuse/index.js +++ b/dist/server/lib/notifier/shared/abuse/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse-state-change-for-reporter"), exports); -tslib_1.__exportStar(require("./new-abuse-for-moderators"), exports); -tslib_1.__exportStar(require("./new-abuse-message-for-reporter"), exports); -tslib_1.__exportStar(require("./new-abuse-message-for-moderators"), exports); +(0, tslib_1.__exportStar)(require("./abuse-state-change-for-reporter"), exports); +(0, tslib_1.__exportStar)(require("./new-abuse-for-moderators"), exports); +(0, tslib_1.__exportStar)(require("./new-abuse-message-for-reporter"), exports); +(0, tslib_1.__exportStar)(require("./new-abuse-message-for-moderators"), exports); diff --git a/dist/server/lib/notifier/shared/abuse/new-abuse-for-moderators.js b/dist/server/lib/notifier/shared/abuse/new-abuse-for-moderators.js index 0b7687b3..6205fa36 100644 --- a/dist/server/lib/notifier/shared/abuse/new-abuse-for-moderators.js +++ b/dist/server/lib/notifier/shared/abuse/new-abuse-for-moderators.js @@ -10,12 +10,12 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewAbuseForModerators extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.moderators = yield user_1.UserModel.listWithRight(6); }); } log() { - logger_1.logger.info('Notifying %s user/moderators of new abuse %s.', this.moderators.length, url_1.getAbuseTargetUrl(this.payload.abuseInstance)); + logger_1.logger.info('Notifying %s user/moderators of new abuse %s.', this.moderators.length, (0, url_1.getAbuseTargetUrl)(this.payload.abuseInstance)); } getSetting(user) { return user.NotificationSetting.abuseAsModerator; @@ -24,7 +24,7 @@ class NewAbuseForModerators extends abstract_notification_1.AbstractNotification return this.moderators; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 3, userId: user.id, diff --git a/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.js b/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.js index 07335059..2407faf5 100644 --- a/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.js +++ b/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.js @@ -8,7 +8,7 @@ const user_1 = require("@server/models/user/user"); const abstract_new_abuse_message_1 = require("./abstract-new-abuse-message"); class NewAbuseMessageForModerators extends abstract_new_abuse_message_1.AbstractNewAbuseMessage { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.moderators = yield user_1.UserModel.listWithRight(6); this.moderators = this.moderators.filter(m => m.Account.id !== this.message.accountId); if (this.moderators.length === 0) @@ -17,7 +17,7 @@ class NewAbuseMessageForModerators extends abstract_new_abuse_message_1.Abstract }); } log() { - logger_1.logger.info('Notifying moderators of new abuse message on %s.', url_1.getAbuseTargetUrl(this.abuse)); + logger_1.logger.info('Notifying moderators of new abuse message on %s.', (0, url_1.getAbuseTargetUrl)(this.abuse)); } getTargetUsers() { return this.moderators; diff --git a/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.js b/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.js index 80112139..86f61d9b 100644 --- a/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.js +++ b/dist/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.js @@ -8,7 +8,7 @@ const user_1 = require("@server/models/user/user"); const abstract_new_abuse_message_1 = require("./abstract-new-abuse-message"); class NewAbuseMessageForReporter extends abstract_new_abuse_message_1.AbstractNewAbuseMessage { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.abuse.ReporterAccount.isOwned() !== true) return; yield this.loadMessageAccount(); @@ -19,7 +19,7 @@ class NewAbuseMessageForReporter extends abstract_new_abuse_message_1.AbstractNe }); } log() { - logger_1.logger.info('Notifying reporter of new abuse message on %s.', url_1.getAbuseTargetUrl(this.abuse)); + logger_1.logger.info('Notifying reporter of new abuse message on %s.', (0, url_1.getAbuseTargetUrl)(this.abuse)); } getTargetUsers() { if (!this.reporter) diff --git a/dist/server/lib/notifier/shared/blacklist/index.js b/dist/server/lib/notifier/shared/blacklist/index.js index 7029f761..d4d1fee0 100644 --- a/dist/server/lib/notifier/shared/blacklist/index.js +++ b/dist/server/lib/notifier/shared/blacklist/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./new-auto-blacklist-for-moderators"), exports); -tslib_1.__exportStar(require("./new-blacklist-for-owner"), exports); -tslib_1.__exportStar(require("./unblacklist-for-owner"), exports); +(0, tslib_1.__exportStar)(require("./new-auto-blacklist-for-moderators"), exports); +(0, tslib_1.__exportStar)(require("./new-blacklist-for-owner"), exports); +(0, tslib_1.__exportStar)(require("./unblacklist-for-owner"), exports); diff --git a/dist/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.js b/dist/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.js index f47aeebf..065ed3e3 100644 --- a/dist/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.js +++ b/dist/server/lib/notifier/shared/blacklist/new-auto-blacklist-for-moderators.js @@ -10,7 +10,7 @@ const video_channel_1 = require("@server/models/video/video-channel"); const abstract_notification_1 = require("../common/abstract-notification"); class NewAutoBlacklistForModerators extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.moderators = yield user_1.UserModel.listWithRight(12); }); } @@ -24,7 +24,7 @@ class NewAutoBlacklistForModerators extends abstract_notification_1.AbstractNoti return this.moderators; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 12, userId: user.id, @@ -35,7 +35,7 @@ class NewAutoBlacklistForModerators extends abstract_notification_1.AbstractNoti }); } createEmail(to) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoAutoBlacklistUrl = constants_1.WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list'; const videoUrl = constants_1.WEBSERVER.URL + this.payload.Video.getWatchStaticPath(); const channel = yield video_channel_1.VideoChannelModel.loadAndPopulateAccount(this.payload.Video.channelId); diff --git a/dist/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.js b/dist/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.js index 5cb73b43..82d54006 100644 --- a/dist/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.js +++ b/dist/server/lib/notifier/shared/blacklist/new-blacklist-for-owner.js @@ -10,7 +10,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewBlacklistForOwner extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.user = yield user_1.UserModel.loadByVideoId(this.payload.videoId); }); } @@ -26,7 +26,7 @@ class NewBlacklistForOwner extends abstract_notification_1.AbstractNotification return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 4, userId: user.id, diff --git a/dist/server/lib/notifier/shared/blacklist/unblacklist-for-owner.js b/dist/server/lib/notifier/shared/blacklist/unblacklist-for-owner.js index 47bb9191..67474c5e 100644 --- a/dist/server/lib/notifier/shared/blacklist/unblacklist-for-owner.js +++ b/dist/server/lib/notifier/shared/blacklist/unblacklist-for-owner.js @@ -10,7 +10,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class UnblacklistForOwner extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.user = yield user_1.UserModel.loadByVideoId(this.payload.id); }); } @@ -26,7 +26,7 @@ class UnblacklistForOwner extends abstract_notification_1.AbstractNotification { return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 5, userId: user.id, diff --git a/dist/server/lib/notifier/shared/comment/comment-mention.js b/dist/server/lib/notifier/shared/comment/comment-mention.js index 9828d0a3..a2a9bd5a 100644 --- a/dist/server/lib/notifier/shared/comment/comment-mention.js +++ b/dist/server/lib/notifier/shared/comment/comment-mention.js @@ -13,7 +13,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const common_1 = require("../common"); class CommentMention extends common_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const extractedUsernames = this.payload.extractMentions(); logger_1.logger.debug('Extracted %d username from comment %s.', extractedUsernames.length, this.payload.url, { usernames: extractedUsernames, text: this.payload.text }); this.users = yield user_1.UserModel.listByUsernames(extractedUsernames); @@ -24,7 +24,7 @@ class CommentMention extends common_1.AbstractNotification { this.users = this.users.filter(u => u.Account.id !== this.payload.accountId); if (this.users.length === 0) return; - this.serverAccountId = (yield application_1.getServerActor()).Account.id; + this.serverAccountId = (yield (0, application_1.getServerActor)()).Account.id; const sourceAccounts = this.users.map(u => u.Account.id).concat([this.serverAccountId]); this.accountMutedHash = yield account_blocklist_1.AccountBlocklistModel.isAccountMutedByMulti(sourceAccounts, this.payload.accountId); this.instanceMutedHash = yield server_blocklist_1.ServerBlocklistModel.isServerMutedByMulti(sourceAccounts, this.payload.Account.Actor.serverId); @@ -45,7 +45,7 @@ class CommentMention extends common_1.AbstractNotification { return this.users; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 11, userId: user.id, @@ -61,7 +61,7 @@ class CommentMention extends common_1.AbstractNotification { const video = comment.Video; const videoUrl = constants_1.WEBSERVER.URL + comment.Video.getWatchStaticPath(); const commentUrl = constants_1.WEBSERVER.URL + comment.getCommentStaticPath(); - const commentHtml = markdown_1.toSafeHtml(comment.text); + const commentHtml = (0, markdown_1.toSafeHtml)(comment.text); return { template: 'video-comment-mention', to, diff --git a/dist/server/lib/notifier/shared/comment/index.js b/dist/server/lib/notifier/shared/comment/index.js index 7911cc8c..becf9ee8 100644 --- a/dist/server/lib/notifier/shared/comment/index.js +++ b/dist/server/lib/notifier/shared/comment/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./comment-mention"), exports); -tslib_1.__exportStar(require("./new-comment-for-video-owner"), exports); +(0, tslib_1.__exportStar)(require("./comment-mention"), exports); +(0, tslib_1.__exportStar)(require("./new-comment-for-video-owner"), exports); diff --git a/dist/server/lib/notifier/shared/comment/new-comment-for-video-owner.js b/dist/server/lib/notifier/shared/comment/new-comment-for-video-owner.js index 0a0adfd6..2be1d4e7 100644 --- a/dist/server/lib/notifier/shared/comment/new-comment-for-video-owner.js +++ b/dist/server/lib/notifier/shared/comment/new-comment-for-video-owner.js @@ -11,7 +11,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewCommentForVideoOwner extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.user = yield user_1.UserModel.loadByVideoId(this.payload.videoId); }); } @@ -23,7 +23,7 @@ class NewCommentForVideoOwner extends abstract_notification_1.AbstractNotificati return true; if (!this.user || this.payload.Account.userId === this.user.id) return true; - return blocklist_1.isBlockedByServerOrAccount(this.payload.Account, this.user.Account); + return (0, blocklist_1.isBlockedByServerOrAccount)(this.payload.Account, this.user.Account); } getSetting(user) { return user.NotificationSetting.newCommentOnMyVideo; @@ -34,7 +34,7 @@ class NewCommentForVideoOwner extends abstract_notification_1.AbstractNotificati return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 2, userId: user.id, @@ -48,7 +48,7 @@ class NewCommentForVideoOwner extends abstract_notification_1.AbstractNotificati const video = this.payload.Video; const videoUrl = constants_1.WEBSERVER.URL + this.payload.Video.getWatchStaticPath(); const commentUrl = constants_1.WEBSERVER.URL + this.payload.getCommentStaticPath(); - const commentHtml = markdown_1.toSafeHtml(this.payload.text); + const commentHtml = (0, markdown_1.toSafeHtml)(this.payload.text); return { template: 'video-comment-new', to, diff --git a/dist/server/lib/notifier/shared/common/index.js b/dist/server/lib/notifier/shared/common/index.js index f1af4252..c8630fd9 100644 --- a/dist/server/lib/notifier/shared/common/index.js +++ b/dist/server/lib/notifier/shared/common/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abstract-notification"), exports); +(0, tslib_1.__exportStar)(require("./abstract-notification"), exports); diff --git a/dist/server/lib/notifier/shared/follow/auto-follow-for-instance.js b/dist/server/lib/notifier/shared/follow/auto-follow-for-instance.js index 78527985..80775ace 100644 --- a/dist/server/lib/notifier/shared/follow/auto-follow-for-instance.js +++ b/dist/server/lib/notifier/shared/follow/auto-follow-for-instance.js @@ -8,7 +8,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class AutoFollowForInstance extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.admins = yield user_1.UserModel.listWithRight(2); }); } @@ -22,7 +22,7 @@ class AutoFollowForInstance extends abstract_notification_1.AbstractNotification return this.admins; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 14, userId: user.id, diff --git a/dist/server/lib/notifier/shared/follow/follow-for-instance.js b/dist/server/lib/notifier/shared/follow/follow-for-instance.js index bd04a422..1d03498e 100644 --- a/dist/server/lib/notifier/shared/follow/follow-for-instance.js +++ b/dist/server/lib/notifier/shared/follow/follow-for-instance.js @@ -10,13 +10,13 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class FollowForInstance extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.admins = yield user_1.UserModel.listWithRight(2); }); } isDisabled() { const follower = Object.assign(this.actorFollow.ActorFollower.Account, { Actor: this.actorFollow.ActorFollower }); - return blocklist_1.isBlockedByServerOrAccount(follower); + return (0, blocklist_1.isBlockedByServerOrAccount)(follower); } log() { logger_1.logger.info('Notifying %d administrators of new instance follower: %s.', this.admins.length, this.actorFollow.ActorFollower.url); @@ -28,7 +28,7 @@ class FollowForInstance extends abstract_notification_1.AbstractNotification { return this.admins; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 13, userId: user.id, diff --git a/dist/server/lib/notifier/shared/follow/follow-for-user.js b/dist/server/lib/notifier/shared/follow/follow-for-user.js index 5cc28def..2ccea77d 100644 --- a/dist/server/lib/notifier/shared/follow/follow-for-user.js +++ b/dist/server/lib/notifier/shared/follow/follow-for-user.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class FollowForUser extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.followType = 'channel'; this.user = yield user_1.UserModel.loadByChannelActorId(this.actorFollow.ActorFollowing.id); if (!this.user) { @@ -19,12 +19,12 @@ class FollowForUser extends abstract_notification_1.AbstractNotification { }); } isDisabled() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.payload.ActorFollowing.isOwned() === false) return true; const followerAccount = this.actorFollow.ActorFollower.Account; const followerAccountWithActor = Object.assign(followerAccount, { Actor: this.actorFollow.ActorFollower }); - return blocklist_1.isBlockedByServerOrAccount(followerAccountWithActor, this.user.Account); + return (0, blocklist_1.isBlockedByServerOrAccount)(followerAccountWithActor, this.user.Account); }); } log() { @@ -39,7 +39,7 @@ class FollowForUser extends abstract_notification_1.AbstractNotification { return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 10, userId: user.id, diff --git a/dist/server/lib/notifier/shared/follow/index.js b/dist/server/lib/notifier/shared/follow/index.js index a44e8223..5fff97dd 100644 --- a/dist/server/lib/notifier/shared/follow/index.js +++ b/dist/server/lib/notifier/shared/follow/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./auto-follow-for-instance"), exports); -tslib_1.__exportStar(require("./follow-for-instance"), exports); -tslib_1.__exportStar(require("./follow-for-user"), exports); +(0, tslib_1.__exportStar)(require("./auto-follow-for-instance"), exports); +(0, tslib_1.__exportStar)(require("./follow-for-instance"), exports); +(0, tslib_1.__exportStar)(require("./follow-for-user"), exports); diff --git a/dist/server/lib/notifier/shared/index.js b/dist/server/lib/notifier/shared/index.js index c0a7cc29..ee817317 100644 --- a/dist/server/lib/notifier/shared/index.js +++ b/dist/server/lib/notifier/shared/index.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./blacklist"), exports); -tslib_1.__exportStar(require("./comment"), exports); -tslib_1.__exportStar(require("./common"), exports); -tslib_1.__exportStar(require("./follow"), exports); -tslib_1.__exportStar(require("./instance"), exports); -tslib_1.__exportStar(require("./video-publication"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./blacklist"), exports); +(0, tslib_1.__exportStar)(require("./comment"), exports); +(0, tslib_1.__exportStar)(require("./common"), exports); +(0, tslib_1.__exportStar)(require("./follow"), exports); +(0, tslib_1.__exportStar)(require("./instance"), exports); +(0, tslib_1.__exportStar)(require("./video-publication"), exports); diff --git a/dist/server/lib/notifier/shared/instance/index.js b/dist/server/lib/notifier/shared/instance/index.js index 6ca46a4f..74e0bc85 100644 --- a/dist/server/lib/notifier/shared/instance/index.js +++ b/dist/server/lib/notifier/shared/instance/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./new-peertube-version-for-admins"), exports); -tslib_1.__exportStar(require("./new-plugin-version-for-admins"), exports); -tslib_1.__exportStar(require("./registration-for-moderators"), exports); +(0, tslib_1.__exportStar)(require("./new-peertube-version-for-admins"), exports); +(0, tslib_1.__exportStar)(require("./new-plugin-version-for-admins"), exports); +(0, tslib_1.__exportStar)(require("./registration-for-moderators"), exports); diff --git a/dist/server/lib/notifier/shared/instance/new-peertube-version-for-admins.js b/dist/server/lib/notifier/shared/instance/new-peertube-version-for-admins.js index 242e344a..7ae78d4e 100644 --- a/dist/server/lib/notifier/shared/instance/new-peertube-version-for-admins.js +++ b/dist/server/lib/notifier/shared/instance/new-peertube-version-for-admins.js @@ -8,7 +8,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewPeerTubeVersionForAdmins extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.admins = yield user_1.UserModel.listWithRight(4); }); } @@ -22,7 +22,7 @@ class NewPeerTubeVersionForAdmins extends abstract_notification_1.AbstractNotifi return this.admins; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 18, userId: user.id, diff --git a/dist/server/lib/notifier/shared/instance/new-plugin-version-for-admins.js b/dist/server/lib/notifier/shared/instance/new-plugin-version-for-admins.js index eeb506a8..a770740a 100644 --- a/dist/server/lib/notifier/shared/instance/new-plugin-version-for-admins.js +++ b/dist/server/lib/notifier/shared/instance/new-plugin-version-for-admins.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewPluginVersionForAdmins extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.admins = yield user_1.UserModel.listWithRight(4); }); } @@ -23,7 +23,7 @@ class NewPluginVersionForAdmins extends abstract_notification_1.AbstractNotifica return this.admins; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 17, userId: user.id, diff --git a/dist/server/lib/notifier/shared/instance/registration-for-moderators.js b/dist/server/lib/notifier/shared/instance/registration-for-moderators.js index e6c396c5..a6edd86f 100644 --- a/dist/server/lib/notifier/shared/instance/registration-for-moderators.js +++ b/dist/server/lib/notifier/shared/instance/registration-for-moderators.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class RegistrationForModerators extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.moderators = yield user_1.UserModel.listWithRight(1); }); } @@ -23,7 +23,7 @@ class RegistrationForModerators extends abstract_notification_1.AbstractNotifica return this.moderators; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 9, userId: user.id, diff --git a/dist/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.js b/dist/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.js index 8296c6f3..79957811 100644 --- a/dist/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.js +++ b/dist/server/lib/notifier/shared/video-publication/abstract-owned-video-publication.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class AbstractOwnedVideoPublication extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.user = yield user_1.UserModel.loadByVideoId(this.payload.id); }); } @@ -25,7 +25,7 @@ class AbstractOwnedVideoPublication extends abstract_notification_1.AbstractNoti return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 6, userId: user.id, diff --git a/dist/server/lib/notifier/shared/video-publication/import-finished-for-owner.js b/dist/server/lib/notifier/shared/video-publication/import-finished-for-owner.js index 54c3f86d..727d4042 100644 --- a/dist/server/lib/notifier/shared/video-publication/import-finished-for-owner.js +++ b/dist/server/lib/notifier/shared/video-publication/import-finished-for-owner.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class ImportFinishedForOwner extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.user = yield user_1.UserModel.loadByVideoImportId(this.videoImport.id); }); } @@ -25,7 +25,7 @@ class ImportFinishedForOwner extends abstract_notification_1.AbstractNotificatio return [this.user]; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: this.payload.success ? 7 diff --git a/dist/server/lib/notifier/shared/video-publication/index.js b/dist/server/lib/notifier/shared/video-publication/index.js index b031a80f..e41fe5cc 100644 --- a/dist/server/lib/notifier/shared/video-publication/index.js +++ b/dist/server/lib/notifier/shared/video-publication/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./new-video-for-subscribers"), exports); -tslib_1.__exportStar(require("./import-finished-for-owner"), exports); -tslib_1.__exportStar(require("./owned-publication-after-auto-unblacklist"), exports); -tslib_1.__exportStar(require("./owned-publication-after-schedule-update"), exports); -tslib_1.__exportStar(require("./owned-publication-after-transcoding"), exports); +(0, tslib_1.__exportStar)(require("./new-video-for-subscribers"), exports); +(0, tslib_1.__exportStar)(require("./import-finished-for-owner"), exports); +(0, tslib_1.__exportStar)(require("./owned-publication-after-auto-unblacklist"), exports); +(0, tslib_1.__exportStar)(require("./owned-publication-after-schedule-update"), exports); +(0, tslib_1.__exportStar)(require("./owned-publication-after-transcoding"), exports); diff --git a/dist/server/lib/notifier/shared/video-publication/new-video-for-subscribers.js b/dist/server/lib/notifier/shared/video-publication/new-video-for-subscribers.js index baaedcea..c61e07bf 100644 --- a/dist/server/lib/notifier/shared/video-publication/new-video-for-subscribers.js +++ b/dist/server/lib/notifier/shared/video-publication/new-video-for-subscribers.js @@ -9,7 +9,7 @@ const user_notification_1 = require("@server/models/user/user-notification"); const abstract_notification_1 = require("../common/abstract-notification"); class NewVideoForSubscribers extends abstract_notification_1.AbstractNotification { prepare() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.users = yield user_1.UserModel.listUserSubscribersOf(this.payload.VideoChannel.actorId); }); } @@ -26,7 +26,7 @@ class NewVideoForSubscribers extends abstract_notification_1.AbstractNotificatio return this.users; } createNotification(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notification = yield user_notification_1.UserNotificationModel.create({ type: 1, userId: user.id, diff --git a/dist/server/lib/object-storage/index.js b/dist/server/lib/object-storage/index.js index 47e2af0d..cf786856 100644 --- a/dist/server/lib/object-storage/index.js +++ b/dist/server/lib/object-storage/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./keys"), exports); -tslib_1.__exportStar(require("./urls"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./keys"), exports); +(0, tslib_1.__exportStar)(require("./urls"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/server/lib/object-storage/keys.js b/dist/server/lib/object-storage/keys.js index 9cab44e1..f27abd39 100644 --- a/dist/server/lib/object-storage/keys.js +++ b/dist/server/lib/object-storage/keys.js @@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.generateWebTorrentObjectStorageKey = exports.generateHLSObjectBaseStorageKey = exports.generateHLSObjectStorageKey = void 0; const path_1 = require("path"); function generateHLSObjectStorageKey(playlist, video, filename) { - return path_1.join(generateHLSObjectBaseStorageKey(playlist, video), filename); + return (0, path_1.join)(generateHLSObjectBaseStorageKey(playlist, video), filename); } exports.generateHLSObjectStorageKey = generateHLSObjectStorageKey; function generateHLSObjectBaseStorageKey(playlist, video) { - return path_1.join(playlist.getStringType(), video.uuid); + return (0, path_1.join)(playlist.getStringType(), video.uuid); } exports.generateHLSObjectBaseStorageKey = generateHLSObjectBaseStorageKey; function generateWebTorrentObjectStorageKey(filename) { diff --git a/dist/server/lib/object-storage/shared/client.js b/dist/server/lib/object-storage/shared/client.js index e7a4c674..f86aa9c1 100644 --- a/dist/server/lib/object-storage/shared/client.js +++ b/dist/server/lib/object-storage/shared/client.js @@ -38,7 +38,7 @@ function getClient() { step: 'build', priority: 'high' }); - logger_1.logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, logger_2.lTags()); + logger_1.logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, (0, logger_2.lTags)()); return s3Client; } exports.getClient = getClient; diff --git a/dist/server/lib/object-storage/shared/index.js b/dist/server/lib/object-storage/shared/index.js index a0c07eb8..93014c85 100644 --- a/dist/server/lib/object-storage/shared/index.js +++ b/dist/server/lib/object-storage/shared/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./client"), exports); -tslib_1.__exportStar(require("./logger"), exports); -tslib_1.__exportStar(require("./object-storage-helpers"), exports); +(0, tslib_1.__exportStar)(require("./client"), exports); +(0, tslib_1.__exportStar)(require("./logger"), exports); +(0, tslib_1.__exportStar)(require("./object-storage-helpers"), exports); diff --git a/dist/server/lib/object-storage/shared/logger.js b/dist/server/lib/object-storage/shared/logger.js index 23256c0d..441954eb 100644 --- a/dist/server/lib/object-storage/shared/logger.js +++ b/dist/server/lib/object-storage/shared/logger.js @@ -2,5 +2,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.lTags = void 0; const logger_1 = require("@server/helpers/logger"); -const lTags = logger_1.loggerTagsFactory('object-storage'); +const lTags = (0, logger_1.loggerTagsFactory)('object-storage'); exports.lTags = lTags; diff --git a/dist/server/lib/object-storage/shared/object-storage-helpers.js b/dist/server/lib/object-storage/shared/object-storage-helpers.js index 36e12937..a7a5b643 100644 --- a/dist/server/lib/object-storage/shared/object-storage-helpers.js +++ b/dist/server/lib/object-storage/shared/object-storage-helpers.js @@ -14,40 +14,40 @@ const urls_1 = require("../urls"); const client_1 = require("./client"); const logger_2 = require("./logger"); function storeObject(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { inputPath, objectStorageKey, bucketInfo } = options; - logger_1.logger.debug('Uploading file %s to %s%s in bucket %s', inputPath, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, logger_2.lTags()); - const stats = yield fs_extra_1.stat(inputPath); + logger_1.logger.debug('Uploading file %s to %s%s in bucket %s', inputPath, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, (0, logger_2.lTags)()); + const stats = yield (0, fs_extra_1.stat)(inputPath); if (stats.size > config_1.CONFIG.OBJECT_STORAGE.MAX_UPLOAD_PART) { return multiPartUpload({ inputPath, objectStorageKey, bucketInfo }); } - const fileStream = fs_extra_1.createReadStream(inputPath); + const fileStream = (0, fs_extra_1.createReadStream)(inputPath); return objectStoragePut({ objectStorageKey, content: fileStream, bucketInfo }); }); } exports.storeObject = storeObject; function removeObject(filename, bucketInfo) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = new client_s3_1.DeleteObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: buildKey(filename, bucketInfo) }); - return client_1.getClient().send(command); + return (0, client_1.getClient)().send(command); }); } exports.removeObject = removeObject; function removePrefix(prefix, bucketInfo) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const s3Client = client_1.getClient(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const s3Client = (0, client_1.getClient)(); const commandPrefix = bucketInfo.PREFIX + prefix; const listCommand = new client_s3_1.ListObjectsV2Command({ Bucket: bucketInfo.BUCKET_NAME, Prefix: commandPrefix }); const listedObjects = yield s3Client.send(listCommand); - if (misc_1.isArray(listedObjects.Contents) !== true) { + if ((0, misc_1.isArray)(listedObjects.Contents) !== true) { const message = `Cannot remove ${commandPrefix} prefix in bucket ${bucketInfo.BUCKET_NAME}: no files listed.`; - logger_1.logger.error(message, Object.assign({ response: listedObjects }, logger_2.lTags())); + logger_1.logger.error(message, Object.assign({ response: listedObjects }, (0, logger_2.lTags)())); throw new Error(message); } for (const object of listedObjects.Contents) { @@ -63,16 +63,16 @@ function removePrefix(prefix, bucketInfo) { } exports.removePrefix = removePrefix; function makeAvailable(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { key, destination, bucketInfo } = options; - yield fs_extra_1.ensureDir(path_1.dirname(options.destination)); + yield (0, fs_extra_1.ensureDir)((0, path_1.dirname)(options.destination)); const command = new client_s3_1.GetObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: buildKey(key, bucketInfo) }); - const response = yield client_1.getClient().send(command); - const file = fs_extra_1.createWriteStream(destination); - yield core_utils_1.pipelinePromise(response.Body, file); + const response = yield (0, client_1.getClient)().send(command); + const file = (0, fs_extra_1.createWriteStream)(destination); + yield (0, core_utils_1.pipelinePromise)(response.Body, file); file.close(); }); } @@ -82,7 +82,7 @@ function buildKey(key, bucketInfo) { } exports.buildKey = buildKey; function objectStoragePut(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { objectStorageKey, content, bucketInfo } = options; const command = new client_s3_1.PutObjectCommand({ Bucket: bucketInfo.BUCKET_NAME, @@ -90,30 +90,30 @@ function objectStoragePut(options) { Body: content, ACL: 'public-read' }); - yield client_1.getClient().send(command); - return urls_1.getPrivateUrl(bucketInfo, objectStorageKey); + yield (0, client_1.getClient)().send(command); + return (0, urls_1.getPrivateUrl)(bucketInfo, objectStorageKey); }); } function multiPartUpload(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { objectStorageKey, inputPath, bucketInfo } = options; const key = buildKey(objectStorageKey, bucketInfo); - const s3Client = client_1.getClient(); - const statResult = yield fs_extra_1.stat(inputPath); + const s3Client = (0, client_1.getClient)(); + const statResult = yield (0, fs_extra_1.stat)(inputPath); const createMultipartCommand = new client_s3_1.CreateMultipartUploadCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: key, ACL: 'public-read' }); const createResponse = yield s3Client.send(createMultipartCommand); - const fd = yield fs_extra_1.open(inputPath, 'r'); + const fd = yield (0, fs_extra_1.open)(inputPath, 'r'); let partNumber = 1; const parts = []; const partSize = config_1.CONFIG.OBJECT_STORAGE.MAX_UPLOAD_PART; for (let start = 0; start < statResult.size; start += partSize) { - logger_1.logger.debug('Uploading part %d of file to %s%s in bucket %s', partNumber, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, logger_2.lTags()); - const stream = fs_extra_1.createReadStream(inputPath, { fd, autoClose: false, start, end: (start + partSize) - 1 }); - stream.byteLength = lodash_1.min([statResult.size - start, partSize]); + logger_1.logger.debug('Uploading part %d of file to %s%s in bucket %s', partNumber, bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, (0, logger_2.lTags)()); + const stream = (0, fs_extra_1.createReadStream)(inputPath, { fd, autoClose: false, start, end: (start + partSize) - 1 }); + stream.byteLength = (0, lodash_1.min)([statResult.size - start, partSize]); const uploadPartCommand = new client_s3_1.UploadPartCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: key, @@ -125,7 +125,7 @@ function multiPartUpload(options) { parts.push({ ETag: uploadResponse.ETag, PartNumber: partNumber }); partNumber += 1; } - yield fs_extra_1.close(fd); + yield (0, fs_extra_1.close)(fd); const completeUploadCommand = new client_s3_1.CompleteMultipartUploadCommand({ Bucket: bucketInfo.BUCKET_NAME, Key: key, @@ -133,7 +133,7 @@ function multiPartUpload(options) { MultipartUpload: { Parts: parts } }); yield s3Client.send(completeUploadCommand); - logger_1.logger.debug('Completed %s%s in bucket %s in %d parts', bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, partNumber - 1, logger_2.lTags()); - return urls_1.getPrivateUrl(bucketInfo, objectStorageKey); + logger_1.logger.debug('Completed %s%s in bucket %s in %d parts', bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, partNumber - 1, (0, logger_2.lTags)()); + return (0, urls_1.getPrivateUrl)(bucketInfo, objectStorageKey); }); } diff --git a/dist/server/lib/object-storage/urls.js b/dist/server/lib/object-storage/urls.js index b6d66ad0..551bb57b 100644 --- a/dist/server/lib/object-storage/urls.js +++ b/dist/server/lib/object-storage/urls.js @@ -4,7 +4,7 @@ exports.getHLSPublicFileUrl = exports.replaceByBaseUrl = exports.getWebTorrentPu const config_1 = require("@server/initializers/config"); const shared_1 = require("./shared"); function getPrivateUrl(config, keyWithoutPrefix) { - return getBaseUrl(config) + shared_1.buildKey(keyWithoutPrefix, config); + return getBaseUrl(config) + (0, shared_1.buildKey)(keyWithoutPrefix, config); } exports.getPrivateUrl = getPrivateUrl; function getWebTorrentPublicFileUrl(fileUrl) { @@ -24,7 +24,7 @@ exports.getHLSPublicFileUrl = getHLSPublicFileUrl; function getBaseUrl(bucketInfo, baseUrl) { if (baseUrl) return baseUrl; - return `${shared_1.getEndpointParsed().protocol}//${bucketInfo.BUCKET_NAME}.${shared_1.getEndpointParsed().host}/`; + return `${(0, shared_1.getEndpointParsed)().protocol}//${bucketInfo.BUCKET_NAME}.${(0, shared_1.getEndpointParsed)().host}/`; } const regex = new RegExp('https?://[^/]+'); function replaceByBaseUrl(fileUrl, baseUrl) { diff --git a/dist/server/lib/object-storage/videos.js b/dist/server/lib/object-storage/videos.js index 18354f00..ac50f5d9 100644 --- a/dist/server/lib/object-storage/videos.js +++ b/dist/server/lib/object-storage/videos.js @@ -9,35 +9,35 @@ const paths_1 = require("../paths"); const keys_1 = require("./keys"); const shared_1 = require("./shared"); function storeHLSFile(playlist, video, filename) { - const baseHlsDirectory = paths_1.getHLSDirectory(video); - return shared_1.storeObject({ - inputPath: path_1.join(baseHlsDirectory, filename), - objectStorageKey: keys_1.generateHLSObjectStorageKey(playlist, video, filename), + const baseHlsDirectory = (0, paths_1.getHLSDirectory)(video); + return (0, shared_1.storeObject)({ + inputPath: (0, path_1.join)(baseHlsDirectory, filename), + objectStorageKey: (0, keys_1.generateHLSObjectStorageKey)(playlist, video, filename), bucketInfo: config_1.CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS }); } exports.storeHLSFile = storeHLSFile; function storeWebTorrentFile(filename) { - return shared_1.storeObject({ - inputPath: path_1.join(config_1.CONFIG.STORAGE.VIDEOS_DIR, filename), - objectStorageKey: keys_1.generateWebTorrentObjectStorageKey(filename), + return (0, shared_1.storeObject)({ + inputPath: (0, path_1.join)(config_1.CONFIG.STORAGE.VIDEOS_DIR, filename), + objectStorageKey: (0, keys_1.generateWebTorrentObjectStorageKey)(filename), bucketInfo: config_1.CONFIG.OBJECT_STORAGE.VIDEOS }); } exports.storeWebTorrentFile = storeWebTorrentFile; function removeHLSObjectStorage(playlist, video) { - return shared_1.removePrefix(keys_1.generateHLSObjectBaseStorageKey(playlist, video), config_1.CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS); + return (0, shared_1.removePrefix)((0, keys_1.generateHLSObjectBaseStorageKey)(playlist, video), config_1.CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS); } exports.removeHLSObjectStorage = removeHLSObjectStorage; function removeWebTorrentObjectStorage(videoFile) { - return shared_1.removeObject(keys_1.generateWebTorrentObjectStorageKey(videoFile.filename), config_1.CONFIG.OBJECT_STORAGE.VIDEOS); + return (0, shared_1.removeObject)((0, keys_1.generateWebTorrentObjectStorageKey)(videoFile.filename), config_1.CONFIG.OBJECT_STORAGE.VIDEOS); } exports.removeWebTorrentObjectStorage = removeWebTorrentObjectStorage; function makeHLSFileAvailable(playlist, video, filename, destination) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const key = keys_1.generateHLSObjectStorageKey(playlist, video, filename); - logger_1.logger.info('Fetching HLS file %s from object storage to %s.', key, destination, shared_1.lTags()); - yield shared_1.makeAvailable({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const key = (0, keys_1.generateHLSObjectStorageKey)(playlist, video, filename); + logger_1.logger.info('Fetching HLS file %s from object storage to %s.', key, destination, (0, shared_1.lTags)()); + yield (0, shared_1.makeAvailable)({ key, destination, bucketInfo: config_1.CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS @@ -47,10 +47,10 @@ function makeHLSFileAvailable(playlist, video, filename, destination) { } exports.makeHLSFileAvailable = makeHLSFileAvailable; function makeWebTorrentFileAvailable(filename, destination) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const key = keys_1.generateWebTorrentObjectStorageKey(filename); - logger_1.logger.info('Fetching WebTorrent file %s from object storage to %s.', key, destination, shared_1.lTags()); - yield shared_1.makeAvailable({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const key = (0, keys_1.generateWebTorrentObjectStorageKey)(filename); + logger_1.logger.info('Fetching WebTorrent file %s from object storage to %s.', key, destination, (0, shared_1.lTags)()); + yield (0, shared_1.makeAvailable)({ key, destination, bucketInfo: config_1.CONFIG.OBJECT_STORAGE.VIDEOS diff --git a/dist/server/lib/paths.js b/dist/server/lib/paths.js index 31100a0f..5bd4e513 100644 --- a/dist/server/lib/paths.js +++ b/dist/server/lib/paths.js @@ -8,11 +8,11 @@ const constants_1 = require("@server/initializers/constants"); const models_1 = require("@server/types/models"); const core_utils_1 = require("@shared/core-utils"); function generateWebTorrentVideoFilename(resolution, extname) { - return uuid_1.buildUUID() + '-' + resolution + extname; + return (0, uuid_1.buildUUID)() + '-' + resolution + extname; } exports.generateWebTorrentVideoFilename = generateWebTorrentVideoFilename; function generateHLSVideoFilename(resolution) { - return `${uuid_1.buildUUID()}-${resolution}-fragmented.mp4`; + return `${(0, uuid_1.buildUUID)()}-${resolution}-fragmented.mp4`; } exports.generateHLSVideoFilename = generateHLSVideoFilename; function getLiveDirectory(video) { @@ -20,39 +20,39 @@ function getLiveDirectory(video) { } exports.getLiveDirectory = getLiveDirectory; function getHLSDirectory(video) { - return path_1.join(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid); + return (0, path_1.join)(constants_1.HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid); } exports.getHLSDirectory = getHLSDirectory; function getHLSRedundancyDirectory(video) { - return path_1.join(constants_1.HLS_REDUNDANCY_DIRECTORY, video.uuid); + return (0, path_1.join)(constants_1.HLS_REDUNDANCY_DIRECTORY, video.uuid); } exports.getHLSRedundancyDirectory = getHLSRedundancyDirectory; function getHlsResolutionPlaylistFilename(videoFilename) { - return core_utils_1.removeFragmentedMP4Ext(videoFilename) + '.m3u8'; + return (0, core_utils_1.removeFragmentedMP4Ext)(videoFilename) + '.m3u8'; } exports.getHlsResolutionPlaylistFilename = getHlsResolutionPlaylistFilename; function generateHLSMasterPlaylistFilename(isLive = false) { if (isLive) return 'master.m3u8'; - return uuid_1.buildUUID() + '-master.m3u8'; + return (0, uuid_1.buildUUID)() + '-master.m3u8'; } exports.generateHLSMasterPlaylistFilename = generateHLSMasterPlaylistFilename; function generateHlsSha256SegmentsFilename(isLive = false) { if (isLive) return 'segments-sha256.json'; - return uuid_1.buildUUID() + '-segments-sha256.json'; + return (0, uuid_1.buildUUID)() + '-segments-sha256.json'; } exports.generateHlsSha256SegmentsFilename = generateHlsSha256SegmentsFilename; function generateTorrentFileName(videoOrPlaylist, resolution) { const extension = '.torrent'; - const uuid = uuid_1.buildUUID(); - if (models_1.isStreamingPlaylist(videoOrPlaylist)) { + const uuid = (0, uuid_1.buildUUID)(); + if ((0, models_1.isStreamingPlaylist)(videoOrPlaylist)) { return `${uuid}-${resolution}-${videoOrPlaylist.getStringType()}${extension}`; } return uuid + '-' + resolution + extension; } exports.generateTorrentFileName = generateTorrentFileName; function getFSTorrentFilePath(videoFile) { - return path_1.join(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename); + return (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename); } exports.getFSTorrentFilePath = getFSTorrentFilePath; diff --git a/dist/server/lib/peertube-socket.js b/dist/server/lib/peertube-socket.js index 3ef60482..f9e5475e 100644 --- a/dist/server/lib/peertube-socket.js +++ b/dist/server/lib/peertube-socket.js @@ -27,12 +27,12 @@ class PeerTubeSocket { this.liveVideosNamespace = io.of('/live-videos') .on('connection', socket => { socket.on('subscribe', ({ videoId }) => { - if (!misc_1.isIdValid(videoId)) + if (!(0, misc_1.isIdValid)(videoId)) return; socket.join(videoId); }); socket.on('unsubscribe', ({ videoId }) => { - if (!misc_1.isIdValid(videoId)) + if (!(0, misc_1.isIdValid)(videoId)) return; socket.leave(videoId); }); diff --git a/dist/server/lib/plugins/hooks.js b/dist/server/lib/plugins/hooks.js index c92d1d89..469d93ce 100644 --- a/dist/server/lib/plugins/hooks.js +++ b/dist/server/lib/plugins/hooks.js @@ -8,11 +8,11 @@ const Hooks = { wrapObject: (result, hookName) => { return plugin_manager_1.PluginManager.Instance.runHook(hookName, result); }, - wrapPromiseFun: (fun, params, hookName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + wrapPromiseFun: (fun, params, hookName) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { const result = yield fun(params); return plugin_manager_1.PluginManager.Instance.runHook(hookName, result, params); }), - wrapFun: (fun, params, hookName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + wrapFun: (fun, params, hookName) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { const result = fun(params); return plugin_manager_1.PluginManager.Instance.runHook(hookName, result, params); }), diff --git a/dist/server/lib/plugins/plugin-helpers-builder.js b/dist/server/lib/plugins/plugin-helpers-builder.js index 71f372c2..23a70d6e 100644 --- a/dist/server/lib/plugins/plugin-helpers-builder.js +++ b/dist/server/lib/plugins/plugin-helpers-builder.js @@ -40,7 +40,7 @@ function buildPluginHelpers(pluginModel, npmName) { } exports.buildPluginHelpers = buildPluginHelpers; function buildPluginLogger(npmName) { - return logger_1.buildLogger(npmName); + return (0, logger_1.buildLogger)(npmName); } function buildDatabaseHelpers() { return { @@ -49,7 +49,7 @@ function buildDatabaseHelpers() { } function buildServerHelpers() { return { - getServerActor: () => application_1.getServerActor() + getServerActor: () => (0, application_1.getServerActor)() }; } function buildVideosHelpers() { @@ -61,7 +61,7 @@ function buildVideosHelpers() { return video_1.VideoModel.load(id); }, removeVideo: (id) => { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(id, t); yield video.destroy({ transaction: t }); })); @@ -70,45 +70,45 @@ function buildVideosHelpers() { } function buildModerationHelpers() { return { - blockServer: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + blockServer: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverToBlock = yield server_1.ServerModel.loadOrCreateByHost(options.hostToBlock); - yield blocklist_1.addServerInBlocklist(options.byAccountId, serverToBlock.id); + yield (0, blocklist_1.addServerInBlocklist)(options.byAccountId, serverToBlock.id); }), - unblockServer: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + unblockServer: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverBlock = yield server_blocklist_1.ServerBlocklistModel.loadByAccountAndHost(options.byAccountId, options.hostToUnblock); if (!serverBlock) return; - yield blocklist_1.removeServerFromBlocklist(serverBlock); + yield (0, blocklist_1.removeServerFromBlocklist)(serverBlock); }), - blockAccount: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + blockAccount: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountToBlock = yield account_1.AccountModel.loadByNameWithHost(options.handleToBlock); if (!accountToBlock) return; - yield blocklist_1.addAccountInBlocklist(options.byAccountId, accountToBlock.id); + yield (0, blocklist_1.addAccountInBlocklist)(options.byAccountId, accountToBlock.id); }), - unblockAccount: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + unblockAccount: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const targetAccount = yield account_1.AccountModel.loadByNameWithHost(options.handleToUnblock); if (!targetAccount) return; const accountBlock = yield account_blocklist_1.AccountBlocklistModel.loadByAccountAndTarget(options.byAccountId, targetAccount.id); if (!accountBlock) return; - yield blocklist_1.removeAccountFromBlocklist(accountBlock); + yield (0, blocklist_1.removeAccountFromBlocklist)(accountBlock); }), - blacklistVideo: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + blacklistVideo: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID); if (!video) return; - yield video_blacklist_2.blacklistVideo(video, options.createOptions); + yield (0, video_blacklist_2.blacklistVideo)(video, options.createOptions); }), - unblacklistVideo: (options) => tslib_1.__awaiter(this, void 0, void 0, function* () { + unblacklistVideo: (options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID); if (!video) return; const videoBlacklist = yield video_blacklist_1.VideoBlacklistModel.loadByVideoId(video.id); if (!videoBlacklist) return; - yield video_blacklist_2.unblacklistVideo(videoBlacklist, video); + yield (0, video_blacklist_2.unblacklistVideo)(videoBlacklist, video); }) }; } @@ -126,7 +126,7 @@ function buildPluginRelatedHelpers(plugin, npmName) { return { getBaseStaticRoute: () => `/plugins/${plugin.name}/${plugin.version}/static/`, getBaseRouterRoute: () => `/plugins/${plugin.name}/${plugin.version}/router/`, - getDataDirectoryPath: () => path_1.join(config_1.CONFIG.STORAGE.PLUGINS_DIR, 'data', npmName) + getDataDirectoryPath: () => (0, path_1.join)(config_1.CONFIG.STORAGE.PLUGINS_DIR, 'data', npmName) }; } function buildUserHelpers() { diff --git a/dist/server/lib/plugins/plugin-index.js b/dist/server/lib/plugins/plugin-index.js index 5a6ce87c..b697bb0e 100644 --- a/dist/server/lib/plugins/plugin-index.js +++ b/dist/server/lib/plugins/plugin-index.js @@ -10,7 +10,7 @@ const constants_1 = require("@server/initializers/constants"); const plugin_1 = require("@server/models/server/plugin"); const plugin_manager_1 = require("./plugin-manager"); function listAvailablePluginsFromIndex(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { start = 0, count = 20, search, sort = 'npmName', pluginType } = options; const searchParams = { start, @@ -22,7 +22,7 @@ function listAvailablePluginsFromIndex(options) { }; const uri = config_1.CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins'; try { - const { body } = yield requests_1.doJSONRequest(uri, { searchParams }); + const { body } = yield (0, requests_1.doJSONRequest)(uri, { searchParams }); logger_1.logger.debug('Got result from PeerTube index.', { body }); addInstanceInformation(body); return body; @@ -42,23 +42,23 @@ function addInstanceInformation(result) { return result; } function getLatestPluginsVersion(npmNames) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const bodyRequest = { npmNames, currentPeerTubeEngine: constants_1.PEERTUBE_VERSION }; - const uri = core_utils_1.sanitizeUrl(config_1.CONFIG.PLUGINS.INDEX.URL) + '/api/v1/plugins/latest-version'; + const uri = (0, core_utils_1.sanitizeUrl)(config_1.CONFIG.PLUGINS.INDEX.URL) + '/api/v1/plugins/latest-version'; const options = { json: bodyRequest, method: 'POST' }; - const { body } = yield requests_1.doJSONRequest(uri, options); + const { body } = yield (0, requests_1.doJSONRequest)(uri, options); return body; }); } exports.getLatestPluginsVersion = getLatestPluginsVersion; function getLatestPluginVersion(npmName) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const results = yield getLatestPluginsVersion([npmName]); if (Array.isArray(results) === false || results.length !== 1) { logger_1.logger.warn('Cannot get latest supported plugin version of %s.', npmName); diff --git a/dist/server/lib/plugins/plugin-manager.js b/dist/server/lib/plugins/plugin-manager.js index 7b979590..3f0bb625 100644 --- a/dist/server/lib/plugins/plugin-manager.js +++ b/dist/server/lib/plugins/plugin-manager.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.PluginManager = void 0; const tslib_1 = require("tslib"); -const decache_1 = tslib_1.__importDefault(require("decache")); +const decache_1 = (0, tslib_1.__importDefault)(require("decache")); const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); @@ -85,7 +85,7 @@ class PluginManager { return this.translations[locale] || {}; } isTokenValid(token, type) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const auth = this.getAuth(token.User.pluginAuth, token.authName); if (!auth) return true; @@ -106,7 +106,7 @@ class PluginManager { }); } onLogout(npmName, authName, user, req) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const auth = this.getAuth(npmName, authName); if (auth === null || auth === void 0 ? void 0 : auth.onLogout) { logger_1.logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName); @@ -124,7 +124,7 @@ class PluginManager { }); } onSettingsChanged(name, settings) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const registered = this.getRegisteredPluginByShortName(name); if (!registered) { logger_1.logger.error('Cannot find plugin %s to call on settings changed.', name); @@ -140,13 +140,13 @@ class PluginManager { }); } runHook(hookName, result, params) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.hooks[hookName]) return Promise.resolve(result); - const hookType = hooks_1.getHookType(hookName); + const hookType = (0, hooks_1.getHookType)(hookName); for (const hook of this.hooks[hookName]) { logger_1.logger.debug('Running hook %s of plugin %s.', hookName, hook.npmName); - result = yield hooks_1.internalRunHook(hook.handler, hookType, result, params, err => { + result = yield (0, hooks_1.internalRunHook)(hook.handler, hookType, result, params, err => { logger_1.logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err }); }); } @@ -154,7 +154,7 @@ class PluginManager { }); } registerPluginsAndThemes() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.resetCSSGlobalFile(); const plugins = yield plugin_1.PluginModel.listEnabledPluginsAndThemes(); for (const plugin of plugins) { @@ -174,7 +174,7 @@ class PluginManager { }); } unregister(npmName) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Unregister plugin %s.', npmName); const plugin = this.getRegisteredPluginOrTheme(npmName); if (!plugin) { @@ -196,15 +196,15 @@ class PluginManager { }); } install(toInstall, version, fromDisk = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let plugin; let npmName; logger_1.logger.info('Installing plugin %s.', toInstall); try { fromDisk - ? yield yarn_1.installNpmPluginFromDisk(toInstall) - : yield yarn_1.installNpmPlugin(toInstall, version); - npmName = fromDisk ? path_1.basename(toInstall) : toInstall; + ? yield (0, yarn_1.installNpmPluginFromDisk)(toInstall) + : yield (0, yarn_1.installNpmPlugin)(toInstall, version); + npmName = fromDisk ? (0, path_1.basename)(toInstall) : toInstall; const pluginType = plugin_1.PluginModel.getTypeFromNpmName(npmName); const pluginName = plugin_1.PluginModel.normalizePluginName(npmName); const packageJSON = yield this.getPackageJSON(pluginName, pluginType); @@ -230,7 +230,7 @@ class PluginManager { catch (err) { logger_1.logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }); try { - yield yarn_1.removeNpmPlugin(npmName); + yield (0, yarn_1.removeNpmPlugin)(npmName); } catch (err) { logger_1.logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }); @@ -242,8 +242,8 @@ class PluginManager { }); } update(toUpdate, fromDisk = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const npmName = fromDisk ? path_1.basename(toUpdate) : toUpdate; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const npmName = fromDisk ? (0, path_1.basename)(toUpdate) : toUpdate; logger_1.logger.info('Updating plugin %s.', npmName); let version; if (!fromDisk) { @@ -255,7 +255,7 @@ class PluginManager { }); } uninstall(npmName) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Uninstalling plugin %s.', npmName); try { yield this.unregister(npmName); @@ -271,12 +271,12 @@ class PluginManager { plugin.enabled = false; plugin.uninstalled = true; yield plugin.save(); - yield yarn_1.removeNpmPlugin(npmName); + yield (0, yarn_1.removeNpmPlugin)(npmName); logger_1.logger.info('Plugin %s uninstalled.', npmName); }); } registerPluginOrTheme(plugin) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const npmName = plugin_1.PluginModel.buildNpmName(plugin.name, plugin.type); logger_1.logger.info('Registering plugin or theme %s.', npmName); const packageJSON = yield this.getPackageJSON(plugin.name, plugin.type); @@ -311,16 +311,16 @@ class PluginManager { }); } registerPlugin(plugin, pluginPath, packageJSON) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const npmName = plugin_1.PluginModel.buildNpmName(plugin.name, plugin.type); - const modulePath = path_1.join(pluginPath, packageJSON.library); - decache_1.default(modulePath); + const modulePath = (0, path_1.join)(pluginPath, packageJSON.library); + (0, decache_1.default)(modulePath); const library = require(modulePath); - if (!plugins_1.isLibraryCodeValid(library)) { + if (!(0, plugins_1.isLibraryCodeValid)(library)) { throw new Error('Library code is not valid (miss register or unregister function)'); } const { registerOptions, registerStore } = this.getRegisterHelpers(npmName, plugin); - yield fs_extra_1.ensureDir(registerOptions.peertubeHelpers.plugin.getDataDirectoryPath()); + yield (0, fs_extra_1.ensureDir)(registerOptions.peertubeHelpers.plugin.getDataDirectoryPath()); yield library.register(registerOptions); logger_1.logger.info('Add plugin %s CSS to global file.', npmName); yield this.addCSSToGlobalFile(pluginPath, packageJSON.css); @@ -328,11 +328,11 @@ class PluginManager { }); } addTranslations(plugin, npmName, translationPaths) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const locale of Object.keys(translationPaths)) { const path = translationPaths[locale]; - const json = yield fs_extra_1.readJSON(path_1.join(this.getPluginPath(plugin.name, plugin.type), path)); - const completeLocale = core_utils_1.getCompleteLocale(locale); + const json = yield (0, fs_extra_1.readJSON)((0, path_1.join)(this.getPluginPath(plugin.name, plugin.type), path)); + const completeLocale = (0, core_utils_1.getCompleteLocale)(locale); if (!this.translations[completeLocale]) this.translations[completeLocale] = {}; this.translations[completeLocale][npmName] = json; @@ -348,27 +348,27 @@ class PluginManager { } resetCSSGlobalFile() { client_html_1.ClientHtml.invalidCache(); - return fs_extra_1.outputFile(constants_1.PLUGIN_GLOBAL_CSS_PATH, ''); + return (0, fs_extra_1.outputFile)(constants_1.PLUGIN_GLOBAL_CSS_PATH, ''); } addCSSToGlobalFile(pluginPath, cssRelativePaths) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const cssPath of cssRelativePaths) { - yield this.concatFiles(path_1.join(pluginPath, cssPath), constants_1.PLUGIN_GLOBAL_CSS_PATH); + yield this.concatFiles((0, path_1.join)(pluginPath, cssPath), constants_1.PLUGIN_GLOBAL_CSS_PATH); } client_html_1.ClientHtml.invalidCache(); }); } concatFiles(input, output) { return new Promise((res, rej) => { - const inputStream = fs_1.createReadStream(input); - const outputStream = fs_1.createWriteStream(output, { flags: 'a' }); + const inputStream = (0, fs_1.createReadStream)(input); + const outputStream = (0, fs_1.createWriteStream)(output, { flags: 'a' }); inputStream.pipe(outputStream); inputStream.on('end', () => res()); inputStream.on('error', err => rej(err)); }); } regeneratePluginGlobalCSS() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.resetCSSGlobalFile(); for (const plugin of this.getRegisteredPlugins()) { yield this.addCSSToGlobalFile(plugin.path, plugin.css); @@ -383,12 +383,12 @@ class PluginManager { } } getPackageJSON(pluginName, pluginType) { - const pluginPath = path_1.join(this.getPluginPath(pluginName, pluginType), 'package.json'); - return fs_extra_1.readJSON(pluginPath); + const pluginPath = (0, path_1.join)(this.getPluginPath(pluginName, pluginType), 'package.json'); + return (0, fs_extra_1.readJSON)(pluginPath); } getPluginPath(pluginName, pluginType) { const npmName = plugin_1.PluginModel.buildNpmName(pluginName, pluginType); - return path_1.join(config_1.CONFIG.STORAGE.PLUGINS_DIR, 'node_modules', npmName); + return (0, path_1.join)(config_1.CONFIG.STORAGE.PLUGINS_DIR, 'node_modules', npmName); } getAuth(npmName, authName) { const plugin = this.getRegisteredPluginOrTheme(npmName); @@ -434,7 +434,7 @@ class PluginManager { packageJSON.clientScripts = []; if (!packageJSON.translations) packageJSON.translations = {}; - const { result: packageJSONValid, badFields } = plugins_1.isPackageJSONValid(packageJSON, pluginType); + const { result: packageJSONValid, badFields } = (0, plugins_1.isPackageJSONValid)(packageJSON, pluginType); if (!packageJSONValid) { const formattedFields = badFields.map(f => `"${f}"`) .join(', '); diff --git a/dist/server/lib/plugins/register-helpers.js b/dist/server/lib/plugins/register-helpers.js index b29a2b76..8b51b64e 100644 --- a/dist/server/lib/plugins/register-helpers.js +++ b/dist/server/lib/plugins/register-helpers.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.RegisterHelpers = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const logger_1 = require("@server/helpers/logger"); const external_auth_1 = require("@server/lib/auth/external-auth"); const video_constant_manager_factory_1 = require("@server/lib/plugins/video-constant-manager-factory"); @@ -40,7 +40,7 @@ class RegisterHelpers { const registerExternalAuth = this.buildRegisterExternalAuth(); const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth(); const unregisterExternalAuth = this.buildUnregisterExternalAuth(); - const peertubeHelpers = plugin_helpers_builder_1.buildPluginHelpers(this.plugin, this.npmName); + const peertubeHelpers = (0, plugin_helpers_builder_1.buildPluginHelpers)(this.plugin, this.npmName); return { registerHook, registerSetting, @@ -128,7 +128,7 @@ class RegisterHelpers { this.externalAuths.push(options); return { userAuthenticated(result) { - external_auth_1.onExternalUserAuthenticated({ + (0, external_auth_1.onExternalUserAuthenticated)({ npmName: self.npmName, authName: options.authName, authResult: result diff --git a/dist/server/lib/plugins/yarn.js b/dist/server/lib/plugins/yarn.js index 28aae614..2a89d705 100644 --- a/dist/server/lib/plugins/yarn.js +++ b/dist/server/lib/plugins/yarn.js @@ -10,11 +10,11 @@ const logger_1 = require("../../helpers/logger"); const config_1 = require("../../initializers/config"); const plugin_index_1 = require("./plugin-index"); function installNpmPlugin(npmName, versionArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { checkNpmPluginNameOrThrow(npmName); if (versionArg) checkPluginVersionOrThrow(versionArg); - const version = versionArg || (yield plugin_index_1.getLatestPluginVersion(npmName)); + const version = versionArg || (yield (0, plugin_index_1.getLatestPluginVersion)(npmName)); let toInstall = npmName; if (version) toInstall += `@${version}`; @@ -24,27 +24,27 @@ function installNpmPlugin(npmName, versionArg) { } exports.installNpmPlugin = installNpmPlugin; function installNpmPluginFromDisk(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield execYarn('add file:' + path); }); } exports.installNpmPluginFromDisk = installNpmPluginFromDisk; function removeNpmPlugin(name) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { checkNpmPluginNameOrThrow(name); yield execYarn('remove ' + name); }); } exports.removeNpmPlugin = removeNpmPlugin; function execYarn(command) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const pluginDirectory = config_1.CONFIG.STORAGE.PLUGINS_DIR; - const pluginPackageJSON = path_1.join(pluginDirectory, 'package.json'); - if (!(yield fs_extra_1.pathExists(pluginPackageJSON))) { - yield fs_extra_1.outputJSON(pluginPackageJSON, {}); + const pluginPackageJSON = (0, path_1.join)(pluginDirectory, 'package.json'); + if (!(yield (0, fs_extra_1.pathExists)(pluginPackageJSON))) { + yield (0, fs_extra_1.outputJSON)(pluginPackageJSON, {}); } - return core_utils_1.execShell(`yarn ${command}`, { cwd: pluginDirectory }); + return (0, core_utils_1.execShell)(`yarn ${command}`, { cwd: pluginDirectory }); } catch (result) { logger_1.logger.error('Cannot exec yarn.', { command, err: result.err, stderr: result.stderr }); @@ -53,10 +53,10 @@ function execYarn(command) { }); } function checkNpmPluginNameOrThrow(name) { - if (!plugins_1.isNpmPluginNameValid(name)) + if (!(0, plugins_1.isNpmPluginNameValid)(name)) throw new Error('Invalid NPM plugin name to install'); } function checkPluginVersionOrThrow(name) { - if (!plugins_1.isPluginVersionValid(name)) + if (!(0, plugins_1.isPluginVersionValid)(name)) throw new Error('Invalid NPM plugin version to install'); } diff --git a/dist/server/lib/redis.js b/dist/server/lib/redis.js index 3733fc39..588988ab 100644 --- a/dist/server/lib/redis.js +++ b/dist/server/lib/redis.js @@ -15,7 +15,7 @@ class Redis { if (this.initialized === true) return; this.initialized = true; - this.client = redis_1.createClient(Redis.getRedisClientOptions()); + this.client = (0, redis_1.createClient)(Redis.getRedisClientOptions()); this.client.on('error', err => { logger_1.logger.error('Error in Redis client.', { err }); process.exit(-1); @@ -37,48 +37,48 @@ class Redis { return this.prefix; } setResetPasswordVerificationString(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const generatedString = yield utils_1.generateRandomString(32); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const generatedString = yield (0, utils_1.generateRandomString)(32); yield this.setValue(this.generateResetPasswordKey(userId), generatedString, constants_1.USER_PASSWORD_RESET_LIFETIME); return generatedString; }); } setCreatePasswordVerificationString(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const generatedString = yield utils_1.generateRandomString(32); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const generatedString = yield (0, utils_1.generateRandomString)(32); yield this.setValue(this.generateResetPasswordKey(userId), generatedString, constants_1.USER_PASSWORD_CREATE_LIFETIME); return generatedString; }); } removePasswordVerificationString(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.removeValue(this.generateResetPasswordKey(userId)); }); } getResetPasswordLink(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.getValue(this.generateResetPasswordKey(userId)); }); } setVerifyEmailVerificationString(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const generatedString = yield utils_1.generateRandomString(32); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const generatedString = yield (0, utils_1.generateRandomString)(32); yield this.setValue(this.generateVerifyEmailKey(userId), generatedString, constants_1.USER_EMAIL_VERIFY_LIFETIME); return generatedString; }); } getVerifyEmailLink(userId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.getValue(this.generateVerifyEmailKey(userId)); }); } setContactFormIp(ip) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.setValue(this.generateContactFormKey(ip), '1', constants_1.CONTACT_FORM_LIFETIME); }); } doesContactFormIpExist(ip) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.exists(this.generateContactFormKey(ip)); }); } @@ -89,7 +89,7 @@ class Redis { return this.setValue(this.generateViewKey(ip, videoUUID), '1', lifetime); } doesVideoIPViewExist(ip, videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.exists(this.generateViewKey(ip, videoUUID)); }); } @@ -97,12 +97,12 @@ class Redis { return this.setValue(this.generateTrackerBlockIPKey(ip), '1', constants_1.TRACKER_RATE_LIMITS.BLOCK_IP_LIFETIME); } doesTrackerBlockIPExist(ip) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.exists(this.generateTrackerBlockIPKey(ip)); }); } getCachedRoute(req) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const cached = yield this.getObject(this.generateCachedRouteKey(req)); return cached; }); @@ -120,7 +120,7 @@ class Redis { ]); } getVideoViews(videoId, hour) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const key = this.generateVideoViewKey(videoId, hour); const valueString = yield this.getValue(key); const valueInt = parseInt(valueString, 10); @@ -132,7 +132,7 @@ class Redis { }); } getVideosIdViewed(hour) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const key = this.generateVideosViewKey(hour); const stringIds = yield this.getSet(key); return stringIds.map(s => parseInt(s, 10)); diff --git a/dist/server/lib/redundancy.js b/dist/server/lib/redundancy.js index d6cbdedc..de13aa42 100644 --- a/dist/server/lib/redundancy.js +++ b/dist/server/lib/redundancy.js @@ -8,18 +8,18 @@ const actor_follow_1 = require("@server/models/actor/actor-follow"); const application_1 = require("@server/models/application/application"); const video_redundancy_1 = require("../models/redundancy/video-redundancy"); const send_1 = require("./activitypub/send"); -const lTags = logger_1.loggerTagsFactory('redundancy'); +const lTags = (0, logger_1.loggerTagsFactory)('redundancy'); function removeVideoRedundancy(videoRedundancy, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); if (videoRedundancy.actorId === serverActor.id) - yield send_1.sendUndoCacheFile(serverActor, videoRedundancy, t); + yield (0, send_1.sendUndoCacheFile)(serverActor, videoRedundancy, t); yield videoRedundancy.destroy({ transaction: t }); }); } exports.removeVideoRedundancy = removeVideoRedundancy; function removeRedundanciesOfServer(serverId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const redundancies = yield video_redundancy_1.VideoRedundancyModel.listLocalOfServer(serverId); for (const redundancy of redundancies) { yield removeVideoRedundancy(redundancy); @@ -28,14 +28,14 @@ function removeRedundanciesOfServer(serverId) { } exports.removeRedundanciesOfServer = removeRedundanciesOfServer; function isRedundancyAccepted(activity, byActor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const configAcceptFrom = config_1.CONFIG.REMOTE_REDUNDANCY.VIDEOS.ACCEPT_FROM; if (configAcceptFrom === 'nobody') { logger_1.logger.info('Do not accept remote redundancy %s due instance accept policy.', activity.id, lTags()); return false; } if (configAcceptFrom === 'followings') { - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const allowed = yield actor_follow_1.ActorFollowModel.isFollowedBy(byActor.id, serverActor.id); if (allowed !== true) { logger_1.logger.info('Do not accept remote redundancy %s because actor %s is not followed by our instance.', activity.id, byActor.url, lTags()); diff --git a/dist/server/lib/schedulers/abstract-scheduler.js b/dist/server/lib/schedulers/abstract-scheduler.js index d7bb161b..515afac9 100644 --- a/dist/server/lib/schedulers/abstract-scheduler.js +++ b/dist/server/lib/schedulers/abstract-scheduler.js @@ -16,7 +16,7 @@ class AbstractScheduler { clearInterval(this.interval); } execute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.isRunning === true) return; this.isRunning = true; diff --git a/dist/server/lib/schedulers/actor-follow-scheduler.js b/dist/server/lib/schedulers/actor-follow-scheduler.js index 4a9bdf25..2a406704 100644 --- a/dist/server/lib/schedulers/actor-follow-scheduler.js +++ b/dist/server/lib/schedulers/actor-follow-scheduler.js @@ -14,13 +14,13 @@ class ActorFollowScheduler extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.actorFollowScores; } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.processPendingScores(); yield this.removeBadActorFollows(); }); } processPendingScores() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const pendingScores = files_cache_1.ActorFollowScoreCache.Instance.getPendingFollowsScore(); const badServerIds = files_cache_1.ActorFollowScoreCache.Instance.getBadFollowingServerIds(); const goodServerIds = files_cache_1.ActorFollowScoreCache.Instance.getGoodFollowingServerIds(); @@ -35,8 +35,8 @@ class ActorFollowScheduler extends abstract_scheduler_1.AbstractScheduler { }); } removeBadActorFollows() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (!core_utils_1.isTestInstance()) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if (!(0, core_utils_1.isTestInstance)()) logger_1.logger.info('Removing bad actor follows (scheduler).'); try { yield actor_follow_1.ActorFollowModel.removeBadActorFollows(); diff --git a/dist/server/lib/schedulers/auto-follow-index-instances.js b/dist/server/lib/schedulers/auto-follow-index-instances.js index 2fe9686d..965766e2 100644 --- a/dist/server/lib/schedulers/auto-follow-index-instances.js +++ b/dist/server/lib/schedulers/auto-follow-index-instances.js @@ -17,29 +17,29 @@ class AutoFollowIndexInstances extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.autoFollowIndexInstances; } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.autoFollow(); }); } autoFollow() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.ENABLED === false) return; const indexUrl = config_1.CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL; logger_1.logger.info('Auto follow instances of index %s.', indexUrl); try { - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const searchParams = { count: 1000 }; if (this.lastCheck) Object.assign(searchParams, { since: this.lastCheck.toISOString() }); this.lastCheck = new Date(); - const { body } = yield requests_1.doJSONRequest(indexUrl, { searchParams }); + const { body } = yield (0, requests_1.doJSONRequest)(indexUrl, { searchParams }); if (!body.data || Array.isArray(body.data) === false) { logger_1.logger.error('Cannot auto follow instances of index %s. Please check the auto follow URL.', indexUrl, { body }); return; } const hosts = body.data.map(o => o.host); - const chunks = lodash_1.chunk(hosts, 20); + const chunks = (0, lodash_1.chunk)(hosts, 20); for (const chunk of chunks) { const unfollowedHosts = yield actor_follow_1.ActorFollowModel.keepUnfollowedInstance(chunk); for (const unfollowedHost of unfollowedHosts) { diff --git a/dist/server/lib/schedulers/images-redundancy-scheduler.js b/dist/server/lib/schedulers/images-redundancy-scheduler.js new file mode 100644 index 00000000..ed872ff9 --- /dev/null +++ b/dist/server/lib/schedulers/images-redundancy-scheduler.js @@ -0,0 +1,96 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ImagesRedundancyScheduler = void 0; +const tslib_1 = require("tslib"); +const actor_follow_1 = require("@server/models/actor/actor-follow"); +const application_1 = require("@server/models/application/application"); +const image_redundancy_1 = require("@server/models/image/image-redundancy"); +const logger_1 = require("../../helpers/logger"); +const config_1 = require("../../initializers/config"); +const abstract_scheduler_1 = require("./abstract-scheduler"); +const fs_1 = require("fs"); +const util_1 = require("util"); +const stream_1 = require("stream"); +const image_1 = require("@server/models/image/image"); +const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch")); +const fs_extra_1 = require("fs-extra"); +const path_1 = require("path"); +const streamPipeline = (0, util_1.promisify)(stream_1.pipeline); +class ImagesRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { + constructor() { + super(); + this.schedulerIntervalMs = config_1.CONFIG.REDUNDANCY.IMAGES.CHECK_INTERVAL; + } + internalExecute() { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + logger_1.logger.info('Running images redundancy scheduler'); + const actors = yield this.getAllActorsWithRedundancy(); + yield Promise.all(actors.map((actor) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverUrl = new URL(actor.url).origin; + const currentImageRedundancy = (yield image_redundancy_1.ImageRedundancyModel.getImageRedundancyForActor(serverUrl))[0]; + var response; + try { + response = yield image_redundancy_1.ImageRedundancyModel.getImagesFromDate(currentImageRedundancy); + } + catch (err) { + logger_1.logger.info('Images redundancy: ' + serverUrl + ' is not reachable:'); + logger_1.logger.info(err); + } + if (!response) + return; + const imagesToDownload = yield response.json(); + if (imagesToDownload && imagesToDownload.length > 0) { + const newFromDate = yield this.downloadImagesFromServer(serverUrl, imagesToDownload); + if (newFromDate) { + currentImageRedundancy.fromDate = newFromDate; + currentImageRedundancy.save(); + } + } + }))); + }); + } + getAllActorsWithRedundancy() { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); + const resultList = yield actor_follow_1.ActorFollowModel.listFollowingForApi({ + id: serverActor.id, + start: undefined, + count: undefined, + sort: '-createdAt' + }); + return resultList.data.filter((a) => { + return a.ActorFollowing.getRedundancyAllowed(); + }).map((a) => a.ActorFollowing); + }); + } + downloadImagesFromServer(serverUrl, imagesToDownload) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + var resDate; + yield Promise.all(imagesToDownload.map((imageToDownload) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, fs_extra_1.ensureDir)((0, path_1.join)(config_1.CONFIG.STORAGE.IMAGES_DIR, imageToDownload.id)); + yield this.downloadFile(image_1.ImageModel.getImageStaticUrl(imageToDownload.id, imageToDownload.filename, serverUrl), image_1.ImageModel.getImageStaticPath(imageToDownload.id, imageToDownload.filename)); + yield this.downloadFile(image_1.ImageModel.getImageStaticUrl(imageToDownload.id, imageToDownload.thumbnailname, serverUrl), image_1.ImageModel.getImageStaticPath(imageToDownload.id, imageToDownload.thumbnailname)); + const torrentHash = yield image_1.ImageModel.generateTorrentForImage(imageToDownload.id, (0, path_1.join)(config_1.CONFIG.STORAGE.IMAGES_DIR, imageToDownload.id)); + const currentCreatedAt = new Date(imageToDownload.createdAt); + resDate = (!resDate || resDate < currentCreatedAt) ? currentCreatedAt : resDate; + imageToDownload.createdAt = imageToDownload.updatedAt = new Date(); + imageToDownload.infoHash = torrentHash; + const newImage = new image_1.ImageModel(imageToDownload); + newImage.save(); + }))); + return resDate; + }); + } + downloadFile(url, filePath) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const response = yield (0, node_fetch_1.default)(url); + if (!response.ok) + throw new Error(`downloadFile: Unexpected response ${response.statusText}`); + yield streamPipeline(response.body, (0, fs_1.createWriteStream)(filePath)); + }); + } + static get Instance() { + return this.instance || (this.instance = new this()); + } +} +exports.ImagesRedundancyScheduler = ImagesRedundancyScheduler; diff --git a/dist/server/lib/schedulers/peertube-version-check-scheduler.js b/dist/server/lib/schedulers/peertube-version-check-scheduler.js index ba74fc79..df027c16 100644 --- a/dist/server/lib/schedulers/peertube-version-check-scheduler.js +++ b/dist/server/lib/schedulers/peertube-version-check-scheduler.js @@ -16,17 +16,17 @@ class PeerTubeVersionCheckScheduler extends abstract_scheduler_1.AbstractSchedul this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.checkPeerTubeVersion; } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.checkLatestVersion(); }); } checkLatestVersion() { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.PEERTUBE.CHECK_LATEST_VERSION.ENABLED === false) return; logger_1.logger.info('Checking latest PeerTube version.'); - const { body } = yield requests_1.doJSONRequest(config_1.CONFIG.PEERTUBE.CHECK_LATEST_VERSION.URL); + const { body } = yield (0, requests_1.doJSONRequest)(config_1.CONFIG.PEERTUBE.CHECK_LATEST_VERSION.URL); if (!((_a = body === null || body === void 0 ? void 0 : body.peertube) === null || _a === void 0 ? void 0 : _a.latestVersion)) { logger_1.logger.warn('Cannot check latest PeerTube version: body is invalid.', { body }); return; @@ -35,7 +35,7 @@ class PeerTubeVersionCheckScheduler extends abstract_scheduler_1.AbstractSchedul const application = yield application_1.ApplicationModel.load(); if (application.latestPeerTubeVersion === latestVersion) return; - if (core_utils_1.compareSemVer(constants_1.PEERTUBE_VERSION, latestVersion) < 0) { + if ((0, core_utils_1.compareSemVer)(constants_1.PEERTUBE_VERSION, latestVersion) < 0) { application.latestPeerTubeVersion = latestVersion; yield application.save(); notifier_1.Notifier.Instance.notifyOfNewPeerTubeVersion(application, latestVersion); diff --git a/dist/server/lib/schedulers/plugins-check-scheduler.js b/dist/server/lib/schedulers/plugins-check-scheduler.js index b77b6384..8c4d97a5 100644 --- a/dist/server/lib/schedulers/plugins-check-scheduler.js +++ b/dist/server/lib/schedulers/plugins-check-scheduler.js @@ -17,17 +17,17 @@ class PluginsCheckScheduler extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.checkPlugins; } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.checkLatestPluginsVersion(); }); } checkLatestPluginsVersion() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.PLUGINS.INDEX.ENABLED === false) return; logger_1.logger.info('Checking latest plugins version.'); const plugins = yield plugin_1.PluginModel.listInstalled(); - const chunks = lodash_1.chunk(plugins, 10); + const chunks = (0, lodash_1.chunk)(plugins, 10); for (const chunk of chunks) { const pluginIndex = {}; for (const plugin of chunk) { @@ -35,16 +35,16 @@ class PluginsCheckScheduler extends abstract_scheduler_1.AbstractScheduler { } const npmNames = Object.keys(pluginIndex); try { - const results = yield plugin_index_1.getLatestPluginsVersion(npmNames); + const results = yield (0, plugin_index_1.getLatestPluginsVersion)(npmNames); for (const result of results) { const plugin = pluginIndex[result.npmName]; if (!result.latestVersion) continue; if (!plugin.latestVersion || - (plugin.latestVersion !== result.latestVersion && core_utils_1.compareSemVer(plugin.latestVersion, result.latestVersion) < 0)) { + (plugin.latestVersion !== result.latestVersion && (0, core_utils_1.compareSemVer)(plugin.latestVersion, result.latestVersion) < 0)) { plugin.latestVersion = result.latestVersion; yield plugin.save(); - if (core_utils_1.compareSemVer(plugin.version, result.latestVersion) < 0) { + if ((0, core_utils_1.compareSemVer)(plugin.version, result.latestVersion) < 0) { notifier_1.Notifier.Instance.notifyOfNewPluginVersion(plugin); } logger_1.logger.info('Plugin %s has a new latest version %s.', result.npmName, plugin.latestVersion); diff --git a/dist/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js b/dist/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js index 7a555124..154db04e 100644 --- a/dist/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js +++ b/dist/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.js @@ -9,7 +9,7 @@ const upload_1 = require("@server/helpers/upload"); const constants_1 = require("@server/initializers/constants"); const core_1 = require("@uploadx/core"); const abstract_scheduler_1 = require("./abstract-scheduler"); -const lTags = logger_1.loggerTagsFactory('scheduler', 'resumable-upload', 'cleaner'); +const lTags = (0, logger_1.loggerTagsFactory)('scheduler', 'resumable-upload', 'cleaner'); class RemoveDanglingResumableUploadsScheduler extends abstract_scheduler_1.AbstractScheduler { constructor() { super(); @@ -17,15 +17,15 @@ class RemoveDanglingResumableUploadsScheduler extends abstract_scheduler_1.Abstr this.lastExecutionTimeMs = new Date().getTime(); } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const path = upload_1.getResumableUploadPath(); - const files = yield fs_extra_1.readdir(path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const path = (0, upload_1.getResumableUploadPath)(); + const files = yield (0, fs_extra_1.readdir)(path); const metafiles = files.filter(f => f.endsWith(core_1.METAFILE_EXTNAME)); if (metafiles.length === 0) return; logger_1.logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()); try { - yield bluebird_1.map(metafiles, metafile => { + yield (0, bluebird_1.map)(metafiles, metafile => { return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs); }, { concurrency: 5 }); } @@ -38,13 +38,13 @@ class RemoveDanglingResumableUploadsScheduler extends abstract_scheduler_1.Abstr }); } deleteIfOlderThan(metafile, olderThan) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const metafilePath = upload_1.getResumableUploadPath(metafile); - const statResult = yield fs_extra_1.stat(metafilePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const metafilePath = (0, upload_1.getResumableUploadPath)(metafile); + const statResult = yield (0, fs_extra_1.stat)(metafilePath); if (statResult.ctimeMs < olderThan) { - yield fs_extra_1.remove(metafilePath); + yield (0, fs_extra_1.remove)(metafilePath); const datafile = metafilePath.replace(new RegExp(`${core_1.METAFILE_EXTNAME}$`), ''); - yield fs_extra_1.remove(datafile); + yield (0, fs_extra_1.remove)(datafile); } }); } diff --git a/dist/server/lib/schedulers/remove-old-jobs-scheduler.js b/dist/server/lib/schedulers/remove-old-jobs-scheduler.js index d79ee4aa..acc99739 100644 --- a/dist/server/lib/schedulers/remove-old-jobs-scheduler.js +++ b/dist/server/lib/schedulers/remove-old-jobs-scheduler.js @@ -12,7 +12,7 @@ class RemoveOldJobsScheduler extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.removeOldJobs; } internalExecute() { - if (!core_utils_1.isTestInstance()) + if (!(0, core_utils_1.isTestInstance)()) logger_1.logger.info('Removing old jobs in scheduler.'); return job_queue_1.JobQueue.Instance.removeOldJobs(); } diff --git a/dist/server/lib/schedulers/update-videos-scheduler.js b/dist/server/lib/schedulers/update-videos-scheduler.js index 0b4fc645..a403e545 100644 --- a/dist/server/lib/schedulers/update-videos-scheduler.js +++ b/dist/server/lib/schedulers/update-videos-scheduler.js @@ -16,18 +16,18 @@ class UpdateVideosScheduler extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = constants_1.SCHEDULER_INTERVALS_MS.updateVideos; } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.updateVideos(); }); } updateVideos() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!(yield schedule_video_update_1.ScheduleVideoUpdateModel.areVideosToUpdate())) return undefined; const schedules = yield schedule_video_update_1.ScheduleVideoUpdateModel.listVideosToUpdate(); const publishedVideos = []; for (const schedule of schedules) { - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(schedule.videoId, t); logger_1.logger.info('Executing scheduled video update on %s.', video.uuid); if (schedule.privacy) { @@ -35,7 +35,7 @@ class UpdateVideosScheduler extends abstract_scheduler_1.AbstractScheduler { const isNewVideo = video.isNewVideo(schedule.privacy); video.setPrivacy(schedule.privacy); yield video.save({ transaction: t }); - yield videos_1.federateVideoIfNeeded(video, isNewVideo, t); + yield (0, videos_1.federateVideoIfNeeded)(video, isNewVideo, t); if (wasConfidentialVideo) { publishedVideos.push(video); } diff --git a/dist/server/lib/schedulers/videos-redundancy-scheduler.js b/dist/server/lib/schedulers/videos-redundancy-scheduler.js index 9951f830..8e077e56 100644 --- a/dist/server/lib/schedulers/videos-redundancy-scheduler.js +++ b/dist/server/lib/schedulers/videos-redundancy-scheduler.js @@ -18,7 +18,7 @@ const hls_1 = require("../hls"); const redundancy_1 = require("../redundancy"); const video_urls_1 = require("../video-urls"); const abstract_scheduler_1 = require("./abstract-scheduler"); -const lTags = logger_1.loggerTagsFactory('redundancy'); +const lTags = (0, logger_1.loggerTagsFactory)('redundancy'); function isMVideoRedundancyFileVideo(o) { return !!o.VideoFile; } @@ -28,7 +28,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { this.schedulerIntervalMs = config_1.CONFIG.REDUNDANCY.VIDEOS.CHECK_INTERVAL; } createManualRedundancy(videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoToDuplicate = yield video_1.VideoModel.loadWithFiles(videoId); if (!videoToDuplicate) { logger_1.logger.warn('Video to manually duplicate %d does not exist anymore.', videoId, lTags()); @@ -43,7 +43,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { }); } internalExecute() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const redundancyConfig of config_1.CONFIG.REDUNDANCY.VIDEOS.STRATEGIES) { logger_1.logger.info('Running redundancy scheduler for strategy %s.', redundancyConfig.strategy, lTags()); try { @@ -76,7 +76,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { return this.instance || (this.instance = new this()); } extendsLocalExpiration() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const expired = yield video_redundancy_1.VideoRedundancyModel.listLocalExpired(); for (const redundancyModel of expired) { try { @@ -89,7 +89,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { }; if (!redundancyConfig || (yield this.isTooHeavy(candidate))) { logger_1.logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy, lTags(candidate.video.uuid)); - yield redundancy_1.removeVideoRedundancy(redundancyModel); + yield (0, redundancy_1.removeVideoRedundancy)(redundancyModel); } else { yield this.extendsRedundancy(redundancyModel); @@ -102,21 +102,21 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { }); } extendsRedundancy(redundancyModel) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const redundancy = config_1.CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy); if (!redundancy) { - yield redundancy_1.removeVideoRedundancy(redundancyModel); + yield (0, redundancy_1.removeVideoRedundancy)(redundancyModel); return; } yield this.extendsExpirationOf(redundancyModel, redundancy.minLifetime); }); } purgeRemoteExpired() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const expired = yield video_redundancy_1.VideoRedundancyModel.listRemoteExpired(); for (const redundancyModel of expired) { try { - yield redundancy_1.removeVideoRedundancy(redundancyModel); + yield (0, redundancy_1.removeVideoRedundancy)(redundancyModel); } catch (err) { logger_1.logger.error('Cannot remove redundancy %s from our redundancy system.', this.buildEntryLogId(redundancyModel), lTags(redundancyModel.getVideoUUID())); @@ -137,7 +137,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { } } createVideoRedundancies(data) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield this.loadAndRefreshVideo(data.video.url); if (!video) { logger_1.logger.info('Video %s we want to duplicate does not existing anymore, skipping.', data.video.url, lTags(data.video.uuid)); @@ -162,7 +162,7 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { }); } createVideoFileRedundancy(redundancy, video, fileArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let strategy = 'manual'; let expiresOn = null; if (redundancy) { @@ -171,26 +171,26 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { } const file = fileArg; file.Video = video; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); logger_1.logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy, lTags(video.uuid)); - const tmpPath = yield webtorrent_1.downloadWebTorrentVideo({ uri: file.torrentUrl }, constants_1.VIDEO_IMPORT_TIMEOUT); - const destPath = path_1.join(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, file.filename); - yield fs_extra_1.move(tmpPath, destPath, { overwrite: true }); + const tmpPath = yield (0, webtorrent_1.downloadWebTorrentVideo)({ uri: file.torrentUrl }, constants_1.VIDEO_IMPORT_TIMEOUT); + const destPath = (0, path_1.join)(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, file.filename); + yield (0, fs_extra_1.move)(tmpPath, destPath, { overwrite: true }); const createdModel = yield video_redundancy_1.VideoRedundancyModel.create({ expiresOn, - url: url_1.getLocalVideoCacheFileActivityPubUrl(file), - fileUrl: video_urls_1.generateWebTorrentRedundancyUrl(file), + url: (0, url_1.getLocalVideoCacheFileActivityPubUrl)(file), + fileUrl: (0, video_urls_1.generateWebTorrentRedundancyUrl)(file), strategy, videoFileId: file.id, actorId: serverActor.id }); createdModel.VideoFile = file; - yield send_1.sendCreateCacheFile(serverActor, video, createdModel); + yield (0, send_1.sendCreateCacheFile)(serverActor, video, createdModel); logger_1.logger.info('Duplicated %s - %d -> %s.', video.url, file.resolution, createdModel.url, lTags(video.uuid)); }); } createStreamingPlaylistRedundancy(redundancy, video, playlistArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let strategy = 'manual'; let expiresOn = null; if (redundancy) { @@ -198,37 +198,37 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { expiresOn = this.buildNewExpiration(redundancy.minLifetime); } const playlist = Object.assign(playlistArg, { Video: video }); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); logger_1.logger.info('Duplicating %s streaming playlist in videos redundancy with "%s" strategy.', video.url, strategy, lTags(video.uuid)); - const destDirectory = path_1.join(constants_1.HLS_REDUNDANCY_DIRECTORY, video.uuid); + const destDirectory = (0, path_1.join)(constants_1.HLS_REDUNDANCY_DIRECTORY, video.uuid); const masterPlaylistUrl = playlist.getMasterPlaylistUrl(video); const maxSizeKB = this.getTotalFileSizes([], [playlist]) / 1000; const toleranceKB = maxSizeKB + ((5 * maxSizeKB) / 100); - yield hls_1.downloadPlaylistSegments(masterPlaylistUrl, destDirectory, constants_1.VIDEO_IMPORT_TIMEOUT, toleranceKB); + yield (0, hls_1.downloadPlaylistSegments)(masterPlaylistUrl, destDirectory, constants_1.VIDEO_IMPORT_TIMEOUT, toleranceKB); const createdModel = yield video_redundancy_1.VideoRedundancyModel.create({ expiresOn, - url: url_1.getLocalVideoCacheStreamingPlaylistActivityPubUrl(video, playlist), - fileUrl: video_urls_1.generateHLSRedundancyUrl(video, playlistArg), + url: (0, url_1.getLocalVideoCacheStreamingPlaylistActivityPubUrl)(video, playlist), + fileUrl: (0, video_urls_1.generateHLSRedundancyUrl)(video, playlistArg), strategy, videoStreamingPlaylistId: playlist.id, actorId: serverActor.id }); createdModel.VideoStreamingPlaylist = playlist; - yield send_1.sendCreateCacheFile(serverActor, video, createdModel); + yield (0, send_1.sendCreateCacheFile)(serverActor, video, createdModel); logger_1.logger.info('Duplicated playlist %s -> %s.', masterPlaylistUrl, createdModel.url, lTags(video.uuid)); }); } extendsExpirationOf(redundancy, expiresAfterMs) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Extending expiration of %s.', redundancy.url, lTags(redundancy.getVideoUUID())); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); redundancy.expiresOn = this.buildNewExpiration(expiresAfterMs); yield redundancy.save(); - yield send_1.sendUpdateCacheFile(serverActor, redundancy); + yield (0, send_1.sendUpdateCacheFile)(serverActor, redundancy); }); } purgeCacheIfNeeded(candidateToDuplicate) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { while (yield this.isTooHeavy(candidateToDuplicate)) { const redundancy = candidateToDuplicate.redundancy; const toDelete = yield video_redundancy_1.VideoRedundancyModel.loadOldestLocalExpired(redundancy.strategy, redundancy.minLifetime); @@ -239,13 +239,13 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { : toDelete.VideoStreamingPlaylist.videoId; const redundancies = yield video_redundancy_1.VideoRedundancyModel.listLocalByVideoId(videoId); for (const redundancy of redundancies) { - yield redundancy_1.removeVideoRedundancy(redundancy); + yield (0, redundancy_1.removeVideoRedundancy)(redundancy); } } }); } isTooHeavy(candidateToDuplicate) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const maxSize = candidateToDuplicate.redundancy.size; const { totalUsed: alreadyUsed } = yield video_redundancy_1.VideoRedundancyModel.getStats(candidateToDuplicate.redundancy.strategy); const videoSize = this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists); @@ -271,13 +271,13 @@ class VideosRedundancyScheduler extends abstract_scheduler_1.AbstractScheduler { return allFiles.reduce(fileReducer, 0); } loadAndRefreshVideo(videoUrl) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const getVideoOptions = { videoObject: videoUrl, syncParam: { likes: false, dislikes: false, shares: false, comments: false, thumbnail: false, refreshVideo: true }, fetchType: 'all' }; - const { video } = yield videos_1.getOrCreateAPVideo(getVideoOptions); + const { video } = yield (0, videos_1.getOrCreateAPVideo)(getVideoOptions); return video; }); } diff --git a/dist/server/lib/search.js b/dist/server/lib/search.js index a4eeab7b..acdcefef 100644 --- a/dist/server/lib/search.js +++ b/dist/server/lib/search.js @@ -20,8 +20,8 @@ function isSearchIndexSearch(query) { } exports.isSearchIndexSearch = isSearchIndexSearch; function buildMutedForSearchIndex(res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const accountIds = [serverActor.Account.id]; if (res.locals.oauth) { accountIds.push(res.locals.oauth.token.User.Account.id); diff --git a/dist/server/lib/server-config-manager.js b/dist/server/lib/server-config-manager.js index 0f45c6c9..90e820e3 100644 --- a/dist/server/lib/server-config-manager.js +++ b/dist/server/lib/server-config-manager.js @@ -16,7 +16,7 @@ class ServerConfigManager { this.homepageEnabled = false; } init() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const instanceHomepage = yield actor_custom_page_1.ActorCustomPageModel.loadInstanceHomepage(); this.updateHomepageState(instanceHomepage === null || instanceHomepage === void 0 ? void 0 : instanceHomepage.content); }); @@ -25,10 +25,10 @@ class ServerConfigManager { this.homepageEnabled = !!content; } getHTMLServerConfig() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.serverCommit === undefined) - this.serverCommit = yield utils_1.getServerCommit(); - const defaultTheme = theme_utils_1.getThemeOrDefault(config_1.CONFIG.THEME.DEFAULT, constants_1.DEFAULT_THEME_NAME); + this.serverCommit = yield (0, utils_1.getServerCommit)(); + const defaultTheme = (0, theme_utils_1.getThemeOrDefault)(config_1.CONFIG.THEME.DEFAULT, constants_1.DEFAULT_THEME_NAME); return { instance: { name: config_1.CONFIG.INSTANCE.NAME, @@ -63,7 +63,7 @@ class ServerConfigManager { default: defaultTheme }, email: { - enabled: config_1.isEmailEnabled() + enabled: (0, config_1.isEmailEnabled)() }, contactForm: { enabled: config_1.CONFIG.CONTACT_FORM.ENABLED @@ -185,11 +185,11 @@ class ServerConfigManager { }); } getServerConfig(ip) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { allowed } = yield hooks_1.Hooks.wrapPromiseFun(signup_1.isSignupAllowed, { ip }, 'filter:api.user.signup.allowed.result'); - const allowedForCurrentIP = signup_1.isSignupAllowedForCurrentIP(ip); + const allowedForCurrentIP = (0, signup_1.isSignupAllowedForCurrentIP)(ip); const signup = { allowed, allowedForCurrentIP, diff --git a/dist/server/lib/signup.js b/dist/server/lib/signup.js index 2bb48b81..554ae3ff 100644 --- a/dist/server/lib/signup.js +++ b/dist/server/lib/signup.js @@ -7,7 +7,7 @@ const config_1 = require("../initializers/config"); const user_1 = require("../models/user/user"); const isCidr = require('is-cidr'); function isSignupAllowed() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (config_1.CONFIG.SIGNUP.ENABLED === false) { return { allowed: false }; } @@ -22,7 +22,7 @@ exports.isSignupAllowed = isSignupAllowed; function isSignupAllowedForCurrentIP(ip) { if (!ip) return false; - const addr = ipaddr_js_1.parse(ip); + const addr = (0, ipaddr_js_1.parse)(ip); const excludeList = ['blacklist']; let matched = ''; if (config_1.CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr(cidr)).length > 0) { @@ -36,7 +36,7 @@ function isSignupAllowedForCurrentIP(ip) { blacklist: config_1.CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) .map(cidr => ipaddr_js_1.IPv4.parseCIDR(cidr)) }; - matched = ipaddr_js_1.subnetMatch(addrV4, rangeList, 'unknown'); + matched = (0, ipaddr_js_1.subnetMatch)(addrV4, rangeList, 'unknown'); } else if (addr.kind() === 'ipv6') { const addrV6 = ipaddr_js_1.IPv6.parse(ip); @@ -46,7 +46,7 @@ function isSignupAllowedForCurrentIP(ip) { blacklist: config_1.CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) .map(cidr => ipaddr_js_1.IPv6.parseCIDR(cidr)) }; - matched = ipaddr_js_1.subnetMatch(addrV6, rangeList, 'unknown'); + matched = (0, ipaddr_js_1.subnetMatch)(addrV6, rangeList, 'unknown'); } return !excludeList.includes(matched); } diff --git a/dist/server/lib/stat-manager.js b/dist/server/lib/stat-manager.js index e5facf4b..238152d4 100644 --- a/dist/server/lib/stat-manager.js +++ b/dist/server/lib/stat-manager.js @@ -41,7 +41,7 @@ class StatsManager { this.inboxMessages.errorsPerType[type]++; } getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { totalLocalVideos, totalLocalVideoViews, totalVideos } = yield video_1.VideoModel.getStats(); const { totalLocalVideoComments, totalVideoComments } = yield video_comment_1.VideoCommentModel.getStats(); const { totalUsers, totalDailyActiveUsers, totalWeeklyActiveUsers, totalMonthlyActiveUsers } = yield user_1.UserModel.getStats(); @@ -72,7 +72,7 @@ class StatsManager { }); } getPerformanceStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const waitTranscodingJobs = yield job_queue_1.JobQueue.Instance.count("waiting", "video-transcoding"); const failTranscodingJobs = yield job_queue_1.JobQueue.Instance.count("failed", "video-transcoding"); const waitImportsCount = yield job_queue_1.JobQueue.Instance.count("waiting", "video-import"); @@ -127,7 +127,7 @@ class StatsManager { size: r.size })); strategies.push({ strategy: "manual", size: null }); - return bluebird_1.mapSeries(strategies, (r) => { + return (0, bluebird_1.mapSeries)(strategies, (r) => { return video_redundancy_1.VideoRedundancyModel.getStats(r.strategy).then((stats) => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })); }); } diff --git a/dist/server/lib/thumbnail.js b/dist/server/lib/thumbnail.js index b50e5cd1..bae3995a 100644 --- a/dist/server/lib/thumbnail.js +++ b/dist/server/lib/thumbnail.js @@ -14,7 +14,7 @@ function updatePlaylistMiniatureFromExisting(options) { const { inputPath, playlist, automaticallyGenerated, keepOriginal = false, size } = options; const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size); const type = 1; - const thumbnailCreator = () => image_utils_1.processImage(inputPath, outputPath, { width, height }, keepOriginal); + const thumbnailCreator = () => (0, image_utils_1.processImage)(inputPath, outputPath, { width, height }, keepOriginal); return updateThumbnailFromFunction({ thumbnailCreator, filename, @@ -33,7 +33,7 @@ function updatePlaylistMiniatureFromUrl(options) { const fileUrl = playlist.isOwned() ? null : downloadUrl; - const thumbnailCreator = () => requests_1.downloadImage(downloadUrl, basePath, filename, { width, height }); + const thumbnailCreator = () => (0, requests_1.downloadImage)(downloadUrl, basePath, filename, { width, height }); return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }); } exports.updatePlaylistMiniatureFromUrl = updatePlaylistMiniatureFromUrl; @@ -49,7 +49,7 @@ function updateVideoMiniatureFromUrl(options) { : existingThumbnail.filename; const thumbnailCreator = () => { if (thumbnailUrlChanged) - return requests_1.downloadImage(downloadUrl, basePath, filename, { width, height }); + return (0, requests_1.downloadImage)(downloadUrl, basePath, filename, { width, height }); return Promise.resolve(); }; return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }); @@ -58,7 +58,7 @@ exports.updateVideoMiniatureFromUrl = updateVideoMiniatureFromUrl; function updateVideoMiniatureFromExisting(options) { const { inputPath, video, type, automaticallyGenerated, size, keepOriginal = false } = options; const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size); - const thumbnailCreator = () => image_utils_1.processImage(inputPath, outputPath, { width, height }, keepOriginal); + const thumbnailCreator = () => (0, image_utils_1.processImage)(inputPath, outputPath, { width, height }, keepOriginal); return updateThumbnailFromFunction({ thumbnailCreator, filename, @@ -77,8 +77,8 @@ function generateVideoMiniature(options) { const { filename, basePath, existingThumbnail, outputPath } = videoMeta; const { height, width } = size || videoMeta; const thumbnailCreator = videoFile.isAudio() - ? () => image_utils_1.processImage(constants_1.ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) - : () => ffmpeg_utils_1.generateImageFromVideoFile(input, basePath, filename, { height, width }); + ? () => (0, image_utils_1.processImage)(constants_1.ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) + : () => (0, ffmpeg_utils_1.generateImageFromVideoFile)(input, basePath, filename, { height, width }); return updateThumbnailFromFunction({ thumbnailCreator, filename, @@ -120,7 +120,7 @@ function buildMetadataFromPlaylist(playlist, size) { filename, basePath, existingThumbnail: playlist.Thumbnail, - outputPath: path_1.join(basePath, filename), + outputPath: (0, path_1.join)(basePath, filename), height: size ? size.height : constants_1.THUMBNAILS_SIZE.height, width: size ? size.width : constants_1.THUMBNAILS_SIZE.width }; @@ -130,25 +130,25 @@ function buildMetadataFromVideo(video, type, size) { ? video.Thumbnails.find(t => t.type === type) : undefined; if (type === 1) { - const filename = image_utils_1.generateImageFilename(); + const filename = (0, image_utils_1.generateImageFilename)(); const basePath = config_1.CONFIG.STORAGE.THUMBNAILS_DIR; return { filename, basePath, existingThumbnail, - outputPath: path_1.join(basePath, filename), + outputPath: (0, path_1.join)(basePath, filename), height: size ? size.height : constants_1.THUMBNAILS_SIZE.height, width: size ? size.width : constants_1.THUMBNAILS_SIZE.width }; } if (type === 2) { - const filename = image_utils_1.generateImageFilename(); + const filename = (0, image_utils_1.generateImageFilename)(); const basePath = config_1.CONFIG.STORAGE.PREVIEWS_DIR; return { filename, basePath, existingThumbnail, - outputPath: path_1.join(basePath, filename), + outputPath: (0, path_1.join)(basePath, filename), height: size ? size.height : constants_1.PREVIEWS_SIZE.height, width: size ? size.width : constants_1.PREVIEWS_SIZE.width }; @@ -156,7 +156,7 @@ function buildMetadataFromVideo(video, type, size) { return undefined; } function updateThumbnailFromFunction(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { thumbnailCreator, filename, width, height, type, existingThumbnail, automaticallyGenerated = null, fileUrl = null } = parameters; const oldFilename = existingThumbnail && existingThumbnail.filename !== filename ? existingThumbnail.filename diff --git a/dist/server/lib/transcoding/video-transcoding-profiles.js b/dist/server/lib/transcoding/video-transcoding-profiles.js index 7e14338c..1e16d8bf 100644 --- a/dist/server/lib/transcoding/video-transcoding-profiles.js +++ b/dist/server/lib/transcoding/video-transcoding-profiles.js @@ -10,7 +10,7 @@ const defaultX264VODOptionsBuilder = (options) => { const { fps, inputRatio, inputBitrate } = options; if (!fps) return { outputOptions: [] }; - const targetBitrate = capBitrate(inputBitrate, core_utils_1.getAverageBitrate(Object.assign(Object.assign({}, options), { fps, ratio: inputRatio }))); + const targetBitrate = capBitrate(inputBitrate, (0, core_utils_1.getAverageBitrate)(Object.assign(Object.assign({}, options), { fps, ratio: inputRatio }))); return { outputOptions: [ `-preset veryfast`, @@ -22,35 +22,35 @@ const defaultX264VODOptionsBuilder = (options) => { }; const defaultX264LiveOptionsBuilder = (options) => { const { streamNum, fps, inputBitrate, inputRatio } = options; - const targetBitrate = capBitrate(inputBitrate, core_utils_1.getAverageBitrate(Object.assign(Object.assign({}, options), { fps, ratio: inputRatio }))); + const targetBitrate = capBitrate(inputBitrate, (0, core_utils_1.getAverageBitrate)(Object.assign(Object.assign({}, options), { fps, ratio: inputRatio }))); return { outputOptions: [ `-preset ultrafast`, - `${ffmpeg_utils_1.buildStreamSuffix('-r:v', streamNum)} ${fps}`, - `${ffmpeg_utils_1.buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`, + `${(0, ffmpeg_utils_1.buildStreamSuffix)('-r:v', streamNum)} ${fps}`, + `${(0, ffmpeg_utils_1.buildStreamSuffix)('-b:v', streamNum)} ${targetBitrate}`, `-maxrate ${targetBitrate}`, `-bufsize ${targetBitrate * 2}`, `-tune fastdecode` ] }; }; -const defaultAACOptionsBuilder = ({ input, streamNum }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { - const probe = yield ffprobe_utils_1.ffprobePromise(input); - if (yield ffprobe_utils_1.canDoQuickAudioTranscode(input, probe)) { +const defaultAACOptionsBuilder = ({ input, streamNum }) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(input); + if (yield (0, ffprobe_utils_1.canDoQuickAudioTranscode)(input, probe)) { logger_1.logger.debug('Copy audio stream %s by AAC encoder.', input); return { copy: true, outputOptions: [] }; } - const parsedAudio = yield ffprobe_utils_1.getAudioStream(input, probe); + const parsedAudio = yield (0, ffprobe_utils_1.getAudioStream)(input, probe); const audioCodecName = parsedAudio.audioStream['codec_name']; - const bitrate = ffprobe_utils_1.getMaxAudioBitrate(audioCodecName, parsedAudio.bitrate); + const bitrate = (0, ffprobe_utils_1.getMaxAudioBitrate)(audioCodecName, parsedAudio.bitrate); logger_1.logger.debug('Calculating audio bitrate of %s by AAC encoder.', input, { bitrate: parsedAudio.bitrate, audioCodecName }); if (bitrate !== undefined && bitrate !== -1) { - return { outputOptions: [ffmpeg_utils_1.buildStreamSuffix('-b:a', streamNum), bitrate + 'k'] }; + return { outputOptions: [(0, ffmpeg_utils_1.buildStreamSuffix)('-b:a', streamNum), bitrate + 'k'] }; } return { outputOptions: [] }; }); const defaultLibFDKAACVODOptionsBuilder = ({ streamNum }) => { - return { outputOptions: [ffmpeg_utils_1.buildStreamSuffix('-q:a', streamNum), '5'] }; + return { outputOptions: [(0, ffmpeg_utils_1.buildStreamSuffix)('-q:a', streamNum), '5'] }; }; class VideoTranscodingProfilesManager { constructor() { @@ -118,12 +118,12 @@ class VideoTranscodingProfilesManager { } addEncoderPriority(type, streamType, encoder, priority) { this.encodersPriorities[type][streamType].push({ name: encoder, priority }); - ffmpeg_utils_1.resetSupportedEncoders(); + (0, ffmpeg_utils_1.resetSupportedEncoders)(); } removeEncoderPriority(type, streamType, encoder, priority) { this.encodersPriorities[type][streamType] = this.encodersPriorities[type][streamType] .filter(o => o.name !== encoder && o.priority !== priority); - ffmpeg_utils_1.resetSupportedEncoders(); + (0, ffmpeg_utils_1.resetSupportedEncoders)(); } getEncodersByPriority(type, streamType) { return this.encodersPriorities[type][streamType] diff --git a/dist/server/lib/transcoding/video-transcoding.js b/dist/server/lib/transcoding/video-transcoding.js index 0e2b42ce..e314057a 100644 --- a/dist/server/lib/transcoding/video-transcoding.js +++ b/dist/server/lib/transcoding/video-transcoding.js @@ -19,12 +19,12 @@ const video_transcoding_profiles_1 = require("./video-transcoding-profiles"); function optimizeOriginalVideofile(video, inputVideoFile, job) { const transcodeDirectory = config_1.CONFIG.STORAGE.TMP_DIR; const newExtname = '.mp4'; - return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, inputVideoFile, (videoInputPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoTranscodedPath = path_1.join(transcodeDirectory, video.id + '-transcoded' + newExtname); - const transcodeType = (yield ffprobe_utils_1.canDoQuickTranscode(videoInputPath)) + return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, inputVideoFile, (videoInputPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoTranscodedPath = (0, path_1.join)(transcodeDirectory, video.id + '-transcoded' + newExtname); + const transcodeType = (yield (0, ffprobe_utils_1.canDoQuickTranscode)(videoInputPath)) ? 'quick-transcode' : 'video'; - const resolution = core_utils_1.toEven(inputVideoFile.resolution); + const resolution = (0, core_utils_1.toEven)(inputVideoFile.resolution); const transcodeOptions = { type: transcodeType, inputPath: videoInputPath, @@ -34,13 +34,13 @@ function optimizeOriginalVideofile(video, inputVideoFile, job) { resolution, job }; - yield ffmpeg_utils_1.transcode(transcodeOptions); + yield (0, ffmpeg_utils_1.transcode)(transcodeOptions); inputVideoFile.extname = newExtname; - inputVideoFile.filename = paths_1.generateWebTorrentVideoFilename(resolution, newExtname); + inputVideoFile.filename = (0, paths_1.generateWebTorrentVideoFilename)(resolution, newExtname); inputVideoFile.storage = 0; const videoOutputPath = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(video, inputVideoFile); const { videoFile } = yield onWebTorrentVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath); - yield fs_extra_1.remove(videoInputPath); + yield (0, fs_extra_1.remove)(videoInputPath); return { transcodeType, videoFile }; })); } @@ -48,16 +48,16 @@ exports.optimizeOriginalVideofile = optimizeOriginalVideofile; function transcodeNewWebTorrentResolution(video, resolution, isPortrait, job) { const transcodeDirectory = config_1.CONFIG.STORAGE.TMP_DIR; const extname = '.mp4'; - return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, video.getMaxQualityFile(), (videoInputPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, video.getMaxQualityFile(), (videoInputPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newVideoFile = new video_file_1.VideoFileModel({ resolution, extname, - filename: paths_1.generateWebTorrentVideoFilename(resolution, extname), + filename: (0, paths_1.generateWebTorrentVideoFilename)(resolution, extname), size: 0, videoId: video.id }); const videoOutputPath = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(video, newVideoFile); - const videoTranscodedPath = path_1.join(transcodeDirectory, newVideoFile.filename); + const videoTranscodedPath = (0, path_1.join)(transcodeDirectory, newVideoFile.filename); const transcodeOptions = resolution === 0 ? { type: 'only-audio', @@ -78,7 +78,7 @@ function transcodeNewWebTorrentResolution(video, resolution, isPortrait, job) { isPortraitMode: isPortrait, job }; - yield ffmpeg_utils_1.transcode(transcodeOptions); + yield (0, ffmpeg_utils_1.transcode)(transcodeOptions); return onWebTorrentVideoFileTranscoding(video, newVideoFile, videoTranscodedPath, videoOutputPath); })); } @@ -87,11 +87,11 @@ function mergeAudioVideofile(video, resolution, job) { const transcodeDirectory = config_1.CONFIG.STORAGE.TMP_DIR; const newExtname = '.mp4'; const inputVideoFile = video.getMinQualityFile(); - return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, inputVideoFile, (audioInputPath) => tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoTranscodedPath = path_1.join(transcodeDirectory, video.id + '-transcoded' + newExtname); + return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(video, inputVideoFile, (audioInputPath) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoTranscodedPath = (0, path_1.join)(transcodeDirectory, video.id + '-transcoded' + newExtname); const previewPath = video.getPreview().getPath(); - const tmpPreviewPath = path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, path_1.basename(previewPath)); - yield fs_extra_1.copyFile(previewPath, tmpPreviewPath); + const tmpPreviewPath = (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, (0, path_1.basename)(previewPath)); + yield (0, fs_extra_1.copyFile)(previewPath, tmpPreviewPath); const transcodeOptions = { type: 'merge-audio', inputPath: tmpPreviewPath, @@ -103,25 +103,25 @@ function mergeAudioVideofile(video, resolution, job) { job }; try { - yield ffmpeg_utils_1.transcode(transcodeOptions); - yield fs_extra_1.remove(audioInputPath); - yield fs_extra_1.remove(tmpPreviewPath); + yield (0, ffmpeg_utils_1.transcode)(transcodeOptions); + yield (0, fs_extra_1.remove)(audioInputPath); + yield (0, fs_extra_1.remove)(tmpPreviewPath); } catch (err) { - yield fs_extra_1.remove(tmpPreviewPath); + yield (0, fs_extra_1.remove)(tmpPreviewPath); throw err; } inputVideoFile.extname = newExtname; - inputVideoFile.filename = paths_1.generateWebTorrentVideoFilename(inputVideoFile.resolution, newExtname); + inputVideoFile.filename = (0, paths_1.generateWebTorrentVideoFilename)(inputVideoFile.resolution, newExtname); const videoOutputPath = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(video, inputVideoFile); - video.duration = yield ffprobe_utils_1.getDurationFromVideoFile(videoTranscodedPath); + video.duration = yield (0, ffprobe_utils_1.getDurationFromVideoFile)(videoTranscodedPath); yield video.save(); return onWebTorrentVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath); })); } exports.mergeAudioVideofile = mergeAudioVideofile; function generateHlsPlaylistResolutionFromTS(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return generateHlsPlaylistCommon({ video: options.video, resolution: options.resolution, @@ -146,29 +146,29 @@ function generateHlsPlaylistResolution(options) { } exports.generateHlsPlaylistResolution = generateHlsPlaylistResolution; function onWebTorrentVideoFileTranscoding(video, videoFile, transcodingPath, outputPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const stats = yield fs_extra_1.stat(transcodingPath); - const fps = yield ffprobe_utils_1.getVideoFileFPS(transcodingPath); - const metadata = yield ffprobe_utils_1.getMetadataFromFile(transcodingPath); - yield fs_extra_1.move(transcodingPath, outputPath, { overwrite: true }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const stats = yield (0, fs_extra_1.stat)(transcodingPath); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(transcodingPath); + const metadata = yield (0, ffprobe_utils_1.getMetadataFromFile)(transcodingPath); + yield (0, fs_extra_1.move)(transcodingPath, outputPath, { overwrite: true }); videoFile.size = stats.size; videoFile.fps = fps; videoFile.metadata = metadata; - yield webtorrent_1.createTorrentAndSetInfoHash(video, videoFile); + yield (0, webtorrent_1.createTorrentAndSetInfoHash)(video, videoFile); yield video_file_1.VideoFileModel.customUpsert(videoFile, 'video', undefined); video.VideoFiles = yield video.$get('VideoFiles'); return { video, videoFile }; }); } function generateHlsPlaylistCommon(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { type, video, inputPath, resolution, copyCodecs, isPortraitMode, isAAC, job } = options; const transcodeDirectory = config_1.CONFIG.STORAGE.TMP_DIR; - const videoTranscodedBasePath = path_1.join(transcodeDirectory, type); - yield fs_extra_1.ensureDir(videoTranscodedBasePath); - const videoFilename = paths_1.generateHLSVideoFilename(resolution); - const resolutionPlaylistFilename = paths_1.getHlsResolutionPlaylistFilename(videoFilename); - const resolutionPlaylistFileTranscodePath = path_1.join(videoTranscodedBasePath, resolutionPlaylistFilename); + const videoTranscodedBasePath = (0, path_1.join)(transcodeDirectory, type); + yield (0, fs_extra_1.ensureDir)(videoTranscodedBasePath); + const videoFilename = (0, paths_1.generateHLSVideoFilename)(resolution); + const resolutionPlaylistFilename = (0, paths_1.getHlsResolutionPlaylistFilename)(videoFilename); + const resolutionPlaylistFileTranscodePath = (0, path_1.join)(videoTranscodedBasePath, resolutionPlaylistFilename); const transcodeOptions = { type, inputPath, @@ -184,19 +184,19 @@ function generateHlsPlaylistCommon(options) { }, job }; - yield ffmpeg_utils_1.transcode(transcodeOptions); + yield (0, ffmpeg_utils_1.transcode)(transcodeOptions); const playlist = yield video_streaming_playlist_1.VideoStreamingPlaylistModel.loadOrGenerate(video); if (!playlist.playlistFilename) { - playlist.playlistFilename = paths_1.generateHLSMasterPlaylistFilename(video.isLive); + playlist.playlistFilename = (0, paths_1.generateHLSMasterPlaylistFilename)(video.isLive); } if (!playlist.segmentsSha256Filename) { - playlist.segmentsSha256Filename = paths_1.generateHlsSha256SegmentsFilename(video.isLive); + playlist.segmentsSha256Filename = (0, paths_1.generateHlsSha256SegmentsFilename)(video.isLive); } playlist.p2pMediaLoaderInfohashes = []; playlist.p2pMediaLoaderPeerVersion = constants_1.P2P_MEDIA_LOADER_PEER_VERSION; playlist.type = 1; yield playlist.save(); - const extname = path_1.extname(videoFilename); + const extname = (0, path_1.extname)(videoFilename); const newVideoFile = new video_file_1.VideoFileModel({ resolution, extname, @@ -206,23 +206,23 @@ function generateHlsPlaylistCommon(options) { videoStreamingPlaylistId: playlist.id }); const videoFilePath = video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(playlist, newVideoFile); - yield fs_extra_1.ensureDir(video_path_manager_1.VideoPathManager.Instance.getFSHLSOutputPath(video)); + yield (0, fs_extra_1.ensureDir)(video_path_manager_1.VideoPathManager.Instance.getFSHLSOutputPath(video)); const resolutionPlaylistPath = video_path_manager_1.VideoPathManager.Instance.getFSHLSOutputPath(video, resolutionPlaylistFilename); - yield fs_extra_1.move(resolutionPlaylistFileTranscodePath, resolutionPlaylistPath, { overwrite: true }); - yield fs_extra_1.move(path_1.join(videoTranscodedBasePath, videoFilename), videoFilePath, { overwrite: true }); - const stats = yield fs_extra_1.stat(videoFilePath); + yield (0, fs_extra_1.move)(resolutionPlaylistFileTranscodePath, resolutionPlaylistPath, { overwrite: true }); + yield (0, fs_extra_1.move)((0, path_1.join)(videoTranscodedBasePath, videoFilename), videoFilePath, { overwrite: true }); + const stats = yield (0, fs_extra_1.stat)(videoFilePath); newVideoFile.size = stats.size; - newVideoFile.fps = yield ffprobe_utils_1.getVideoFileFPS(videoFilePath); - newVideoFile.metadata = yield ffprobe_utils_1.getMetadataFromFile(videoFilePath); - yield webtorrent_1.createTorrentAndSetInfoHash(playlist, newVideoFile); + newVideoFile.fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(videoFilePath); + newVideoFile.metadata = yield (0, ffprobe_utils_1.getMetadataFromFile)(videoFilePath); + yield (0, webtorrent_1.createTorrentAndSetInfoHash)(playlist, newVideoFile); const savedVideoFile = yield video_file_1.VideoFileModel.customUpsert(newVideoFile, 'streaming-playlist', undefined); const playlistWithFiles = playlist; playlistWithFiles.VideoFiles = yield playlist.$get('VideoFiles'); playlist.assignP2PMediaLoaderInfoHashes(video, playlistWithFiles.VideoFiles); yield playlist.save(); video.setHLSPlaylist(playlist); - yield hls_1.updateMasterHLSPlaylist(video, playlistWithFiles); - yield hls_1.updateSha256VODSegments(video, playlistWithFiles); + yield (0, hls_1.updateMasterHLSPlaylist)(video, playlistWithFiles); + yield (0, hls_1.updateSha256VODSegments)(video, playlistWithFiles); return { resolutionPlaylistPath, videoFile: savedVideoFile }; }); } diff --git a/dist/server/lib/user.js b/dist/server/lib/user.js index ed0aa980..a677f20f 100644 --- a/dist/server/lib/user.js +++ b/dist/server/lib/user.js @@ -18,9 +18,9 @@ const redis_1 = require("./redis"); const video_channel_1 = require("./video-channel"); const video_playlist_1 = require("./video-playlist"); function createUserAccountAndChannelAndPlaylist(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { userToCreate, userDisplayName, channelNames, validateUser = true } = parameters; - const { user, account, videoChannel } = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + const { user, account, videoChannel } = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const userOptions = { transaction: t, validate: validateUser @@ -36,13 +36,13 @@ function createUserAccountAndChannelAndPlaylist(parameters) { }); userCreated.Account = accountCreated; const channelAttributes = yield buildChannelAttributes(userCreated, t, channelNames); - const videoChannel = yield video_channel_1.createLocalVideoChannel(channelAttributes, accountCreated, t); - const videoPlaylist = yield video_playlist_1.createWatchLaterPlaylist(accountCreated, t); + const videoChannel = yield (0, video_channel_1.createLocalVideoChannel)(channelAttributes, accountCreated, t); + const videoPlaylist = yield (0, video_playlist_1.createWatchLaterPlaylist)(accountCreated, t); return { user: userCreated, account: accountCreated, videoChannel, videoPlaylist }; })); const [accountActorWithKeys, channelActorWithKeys] = yield Promise.all([ - actors_1.generateAndSaveActorKeys(account.Actor), - actors_1.generateAndSaveActorKeys(videoChannel.Actor) + (0, actors_1.generateAndSaveActorKeys)(account.Actor), + (0, actors_1.generateAndSaveActorKeys)(videoChannel.Actor) ]); account.Actor = accountActorWithKeys; videoChannel.Actor = channelActorWithKeys; @@ -51,10 +51,10 @@ function createUserAccountAndChannelAndPlaylist(parameters) { } exports.createUserAccountAndChannelAndPlaylist = createUserAccountAndChannelAndPlaylist; function createLocalAccountWithoutKeys(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { name, displayName, userId, applicationId, t, type = 'Person' } = parameters; - const url = url_1.getLocalAccountActivityPubUrl(name); - const actorInstance = local_actor_1.buildActorInstance(type, url, name); + const url = (0, url_1.getLocalAccountActivityPubUrl)(name); + const actorInstance = (0, local_actor_1.buildActorInstance)(type, url, name); const actorInstanceCreated = yield actorInstance.save({ transaction: t }); const accountInstance = new account_1.AccountModel({ name: displayName || name, @@ -69,7 +69,7 @@ function createLocalAccountWithoutKeys(parameters) { } exports.createLocalAccountWithoutKeys = createLocalAccountWithoutKeys; function createApplicationActor(applicationId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountCreated = yield createLocalAccountWithoutKeys({ name: constants_1.SERVER_ACTOR_NAME, userId: null, @@ -77,13 +77,13 @@ function createApplicationActor(applicationId) { t: undefined, type: 'Application' }); - accountCreated.Actor = yield actors_1.generateAndSaveActorKeys(accountCreated.Actor); + accountCreated.Actor = yield (0, actors_1.generateAndSaveActorKeys)(accountCreated.Actor); return accountCreated; }); } exports.createApplicationActor = createApplicationActor; function sendVerifyUserEmail(user, isPendingEmail = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const verificationString = yield redis_1.Redis.Instance.setVerifyEmailVerificationString(user.id); let url = constants_1.WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString; if (isPendingEmail) @@ -95,7 +95,7 @@ function sendVerifyUserEmail(user, isPendingEmail = false) { } exports.sendVerifyUserEmail = sendVerifyUserEmail; function getOriginalVideoFileTotalFromUser(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = user_1.UserModel.generateUserQuotaBaseSQL({ withSelect: true, whereUserId: '$userId' @@ -106,7 +106,7 @@ function getOriginalVideoFileTotalFromUser(user) { } exports.getOriginalVideoFileTotalFromUser = getOriginalVideoFileTotalFromUser; function getOriginalVideoFileTotalDailyFromUser(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = user_1.UserModel.generateUserQuotaBaseSQL({ withSelect: true, whereUserId: '$userId', @@ -118,7 +118,7 @@ function getOriginalVideoFileTotalDailyFromUser(user) { } exports.getOriginalVideoFileTotalDailyFromUser = getOriginalVideoFileTotalDailyFromUser; function isAbleToUploadVideo(userId, newVideoSize) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield user_1.UserModel.loadById(userId); if (user.videoQuota === -1 && user.videoQuotaDaily === -1) return Promise.resolve(true); @@ -159,13 +159,13 @@ function createDefaultUserNotificationSettings(user, t) { return user_notification_setting_1.UserNotificationSettingModel.create(values, { transaction: t }); } function buildChannelAttributes(user, transaction, channelNames) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (channelNames) return channelNames; let channelName = user.username + '_channel'; const actor = yield actor_1.ActorModel.loadLocalByName(channelName, transaction); if (actor) - channelName = uuid_1.buildUUID(); + channelName = (0, uuid_1.buildUUID)(); const videoChannelDisplayName = `Main ${user.username} channel`; return { name: channelName, diff --git a/dist/server/lib/video-blacklist.js b/dist/server/lib/video-blacklist.js index 3e12deb4..fbff2d76 100644 --- a/dist/server/lib/video-blacklist.js +++ b/dist/server/lib/video-blacklist.js @@ -12,9 +12,9 @@ const videos_1 = require("./activitypub/videos"); const live_manager_1 = require("./live/live-manager"); const notifier_1 = require("./notifier"); const hooks_1 = require("./plugins/hooks"); -const lTags = logger_1.loggerTagsFactory('blacklist'); +const lTags = (0, logger_1.loggerTagsFactory)('blacklist'); function autoBlacklistVideoIfNeeded(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, user, isRemote, isNew, notify = true, transaction } = parameters; const doAutoBlacklist = yield hooks_1.Hooks.wrapFun(autoBlacklistNeeded, { video, user, isRemote, isNew }, 'filter:video.auto-blacklist.result'); if (!doAutoBlacklist) @@ -35,7 +35,7 @@ function autoBlacklistVideoIfNeeded(parameters) { video.VideoBlacklist = videoBlacklist; videoBlacklist.Video = video; if (notify) { - database_utils_1.afterCommitIfTransaction(transaction, () => { + (0, database_utils_1.afterCommitIfTransaction)(transaction, () => { notifier_1.Notifier.Instance.notifyOnVideoAutoBlacklist(videoBlacklist); }); } @@ -45,7 +45,7 @@ function autoBlacklistVideoIfNeeded(parameters) { } exports.autoBlacklistVideoIfNeeded = autoBlacklistVideoIfNeeded; function blacklistVideo(videoInstance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const blacklist = yield video_blacklist_1.VideoBlacklistModel.create({ videoId: videoInstance.id, unfederated: options.unfederate === true, @@ -54,7 +54,7 @@ function blacklistVideo(videoInstance, options) { }); blacklist.Video = videoInstance; if (options.unfederate === true) { - yield send_1.sendDeleteVideo(videoInstance, undefined); + yield (0, send_1.sendDeleteVideo)(videoInstance, undefined); } if (videoInstance.isLive) { live_manager_1.LiveManager.Instance.stopSessionOf(videoInstance.id); @@ -64,14 +64,14 @@ function blacklistVideo(videoInstance, options) { } exports.blacklistVideo = blacklistVideo; function unblacklistVideo(videoBlacklist, video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoBlacklistType = yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoBlacklistType = yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const unfederated = videoBlacklist.unfederated; const videoBlacklistType = videoBlacklist.type; yield videoBlacklist.destroy({ transaction: t }); video.VideoBlacklist = undefined; if (unfederated === true) { - yield videos_1.federateVideoIfNeeded(video, true, t); + yield (0, videos_1.federateVideoIfNeeded)(video, true, t); } return videoBlacklistType; })); diff --git a/dist/server/lib/video-channel.js b/dist/server/lib/video-channel.js index 711fd2ce..77c41de0 100644 --- a/dist/server/lib/video-channel.js +++ b/dist/server/lib/video-channel.js @@ -8,9 +8,9 @@ const url_1 = require("./activitypub/url"); const videos_1 = require("./activitypub/videos"); const local_actor_1 = require("./local-actor"); function createLocalVideoChannel(videoChannelInfo, account, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const url = url_1.getLocalVideoChannelActivityPubUrl(videoChannelInfo.name); - const actorInstance = local_actor_1.buildActorInstance('Group', url, videoChannelInfo.name); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const url = (0, url_1.getLocalVideoChannelActivityPubUrl)(videoChannelInfo.name); + const actorInstance = (0, local_actor_1.buildActorInstance)('Group', url, videoChannelInfo.name); const actorInstanceCreated = yield actorInstance.save({ transaction: t }); const videoChannelData = { name: videoChannelInfo.displayName, @@ -28,11 +28,11 @@ function createLocalVideoChannel(videoChannelInfo, account, t) { } exports.createLocalVideoChannel = createLocalVideoChannel; function federateAllVideosOfChannel(videoChannel) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoIds = yield video_1.VideoModel.getAllIdsFromChannel(videoChannel); for (const videoId of videoIds) { const video = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(videoId); - yield videos_1.federateVideoIfNeeded(video, false); + yield (0, videos_1.federateVideoIfNeeded)(video, false); } }); } diff --git a/dist/server/lib/video-comment.js b/dist/server/lib/video-comment.js index ff03a844..37c84926 100644 --- a/dist/server/lib/video-comment.js +++ b/dist/server/lib/video-comment.js @@ -10,11 +10,11 @@ const send_1 = require("./activitypub/send"); const url_1 = require("./activitypub/url"); const hooks_1 = require("./plugins/hooks"); function removeComment(videoCommentInstance) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const videoCommentInstanceBefore = lodash_1.cloneDeep(videoCommentInstance); - yield database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const videoCommentInstanceBefore = (0, lodash_1.cloneDeep)(videoCommentInstance); + yield database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (videoCommentInstance.isOwned() || videoCommentInstance.Video.isOwned()) { - yield send_1.sendDeleteVideoComment(videoCommentInstance, t); + yield (0, send_1.sendDeleteVideoComment)(videoCommentInstance, t); } videoCommentInstance.markAsDeleted(); yield videoCommentInstance.save({ transaction: t }); @@ -25,7 +25,7 @@ function removeComment(videoCommentInstance) { } exports.removeComment = removeComment; function createVideoComment(obj, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let originCommentId = null; let inReplyToCommentId = null; if (obj.inReplyToComment && obj.inReplyToComment !== null) { @@ -40,12 +40,12 @@ function createVideoComment(obj, t) { accountId: obj.account.id, url: new Date().toISOString() }, { transaction: t, validate: false }); - comment.url = url_1.getLocalVideoCommentActivityPubUrl(obj.video, comment); + comment.url = (0, url_1.getLocalVideoCommentActivityPubUrl)(obj.video, comment); const savedComment = yield comment.save({ transaction: t }); savedComment.InReplyToVideoComment = obj.inReplyToComment; savedComment.Video = obj.video; savedComment.Account = obj.account; - yield send_1.sendCreateVideoComment(savedComment, t); + yield (0, send_1.sendCreateVideoComment)(savedComment, t); return savedComment; }); } diff --git a/dist/server/lib/video-path-manager.js b/dist/server/lib/video-path-manager.js index 500f5885..9961ee48 100644 --- a/dist/server/lib/video-path-manager.js +++ b/dist/server/lib/video-path-manager.js @@ -12,57 +12,57 @@ const paths_1 = require("./paths"); class VideoPathManager { constructor() { } getFSHLSOutputPath(video, filename) { - const base = paths_1.getHLSDirectory(video); + const base = (0, paths_1.getHLSDirectory)(video); if (!filename) return base; - return path_1.join(base, filename); + return (0, path_1.join)(base, filename); } getFSRedundancyVideoFilePath(videoOrPlaylist, videoFile) { if (videoFile.isHLS()) { - const video = video_1.extractVideo(videoOrPlaylist); - return path_1.join(paths_1.getHLSRedundancyDirectory(video), videoFile.filename); + const video = (0, video_1.extractVideo)(videoOrPlaylist); + return (0, path_1.join)((0, paths_1.getHLSRedundancyDirectory)(video), videoFile.filename); } - return path_1.join(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, videoFile.filename); + return (0, path_1.join)(config_1.CONFIG.STORAGE.REDUNDANCY_DIR, videoFile.filename); } getFSVideoFileOutputPath(videoOrPlaylist, videoFile) { if (videoFile.isHLS()) { - const video = video_1.extractVideo(videoOrPlaylist); - return path_1.join(paths_1.getHLSDirectory(video), videoFile.filename); + const video = (0, video_1.extractVideo)(videoOrPlaylist); + return (0, path_1.join)((0, paths_1.getHLSDirectory)(video), videoFile.filename); } - return path_1.join(config_1.CONFIG.STORAGE.VIDEOS_DIR, videoFile.filename); + return (0, path_1.join)(config_1.CONFIG.STORAGE.VIDEOS_DIR, videoFile.filename); } makeAvailableVideoFile(videoOrPlaylist, videoFile, cb) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (videoFile.storage === 0) { return this.makeAvailableFactory(() => this.getFSVideoFileOutputPath(videoOrPlaylist, videoFile), false, cb); } const destination = this.buildTMPDestination(videoFile.filename); if (videoFile.isHLS()) { - const video = video_1.extractVideo(videoOrPlaylist); - return this.makeAvailableFactory(() => object_storage_1.makeHLSFileAvailable(videoOrPlaylist, video, videoFile.filename, destination), true, cb); + const video = (0, video_1.extractVideo)(videoOrPlaylist); + return this.makeAvailableFactory(() => (0, object_storage_1.makeHLSFileAvailable)(videoOrPlaylist, video, videoFile.filename, destination), true, cb); } - return this.makeAvailableFactory(() => object_storage_1.makeWebTorrentFileAvailable(videoFile.filename, destination), true, cb); + return this.makeAvailableFactory(() => (0, object_storage_1.makeWebTorrentFileAvailable)(videoFile.filename, destination), true, cb); }); } makeAvailableResolutionPlaylistFile(playlist, videoFile, cb) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const filename = paths_1.getHlsResolutionPlaylistFilename(videoFile.filename); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const filename = (0, paths_1.getHlsResolutionPlaylistFilename)(videoFile.filename); if (videoFile.storage === 0) { - return this.makeAvailableFactory(() => path_1.join(paths_1.getHLSDirectory(playlist.Video), filename), false, cb); + return this.makeAvailableFactory(() => (0, path_1.join)((0, paths_1.getHLSDirectory)(playlist.Video), filename), false, cb); } - return this.makeAvailableFactory(() => object_storage_1.makeHLSFileAvailable(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), true, cb); + return this.makeAvailableFactory(() => (0, object_storage_1.makeHLSFileAvailable)(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), true, cb); }); } makeAvailablePlaylistFile(playlist, filename, cb) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (playlist.storage === 0) { - return this.makeAvailableFactory(() => path_1.join(paths_1.getHLSDirectory(playlist.Video), filename), false, cb); + return this.makeAvailableFactory(() => (0, path_1.join)((0, paths_1.getHLSDirectory)(playlist.Video), filename), false, cb); } - return this.makeAvailableFactory(() => object_storage_1.makeHLSFileAvailable(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), true, cb); + return this.makeAvailableFactory(() => (0, object_storage_1.makeHLSFileAvailable)(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), true, cb); }); } makeAvailableFactory(method, clean, cb) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let result; const destination = yield method(); try { @@ -70,16 +70,16 @@ class VideoPathManager { } catch (err) { if (destination && clean) - yield fs_extra_1.remove(destination); + yield (0, fs_extra_1.remove)(destination); throw err; } if (clean) - yield fs_extra_1.remove(destination); + yield (0, fs_extra_1.remove)(destination); return result; }); } buildTMPDestination(filename) { - return path_1.join(config_1.CONFIG.STORAGE.TMP_DIR, uuid_1.buildUUID() + path_1.extname(filename)); + return (0, path_1.join)(config_1.CONFIG.STORAGE.TMP_DIR, (0, uuid_1.buildUUID)() + (0, path_1.extname)(filename)); } static get Instance() { return this.instance || (this.instance = new this()); diff --git a/dist/server/lib/video-playlist.js b/dist/server/lib/video-playlist.js index 403b9bf2..d768d598 100644 --- a/dist/server/lib/video-playlist.js +++ b/dist/server/lib/video-playlist.js @@ -5,14 +5,14 @@ const tslib_1 = require("tslib"); const video_playlist_1 = require("../models/video/video-playlist"); const url_1 = require("./activitypub/url"); function createWatchLaterPlaylist(account, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoPlaylist = new video_playlist_1.VideoPlaylistModel({ name: 'Watch later', privacy: 3, type: 2, ownerAccountId: account.id }); - videoPlaylist.url = url_1.getLocalVideoPlaylistActivityPubUrl(videoPlaylist); + videoPlaylist.url = (0, url_1.getLocalVideoPlaylistActivityPubUrl)(videoPlaylist); yield videoPlaylist.save({ transaction: t }); videoPlaylist.OwnerAccount = account; return videoPlaylist; diff --git a/dist/server/lib/video-state.js b/dist/server/lib/video-state.js index 3d22bf30..19d32db5 100644 --- a/dist/server/lib/video-state.js +++ b/dist/server/lib/video-state.js @@ -27,12 +27,12 @@ function buildNextVideoState(currentState) { } exports.buildNextVideoState = buildNextVideoState; function moveToNextState(video, isNewVideo = true) { - return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return database_1.sequelizeTypescript.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoDatabase = yield video_1.VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t); if (!videoDatabase) return undefined; if (videoDatabase.state === 1) { - return videos_1.federateVideoIfNeeded(videoDatabase, false, t); + return (0, videos_1.federateVideoIfNeeded)(videoDatabase, false, t); } const newState = buildNextVideoState(videoDatabase.state); if (newState === 1) { @@ -45,11 +45,11 @@ function moveToNextState(video, isNewVideo = true) { } exports.moveToNextState = moveToNextState; function moveToPublishedState(video, isNewVideo, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.info('Publishing video %s.', video.uuid, { tags: [video.uuid] }); const previousState = video.state; yield video.setNewState(1, isNewVideo, transaction); - yield videos_1.federateVideoIfNeeded(video, isNewVideo, transaction); + yield (0, videos_1.federateVideoIfNeeded)(video, isNewVideo, transaction); if (isNewVideo) notifier_1.Notifier.Instance.notifyOnNewVideoIfNeeded(video); if (previousState === 2) { @@ -58,14 +58,14 @@ function moveToPublishedState(video, isNewVideo, transaction) { }); } function moveToExternalStorageState(video, isNewVideo, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoJobInfo = yield video_job_info_1.VideoJobInfoModel.load(video.id, transaction); const pendingTranscode = (videoJobInfo === null || videoJobInfo === void 0 ? void 0 : videoJobInfo.pendingTranscode) || 0; if (pendingTranscode !== 0) return; yield video.setNewState(6, isNewVideo, transaction); logger_1.logger.info('Creating external storage move job for video %s.', video.uuid, { tags: [video.uuid] }); - video_2.addMoveToObjectStorageJob(video, isNewVideo) + (0, video_2.addMoveToObjectStorageJob)(video, isNewVideo) .catch(err => logger_1.logger.error('Cannot add move to object storage job', { err })); }); } diff --git a/dist/server/lib/video.js b/dist/server/lib/video.js index f547120f..faa00860 100644 --- a/dist/server/lib/video.js +++ b/dist/server/lib/video.js @@ -31,7 +31,7 @@ function buildLocalVideoFromReq(videoInfo, channelId) { } exports.buildLocalVideoFromReq = buildLocalVideoFromReq; function buildVideoThumbnailsFromReq(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, files, fallback, automaticallyGenerated } = options; const promises = [ { @@ -45,7 +45,7 @@ function buildVideoThumbnailsFromReq(options) { ].map(p => { const fields = files === null || files === void 0 ? void 0 : files[p.fieldName]; if (fields) { - return thumbnail_1.updateVideoMiniatureFromExisting({ + return (0, thumbnail_1.updateVideoMiniatureFromExisting)({ inputPath: fields[0].path, video, type: p.type, @@ -59,7 +59,7 @@ function buildVideoThumbnailsFromReq(options) { } exports.buildVideoThumbnailsFromReq = buildVideoThumbnailsFromReq; function setVideoTags(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, tags, transaction } = options; const internalTags = tags || []; const tagInstances = yield tag_1.TagModel.findOrCreateTags(internalTags, transaction); @@ -69,7 +69,7 @@ function setVideoTags(options) { } exports.setVideoTags = setVideoTags; function addOptimizeOrMergeAudioJob(video, videoFile, user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let dataInput; if (videoFile.isAudio()) { dataInput = { @@ -94,14 +94,14 @@ function addOptimizeOrMergeAudioJob(video, videoFile, user) { } exports.addOptimizeOrMergeAudioJob = addOptimizeOrMergeAudioJob; function addTranscodingJob(payload, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_job_info_1.VideoJobInfoModel.increaseOrCreate(payload.videoUUID, 'pendingTranscode'); return job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: payload }, options); }); } exports.addTranscodingJob = addTranscodingJob; function addMoveToObjectStorageJob(video, isNewVideo = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield video_job_info_1.VideoJobInfoModel.increaseOrCreate(video.uuid, 'pendingMove'); const dataInput = { videoUUID: video.uuid, isNewVideo }; return job_queue_1.JobQueue.Instance.createJobWithPromise({ type: 'move-to-object-storage', payload: dataInput }); @@ -109,7 +109,7 @@ function addMoveToObjectStorageJob(video, isNewVideo = true) { } exports.addMoveToObjectStorageJob = addMoveToObjectStorageJob; function getTranscodingJobPriority(user) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const now = new Date(); const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7); const videoUploadedByUser = yield video_1.VideoModel.countVideosUploadedByUserSince(user.id, lastWeek); diff --git a/dist/server/middlewares/activitypub.js b/dist/server/middlewares/activitypub.js index c2e8a4b4..fe0a5fcd 100644 --- a/dist/server/middlewares/activitypub.js +++ b/dist/server/middlewares/activitypub.js @@ -10,14 +10,14 @@ const peertube_crypto_1 = require("../helpers/peertube-crypto"); const constants_1 = require("../initializers/constants"); const actors_1 = require("../lib/activitypub/actors"); function checkSignature(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { const httpSignatureChecked = yield checkHttpSignature(req, res); if (httpSignatureChecked !== true) return; const actor = res.locals.signature.actor; const bodyActor = req.body.actor; - const bodyActorId = activitypub_1.getAPId(bodyActor); + const bodyActorId = (0, activitypub_1.getAPId)(bodyActor); if (bodyActorId && bodyActorId !== actor.url) { const jsonLDSignatureChecked = yield checkJsonLDSignature(req, res); if (jsonLDSignatureChecked !== true) @@ -27,7 +27,7 @@ function checkSignature(req, res, next) { } catch (err) { const activity = req.body; - if (actor_1.isActorDeleteActivityValid(activity) && activity.object === activity.actor) { + if ((0, actor_1.isActorDeleteActivityValid)(activity) && activity.object === activity.actor) { logger_1.logger.debug('Handling signature error on actor delete activity', { err }); return res.status(http_error_codes_1.HttpStatusCode.NO_CONTENT_204).end(); } @@ -50,13 +50,13 @@ function executeIfActivityPub(req, res, next) { } exports.executeIfActivityPub = executeIfActivityPub; function checkHttpSignature(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sig = req.headers[constants_1.HTTP_SIGNATURE.HEADER_NAME]; if (sig && sig.startsWith('Signature ') === true) req.headers[constants_1.HTTP_SIGNATURE.HEADER_NAME] = sig.replace(/^Signature /, ''); let parsed; try { - parsed = peertube_crypto_1.parseHTTPSignature(req, constants_1.HTTP_SIGNATURE.CLOCK_SKEW_SECONDS); + parsed = (0, peertube_crypto_1.parseHTTPSignature)(req, constants_1.HTTP_SIGNATURE.CLOCK_SKEW_SECONDS); } catch (err) { logger_1.logger.warn('Invalid signature because of exception in signature parser', { reqBody: req.body, err }); @@ -80,10 +80,10 @@ function checkHttpSignature(req, res) { logger_1.logger.debug('Checking HTTP signature of actor %s...', keyId); let [actorUrl] = keyId.split('#'); if (actorUrl.startsWith('acct:')) { - actorUrl = yield actors_1.loadActorUrlOrGetFromWebfinger(actorUrl.replace(/^acct:/, '')); + actorUrl = yield (0, actors_1.loadActorUrlOrGetFromWebfinger)(actorUrl.replace(/^acct:/, '')); } - const actor = yield actors_1.getOrCreateAPActor(actorUrl); - const verified = peertube_crypto_1.isHTTPSignatureVerified(parsed, actor); + const actor = yield (0, actors_1.getOrCreateAPActor)(actorUrl); + const verified = (0, peertube_crypto_1.isHTTPSignatureVerified)(parsed, actor); if (verified !== true) { logger_1.logger.warn('Signature from %s is invalid', actorUrl, { parsed }); res.fail({ @@ -101,7 +101,7 @@ function checkHttpSignature(req, res) { } exports.checkHttpSignature = checkHttpSignature; function checkJsonLDSignature(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const signatureObject = req.body.signature; if (!signatureObject || !signatureObject.creator) { res.fail({ @@ -112,8 +112,8 @@ function checkJsonLDSignature(req, res) { } const [creator] = signatureObject.creator.split('#'); logger_1.logger.debug('Checking JsonLD signature of actor %s...', creator); - const actor = yield actors_1.getOrCreateAPActor(creator); - const verified = yield peertube_crypto_1.isJsonLDSignatureVerified(actor, req.body); + const actor = yield (0, actors_1.getOrCreateAPActor)(creator); + const verified = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(actor, req.body); if (verified !== true) { logger_1.logger.warn('Signature not verified.', req.body); res.fail({ diff --git a/dist/server/middlewares/async.js b/dist/server/middlewares/async.js index 5143ffc3..361e99d0 100644 --- a/dist/server/middlewares/async.js +++ b/dist/server/middlewares/async.js @@ -6,7 +6,7 @@ const database_utils_1 = require("../helpers/database-utils"); function asyncMiddleware(fun) { return (req, res, next) => { if (Array.isArray(fun) === true) { - return async_1.eachSeries(fun, (f, cb) => { + return (0, async_1.eachSeries)(fun, (f, cb) => { Promise.resolve(f(req, res, err => cb(err))) .catch(err => next(err)); }, next); @@ -18,7 +18,7 @@ function asyncMiddleware(fun) { exports.asyncMiddleware = asyncMiddleware; function asyncRetryTransactionMiddleware(fun) { return (req, res, next) => { - return Promise.resolve(database_utils_1.retryTransactionWrapper(fun, req, res, next)).catch(err => next(err)); + return Promise.resolve((0, database_utils_1.retryTransactionWrapper)(fun, req, res, next)).catch(err => next(err)); }; } exports.asyncRetryTransactionMiddleware = asyncRetryTransactionMiddleware; diff --git a/dist/server/middlewares/auth.js b/dist/server/middlewares/auth.js index aae93e9f..a79ace85 100644 --- a/dist/server/middlewares/auth.js +++ b/dist/server/middlewares/auth.js @@ -6,7 +6,7 @@ const http_error_codes_1 = require("../../shared/models/http/http-error-codes"); const logger_1 = require("../helpers/logger"); const oauth_1 = require("../lib/auth/oauth"); function authenticate(req, res, next, authenticateInQuery = false) { - oauth_1.handleOAuthAuthenticate(req, res, authenticateInQuery) + (0, oauth_1.handleOAuthAuthenticate)(req, res, authenticateInQuery) .then((token) => { res.locals.oauth = { token }; res.locals.authenticated = true; @@ -29,7 +29,7 @@ function authenticateSocket(socket, next) { return next(new Error('No access token provided')); if (typeof accessToken !== 'string') return next(new Error('Access token is invalid')); - oauth_model_1.getAccessToken(accessToken) + (0, oauth_model_1.getAccessToken)(accessToken) .then(tokenDB => { const now = new Date(); if (!tokenDB || tokenDB.accessTokenExpiresAt < now || tokenDB.refreshTokenExpiresAt < now) { diff --git a/dist/server/middlewares/cache/index.js b/dist/server/middlewares/cache/index.js index 93754cb4..ab592f40 100644 --- a/dist/server/middlewares/cache/index.js +++ b/dist/server/middlewares/cache/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./cache"), exports); +(0, tslib_1.__exportStar)(require("./cache"), exports); diff --git a/dist/server/middlewares/cache/shared/api-cache.js b/dist/server/middlewares/cache/shared/api-cache.js index 3cea3b4a..59bd412b 100644 --- a/dist/server/middlewares/cache/shared/api-cache.js +++ b/dist/server/middlewares/cache/shared/api-cache.js @@ -11,7 +11,7 @@ class ApiCache { this.options = Object.assign({ headerBlacklist: [], excludeStatus: [] }, options); } buildMiddleware(strDuration) { - const duration = core_utils_1.parseDurationToMs(strDuration); + const duration = (0, core_utils_1.parseDurationToMs)(strDuration); return (req, res, next) => { const key = redis_1.Redis.Instance.getPrefix() + 'api-cache-' + req.originalUrl; const redis = redis_1.Redis.Instance.getClient(); @@ -131,7 +131,7 @@ class ApiCache { } sendCachedResponse(request, response, cacheObject, duration) { const headers = response.getHeaders(); - if (core_utils_1.isTestInstance()) { + if ((0, core_utils_1.isTestInstance)()) { Object.assign(headers, { 'x-api-cache-cached': 'true' }); diff --git a/dist/server/middlewares/cache/shared/index.js b/dist/server/middlewares/cache/shared/index.js index d1512d47..07b8f12f 100644 --- a/dist/server/middlewares/cache/shared/index.js +++ b/dist/server/middlewares/cache/shared/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./api-cache"), exports); +(0, tslib_1.__exportStar)(require("./api-cache"), exports); diff --git a/dist/server/middlewares/csp.js b/dist/server/middlewares/csp.js index c9651bd2..1ce6da95 100644 --- a/dist/server/middlewares/csp.js +++ b/dist/server/middlewares/csp.js @@ -19,12 +19,12 @@ const baseDirectives = Object.assign({}, { frameSrc: ['\'self\''], workerSrc: ['\'self\'', 'blob:'] }, config_1.CONFIG.CSP.REPORT_URI ? { reportUri: config_1.CONFIG.CSP.REPORT_URI } : {}, config_1.CONFIG.WEBSERVER.SCHEME === 'https' ? { upgradeInsecureRequests: [] } : {}); -const baseCSP = helmet_1.contentSecurityPolicy({ +const baseCSP = (0, helmet_1.contentSecurityPolicy)({ directives: baseDirectives, reportOnly: config_1.CONFIG.CSP.REPORT_ONLY }); exports.baseCSP = baseCSP; -const embedCSP = helmet_1.contentSecurityPolicy({ +const embedCSP = (0, helmet_1.contentSecurityPolicy)({ directives: Object.assign({}, baseDirectives, { frameAncestors: ['*'] }), reportOnly: config_1.CONFIG.CSP.REPORT_ONLY }); diff --git a/dist/server/middlewares/index.js b/dist/server/middlewares/index.js index 4359592e..1d40bc30 100644 --- a/dist/server/middlewares/index.js +++ b/dist/server/middlewares/index.js @@ -1,17 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./validators"), exports); -tslib_1.__exportStar(require("./cache"), exports); -tslib_1.__exportStar(require("./activitypub"), exports); -tslib_1.__exportStar(require("./async"), exports); -tslib_1.__exportStar(require("./auth"), exports); -tslib_1.__exportStar(require("./pagination"), exports); -tslib_1.__exportStar(require("./robots"), exports); -tslib_1.__exportStar(require("./servers"), exports); -tslib_1.__exportStar(require("./sort"), exports); -tslib_1.__exportStar(require("./user-right"), exports); -tslib_1.__exportStar(require("./dnt"), exports); -tslib_1.__exportStar(require("./error"), exports); -tslib_1.__exportStar(require("./doc"), exports); -tslib_1.__exportStar(require("./csp"), exports); +(0, tslib_1.__exportStar)(require("./validators"), exports); +(0, tslib_1.__exportStar)(require("./cache"), exports); +(0, tslib_1.__exportStar)(require("./activitypub"), exports); +(0, tslib_1.__exportStar)(require("./async"), exports); +(0, tslib_1.__exportStar)(require("./auth"), exports); +(0, tslib_1.__exportStar)(require("./pagination"), exports); +(0, tslib_1.__exportStar)(require("./robots"), exports); +(0, tslib_1.__exportStar)(require("./servers"), exports); +(0, tslib_1.__exportStar)(require("./sort"), exports); +(0, tslib_1.__exportStar)(require("./user-right"), exports); +(0, tslib_1.__exportStar)(require("./dnt"), exports); +(0, tslib_1.__exportStar)(require("./error"), exports); +(0, tslib_1.__exportStar)(require("./doc"), exports); +(0, tslib_1.__exportStar)(require("./csp"), exports); diff --git a/dist/server/middlewares/servers.js b/dist/server/middlewares/servers.js index 8ebdd9cc..c382b0be 100644 --- a/dist/server/middlewares/servers.js +++ b/dist/server/middlewares/servers.js @@ -7,7 +7,7 @@ function setBodyHostsPort(req, res, next) { if (!req.body.hosts) return next(); for (let i = 0; i < req.body.hosts.length; i++) { - const hostWithPort = express_utils_1.getHostWithPort(req.body.hosts[i]); + const hostWithPort = (0, express_utils_1.getHostWithPort)(req.body.hosts[i]); if (hostWithPort === null) { return res.fail({ status: http_error_codes_1.HttpStatusCode.INTERNAL_SERVER_ERROR_500, diff --git a/dist/server/middlewares/validators/abuse.js b/dist/server/middlewares/validators/abuse.js index 6e857c30..56e0c321 100644 --- a/dist/server/middlewares/validators/abuse.js +++ b/dist/server/middlewares/validators/abuse.js @@ -10,21 +10,21 @@ const abuse_message_1 = require("@server/models/abuse/abuse-message"); const http_error_codes_1 = require("../../../shared/models/http/http-error-codes"); const shared_1 = require("./shared"); const abuseReportValidator = [ - express_validator_1.body('account.id') + (0, express_validator_1.body)('account.id') .optional() .custom(misc_1.isIdValid) .withMessage('Should have a valid accountId'), - express_validator_1.body('video.id') + (0, express_validator_1.body)('video.id') .optional() .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdOrUUIDValid) .withMessage('Should have a valid videoId'), - express_validator_1.body('video.startAt') + (0, express_validator_1.body)('video.startAt') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(abuses_1.isAbuseTimestampValid) .withMessage('Should have valid starting time value'), - express_validator_1.body('video.endAt') + (0, express_validator_1.body)('video.endAt') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(abuses_1.isAbuseTimestampValid) @@ -32,28 +32,28 @@ const abuseReportValidator = [ .bail() .custom(abuses_1.isAbuseTimestampCoherent) .withMessage('Should have a startAt timestamp beginning before endAt'), - express_validator_1.body('comment.id') + (0, express_validator_1.body)('comment.id') .optional() .custom(misc_1.isIdValid) .withMessage('Should have a valid commentId'), - express_validator_1.body('reason') + (0, express_validator_1.body)('reason') .custom(abuses_1.isAbuseReasonValid) .withMessage('Should have a valid reason'), - express_validator_1.body('predefinedReasons') + (0, express_validator_1.body)('predefinedReasons') .optional() .custom(abuses_1.areAbusePredefinedReasonsValid) .withMessage('Should have a valid list of predefined reasons'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f; logger_1.logger.debug('Checking abuseReport parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const body = req.body; - if (((_a = body.video) === null || _a === void 0 ? void 0 : _a.id) && !(yield shared_1.doesVideoExist(body.video.id, res))) + if (((_a = body.video) === null || _a === void 0 ? void 0 : _a.id) && !(yield (0, shared_1.doesVideoExist)(body.video.id, res))) return; - if (((_b = body.account) === null || _b === void 0 ? void 0 : _b.id) && !(yield shared_1.doesAccountIdExist(body.account.id, res))) + if (((_b = body.account) === null || _b === void 0 ? void 0 : _b.id) && !(yield (0, shared_1.doesAccountIdExist)(body.account.id, res))) return; - if (((_c = body.comment) === null || _c === void 0 ? void 0 : _c.id) && !(yield shared_1.doesCommentIdExist(body.comment.id, res))) + if (((_c = body.comment) === null || _c === void 0 ? void 0 : _c.id) && !(yield (0, shared_1.doesCommentIdExist)(body.comment.id, res))) return; if (!((_d = body.video) === null || _d === void 0 ? void 0 : _d.id) && !((_e = body.account) === null || _e === void 0 ? void 0 : _e.id) && !((_f = body.comment) === null || _f === void 0 ? void 0 : _f.id)) { res.fail({ message: 'video id or account id or comment id is required.' }); @@ -64,101 +64,101 @@ const abuseReportValidator = [ ]; exports.abuseReportValidator = abuseReportValidator; const abuseGetValidator = [ - express_validator_1.param('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking abuseGetValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAbuseExist(req.params.id, res))) + if (!(yield (0, shared_1.doesAbuseExist)(req.params.id, res))) return; return next(); }) ]; exports.abuseGetValidator = abuseGetValidator; const abuseUpdateValidator = [ - express_validator_1.param('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.body('state') + (0, express_validator_1.param)('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), + (0, express_validator_1.body)('state') .optional() .custom(abuses_1.isAbuseStateValid).withMessage('Should have a valid abuse state'), - express_validator_1.body('moderationComment') + (0, express_validator_1.body)('moderationComment') .optional() .custom(abuses_1.isAbuseModerationCommentValid).withMessage('Should have a valid moderation comment'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAbuseExist(req.params.id, res))) + if (!(yield (0, shared_1.doesAbuseExist)(req.params.id, res))) return; return next(); }) ]; exports.abuseUpdateValidator = abuseUpdateValidator; const abuseListForAdminsValidator = [ - express_validator_1.query('id') + (0, express_validator_1.query)('id') .optional() .custom(misc_1.isIdValid).withMessage('Should have a valid id'), - express_validator_1.query('filter') + (0, express_validator_1.query)('filter') .optional() .custom(abuses_1.isAbuseFilterValid) .withMessage('Should have a valid filter'), - express_validator_1.query('predefinedReason') + (0, express_validator_1.query)('predefinedReason') .optional() .custom(abuses_1.isAbusePredefinedReasonValid) .withMessage('Should have a valid predefinedReason'), - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .custom(misc_1.exists).withMessage('Should have a valid search'), - express_validator_1.query('state') + (0, express_validator_1.query)('state') .optional() .custom(abuses_1.isAbuseStateValid).withMessage('Should have a valid abuse state'), - express_validator_1.query('videoIs') + (0, express_validator_1.query)('videoIs') .optional() .custom(abuses_1.isAbuseVideoIsValid).withMessage('Should have a valid "video is" attribute'), - express_validator_1.query('searchReporter') + (0, express_validator_1.query)('searchReporter') .optional() .custom(misc_1.exists).withMessage('Should have a valid reporter search'), - express_validator_1.query('searchReportee') + (0, express_validator_1.query)('searchReportee') .optional() .custom(misc_1.exists).withMessage('Should have a valid reportee search'), - express_validator_1.query('searchVideo') + (0, express_validator_1.query)('searchVideo') .optional() .custom(misc_1.exists).withMessage('Should have a valid video search'), - express_validator_1.query('searchVideoChannel') + (0, express_validator_1.query)('searchVideoChannel') .optional() .custom(misc_1.exists).withMessage('Should have a valid video channel search'), (req, res, next) => { logger_1.logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.abuseListForAdminsValidator = abuseListForAdminsValidator; const abuseListForUserValidator = [ - express_validator_1.query('id') + (0, express_validator_1.query)('id') .optional() .custom(misc_1.isIdValid).withMessage('Should have a valid id'), - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .custom(misc_1.exists).withMessage('Should have a valid search'), - express_validator_1.query('state') + (0, express_validator_1.query)('state') .optional() .custom(abuses_1.isAbuseStateValid).withMessage('Should have a valid abuse state'), (req, res, next) => { logger_1.logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.abuseListForUserValidator = abuseListForUserValidator; const getAbuseValidator = [ - express_validator_1.param('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking getAbuseValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAbuseExist(req.params.id, res))) + if (!(yield (0, shared_1.doesAbuseExist)(req.params.id, res))) return; const user = res.locals.oauth.token.user; const abuse = res.locals.abuse; @@ -186,20 +186,20 @@ const checkAbuseValidForMessagesValidator = [ ]; exports.checkAbuseValidForMessagesValidator = checkAbuseValidForMessagesValidator; const addAbuseMessageValidator = [ - express_validator_1.body('message').custom(abuses_1.isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'), + (0, express_validator_1.body)('message').custom(abuses_1.isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'), (req, res, next) => { logger_1.logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.addAbuseMessageValidator = addAbuseMessageValidator; const deleteAbuseMessageValidator = [ - express_validator_1.param('messageId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid message id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('messageId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid message id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const user = res.locals.oauth.token.user; const abuse = res.locals.abuse; diff --git a/dist/server/middlewares/validators/account.js b/dist/server/middlewares/validators/account.js index 531023cb..a14e3fac 100644 --- a/dist/server/middlewares/validators/account.js +++ b/dist/server/middlewares/validators/account.js @@ -7,24 +7,24 @@ const accounts_1 = require("../../helpers/custom-validators/accounts"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const localAccountValidator = [ - express_validator_1.param('name').custom(accounts_1.isAccountNameValid).withMessage('Should have a valid account name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('name').custom(accounts_1.isAccountNameValid).withMessage('Should have a valid account name'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking localAccountValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesLocalAccountNameExist(req.params.name, res))) + if (!(yield (0, shared_1.doesLocalAccountNameExist)(req.params.name, res))) return; return next(); }) ]; exports.localAccountValidator = localAccountValidator; const accountNameWithHostGetValidator = [ - express_validator_1.param('accountName').exists().withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('accountName').exists().withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountNameWithHostExist(req.params.accountName, res))) + if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.params.accountName, res))) return; return next(); }) diff --git a/dist/server/middlewares/validators/activitypub/activity.js b/dist/server/middlewares/validators/activitypub/activity.js index 8a630a44..be00d513 100644 --- a/dist/server/middlewares/validators/activitypub/activity.js +++ b/dist/server/middlewares/validators/activitypub/activity.js @@ -7,13 +7,13 @@ const http_error_codes_1 = require("../../../../shared/models/http/http-error-co const activity_1 = require("../../../helpers/custom-validators/activitypub/activity"); const logger_1 = require("../../../helpers/logger"); function activityPubValidator(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Checking activity pub parameters'); - if (!activity_1.isRootActivityValid(req.body)) { + if (!(0, activity_1.isRootActivityValid)(req.body)) { logger_1.logger.warn('Incorrect activity parameters.', { activity: req.body }); return res.fail({ message: 'Incorrect activity' }); } - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const remoteActor = res.locals.signature.actor; if (serverActor.id === remoteActor.id || remoteActor.serverId === null) { logger_1.logger.error('Receiving request in INBOX by ourselves!', req.body); diff --git a/dist/server/middlewares/validators/activitypub/index.js b/dist/server/middlewares/validators/activitypub/index.js index 69138152..f9eb491d 100644 --- a/dist/server/middlewares/validators/activitypub/index.js +++ b/dist/server/middlewares/validators/activitypub/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./activity"), exports); -tslib_1.__exportStar(require("./signature"), exports); -tslib_1.__exportStar(require("./pagination"), exports); +(0, tslib_1.__exportStar)(require("./activity"), exports); +(0, tslib_1.__exportStar)(require("./signature"), exports); +(0, tslib_1.__exportStar)(require("./pagination"), exports); diff --git a/dist/server/middlewares/validators/activitypub/pagination.js b/dist/server/middlewares/validators/activitypub/pagination.js index cedfe7d7..ca341727 100644 --- a/dist/server/middlewares/validators/activitypub/pagination.js +++ b/dist/server/middlewares/validators/activitypub/pagination.js @@ -6,15 +6,15 @@ const constants_1 = require("@server/initializers/constants"); const logger_1 = require("../../../helpers/logger"); const shared_1 = require("../shared"); const apPaginationValidator = [ - express_validator_1.query('page') + (0, express_validator_1.query)('page') .optional() .isInt({ min: 1 }).withMessage('Should have a valid page number'), - express_validator_1.query('size') + (0, express_validator_1.query)('size') .optional() .isInt({ min: 0, max: constants_1.PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${constants_1.PAGINATION.OUTBOX.COUNT.MAX})`), (req, res, next) => { logger_1.logger.debug('Checking pagination parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/activitypub/signature.js b/dist/server/middlewares/validators/activitypub/signature.js index 322d1725..f581dddf 100644 --- a/dist/server/middlewares/validators/activitypub/signature.js +++ b/dist/server/middlewares/validators/activitypub/signature.js @@ -7,21 +7,21 @@ const misc_1 = require("../../../helpers/custom-validators/misc"); const logger_1 = require("../../../helpers/logger"); const shared_1 = require("../shared"); const signatureValidator = [ - express_validator_1.body('signature.type') + (0, express_validator_1.body)('signature.type') .optional() .custom(signature_1.isSignatureTypeValid).withMessage('Should have a valid signature type'), - express_validator_1.body('signature.created') + (0, express_validator_1.body)('signature.created') .optional() .custom(misc_1.isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'), - express_validator_1.body('signature.creator') + (0, express_validator_1.body)('signature.creator') .optional() .custom(signature_1.isSignatureCreatorValid).withMessage('Should have a valid signature creator'), - express_validator_1.body('signature.signatureValue') + (0, express_validator_1.body)('signature.signatureValue') .optional() .custom(signature_1.isSignatureValueValid).withMessage('Should have a valid signature value'), (req, res, next) => { logger_1.logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/actor-image.js b/dist/server/middlewares/validators/actor-image.js index 28cb82c2..cb3a6926 100644 --- a/dist/server/middlewares/validators/actor-image.js +++ b/dist/server/middlewares/validators/actor-image.js @@ -8,12 +8,12 @@ const logger_1 = require("../../helpers/logger"); const constants_1 = require("../../initializers/constants"); const shared_1 = require("./shared"); const updateActorImageValidatorFactory = (fieldname) => ([ - express_validator_1.body(fieldname).custom((value, { req }) => actor_images_1.isActorImageFile(req.files, fieldname)).withMessage('This file is not supported or too large. Please, make sure it is of the following type : ' + + (0, express_validator_1.body)(fieldname).custom((value, { req }) => (0, actor_images_1.isActorImageFile)(req.files, fieldname)).withMessage('This file is not supported or too large. Please, make sure it is of the following type : ' + constants_1.CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME.join(', ')), (req, res, next) => { logger_1.logger.debug('Checking updateActorImageValidator parameters', { files: req.files }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); } ]); diff --git a/dist/server/middlewares/validators/blocklist.js b/dist/server/middlewares/validators/blocklist.js index e9e88a31..f0814d7b 100644 --- a/dist/server/middlewares/validators/blocklist.js +++ b/dist/server/middlewares/validators/blocklist.js @@ -13,12 +13,12 @@ const server_1 = require("../../models/server/server"); const server_blocklist_1 = require("../../models/server/server-blocklist"); const shared_1 = require("./shared"); const blockAccountValidator = [ - express_validator_1.body('accountName').exists().withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('accountName').exists().withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountNameWithHostExist(req.body.accountName, res))) + if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.body.accountName, res))) return; const user = res.locals.oauth.token.User; const accountToBlock = res.locals.account; @@ -34,12 +34,12 @@ const blockAccountValidator = [ ]; exports.blockAccountValidator = blockAccountValidator; const unblockAccountByAccountValidator = [ - express_validator_1.param('accountName').exists().withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('accountName').exists().withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountNameWithHostExist(req.params.accountName, res))) + if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.params.accountName, res))) return; const user = res.locals.oauth.token.User; const targetAccount = res.locals.account; @@ -50,14 +50,14 @@ const unblockAccountByAccountValidator = [ ]; exports.unblockAccountByAccountValidator = unblockAccountByAccountValidator; const unblockAccountByServerValidator = [ - express_validator_1.param('accountName').exists().withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('accountName').exists().withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountNameWithHostExist(req.params.accountName, res))) + if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.params.accountName, res))) return; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const targetAccount = res.locals.account; if (!(yield doesUnblockAccountExist(serverActor.Account.id, targetAccount.id, res))) return; @@ -66,10 +66,10 @@ const unblockAccountByServerValidator = [ ]; exports.unblockAccountByServerValidator = unblockAccountByServerValidator; const blockServerValidator = [ - express_validator_1.body('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking serverGetValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const host = req.body.host; if (host === constants_1.WEBSERVER.HOST) { @@ -85,10 +85,10 @@ const blockServerValidator = [ ]; exports.blockServerValidator = blockServerValidator; const unblockServerByAccountValidator = [ - express_validator_1.param('host').custom(servers_1.isHostValid).withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('host').custom(servers_1.isHostValid).withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const user = res.locals.oauth.token.User; if (!(yield doesUnblockServerExist(user.Account.id, req.params.host, res))) @@ -98,12 +98,12 @@ const unblockServerByAccountValidator = [ ]; exports.unblockServerByAccountValidator = unblockServerByAccountValidator; const unblockServerByServerValidator = [ - express_validator_1.param('host').custom(servers_1.isHostValid).withMessage('Should have an account name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('host').custom(servers_1.isHostValid).withMessage('Should have an account name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); if (!(yield doesUnblockServerExist(serverActor.Account.id, req.params.host, res))) return; return next(); @@ -111,7 +111,7 @@ const unblockServerByServerValidator = [ ]; exports.unblockServerByServerValidator = unblockServerByServerValidator; function doesUnblockAccountExist(accountId, targetAccountId, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountBlock = yield account_blocklist_1.AccountBlocklistModel.loadByAccountAndTarget(accountId, targetAccountId); if (!accountBlock) { res.fail({ @@ -125,7 +125,7 @@ function doesUnblockAccountExist(accountId, targetAccountId, res) { }); } function doesUnblockServerExist(accountId, host, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverBlock = yield server_blocklist_1.ServerBlocklistModel.loadByAccountAndHost(accountId, host); if (!serverBlock) { res.fail({ diff --git a/dist/server/middlewares/validators/bulk.js b/dist/server/middlewares/validators/bulk.js index 6ffc497c..53732eb1 100644 --- a/dist/server/middlewares/validators/bulk.js +++ b/dist/server/middlewares/validators/bulk.js @@ -8,14 +8,14 @@ const models_1 = require("@shared/models"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const bulkRemoveCommentsOfValidator = [ - express_validator_1.body('accountName').exists().withMessage('Should have an account name with host'), - express_validator_1.body('scope') + (0, express_validator_1.body)('accountName').exists().withMessage('Should have an account name with host'), + (0, express_validator_1.body)('scope') .custom(bulk_1.isBulkRemoveCommentsOfScopeValid).withMessage('Should have a valid scope'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountNameWithHostExist(req.body.accountName, res))) + if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.body.accountName, res))) return; const user = res.locals.oauth.token.User; const body = req.body; diff --git a/dist/server/middlewares/validators/config.js b/dist/server/middlewares/validators/config.js index f35215c9..9ab58087 100644 --- a/dist/server/middlewares/validators/config.js +++ b/dist/server/middlewares/validators/config.js @@ -10,76 +10,76 @@ const logger_1 = require("../../helpers/logger"); const theme_utils_1 = require("../../lib/plugins/theme-utils"); const shared_1 = require("./shared"); const customConfigUpdateValidator = [ - express_validator_1.body('instance.name').exists().withMessage('Should have a valid instance name'), - express_validator_1.body('instance.shortDescription').exists().withMessage('Should have a valid instance short description'), - express_validator_1.body('instance.description').exists().withMessage('Should have a valid instance description'), - express_validator_1.body('instance.terms').exists().withMessage('Should have a valid instance terms'), - express_validator_1.body('instance.defaultNSFWPolicy').custom(users_1.isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), - express_validator_1.body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), - express_validator_1.body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), - express_validator_1.body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), - express_validator_1.body('services.twitter.username').exists().withMessage('Should have a valid twitter username'), - express_validator_1.body('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'), - express_validator_1.body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'), - express_validator_1.body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'), - express_validator_1.body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'), - express_validator_1.body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), - express_validator_1.body('signup.limit').isInt().withMessage('Should have a valid signup limit'), - express_validator_1.body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), - express_validator_1.body('signup.minimumAge').isInt().withMessage("Should have a valid minimum age required"), - express_validator_1.body('admin.email').isEmail().withMessage('Should have a valid administrator email'), - express_validator_1.body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), - express_validator_1.body('user.videoQuota').custom(users_1.isUserVideoQuotaValid).withMessage('Should have a valid video quota'), - express_validator_1.body('user.videoQuotaDaily').custom(users_1.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), - express_validator_1.body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), - express_validator_1.body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), - express_validator_1.body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), - express_validator_1.body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'), - express_validator_1.body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), - express_validator_1.body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), - express_validator_1.body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), - express_validator_1.body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'), - express_validator_1.body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'), - express_validator_1.body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), - express_validator_1.body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), - express_validator_1.body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'), - express_validator_1.body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'), - express_validator_1.body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), - express_validator_1.body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), - express_validator_1.body('theme.default').custom(v => plugins_1.isThemeNameValid(v) && theme_utils_1.isThemeRegistered(v)).withMessage('Should have a valid theme'), - express_validator_1.body('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'), - express_validator_1.body('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'), - express_validator_1.body('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'), - express_validator_1.body('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'), - express_validator_1.body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'), - express_validator_1.body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'), - express_validator_1.body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'), - express_validator_1.body('live.maxInstanceLives').custom(misc_1.isIntOrNull).withMessage('Should have a valid max instance lives'), - express_validator_1.body('live.maxUserLives').custom(misc_1.isIntOrNull).withMessage('Should have a valid max user lives'), - express_validator_1.body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'), - express_validator_1.body('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'), - express_validator_1.body('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), - express_validator_1.body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), - express_validator_1.body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'), - express_validator_1.body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'), - express_validator_1.body('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'), - express_validator_1.body('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'), - express_validator_1.body('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'), - express_validator_1.body('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'), + (0, express_validator_1.body)('instance.name').exists().withMessage('Should have a valid instance name'), + (0, express_validator_1.body)('instance.shortDescription').exists().withMessage('Should have a valid instance short description'), + (0, express_validator_1.body)('instance.description').exists().withMessage('Should have a valid instance description'), + (0, express_validator_1.body)('instance.terms').exists().withMessage('Should have a valid instance terms'), + (0, express_validator_1.body)('instance.defaultNSFWPolicy').custom(users_1.isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), + (0, express_validator_1.body)('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), + (0, express_validator_1.body)('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), + (0, express_validator_1.body)('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), + (0, express_validator_1.body)('services.twitter.username').exists().withMessage('Should have a valid twitter username'), + (0, express_validator_1.body)('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'), + (0, express_validator_1.body)('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'), + (0, express_validator_1.body)('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'), + (0, express_validator_1.body)('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'), + (0, express_validator_1.body)('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), + (0, express_validator_1.body)('signup.limit').isInt().withMessage('Should have a valid signup limit'), + (0, express_validator_1.body)('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), + (0, express_validator_1.body)('signup.minimumAge').isInt().withMessage("Should have a valid minimum age required"), + (0, express_validator_1.body)('admin.email').isEmail().withMessage('Should have a valid administrator email'), + (0, express_validator_1.body)('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), + (0, express_validator_1.body)('user.videoQuota').custom(users_1.isUserVideoQuotaValid).withMessage('Should have a valid video quota'), + (0, express_validator_1.body)('user.videoQuotaDaily').custom(users_1.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), + (0, express_validator_1.body)('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), + (0, express_validator_1.body)('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), + (0, express_validator_1.body)('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), + (0, express_validator_1.body)('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'), + (0, express_validator_1.body)('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), + (0, express_validator_1.body)('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), + (0, express_validator_1.body)('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'), + (0, express_validator_1.body)('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'), + (0, express_validator_1.body)('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), + (0, express_validator_1.body)('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), + (0, express_validator_1.body)('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'), + (0, express_validator_1.body)('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'), + (0, express_validator_1.body)('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), + (0, express_validator_1.body)('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), + (0, express_validator_1.body)('theme.default').custom(v => (0, plugins_1.isThemeNameValid)(v) && (0, theme_utils_1.isThemeRegistered)(v)).withMessage('Should have a valid theme'), + (0, express_validator_1.body)('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'), + (0, express_validator_1.body)('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'), + (0, express_validator_1.body)('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'), + (0, express_validator_1.body)('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'), + (0, express_validator_1.body)('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'), + (0, express_validator_1.body)('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'), + (0, express_validator_1.body)('live.maxDuration').isInt().withMessage('Should have a valid live max duration'), + (0, express_validator_1.body)('live.maxInstanceLives').custom(misc_1.isIntOrNull).withMessage('Should have a valid max instance lives'), + (0, express_validator_1.body)('live.maxUserLives').custom(misc_1.isIntOrNull).withMessage('Should have a valid max user lives'), + (0, express_validator_1.body)('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'), + (0, express_validator_1.body)('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'), + (0, express_validator_1.body)('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), + (0, express_validator_1.body)('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), + (0, express_validator_1.body)('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'), + (0, express_validator_1.body)('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'), + (0, express_validator_1.body)('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'), + (0, express_validator_1.body)('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'), + (0, express_validator_1.body)('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'), + (0, express_validator_1.body)('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'), (req, res, next) => { logger_1.logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!checkInvalidConfigIfEmailDisabled(req.body, res)) return; @@ -92,7 +92,7 @@ const customConfigUpdateValidator = [ ]; exports.customConfigUpdateValidator = customConfigUpdateValidator; function checkInvalidConfigIfEmailDisabled(customConfig, res) { - if (config_1.isEmailEnabled()) + if ((0, config_1.isEmailEnabled)()) return true; if (customConfig.signup.requiresEmailVerification === true) { res.fail({ message: 'Emailer is disabled but you require signup email verification.' }); diff --git a/dist/server/middlewares/validators/feeds.js b/dist/server/middlewares/validators/feeds.js index 9ce279d7..cf4627f5 100644 --- a/dist/server/middlewares/validators/feeds.js +++ b/dist/server/middlewares/validators/feeds.js @@ -9,8 +9,8 @@ const misc_1 = require("../../helpers/custom-validators/misc"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const feedsFormatValidator = [ - express_validator_1.param('format').optional().custom(feeds_1.isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), - express_validator_1.query('format').optional().custom(feeds_1.isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)') + (0, express_validator_1.param)('format').optional().custom(feeds_1.isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), + (0, express_validator_1.query)('format').optional().custom(feeds_1.isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)') ]; exports.feedsFormatValidator = feedsFormatValidator; function setFeedFormatContentType(req, res, next) { @@ -41,66 +41,66 @@ function setFeedFormatContentType(req, res, next) { } exports.setFeedFormatContentType = setFeedFormatContentType; const videoFeedsValidator = [ - express_validator_1.query('accountId') + (0, express_validator_1.query)('accountId') .optional() .custom(misc_1.isIdValid) .withMessage('Should have a valid account id'), - express_validator_1.query('accountName') + (0, express_validator_1.query)('accountName') .optional(), - express_validator_1.query('videoChannelId') + (0, express_validator_1.query)('videoChannelId') .optional() .custom(misc_1.isIdValid) .withMessage('Should have a valid channel id'), - express_validator_1.query('videoChannelName') + (0, express_validator_1.query)('videoChannelName') .optional(), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking feeds parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (req.query.accountId && !(yield shared_1.doesAccountIdExist(req.query.accountId, res))) + if (req.query.accountId && !(yield (0, shared_1.doesAccountIdExist)(req.query.accountId, res))) return; - if (req.query.videoChannelId && !(yield shared_1.doesVideoChannelIdExist(req.query.videoChannelId, res))) + if (req.query.videoChannelId && !(yield (0, shared_1.doesVideoChannelIdExist)(req.query.videoChannelId, res))) return; - if (req.query.accountName && !(yield shared_1.doesAccountNameWithHostExist(req.query.accountName, res))) + if (req.query.accountName && !(yield (0, shared_1.doesAccountNameWithHostExist)(req.query.accountName, res))) return; - if (req.query.videoChannelName && !(yield shared_1.doesVideoChannelNameWithHostExist(req.query.videoChannelName, res))) + if (req.query.videoChannelName && !(yield (0, shared_1.doesVideoChannelNameWithHostExist)(req.query.videoChannelName, res))) return; return next(); }) ]; exports.videoFeedsValidator = videoFeedsValidator; const videoSubscriptionFeedsValidator = [ - express_validator_1.query('accountId') + (0, express_validator_1.query)('accountId') .custom(misc_1.isIdValid) .withMessage('Should have a valid account id'), - express_validator_1.query('token') + (0, express_validator_1.query)('token') .custom(misc_1.exists) .withMessage('Should have a token'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking subscription feeds parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesAccountIdExist(req.query.accountId, res))) + if (!(yield (0, shared_1.doesAccountIdExist)(req.query.accountId, res))) return; - if (!(yield shared_1.doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res))) + if (!(yield (0, shared_1.doesUserFeedTokenCorrespond)(res.locals.account.userId, req.query.token, res))) return; return next(); }) ]; exports.videoSubscriptionFeedsValidator = videoSubscriptionFeedsValidator; const videoCommentsFeedsValidator = [ - express_validator_1.query('videoId') + (0, express_validator_1.query)('videoId') .customSanitizer(misc_1.toCompleteUUID) .optional() .custom(misc_1.isIdOrUUIDValid), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking feeds parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (req.query.videoId && (req.query.videoChannelId || req.query.videoChannelName)) { return res.fail({ message: 'videoId cannot be mixed with a channel filter' }); } - if (req.query.videoId && !(yield shared_1.doesVideoExist(req.query.videoId, res))) + if (req.query.videoId && !(yield (0, shared_1.doesVideoExist)(req.query.videoId, res))) return; return next(); }) diff --git a/dist/server/middlewares/validators/follows.js b/dist/server/middlewares/validators/follows.js index 2467c515..823d0e49 100644 --- a/dist/server/middlewares/validators/follows.js +++ b/dist/server/middlewares/validators/follows.js @@ -17,28 +17,28 @@ const actor_2 = require("../../models/actor/actor"); const actor_follow_1 = require("../../models/actor/actor-follow"); const shared_1 = require("./shared"); const listFollowsValidator = [ - express_validator_1.query('state') + (0, express_validator_1.query)('state') .optional() .custom(follows_1.isFollowStateValid).withMessage('Should have a valid follow state'), - express_validator_1.query('actorType') + (0, express_validator_1.query)('actorType') .optional() .custom(actor_1.isActorTypeValid).withMessage('Should have a valid actor type'), (req, res, next) => { - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.listFollowsValidator = listFollowsValidator; const followValidator = [ - express_validator_1.body('hosts') + (0, express_validator_1.body)('hosts') .toArray() .custom(servers_1.isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), - express_validator_1.body('handles') + (0, express_validator_1.body)('handles') .toArray() .custom(follows_1.isEachUniqueHandleValid).withMessage('Should have an array of handles'), (req, res, next) => { - if (core_utils_1.isTestInstance() === false && constants_1.WEBSERVER.SCHEME === 'http') { + if ((0, core_utils_1.isTestInstance)() === false && constants_1.WEBSERVER.SCHEME === 'http') { return res .status(http_error_codes_1.HttpStatusCode.INTERNAL_SERVER_ERROR_500) .json({ @@ -46,7 +46,7 @@ const followValidator = [ }); } logger_1.logger.debug('Checking follow parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const body = req.body; if (body.hosts.length === 0 && body.handles.length === 0) { @@ -61,15 +61,15 @@ const followValidator = [ ]; exports.followValidator = followValidator; const removeFollowingValidator = [ - express_validator_1.param('hostOrHandle') - .custom(value => servers_1.isHostValid(value) || follows_1.isRemoteHandleValid(value)) + (0, express_validator_1.param)('hostOrHandle') + .custom(value => (0, servers_1.isHostValid)(value) || (0, follows_1.isRemoteHandleValid)(value)) .withMessage('Should have a valid host/handle'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking unfollowing parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - const serverActor = yield application_1.getServerActor(); - const { name, host } = follow_1.getRemoteNameAndHost(req.params.hostOrHandle); + const serverActor = yield (0, application_1.getServerActor)(); + const { name, host } = (0, follow_1.getRemoteNameAndHost)(req.params.hostOrHandle); const follow = yield actor_follow_1.ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(serverActor.id, name, host); if (!follow) { return res.fail({ @@ -83,16 +83,16 @@ const removeFollowingValidator = [ ]; exports.removeFollowingValidator = removeFollowingValidator; const getFollowerValidator = [ - express_validator_1.param('nameWithHost').custom(actor_1.isValidActorHandle).withMessage('Should have a valid nameWithHost'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('nameWithHost').custom(actor_1.isValidActorHandle).withMessage('Should have a valid nameWithHost'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking get follower parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; let follow; try { - const actorUrl = yield actors_1.loadActorUrlOrGetFromWebfinger(req.params.nameWithHost); + const actorUrl = yield (0, actors_1.loadActorUrlOrGetFromWebfinger)(req.params.nameWithHost); const actor = yield actor_2.ActorModel.loadByUrl(actorUrl); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); follow = yield actor_follow_1.ActorFollowModel.loadByActorAndTarget(actor.id, serverActor.id); } catch (err) { diff --git a/dist/server/middlewares/validators/index.js b/dist/server/middlewares/validators/index.js index a02448ff..91e76f26 100644 --- a/dist/server/middlewares/validators/index.js +++ b/dist/server/middlewares/validators/index.js @@ -1,20 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./account"), exports); -tslib_1.__exportStar(require("./actor-image"), exports); -tslib_1.__exportStar(require("./blocklist"), exports); -tslib_1.__exportStar(require("./oembed"), exports); -tslib_1.__exportStar(require("./activitypub"), exports); -tslib_1.__exportStar(require("./pagination"), exports); -tslib_1.__exportStar(require("./follows"), exports); -tslib_1.__exportStar(require("./feeds"), exports); -tslib_1.__exportStar(require("./sort"), exports); -tslib_1.__exportStar(require("./users"), exports); -tslib_1.__exportStar(require("./user-subscriptions"), exports); -tslib_1.__exportStar(require("./videos"), exports); -tslib_1.__exportStar(require("./search"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./user-history"), exports); -tslib_1.__exportStar(require("./webfinger"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./account"), exports); +(0, tslib_1.__exportStar)(require("./actor-image"), exports); +(0, tslib_1.__exportStar)(require("./blocklist"), exports); +(0, tslib_1.__exportStar)(require("./oembed"), exports); +(0, tslib_1.__exportStar)(require("./activitypub"), exports); +(0, tslib_1.__exportStar)(require("./pagination"), exports); +(0, tslib_1.__exportStar)(require("./follows"), exports); +(0, tslib_1.__exportStar)(require("./feeds"), exports); +(0, tslib_1.__exportStar)(require("./sort"), exports); +(0, tslib_1.__exportStar)(require("./users"), exports); +(0, tslib_1.__exportStar)(require("./user-subscriptions"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./search"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./user-history"), exports); +(0, tslib_1.__exportStar)(require("./webfinger"), exports); diff --git a/dist/server/middlewares/validators/jobs.js b/dist/server/middlewares/validators/jobs.js index a7a71d5a..0048c343 100644 --- a/dist/server/middlewares/validators/jobs.js +++ b/dist/server/middlewares/validators/jobs.js @@ -5,17 +5,17 @@ const express_validator_1 = require("express-validator"); const jobs_1 = require("../../helpers/custom-validators/jobs"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); -const lTags = logger_1.loggerTagsFactory('validators', 'jobs'); +const lTags = (0, logger_1.loggerTagsFactory)('validators', 'jobs'); const listJobsValidator = [ - express_validator_1.param('state') + (0, express_validator_1.param)('state') .optional() .custom(jobs_1.isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), - express_validator_1.query('jobType') + (0, express_validator_1.query)('jobType') .optional() .custom(jobs_1.isValidJobType).withMessage('Should have a valid job state'), (req, res, next) => { logger_1.logger.debug('Checking listJobsValidator parameters.', Object.assign({ parameters: req.params }, lTags())); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/logs.js b/dist/server/middlewares/validators/logs.js index f6f03c56..78373cfb 100644 --- a/dist/server/middlewares/validators/logs.js +++ b/dist/server/middlewares/validators/logs.js @@ -7,31 +7,31 @@ const misc_1 = require("../../helpers/custom-validators/misc"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const getLogsValidator = [ - express_validator_1.query('startDate') + (0, express_validator_1.query)('startDate') .custom(misc_1.isDateValid).withMessage('Should have a start date that conforms to ISO 8601'), - express_validator_1.query('level') + (0, express_validator_1.query)('level') .optional() .custom(logs_1.isValidLogLevel).withMessage('Should have a valid level'), - express_validator_1.query('endDate') + (0, express_validator_1.query)('endDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have an end date that conforms to ISO 8601'), (req, res, next) => { logger_1.logger.debug('Checking getLogsValidator parameters.', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.getLogsValidator = getLogsValidator; const getAuditLogsValidator = [ - express_validator_1.query('startDate') + (0, express_validator_1.query)('startDate') .custom(misc_1.isDateValid).withMessage('Should have a start date that conforms to ISO 8601'), - express_validator_1.query('endDate') + (0, express_validator_1.query)('endDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a end date that conforms to ISO 8601'), (req, res, next) => { logger_1.logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/oembed.js b/dist/server/middlewares/validators/oembed.js index 7baf7a19..864be43f 100644 --- a/dist/server/middlewares/validators/oembed.js +++ b/dist/server/middlewares/validators/oembed.js @@ -13,15 +13,15 @@ const logger_1 = require("../../helpers/logger"); const constants_1 = require("../../initializers/constants"); const shared_1 = require("./shared"); const playlistPaths = [ - path_1.join('videos', 'watch', 'playlist'), - path_1.join('w', 'p') + (0, path_1.join)('videos', 'watch', 'playlist'), + (0, path_1.join)('w', 'p') ]; const videoPaths = [ - path_1.join('videos', 'watch'), + (0, path_1.join)('videos', 'watch'), 'w' ]; function buildUrls(paths) { - return paths.map(p => constants_1.WEBSERVER.SCHEME + '://' + path_1.join(constants_1.WEBSERVER.HOST, p) + '/'); + return paths.map(p => constants_1.WEBSERVER.SCHEME + '://' + (0, path_1.join)(constants_1.WEBSERVER.HOST, p) + '/'); } const startPlaylistURLs = buildUrls(playlistPaths); const startVideoURLs = buildUrls(videoPaths); @@ -30,17 +30,17 @@ const isURLOptions = { require_host: true, require_tld: true }; -if (core_utils_1.isTestInstance()) { +if ((0, core_utils_1.isTestInstance)()) { isURLOptions.require_tld = false; } const oembedValidator = [ - express_validator_1.query('url').isURL(isURLOptions).withMessage('Should have a valid url'), - express_validator_1.query('maxwidth').optional().isInt().withMessage('Should have a valid max width'), - express_validator_1.query('maxheight').optional().isInt().withMessage('Should have a valid max height'), - express_validator_1.query('format').optional().isIn(['xml', 'json']).withMessage('Should have a valid format'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.query)('url').isURL(isURLOptions).withMessage('Should have a valid url'), + (0, express_validator_1.query)('maxwidth').optional().isInt().withMessage('Should have a valid max width'), + (0, express_validator_1.query)('maxheight').optional().isInt().withMessage('Should have a valid max height'), + (0, express_validator_1.query)('format').optional().isIn(['xml', 'json']).withMessage('Should have a valid format'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking oembed parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (req.query.format !== undefined && req.query.format !== 'json') { return res.fail({ @@ -78,12 +78,12 @@ const oembedValidator = [ } }); } - const elementId = misc_1.toCompleteUUID(matches[1]); - if (misc_1.isIdOrUUIDValid(elementId) === false) { + const elementId = (0, misc_1.toCompleteUUID)(matches[1]); + if ((0, misc_1.isIdOrUUIDValid)(elementId) === false) { return res.fail({ message: 'Invalid video or playlist id.' }); } if (isVideo) { - const video = yield model_loaders_1.loadVideo(elementId, 'all'); + const video = yield (0, model_loaders_1.loadVideo)(elementId, 'all'); if (!video) { return res.fail({ status: http_error_codes_1.HttpStatusCode.NOT_FOUND_404, diff --git a/dist/server/middlewares/validators/pagination.js b/dist/server/middlewares/validators/pagination.js index ded55ad7..9cafd954 100644 --- a/dist/server/middlewares/validators/pagination.js +++ b/dist/server/middlewares/validators/pagination.js @@ -9,15 +9,15 @@ const paginationValidator = paginationValidatorBuilder(); exports.paginationValidator = paginationValidator; function paginationValidatorBuilder(tags = []) { return [ - express_validator_1.query('start') + (0, express_validator_1.query)('start') .optional() .isInt({ min: 0 }).withMessage('Should have a number start'), - express_validator_1.query('count') + (0, express_validator_1.query)('count') .optional() .isInt({ min: 0, max: constants_1.PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${constants_1.PAGINATION.GLOBAL.COUNT.MAX})`), (req, res, next) => { logger_1.logger.debug('Checking pagination parameters', { parameters: req.query, tags }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/plugins.js b/dist/server/middlewares/validators/plugins.js index 6f294c58..5c645896 100644 --- a/dist/server/middlewares/validators/plugins.js +++ b/dist/server/middlewares/validators/plugins.js @@ -13,15 +13,15 @@ const plugin_1 = require("../../models/server/plugin"); const shared_1 = require("./shared"); const getPluginValidator = (pluginType, withVersion = true) => { const validators = [ - express_validator_1.param('pluginName').custom(plugins_1.isPluginNameValid).withMessage('Should have a valid plugin name') + (0, express_validator_1.param)('pluginName').custom(plugins_1.isPluginNameValid).withMessage('Should have a valid plugin name') ]; if (withVersion) { - validators.push(express_validator_1.param('pluginVersion').custom(plugins_1.isPluginVersionValid).withMessage('Should have a valid plugin version')); + validators.push((0, express_validator_1.param)('pluginVersion').custom(plugins_1.isPluginVersionValid).withMessage('Should have a valid plugin version')); } return validators.concat([ (req, res, next) => { logger_1.logger.debug('Checking getPluginValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const npmName = plugin_1.PluginModel.buildNpmName(req.params.pluginName, pluginType); const plugin = plugin_manager_1.PluginManager.Instance.getRegisteredPluginOrTheme(npmName); @@ -44,10 +44,10 @@ const getPluginValidator = (pluginType, withVersion = true) => { }; exports.getPluginValidator = getPluginValidator; const getExternalAuthValidator = [ - express_validator_1.param('authName').custom(misc_1.exists).withMessage('Should have a valid auth name'), + (0, express_validator_1.param)('authName').custom(misc_1.exists).withMessage('Should have a valid auth name'), (req, res, next) => { logger_1.logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const plugin = res.locals.registeredPlugin; if (!plugin.registerHelpers) { @@ -69,42 +69,42 @@ const getExternalAuthValidator = [ ]; exports.getExternalAuthValidator = getExternalAuthValidator; const pluginStaticDirectoryValidator = [ - express_validator_1.param('staticEndpoint').custom(misc_1.isSafePath).withMessage('Should have a valid static endpoint'), + (0, express_validator_1.param)('staticEndpoint').custom(misc_1.isSafePath).withMessage('Should have a valid static endpoint'), (req, res, next) => { logger_1.logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.pluginStaticDirectoryValidator = pluginStaticDirectoryValidator; const listPluginsValidator = [ - express_validator_1.query('pluginType') + (0, express_validator_1.query)('pluginType') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(plugins_1.isPluginTypeValid).withMessage('Should have a valid plugin type'), - express_validator_1.query('uninstalled') + (0, express_validator_1.query)('uninstalled') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid uninstalled attribute'), (req, res, next) => { logger_1.logger.debug('Checking listPluginsValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.listPluginsValidator = listPluginsValidator; const installOrUpdatePluginValidator = [ - express_validator_1.body('npmName') + (0, express_validator_1.body)('npmName') .optional() .custom(plugins_1.isNpmPluginNameValid).withMessage('Should have a valid npm name'), - express_validator_1.body('path') + (0, express_validator_1.body)('path') .optional() .custom(misc_1.isSafePath).withMessage('Should have a valid safe path'), (req, res, next) => { logger_1.logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const body = req.body; if (!body.path && !body.npmName) { @@ -115,20 +115,20 @@ const installOrUpdatePluginValidator = [ ]; exports.installOrUpdatePluginValidator = installOrUpdatePluginValidator; const uninstallPluginValidator = [ - express_validator_1.body('npmName').custom(plugins_1.isNpmPluginNameValid).withMessage('Should have a valid npm name'), + (0, express_validator_1.body)('npmName').custom(plugins_1.isNpmPluginNameValid).withMessage('Should have a valid npm name'), (req, res, next) => { logger_1.logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.uninstallPluginValidator = uninstallPluginValidator; const existingPluginValidator = [ - express_validator_1.param('npmName').custom(plugins_1.isNpmPluginNameValid).withMessage('Should have a valid plugin name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('npmName').custom(plugins_1.isNpmPluginNameValid).withMessage('Should have a valid plugin name'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const plugin = yield plugin_1.PluginModel.loadByNpmName(req.params.npmName); if (!plugin) { @@ -143,29 +143,29 @@ const existingPluginValidator = [ ]; exports.existingPluginValidator = existingPluginValidator; const updatePluginSettingsValidator = [ - express_validator_1.body('settings').exists().withMessage('Should have settings'), + (0, express_validator_1.body)('settings').exists().withMessage('Should have settings'), (req, res, next) => { logger_1.logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.updatePluginSettingsValidator = updatePluginSettingsValidator; const listAvailablePluginsValidator = [ - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .exists().withMessage('Should have a valid search'), - express_validator_1.query('pluginType') + (0, express_validator_1.query)('pluginType') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(plugins_1.isPluginTypeValid).withMessage('Should have a valid plugin type'), - express_validator_1.query('currentPeerTubeEngine') + (0, express_validator_1.query)('currentPeerTubeEngine') .optional() .custom(plugins_1.isPluginVersionValid).withMessage('Should have a valid current peertube engine'), (req, res, next) => { logger_1.logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (config_1.CONFIG.PLUGINS.INDEX.ENABLED === false) { return res.fail({ message: 'Plugin index is not enabled' }); diff --git a/dist/server/middlewares/validators/redundancy.js b/dist/server/middlewares/validators/redundancy.js index f08d47bb..4598e538 100644 --- a/dist/server/middlewares/validators/redundancy.js +++ b/dist/server/middlewares/validators/redundancy.js @@ -12,19 +12,19 @@ const video_redundancy_1 = require("../../models/redundancy/video-redundancy"); const server_1 = require("../../models/server/server"); const shared_1 = require("./shared"); const videoFileRedundancyGetValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('resolution') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('resolution') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.exists).withMessage('Should have a valid resolution'), - express_validator_1.param('fps') + (0, express_validator_1.param)('fps') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.exists).withMessage('Should have a valid fps'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; const video = res.locals.videoAll; const paramResolution = req.params.resolution; @@ -52,15 +52,15 @@ const videoFileRedundancyGetValidator = [ ]; exports.videoFileRedundancyGetValidator = videoFileRedundancyGetValidator; const videoPlaylistRedundancyGetValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('streamingPlaylistType') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('streamingPlaylistType') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.exists).withMessage('Should have a valid streaming playlist type'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; const video = res.locals.videoAll; const paramPlaylistType = req.params.streamingPlaylistType; @@ -85,13 +85,13 @@ const videoPlaylistRedundancyGetValidator = [ ]; exports.videoPlaylistRedundancyGetValidator = videoPlaylistRedundancyGetValidator; const updateServerRedundancyValidator = [ - express_validator_1.param('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), - express_validator_1.body('redundancyAllowed') + (0, express_validator_1.param)('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), + (0, express_validator_1.body)('redundancyAllowed') .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const server = yield server_1.ServerModel.loadByHost(req.params.host); if (!server) { @@ -106,26 +106,26 @@ const updateServerRedundancyValidator = [ ]; exports.updateServerRedundancyValidator = updateServerRedundancyValidator; const listVideoRedundanciesValidator = [ - express_validator_1.query('target') + (0, express_validator_1.query)('target') .custom(video_redundancies_1.isVideoRedundancyTarget).withMessage('Should have a valid video redundancies target'), (req, res, next) => { logger_1.logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.listVideoRedundanciesValidator = listVideoRedundanciesValidator; const addVideoRedundancyValidator = [ - express_validator_1.body('videoId') + (0, express_validator_1.body)('videoId') .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdOrUUIDValid) .withMessage('Should have a valid video id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.body.videoId, res, 'only-video'))) + if (!(yield (0, shared_1.doesVideoExist)(req.body.videoId, res, 'only-video'))) return; if (res.locals.onlyVideo.remote === false) { return res.fail({ message: 'Cannot create a redundancy on a local video' }); @@ -145,12 +145,12 @@ const addVideoRedundancyValidator = [ ]; exports.addVideoRedundancyValidator = addVideoRedundancyValidator; const removeVideoRedundancyValidator = [ - express_validator_1.param('redundancyId') + (0, express_validator_1.param)('redundancyId') .custom(misc_1.isIdValid) .withMessage('Should have a valid redundancy id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const redundancy = yield video_redundancy_1.VideoRedundancyModel.loadByIdWithVideo(parseInt(req.params.redundancyId, 10)); if (!redundancy) { diff --git a/dist/server/middlewares/validators/search.js b/dist/server/middlewares/validators/search.js index 604b8ae7..699b944e 100644 --- a/dist/server/middlewares/validators/search.js +++ b/dist/server/middlewares/validators/search.js @@ -8,82 +8,82 @@ const misc_1 = require("../../helpers/custom-validators/misc"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const videosSearchValidator = [ - express_validator_1.query('search').optional().not().isEmpty().withMessage('Should have a valid search'), - express_validator_1.query('host') + (0, express_validator_1.query)('search').optional().not().isEmpty().withMessage('Should have a valid search'), + (0, express_validator_1.query)('host') .optional() .custom(servers_1.isHostValid).withMessage('Should have a valid host'), - express_validator_1.query('startDate') + (0, express_validator_1.query)('startDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a start date that conforms to ISO 8601'), - express_validator_1.query('endDate') + (0, express_validator_1.query)('endDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a end date that conforms to ISO 8601'), - express_validator_1.query('originallyPublishedStartDate') + (0, express_validator_1.query)('originallyPublishedStartDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a published start date that conforms to ISO 8601'), - express_validator_1.query('originallyPublishedEndDate') + (0, express_validator_1.query)('originallyPublishedEndDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a published end date that conforms to ISO 8601'), - express_validator_1.query('durationMin') + (0, express_validator_1.query)('durationMin') .optional() .isInt().withMessage('Should have a valid min duration'), - express_validator_1.query('durationMax') + (0, express_validator_1.query)('durationMax') .optional() .isInt().withMessage('Should have a valid max duration'), - express_validator_1.query('uuids') + (0, express_validator_1.query)('uuids') .optional() .toArray() .customSanitizer(misc_1.toCompleteUUIDs) .custom(misc_1.areUUIDsValid).withMessage('Should have valid uuids'), - express_validator_1.query('searchTarget').optional().custom(search_1.isSearchTargetValid).withMessage('Should have a valid search target'), + (0, express_validator_1.query)('searchTarget').optional().custom(search_1.isSearchTargetValid).withMessage('Should have a valid search target'), (req, res, next) => { logger_1.logger.debug('Checking videos search query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.videosSearchValidator = videosSearchValidator; const videoChannelsListSearchValidator = [ - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .not().isEmpty().withMessage('Should have a valid search'), - express_validator_1.query('host') + (0, express_validator_1.query)('host') .optional() .custom(servers_1.isHostValid).withMessage('Should have a valid host'), - express_validator_1.query('searchTarget') + (0, express_validator_1.query)('searchTarget') .optional() .custom(search_1.isSearchTargetValid).withMessage('Should have a valid search target'), - express_validator_1.query('handles') + (0, express_validator_1.query)('handles') .optional() .toArray() .custom(misc_1.isNotEmptyStringArray).withMessage('Should have valid handles'), (req, res, next) => { logger_1.logger.debug('Checking video channels search query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.videoChannelsListSearchValidator = videoChannelsListSearchValidator; const videoPlaylistsListSearchValidator = [ - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .not().isEmpty().withMessage('Should have a valid search'), - express_validator_1.query('host') + (0, express_validator_1.query)('host') .optional() .custom(servers_1.isHostValid).withMessage('Should have a valid host'), - express_validator_1.query('searchTarget') + (0, express_validator_1.query)('searchTarget') .optional() .custom(search_1.isSearchTargetValid).withMessage('Should have a valid search target'), - express_validator_1.query('uuids') + (0, express_validator_1.query)('uuids') .optional() .toArray() .customSanitizer(misc_1.toCompleteUUIDs) .custom(misc_1.areUUIDsValid).withMessage('Should have valid uuids'), (req, res, next) => { logger_1.logger.debug('Checking video playlists search query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/server.js b/dist/server/middlewares/validators/server.js index 7a4da652..91a3aa01 100644 --- a/dist/server/middlewares/validators/server.js +++ b/dist/server/middlewares/validators/server.js @@ -12,10 +12,10 @@ const redis_1 = require("../../lib/redis"); const server_1 = require("../../models/server/server"); const shared_1 = require("./shared"); const serverGetValidator = [ - express_validator_1.body('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('host').custom(servers_1.isHostValid).withMessage('Should have a valid host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking serverGetValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const server = yield server_1.ServerModel.loadByHost(req.body.host); if (!server) { @@ -30,15 +30,15 @@ const serverGetValidator = [ ]; exports.serverGetValidator = serverGetValidator; const contactAdministratorValidator = [ - express_validator_1.body('fromName') + (0, express_validator_1.body)('fromName') .custom(users_1.isUserDisplayNameValid).withMessage('Should have a valid name'), - express_validator_1.body('fromEmail') + (0, express_validator_1.body)('fromEmail') .isEmail().withMessage('Should have a valid email'), - express_validator_1.body('body') + (0, express_validator_1.body)('body') .custom(servers_1.isValidContactBody).withMessage('Should have a valid body'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (config_1.CONFIG.CONTACT_FORM.ENABLED === false) { return res.fail({ @@ -46,7 +46,7 @@ const contactAdministratorValidator = [ message: 'Contact form is not enabled on this instance.' }); } - if (config_1.isEmailEnabled() === false) { + if ((0, config_1.isEmailEnabled)() === false) { return res.fail({ status: http_error_codes_1.HttpStatusCode.CONFLICT_409, message: 'Emailer is not enabled on this instance.' diff --git a/dist/server/middlewares/validators/shared/abuses.js b/dist/server/middlewares/validators/shared/abuses.js index 52a17f4f..dcc5419f 100644 --- a/dist/server/middlewares/validators/shared/abuses.js +++ b/dist/server/middlewares/validators/shared/abuses.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const abuse_1 = require("@server/models/abuse/abuse"); const models_1 = require("@shared/models"); function doesAbuseExist(abuseId, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const abuse = yield abuse_1.AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)); if (!abuse) { res.fail({ diff --git a/dist/server/middlewares/validators/shared/accounts.js b/dist/server/middlewares/validators/shared/accounts.js index 205f321d..e6d5c2ca 100644 --- a/dist/server/middlewares/validators/shared/accounts.js +++ b/dist/server/middlewares/validators/shared/accounts.js @@ -21,7 +21,7 @@ function doesAccountNameWithHostExist(nameWithDomain, res, sendNotFound = true) } exports.doesAccountNameWithHostExist = doesAccountNameWithHostExist; function doesAccountExist(p, res, sendNotFound) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const account = yield p; if (!account) { if (sendNotFound === true) { @@ -38,7 +38,7 @@ function doesAccountExist(p, res, sendNotFound) { } exports.doesAccountExist = doesAccountExist; function doesUserFeedTokenCorrespond(id, token, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield user_1.UserModel.loadByIdWithChannels(parseInt(id + '', 10)); if (token !== user.feedToken) { res.fail({ diff --git a/dist/server/middlewares/validators/shared/index.js b/dist/server/middlewares/validators/shared/index.js index 7b2dafa3..c9f3b81a 100644 --- a/dist/server/middlewares/validators/shared/index.js +++ b/dist/server/middlewares/validators/shared/index.js @@ -1,14 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuses"), exports); -tslib_1.__exportStar(require("./accounts"), exports); -tslib_1.__exportStar(require("./utils"), exports); -tslib_1.__exportStar(require("./video-blacklists"), exports); -tslib_1.__exportStar(require("./video-captions"), exports); -tslib_1.__exportStar(require("./video-channels"), exports); -tslib_1.__exportStar(require("./video-comments"), exports); -tslib_1.__exportStar(require("./video-imports"), exports); -tslib_1.__exportStar(require("./video-ownerships"), exports); -tslib_1.__exportStar(require("./video-playlists"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./abuses"), exports); +(0, tslib_1.__exportStar)(require("./accounts"), exports); +(0, tslib_1.__exportStar)(require("./utils"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklists"), exports); +(0, tslib_1.__exportStar)(require("./video-captions"), exports); +(0, tslib_1.__exportStar)(require("./video-channels"), exports); +(0, tslib_1.__exportStar)(require("./video-comments"), exports); +(0, tslib_1.__exportStar)(require("./video-imports"), exports); +(0, tslib_1.__exportStar)(require("./video-ownerships"), exports); +(0, tslib_1.__exportStar)(require("./video-playlists"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/server/middlewares/validators/shared/utils.js b/dist/server/middlewares/validators/shared/utils.js index c88e5bf8..010ec4de 100644 --- a/dist/server/middlewares/validators/shared/utils.js +++ b/dist/server/middlewares/validators/shared/utils.js @@ -5,7 +5,7 @@ const express_validator_1 = require("express-validator"); const misc_1 = require("@server/helpers/custom-validators/misc"); const logger_1 = require("../../../helpers/logger"); function areValidationErrors(req, res) { - const errors = express_validator_1.validationResult(req); + const errors = (0, express_validator_1.validationResult)(req); if (!errors.isEmpty()) { logger_1.logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors.mapped() }); res.fail({ @@ -22,7 +22,7 @@ function areValidationErrors(req, res) { exports.areValidationErrors = areValidationErrors; function checkSort(sortableColumns, tags = []) { return [ - express_validator_1.query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'), + (0, express_validator_1.query)('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'), (req, res, next) => { logger_1.logger.debug('Checking sort parameters', { parameters: req.query, tags }); if (areValidationErrors(req, res)) @@ -38,13 +38,13 @@ function createSortableColumns(sortableColumns) { } exports.createSortableColumns = createSortableColumns; function isValidVideoIdParam(paramName) { - return express_validator_1.param(paramName) + return (0, express_validator_1.param)(paramName) .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdOrUUIDValid).withMessage('Should have a valid video id'); } exports.isValidVideoIdParam = isValidVideoIdParam; function isValidPlaylistIdParam(paramName) { - return express_validator_1.param(paramName) + return (0, express_validator_1.param)(paramName) .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdOrUUIDValid).withMessage('Should have a valid playlist id'); } diff --git a/dist/server/middlewares/validators/shared/video-blacklists.js b/dist/server/middlewares/validators/shared/video-blacklists.js index 64dc6dd8..00656bb8 100644 --- a/dist/server/middlewares/validators/shared/video-blacklists.js +++ b/dist/server/middlewares/validators/shared/video-blacklists.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_blacklist_1 = require("@server/models/video/video-blacklist"); const models_1 = require("@shared/models"); function doesVideoBlacklistExist(videoId, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoBlacklist = yield video_blacklist_1.VideoBlacklistModel.loadByVideoId(videoId); if (videoBlacklist === null) { res.fail({ diff --git a/dist/server/middlewares/validators/shared/video-captions.js b/dist/server/middlewares/validators/shared/video-captions.js index 86bdf38a..65a8d9c4 100644 --- a/dist/server/middlewares/validators/shared/video-captions.js +++ b/dist/server/middlewares/validators/shared/video-captions.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_caption_1 = require("@server/models/video/video-caption"); const models_1 = require("@shared/models"); function doesVideoCaptionExist(video, language, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoCaption = yield video_caption_1.VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language); if (!videoCaption) { res.fail({ diff --git a/dist/server/middlewares/validators/shared/video-channels.js b/dist/server/middlewares/validators/shared/video-channels.js index 17882f5d..8b3b900e 100644 --- a/dist/server/middlewares/validators/shared/video-channels.js +++ b/dist/server/middlewares/validators/shared/video-channels.js @@ -5,21 +5,21 @@ const tslib_1 = require("tslib"); const video_channel_1 = require("@server/models/video/video-channel"); const models_1 = require("@shared/models"); function doesLocalVideoChannelNameExist(name, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = yield video_channel_1.VideoChannelModel.loadLocalByNameAndPopulateAccount(name); return processVideoChannelExist(videoChannel, res); }); } exports.doesLocalVideoChannelNameExist = doesLocalVideoChannelNameExist; function doesVideoChannelIdExist(id, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = yield video_channel_1.VideoChannelModel.loadAndPopulateAccount(+id); return processVideoChannelExist(videoChannel, res); }); } exports.doesVideoChannelIdExist = doesVideoChannelIdExist; function doesVideoChannelNameWithHostExist(nameWithDomain, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = yield video_channel_1.VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain); return processVideoChannelExist(videoChannel, res); }); diff --git a/dist/server/middlewares/validators/shared/video-comments.js b/dist/server/middlewares/validators/shared/video-comments.js index 5087890c..cf3a2405 100644 --- a/dist/server/middlewares/validators/shared/video-comments.js +++ b/dist/server/middlewares/validators/shared/video-comments.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_comment_1 = require("@server/models/video/video-comment"); const models_1 = require("@shared/models"); function doesVideoCommentThreadExist(idArg, video, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const id = parseInt(idArg + '', 10); const videoComment = yield video_comment_1.VideoCommentModel.loadById(id); if (!videoComment) { @@ -29,7 +29,7 @@ function doesVideoCommentThreadExist(idArg, video, res) { } exports.doesVideoCommentThreadExist = doesVideoCommentThreadExist; function doesVideoCommentExist(idArg, video, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const id = parseInt(idArg + '', 10); const videoComment = yield video_comment_1.VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id); if (!videoComment) { @@ -49,7 +49,7 @@ function doesVideoCommentExist(idArg, video, res) { } exports.doesVideoCommentExist = doesVideoCommentExist; function doesCommentIdExist(idArg, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const id = parseInt(idArg + '', 10); const videoComment = yield video_comment_1.VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id); if (!videoComment) { diff --git a/dist/server/middlewares/validators/shared/video-imports.js b/dist/server/middlewares/validators/shared/video-imports.js index 2d492f71..26c1f829 100644 --- a/dist/server/middlewares/validators/shared/video-imports.js +++ b/dist/server/middlewares/validators/shared/video-imports.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_import_1 = require("@server/models/video/video-import"); const models_1 = require("@shared/models"); function doesVideoImportExist(id, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoImport = yield video_import_1.VideoImportModel.loadAndPopulateVideo(id); if (!videoImport) { res.fail({ diff --git a/dist/server/middlewares/validators/shared/video-ownerships.js b/dist/server/middlewares/validators/shared/video-ownerships.js index 701658b7..ffe140eb 100644 --- a/dist/server/middlewares/validators/shared/video-ownerships.js +++ b/dist/server/middlewares/validators/shared/video-ownerships.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_change_ownership_1 = require("@server/models/video/video-change-ownership"); const models_1 = require("@shared/models"); function doesChangeVideoOwnershipExist(idArg, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const id = parseInt(idArg + '', 10); const videoChangeOwnership = yield video_change_ownership_1.VideoChangeOwnershipModel.load(id); if (!videoChangeOwnership) { diff --git a/dist/server/middlewares/validators/shared/video-playlists.js b/dist/server/middlewares/validators/shared/video-playlists.js index 3cea9af7..a923ac28 100644 --- a/dist/server/middlewares/validators/shared/video-playlists.js +++ b/dist/server/middlewares/validators/shared/video-playlists.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const video_playlist_1 = require("@server/models/video/video-playlist"); const models_1 = require("@shared/models"); function doesVideoPlaylistExist(id, res, fetchType = 'summary') { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (fetchType === 'summary') { const videoPlaylist = yield video_playlist_1.VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined); res.locals.videoPlaylistSummary = videoPlaylist; diff --git a/dist/server/middlewares/validators/shared/videos.js b/dist/server/middlewares/validators/shared/videos.js index f801070e..eb190e98 100644 --- a/dist/server/middlewares/validators/shared/videos.js +++ b/dist/server/middlewares/validators/shared/videos.js @@ -7,9 +7,9 @@ const video_channel_1 = require("@server/models/video/video-channel"); const video_file_1 = require("@server/models/video/video-file"); const models_1 = require("@shared/models"); function doesVideoExist(id, res, fetchType = 'all') { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined; - const video = yield model_loaders_1.loadVideo(id, fetchType, userId); + const video = yield (0, model_loaders_1.loadVideo)(id, fetchType, userId); if (video === null) { res.fail({ status: models_1.HttpStatusCode.NOT_FOUND_404, @@ -39,7 +39,7 @@ function doesVideoExist(id, res, fetchType = 'all') { } exports.doesVideoExist = doesVideoExist; function doesVideoFileOfVideoExist(id, videoIdOrUUID, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!(yield video_file_1.VideoFileModel.doesVideoExistForVideoFile(id, videoIdOrUUID))) { res.fail({ status: models_1.HttpStatusCode.NOT_FOUND_404, @@ -52,7 +52,7 @@ function doesVideoFileOfVideoExist(id, videoIdOrUUID, res) { } exports.doesVideoFileOfVideoExist = doesVideoFileOfVideoExist; function doesVideoChannelOfAccountExist(channelId, user, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoChannel = yield video_channel_1.VideoChannelModel.loadAndPopulateAccount(channelId); if (videoChannel === null) { res.fail({ message: 'Unknown video "video channel" for this instance.' }); diff --git a/dist/server/middlewares/validators/sort.js b/dist/server/middlewares/validators/sort.js index ee474fe9..39890ea9 100644 --- a/dist/server/middlewares/validators/sort.js +++ b/dist/server/middlewares/validators/sort.js @@ -3,75 +3,75 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.pluginsSortValidator = exports.videoPlaylistsSearchSortValidator = exports.videoRedundanciesSortValidator = exports.videoPlaylistsSortValidator = exports.userNotificationsSortValidator = exports.serversBlocklistSortValidator = exports.accountsBlocklistSortValidator = exports.videoChannelsSearchSortValidator = exports.availablePluginsSortValidator = exports.userSubscriptionsSortValidator = exports.videoRatesSortValidator = exports.videoCommentThreadsSortValidator = exports.jobsSortValidator = exports.followingSortValidator = exports.followersSortValidator = exports.accountsSortValidator = exports.blacklistSortValidator = exports.videosSortValidator = exports.videosSearchSortValidator = exports.videoCommentsValidator = exports.videoImportsSortValidator = exports.videoChannelsSortValidator = exports.abusesSortValidator = exports.usersSortValidator = void 0; const constants_1 = require("../../initializers/constants"); const shared_1 = require("./shared"); -const SORTABLE_USERS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.USERS); -const SORTABLE_ACCOUNTS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.ACCOUNTS); -const SORTABLE_JOBS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.JOBS); -const SORTABLE_ABUSES_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.ABUSES); -const SORTABLE_VIDEOS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEOS); -const SORTABLE_VIDEOS_SEARCH_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEOS_SEARCH); -const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH); -const SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_PLAYLISTS_SEARCH); -const SORTABLE_VIDEO_IMPORTS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_IMPORTS); -const SORTABLE_VIDEO_COMMENTS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS); -const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS); -const SORTABLE_VIDEO_RATES_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_RATES); -const SORTABLE_BLACKLISTS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.BLACKLISTS); -const SORTABLE_VIDEO_CHANNELS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_CHANNELS); -const SORTABLE_FOLLOWERS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.FOLLOWERS); -const SORTABLE_FOLLOWING_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.FOLLOWING); -const SORTABLE_USER_SUBSCRIPTIONS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.USER_SUBSCRIPTIONS); -const SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.ACCOUNTS_BLOCKLIST); -const SORTABLE_SERVERS_BLOCKLIST_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.SERVERS_BLOCKLIST); -const SORTABLE_USER_NOTIFICATIONS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.USER_NOTIFICATIONS); -const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_PLAYLISTS); -const SORTABLE_PLUGINS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.PLUGINS); -const SORTABLE_AVAILABLE_PLUGINS_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.AVAILABLE_PLUGINS); -const SORTABLE_VIDEO_REDUNDANCIES_COLUMNS = shared_1.createSortableColumns(constants_1.SORTABLE_COLUMNS.VIDEO_REDUNDANCIES); -const usersSortValidator = shared_1.checkSort(SORTABLE_USERS_COLUMNS); +const SORTABLE_USERS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.USERS); +const SORTABLE_ACCOUNTS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.ACCOUNTS); +const SORTABLE_JOBS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.JOBS); +const SORTABLE_ABUSES_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.ABUSES); +const SORTABLE_VIDEOS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEOS); +const SORTABLE_VIDEOS_SEARCH_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEOS_SEARCH); +const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH); +const SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_PLAYLISTS_SEARCH); +const SORTABLE_VIDEO_IMPORTS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_IMPORTS); +const SORTABLE_VIDEO_COMMENTS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS); +const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS); +const SORTABLE_VIDEO_RATES_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_RATES); +const SORTABLE_BLACKLISTS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.BLACKLISTS); +const SORTABLE_VIDEO_CHANNELS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_CHANNELS); +const SORTABLE_FOLLOWERS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.FOLLOWERS); +const SORTABLE_FOLLOWING_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.FOLLOWING); +const SORTABLE_USER_SUBSCRIPTIONS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.USER_SUBSCRIPTIONS); +const SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.ACCOUNTS_BLOCKLIST); +const SORTABLE_SERVERS_BLOCKLIST_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.SERVERS_BLOCKLIST); +const SORTABLE_USER_NOTIFICATIONS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.USER_NOTIFICATIONS); +const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_PLAYLISTS); +const SORTABLE_PLUGINS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.PLUGINS); +const SORTABLE_AVAILABLE_PLUGINS_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.AVAILABLE_PLUGINS); +const SORTABLE_VIDEO_REDUNDANCIES_COLUMNS = (0, shared_1.createSortableColumns)(constants_1.SORTABLE_COLUMNS.VIDEO_REDUNDANCIES); +const usersSortValidator = (0, shared_1.checkSort)(SORTABLE_USERS_COLUMNS); exports.usersSortValidator = usersSortValidator; -const accountsSortValidator = shared_1.checkSort(SORTABLE_ACCOUNTS_COLUMNS); +const accountsSortValidator = (0, shared_1.checkSort)(SORTABLE_ACCOUNTS_COLUMNS); exports.accountsSortValidator = accountsSortValidator; -const jobsSortValidator = shared_1.checkSort(SORTABLE_JOBS_COLUMNS, ['jobs']); +const jobsSortValidator = (0, shared_1.checkSort)(SORTABLE_JOBS_COLUMNS, ['jobs']); exports.jobsSortValidator = jobsSortValidator; -const abusesSortValidator = shared_1.checkSort(SORTABLE_ABUSES_COLUMNS); +const abusesSortValidator = (0, shared_1.checkSort)(SORTABLE_ABUSES_COLUMNS); exports.abusesSortValidator = abusesSortValidator; -const videosSortValidator = shared_1.checkSort(SORTABLE_VIDEOS_COLUMNS); +const videosSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEOS_COLUMNS); exports.videosSortValidator = videosSortValidator; -const videoImportsSortValidator = shared_1.checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS); +const videoImportsSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_IMPORTS_COLUMNS); exports.videoImportsSortValidator = videoImportsSortValidator; -const videosSearchSortValidator = shared_1.checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS); +const videosSearchSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEOS_SEARCH_COLUMNS); exports.videosSearchSortValidator = videosSearchSortValidator; -const videoChannelsSearchSortValidator = shared_1.checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS); +const videoChannelsSearchSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS); exports.videoChannelsSearchSortValidator = videoChannelsSearchSortValidator; -const videoPlaylistsSearchSortValidator = shared_1.checkSort(SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS); +const videoPlaylistsSearchSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS); exports.videoPlaylistsSearchSortValidator = videoPlaylistsSearchSortValidator; -const videoCommentsValidator = shared_1.checkSort(SORTABLE_VIDEO_COMMENTS_COLUMNS); +const videoCommentsValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_COMMENTS_COLUMNS); exports.videoCommentsValidator = videoCommentsValidator; -const videoCommentThreadsSortValidator = shared_1.checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS); +const videoCommentThreadsSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS); exports.videoCommentThreadsSortValidator = videoCommentThreadsSortValidator; -const videoRatesSortValidator = shared_1.checkSort(SORTABLE_VIDEO_RATES_COLUMNS); +const videoRatesSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_RATES_COLUMNS); exports.videoRatesSortValidator = videoRatesSortValidator; -const blacklistSortValidator = shared_1.checkSort(SORTABLE_BLACKLISTS_COLUMNS); +const blacklistSortValidator = (0, shared_1.checkSort)(SORTABLE_BLACKLISTS_COLUMNS); exports.blacklistSortValidator = blacklistSortValidator; -const videoChannelsSortValidator = shared_1.checkSort(SORTABLE_VIDEO_CHANNELS_COLUMNS); +const videoChannelsSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_CHANNELS_COLUMNS); exports.videoChannelsSortValidator = videoChannelsSortValidator; -const followersSortValidator = shared_1.checkSort(SORTABLE_FOLLOWERS_COLUMNS); +const followersSortValidator = (0, shared_1.checkSort)(SORTABLE_FOLLOWERS_COLUMNS); exports.followersSortValidator = followersSortValidator; -const followingSortValidator = shared_1.checkSort(SORTABLE_FOLLOWING_COLUMNS); +const followingSortValidator = (0, shared_1.checkSort)(SORTABLE_FOLLOWING_COLUMNS); exports.followingSortValidator = followingSortValidator; -const userSubscriptionsSortValidator = shared_1.checkSort(SORTABLE_USER_SUBSCRIPTIONS_COLUMNS); +const userSubscriptionsSortValidator = (0, shared_1.checkSort)(SORTABLE_USER_SUBSCRIPTIONS_COLUMNS); exports.userSubscriptionsSortValidator = userSubscriptionsSortValidator; -const accountsBlocklistSortValidator = shared_1.checkSort(SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS); +const accountsBlocklistSortValidator = (0, shared_1.checkSort)(SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS); exports.accountsBlocklistSortValidator = accountsBlocklistSortValidator; -const serversBlocklistSortValidator = shared_1.checkSort(SORTABLE_SERVERS_BLOCKLIST_COLUMNS); +const serversBlocklistSortValidator = (0, shared_1.checkSort)(SORTABLE_SERVERS_BLOCKLIST_COLUMNS); exports.serversBlocklistSortValidator = serversBlocklistSortValidator; -const userNotificationsSortValidator = shared_1.checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS); +const userNotificationsSortValidator = (0, shared_1.checkSort)(SORTABLE_USER_NOTIFICATIONS_COLUMNS); exports.userNotificationsSortValidator = userNotificationsSortValidator; -const videoPlaylistsSortValidator = shared_1.checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS); +const videoPlaylistsSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_PLAYLISTS_COLUMNS); exports.videoPlaylistsSortValidator = videoPlaylistsSortValidator; -const pluginsSortValidator = shared_1.checkSort(SORTABLE_PLUGINS_COLUMNS); +const pluginsSortValidator = (0, shared_1.checkSort)(SORTABLE_PLUGINS_COLUMNS); exports.pluginsSortValidator = pluginsSortValidator; -const availablePluginsSortValidator = shared_1.checkSort(SORTABLE_AVAILABLE_PLUGINS_COLUMNS); +const availablePluginsSortValidator = (0, shared_1.checkSort)(SORTABLE_AVAILABLE_PLUGINS_COLUMNS); exports.availablePluginsSortValidator = availablePluginsSortValidator; -const videoRedundanciesSortValidator = shared_1.checkSort(SORTABLE_VIDEO_REDUNDANCIES_COLUMNS); +const videoRedundanciesSortValidator = (0, shared_1.checkSort)(SORTABLE_VIDEO_REDUNDANCIES_COLUMNS); exports.videoRedundanciesSortValidator = videoRedundanciesSortValidator; diff --git a/dist/server/middlewares/validators/themes.js b/dist/server/middlewares/validators/themes.js index d9a41331..9c78376c 100644 --- a/dist/server/middlewares/validators/themes.js +++ b/dist/server/middlewares/validators/themes.js @@ -9,12 +9,12 @@ const logger_1 = require("../../helpers/logger"); const plugin_manager_1 = require("../../lib/plugins/plugin-manager"); const shared_1 = require("./shared"); const serveThemeCSSValidator = [ - express_validator_1.param('themeName').custom(plugins_1.isPluginNameValid).withMessage('Should have a valid theme name'), - express_validator_1.param('themeVersion').custom(plugins_1.isPluginVersionValid).withMessage('Should have a valid theme version'), - express_validator_1.param('staticEndpoint').custom(misc_1.isSafePath).withMessage('Should have a valid static endpoint'), + (0, express_validator_1.param)('themeName').custom(plugins_1.isPluginNameValid).withMessage('Should have a valid theme name'), + (0, express_validator_1.param)('themeVersion').custom(plugins_1.isPluginVersionValid).withMessage('Should have a valid theme version'), + (0, express_validator_1.param)('staticEndpoint').custom(misc_1.isSafePath).withMessage('Should have a valid static endpoint'), (req, res, next) => { logger_1.logger.debug('Checking serveThemeCSS parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const theme = plugin_manager_1.PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName); if (!theme || theme.version !== req.params.themeVersion) { diff --git a/dist/server/middlewares/validators/user-history.js b/dist/server/middlewares/validators/user-history.js index 80c90d61..3e9f1986 100644 --- a/dist/server/middlewares/validators/user-history.js +++ b/dist/server/middlewares/validators/user-history.js @@ -6,24 +6,24 @@ const misc_1 = require("../../helpers/custom-validators/misc"); const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const userHistoryListValidator = [ - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .custom(misc_1.exists).withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.userHistoryListValidator = userHistoryListValidator; const userHistoryRemoveValidator = [ - express_validator_1.body('beforeDate') + (0, express_validator_1.body)('beforeDate') .optional() .custom(misc_1.isDateValid).withMessage('Should have a before date that conforms to ISO 8601'), (req, res, next) => { logger_1.logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/user-notifications.js b/dist/server/middlewares/validators/user-notifications.js index 331f87be..a0fc2dec 100644 --- a/dist/server/middlewares/validators/user-notifications.js +++ b/dist/server/middlewares/validators/user-notifications.js @@ -7,58 +7,58 @@ const user_notifications_1 = require("../../helpers/custom-validators/user-notif const logger_1 = require("../../helpers/logger"); const shared_1 = require("./shared"); const listUserNotificationsValidator = [ - express_validator_1.query('unread') + (0, express_validator_1.query)('unread') .optional() .customSanitizer(misc_1.toBooleanOrNull) .isBoolean().withMessage('Should have a valid unread boolean'), (req, res, next) => { logger_1.logger.debug('Checking listUserNotificationsValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.listUserNotificationsValidator = listUserNotificationsValidator; const updateNotificationSettingsValidator = [ - express_validator_1.body('newVideoFromSubscription') + (0, express_validator_1.body)('newVideoFromSubscription') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'), - express_validator_1.body('newCommentOnMyVideo') + (0, express_validator_1.body)('newCommentOnMyVideo') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new comment on my video notification setting'), - express_validator_1.body('abuseAsModerator') + (0, express_validator_1.body)('abuseAsModerator') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid abuse as moderator notification setting'), - express_validator_1.body('videoAutoBlacklistAsModerator') + (0, express_validator_1.body)('videoAutoBlacklistAsModerator') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid video auto blacklist notification setting'), - express_validator_1.body('blacklistOnMyVideo') + (0, express_validator_1.body)('blacklistOnMyVideo') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new blacklist on my video notification setting'), - express_validator_1.body('myVideoImportFinished') + (0, express_validator_1.body)('myVideoImportFinished') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid video import finished video notification setting'), - express_validator_1.body('myVideoPublished') + (0, express_validator_1.body)('myVideoPublished') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid video published notification setting'), - express_validator_1.body('commentMention') + (0, express_validator_1.body)('commentMention') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid comment mention notification setting'), - express_validator_1.body('newFollow') + (0, express_validator_1.body)('newFollow') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new follow notification setting'), - express_validator_1.body('newUserRegistration') + (0, express_validator_1.body)('newUserRegistration') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new user registration notification setting'), - express_validator_1.body('newInstanceFollower') + (0, express_validator_1.body)('newInstanceFollower') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new instance follower notification setting'), - express_validator_1.body('autoInstanceFollowing') + (0, express_validator_1.body)('autoInstanceFollowing') .custom(user_notifications_1.isUserNotificationSettingValid).withMessage('Should have a valid new instance following notification setting'), (req, res, next) => { logger_1.logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.updateNotificationSettingsValidator = updateNotificationSettingsValidator; const markAsReadUserNotificationsValidator = [ - express_validator_1.body('ids') + (0, express_validator_1.body)('ids') .optional() .custom(misc_1.isNotEmptyIntArray).withMessage('Should have a valid notification ids to mark as read'), (req, res, next) => { logger_1.logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/user-subscriptions.js b/dist/server/middlewares/validators/user-subscriptions.js index d2c1f195..b243a79d 100644 --- a/dist/server/middlewares/validators/user-subscriptions.js +++ b/dist/server/middlewares/validators/user-subscriptions.js @@ -11,42 +11,42 @@ const constants_1 = require("../../initializers/constants"); const actor_follow_1 = require("../../models/actor/actor-follow"); const shared_1 = require("./shared"); const userSubscriptionListValidator = [ - express_validator_1.query('search').optional().not().isEmpty().withMessage('Should have a valid search'), + (0, express_validator_1.query)('search').optional().not().isEmpty().withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.userSubscriptionListValidator = userSubscriptionListValidator; const userSubscriptionAddValidator = [ - express_validator_1.body('uri').custom(actor_1.isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), + (0, express_validator_1.body)('uri').custom(actor_1.isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), (req, res, next) => { logger_1.logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.userSubscriptionAddValidator = userSubscriptionAddValidator; const areSubscriptionsExistValidator = [ - express_validator_1.query('uris') + (0, express_validator_1.query)('uris') .customSanitizer(misc_1.toArray) .custom(actor_1.areValidActorHandles).withMessage('Should have a valid uri array'), (req, res, next) => { logger_1.logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.areSubscriptionsExistValidator = areSubscriptionsExistValidator; const userSubscriptionGetValidator = [ - express_validator_1.param('uri').custom(actor_1.isValidActorHandle).withMessage('Should have a valid URI to unfollow'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('uri').custom(actor_1.isValidActorHandle).withMessage('Should have a valid URI to unfollow'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; let [name, host] = req.params.uri.split('@'); if (host === constants_1.WEBSERVER.HOST) diff --git a/dist/server/middlewares/validators/users.js b/dist/server/middlewares/validators/users.js index e95dda16..669b14c4 100644 --- a/dist/server/middlewares/validators/users.js +++ b/dist/server/middlewares/validators/users.js @@ -19,32 +19,32 @@ const actor_1 = require("../../models/actor/actor"); const user_1 = require("../../models/user/user"); const shared_1 = require("./shared"); const usersListValidator = [ - express_validator_1.query('blocked') + (0, express_validator_1.query)('blocked') .optional() .customSanitizer(misc_1.toBooleanOrNull) .isBoolean().withMessage('Should be a valid boolean banned state'), (req, res, next) => { logger_1.logger.debug('Checking usersList parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.usersListValidator = usersListValidator; const usersAddValidator = [ - express_validator_1.body('username').custom(users_2.isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), - express_validator_1.body('password').custom(users_2.isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), - express_validator_1.body('email').isEmail().withMessage('Should have a valid email'), - express_validator_1.body('channelName').optional().custom(video_channels_1.isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), - express_validator_1.body('videoQuota').custom(users_2.isUserVideoQuotaValid).withMessage('Should have a valid user quota'), - express_validator_1.body('videoQuotaDaily').custom(users_2.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), - express_validator_1.body('role') + (0, express_validator_1.body)('username').custom(users_2.isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), + (0, express_validator_1.body)('password').custom(users_2.isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), + (0, express_validator_1.body)('email').isEmail().withMessage('Should have a valid email'), + (0, express_validator_1.body)('channelName').optional().custom(video_channels_1.isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), + (0, express_validator_1.body)('videoQuota').custom(users_2.isUserVideoQuotaValid).withMessage('Should have a valid user quota'), + (0, express_validator_1.body)('videoQuotaDaily').custom(users_2.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), + (0, express_validator_1.body)('role') .customSanitizer(misc_1.toIntOrNull) .custom(users_2.isUserRoleValid).withMessage('Should have a valid role'), - express_validator_1.body('adminFlags').optional().custom(users_2.isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { - logger_1.logger.debug('Checking usersAdd parameters', { parameters: lodash_1.omit(req.body, 'password') }); - if (shared_1.areValidationErrors(req, res)) + (0, express_validator_1.body)('adminFlags').optional().custom(users_2.isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { + logger_1.logger.debug('Checking usersAdd parameters', { parameters: (0, lodash_1.omit)(req.body, 'password') }); + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserNameOrEmailDoesNotAlreadyExist(req.body.username, req.body.email, res))) return; @@ -72,21 +72,21 @@ const usersAddValidator = [ ]; exports.usersAddValidator = usersAddValidator; const usersRegisterValidator = [ - express_validator_1.body('username').custom(users_2.isUserUsernameValid).withMessage('Should have a valid username'), - express_validator_1.body('password').custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), - express_validator_1.body('email').isEmail().withMessage('Should have a valid email'), - express_validator_1.body('displayName') + (0, express_validator_1.body)('username').custom(users_2.isUserUsernameValid).withMessage('Should have a valid username'), + (0, express_validator_1.body)('password').custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), + (0, express_validator_1.body)('email').isEmail().withMessage('Should have a valid email'), + (0, express_validator_1.body)('displayName') .optional() .custom(users_2.isUserDisplayNameValid).withMessage('Should have a valid display name'), - express_validator_1.body('channel.name') + (0, express_validator_1.body)('channel.name') .optional() .custom(video_channels_1.isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), - express_validator_1.body('channel.displayName') + (0, express_validator_1.body)('channel.displayName') .optional() .custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { - logger_1.logger.debug('Checking usersRegister parameters', { parameters: lodash_1.omit(req.body, 'password') }); - if (shared_1.areValidationErrors(req, res)) + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { + logger_1.logger.debug('Checking usersRegister parameters', { parameters: (0, lodash_1.omit)(req.body, 'password') }); + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserNameOrEmailDoesNotAlreadyExist(req.body.username, req.body.email, res))) return; @@ -111,10 +111,10 @@ const usersRegisterValidator = [ ]; exports.usersRegisterValidator = usersRegisterValidator; const usersRemoveValidator = [ - express_validator_1.param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersRemove parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res))) return; @@ -127,11 +127,11 @@ const usersRemoveValidator = [ ]; exports.usersRemoveValidator = usersRemoveValidator; const usersBlockingValidator = [ - express_validator_1.param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.body('reason').optional().custom(users_2.isUserBlockedReasonValid).withMessage('Should have a valid blocking reason'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + (0, express_validator_1.body)('reason').optional().custom(users_2.isUserBlockedReasonValid).withMessage('Should have a valid blocking reason'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersBlocking parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res))) return; @@ -154,21 +154,21 @@ const deleteMeValidator = [ ]; exports.deleteMeValidator = deleteMeValidator; const usersUpdateValidator = [ - express_validator_1.param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.body('password').optional().custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), - express_validator_1.body('email').optional().isEmail().withMessage('Should have a valid email attribute'), - express_validator_1.body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'), - express_validator_1.body('videoQuota').optional().custom(users_2.isUserVideoQuotaValid).withMessage('Should have a valid user quota'), - express_validator_1.body('videoQuotaDaily').optional().custom(users_2.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), - express_validator_1.body('pluginAuth').optional(), - express_validator_1.body('role') + (0, express_validator_1.param)('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + (0, express_validator_1.body)('password').optional().custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), + (0, express_validator_1.body)('email').optional().isEmail().withMessage('Should have a valid email attribute'), + (0, express_validator_1.body)('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'), + (0, express_validator_1.body)('videoQuota').optional().custom(users_2.isUserVideoQuotaValid).withMessage('Should have a valid user quota'), + (0, express_validator_1.body)('videoQuotaDaily').optional().custom(users_2.isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), + (0, express_validator_1.body)('pluginAuth').optional(), + (0, express_validator_1.body)('role') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(users_2.isUserRoleValid).withMessage('Should have a valid role'), - express_validator_1.body('adminFlags').optional().custom(users_2.isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('adminFlags').optional().custom(users_2.isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersUpdate parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res))) return; @@ -181,50 +181,50 @@ const usersUpdateValidator = [ ]; exports.usersUpdateValidator = usersUpdateValidator; const usersUpdateMeValidator = [ - express_validator_1.body('displayName') + (0, express_validator_1.body)('displayName') .optional() .custom(users_2.isUserDisplayNameValid).withMessage('Should have a valid display name'), - express_validator_1.body('description') + (0, express_validator_1.body)('description') .optional() .custom(users_2.isUserDescriptionValid).withMessage('Should have a valid description'), - express_validator_1.body('currentPassword') + (0, express_validator_1.body)('currentPassword') .optional() .custom(users_2.isUserPasswordValid).withMessage('Should have a valid current password'), - express_validator_1.body('password') + (0, express_validator_1.body)('password') .optional() .custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), - express_validator_1.body('email') + (0, express_validator_1.body)('email') .optional() .isEmail().withMessage('Should have a valid email attribute'), - express_validator_1.body('nsfwPolicy') + (0, express_validator_1.body)('nsfwPolicy') .optional() .custom(users_2.isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'), - express_validator_1.body('autoPlayVideo') + (0, express_validator_1.body)('autoPlayVideo') .optional() .custom(users_2.isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'), - express_validator_1.body('videoLanguages') + (0, express_validator_1.body)('videoLanguages') .optional() .custom(users_2.isUserVideoLanguages).withMessage('Should have a valid video languages attribute'), - express_validator_1.body('videosHistoryEnabled') + (0, express_validator_1.body)('videosHistoryEnabled') .optional() .custom(users_2.isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), - express_validator_1.body('theme') + (0, express_validator_1.body)('theme') .optional() - .custom(v => plugins_1.isThemeNameValid(v) && theme_utils_1.isThemeRegistered(v)).withMessage('Should have a valid theme'), - express_validator_1.body('noInstanceConfigWarningModal') + .custom(v => (0, plugins_1.isThemeNameValid)(v) && (0, theme_utils_1.isThemeRegistered)(v)).withMessage('Should have a valid theme'), + (0, express_validator_1.body)('noInstanceConfigWarningModal') .optional() - .custom(v => users_2.isUserNoModal(v)).withMessage('Should have a valid noInstanceConfigWarningModal boolean'), - express_validator_1.body('noWelcomeModal') + .custom(v => (0, users_2.isUserNoModal)(v)).withMessage('Should have a valid noInstanceConfigWarningModal boolean'), + (0, express_validator_1.body)('noWelcomeModal') .optional() - .custom(v => users_2.isUserNoModal(v)).withMessage('Should have a valid noWelcomeModal boolean'), - express_validator_1.body('noAccountSetupWarningModal') + .custom(v => (0, users_2.isUserNoModal)(v)).withMessage('Should have a valid noWelcomeModal boolean'), + (0, express_validator_1.body)('noAccountSetupWarningModal') .optional() - .custom(v => users_2.isUserNoModal(v)).withMessage('Should have a valid noAccountSetupWarningModal boolean'), - express_validator_1.body('autoPlayNextVideo') + .custom(v => (0, users_2.isUserNoModal)(v)).withMessage('Should have a valid noAccountSetupWarningModal boolean'), + (0, express_validator_1.body)('autoPlayNextVideo') .optional() - .custom(v => users_2.isUserAutoPlayNextVideoValid(v)).withMessage('Should have a valid autoPlayNextVideo boolean'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { - logger_1.logger.debug('Checking usersUpdateMe parameters', { parameters: lodash_1.omit(req.body, 'password') }); + .custom(v => (0, users_2.isUserAutoPlayNextVideoValid)(v)).withMessage('Should have a valid autoPlayNextVideo boolean'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { + logger_1.logger.debug('Checking usersUpdateMe parameters', { parameters: (0, lodash_1.omit)(req.body, 'password') }); const user = res.locals.oauth.token.User; if (req.body.password || req.body.email) { if (user.pluginAuth !== null) { @@ -240,18 +240,18 @@ const usersUpdateMeValidator = [ }); } } - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); }) ]; exports.usersUpdateMeValidator = usersUpdateMeValidator; const usersGetValidator = [ - express_validator_1.param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + (0, express_validator_1.query)('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersGet parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res, req.query.withStats))) return; @@ -260,19 +260,19 @@ const usersGetValidator = [ ]; exports.usersGetValidator = usersGetValidator; const usersVideoRatingValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersVideoRating parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'id'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'id'))) return; return next(); }) ]; exports.usersVideoRatingValidator = usersVideoRatingValidator; const ensureUserRegistrationAllowed = [ - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { const allowedParams = { body: req.body, ip: req.ip @@ -290,7 +290,7 @@ const ensureUserRegistrationAllowed = [ exports.ensureUserRegistrationAllowed = ensureUserRegistrationAllowed; const ensureUserRegistrationAllowedForIP = [ (req, res, next) => { - const allowed = signup_1.isSignupAllowedForCurrentIP(req.ip); + const allowed = (0, signup_1.isSignupAllowedForCurrentIP)(req.ip); if (allowed === false) { return res.fail({ status: http_error_codes_1.HttpStatusCode.FORBIDDEN_403, @@ -302,10 +302,10 @@ const ensureUserRegistrationAllowedForIP = [ ]; exports.ensureUserRegistrationAllowedForIP = ensureUserRegistrationAllowedForIP; const usersAskResetPasswordValidator = [ - express_validator_1.body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const exists = yield checkUserEmailExist(req.body.email, res, false); if (!exists) { @@ -317,12 +317,12 @@ const usersAskResetPasswordValidator = [ ]; exports.usersAskResetPasswordValidator = usersAskResetPasswordValidator; const usersResetPasswordValidator = [ - express_validator_1.param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'), - express_validator_1.body('password').custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + (0, express_validator_1.body)('verificationString').not().isEmpty().withMessage('Should have a valid verification string'), + (0, express_validator_1.body)('password').custom(users_2.isUserPasswordValid).withMessage('Should have a valid password'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersResetPassword parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res))) return; @@ -339,10 +339,10 @@ const usersResetPasswordValidator = [ ]; exports.usersResetPasswordValidator = usersResetPasswordValidator; const usersAskSendVerifyEmailValidator = [ - express_validator_1.body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking askUsersSendVerifyEmail parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const exists = yield checkUserEmailExist(req.body.email, res, false); if (!exists) { @@ -354,16 +354,16 @@ const usersAskSendVerifyEmailValidator = [ ]; exports.usersAskSendVerifyEmailValidator = usersAskSendVerifyEmailValidator; const usersVerifyEmailValidator = [ - express_validator_1.param('id') + (0, express_validator_1.param)('id') .isInt().not().isEmpty().withMessage('Should have a valid id'), - express_validator_1.body('verificationString') + (0, express_validator_1.body)('verificationString') .not().isEmpty().withMessage('Should have a valid verification string'), - express_validator_1.body('isPendingEmail') + (0, express_validator_1.body)('isPendingEmail') .optional() .customSanitizer(misc_1.toBooleanOrNull), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (!(yield checkUserIdExist(req.params.id, res))) return; @@ -380,7 +380,7 @@ const usersVerifyEmailValidator = [ ]; exports.usersVerifyEmailValidator = usersVerifyEmailValidator; const userAutocompleteValidator = [ - express_validator_1.param('search').isString().not().isEmpty().withMessage('Should have a search parameter') + (0, express_validator_1.param)('search').isString().not().isEmpty().withMessage('Should have a search parameter') ]; exports.userAutocompleteValidator = userAutocompleteValidator; const ensureAuthUserOwnsAccountValidator = [ @@ -419,7 +419,7 @@ function checkUserEmailExist(email, res, abortResponse = true) { return checkUserExist(() => user_1.UserModel.loadByEmail(email), res, abortResponse); } function checkUserNameOrEmailDoesNotAlreadyExist(username, email, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield user_1.UserModel.loadByUsernameOrEmail(username, email); if (user) { res.fail({ @@ -440,7 +440,7 @@ function checkUserNameOrEmailDoesNotAlreadyExist(username, email, res) { }); } function checkUserExist(finder, res, abortResponse = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield finder(); if (!user) { if (abortResponse === true) { diff --git a/dist/server/middlewares/validators/videos/index.js b/dist/server/middlewares/validators/videos/index.js index 2e46daa7..c320ddad 100644 --- a/dist/server/middlewares/validators/videos/index.js +++ b/dist/server/middlewares/validators/videos/index.js @@ -1,14 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-blacklist"), exports); -tslib_1.__exportStar(require("./video-captions"), exports); -tslib_1.__exportStar(require("./video-channels"), exports); -tslib_1.__exportStar(require("./video-comments"), exports); -tslib_1.__exportStar(require("./video-imports"), exports); -tslib_1.__exportStar(require("./video-live"), exports); -tslib_1.__exportStar(require("./video-ownership-changes"), exports); -tslib_1.__exportStar(require("./video-watch"), exports); -tslib_1.__exportStar(require("./video-rates"), exports); -tslib_1.__exportStar(require("./video-shares"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist"), exports); +(0, tslib_1.__exportStar)(require("./video-captions"), exports); +(0, tslib_1.__exportStar)(require("./video-channels"), exports); +(0, tslib_1.__exportStar)(require("./video-comments"), exports); +(0, tslib_1.__exportStar)(require("./video-imports"), exports); +(0, tslib_1.__exportStar)(require("./video-live"), exports); +(0, tslib_1.__exportStar)(require("./video-ownership-changes"), exports); +(0, tslib_1.__exportStar)(require("./video-watch"), exports); +(0, tslib_1.__exportStar)(require("./video-rates"), exports); +(0, tslib_1.__exportStar)(require("./video-shares"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/server/middlewares/validators/videos/video-blacklist.js b/dist/server/middlewares/validators/videos/video-blacklist.js index 7ff6bc36..f11a3687 100644 --- a/dist/server/middlewares/validators/videos/video-blacklist.js +++ b/dist/server/middlewares/validators/videos/video-blacklist.js @@ -9,33 +9,33 @@ const video_blacklist_1 = require("../../../helpers/custom-validators/video-blac const logger_1 = require("../../../helpers/logger"); const shared_1 = require("../shared"); const videosBlacklistRemoveValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking blacklistRemove parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; - if (!(yield shared_1.doesVideoBlacklistExist(res.locals.videoAll.id, res))) + if (!(yield (0, shared_1.doesVideoBlacklistExist)(res.locals.videoAll.id, res))) return; return next(); }) ]; exports.videosBlacklistRemoveValidator = videosBlacklistRemoveValidator; const videosBlacklistAddValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.body('unfederate') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.body)('unfederate') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid unfederate boolean'), - express_validator_1.body('reason') + (0, express_validator_1.body)('reason') .optional() .custom(video_blacklist_1.isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; const video = res.locals.videoAll; if (req.body.unfederate === true && video.remote === true) { @@ -49,34 +49,34 @@ const videosBlacklistAddValidator = [ ]; exports.videosBlacklistAddValidator = videosBlacklistAddValidator; const videosBlacklistUpdateValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.body('reason') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.body)('reason') .optional() .custom(video_blacklist_1.isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosBlacklistUpdate parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; - if (!(yield shared_1.doesVideoBlacklistExist(res.locals.videoAll.id, res))) + if (!(yield (0, shared_1.doesVideoBlacklistExist)(res.locals.videoAll.id, res))) return; return next(); }) ]; exports.videosBlacklistUpdateValidator = videosBlacklistUpdateValidator; const videosBlacklistFiltersValidator = [ - express_validator_1.query('type') + (0, express_validator_1.query)('type') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(video_blacklist_1.isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .not() .isEmpty().withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking videos blacklist filters query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/videos/video-captions.js b/dist/server/middlewares/validators/videos/video-captions.js index 2864c59c..befce38f 100644 --- a/dist/server/middlewares/validators/videos/video-captions.js +++ b/dist/server/middlewares/validators/videos/video-captions.js @@ -9,54 +9,54 @@ const logger_1 = require("../../../helpers/logger"); const constants_1 = require("../../../initializers/constants"); const shared_1 = require("../shared"); const addVideoCaptionValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('captionLanguage') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('captionLanguage') .custom(video_captions_1.isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'), - express_validator_1.body('captionfile') - .custom((_, { req }) => video_captions_1.isVideoCaptionFile(req.files, 'captionfile')) + (0, express_validator_1.body)('captionfile') + .custom((_, { req }) => (0, video_captions_1.isVideoCaptionFile)(req.files, 'captionfile')) .withMessage('This caption file is not supported or too large. ' + `Please, make sure it is under ${constants_1.CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max} bytes ` + 'and one of the following mimetypes: ' + Object.keys(constants_1.MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT).map(key => `${key} (${constants_1.MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT[key]})`).join(', ')), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking addVideoCaption parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); const user = res.locals.oauth.token.User; - if (!shared_1.checkUserCanManageVideo(user, res.locals.videoAll, 17, res)) - return express_utils_1.cleanUpReqFiles(req); + if (!(0, shared_1.checkUserCanManageVideo)(user, res.locals.videoAll, 17, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]; exports.addVideoCaptionValidator = addVideoCaptionValidator; const deleteVideoCaptionValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('captionLanguage') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('captionLanguage') .custom(video_captions_1.isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking deleteVideoCaption parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; - if (!(yield shared_1.doesVideoCaptionExist(res.locals.videoAll, req.params.captionLanguage, res))) + if (!(yield (0, shared_1.doesVideoCaptionExist)(res.locals.videoAll, req.params.captionLanguage, res))) return; const user = res.locals.oauth.token.User; - if (!shared_1.checkUserCanManageVideo(user, res.locals.videoAll, 17, res)) + if (!(0, shared_1.checkUserCanManageVideo)(user, res.locals.videoAll, 17, res)) return; return next(); }) ]; exports.deleteVideoCaptionValidator = deleteVideoCaptionValidator; const listVideoCaptionsValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking listVideoCaptions parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'id'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'id'))) return; return next(); }) diff --git a/dist/server/middlewares/validators/videos/video-channels.js b/dist/server/middlewares/validators/videos/video-channels.js index aac7b32f..941086e5 100644 --- a/dist/server/middlewares/validators/videos/video-channels.js +++ b/dist/server/middlewares/validators/videos/video-channels.js @@ -12,13 +12,13 @@ const actor_1 = require("../../../models/actor/actor"); const video_channel_1 = require("../../../models/video/video-channel"); const shared_1 = require("../shared"); const videoChannelsAddValidator = [ - express_validator_1.body('name').custom(video_channels_1.isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), - express_validator_1.body('displayName').custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), - express_validator_1.body('description').optional().custom(video_channels_1.isVideoChannelDescriptionValid).withMessage('Should have a valid description'), - express_validator_1.body('support').optional().custom(video_channels_1.isVideoChannelSupportValid).withMessage('Should have a valid support text'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.body)('name').custom(video_channels_1.isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), + (0, express_validator_1.body)('displayName').custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), + (0, express_validator_1.body)('description').optional().custom(video_channels_1.isVideoChannelDescriptionValid).withMessage('Should have a valid description'), + (0, express_validator_1.body)('support').optional().custom(video_channels_1.isVideoChannelSupportValid).withMessage('Should have a valid support text'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const actor = yield actor_1.ActorModel.loadLocalByName(req.body.name); if (actor) { @@ -38,24 +38,24 @@ const videoChannelsAddValidator = [ ]; exports.videoChannelsAddValidator = videoChannelsAddValidator; const videoChannelsUpdateValidator = [ - express_validator_1.param('nameWithHost').exists().withMessage('Should have an video channel name with host'), - express_validator_1.body('displayName') + (0, express_validator_1.param)('nameWithHost').exists().withMessage('Should have an video channel name with host'), + (0, express_validator_1.body)('displayName') .optional() .custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), - express_validator_1.body('description') + (0, express_validator_1.body)('description') .optional() .custom(video_channels_1.isVideoChannelDescriptionValid).withMessage('Should have a valid description'), - express_validator_1.body('support') + (0, express_validator_1.body)('support') .optional() .custom(video_channels_1.isVideoChannelSupportValid).withMessage('Should have a valid support text'), - express_validator_1.body('bulkVideosSupportUpdate') + (0, express_validator_1.body)('bulkVideosSupportUpdate') .optional() .custom(misc_1.isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoChannelNameWithHostExist(req.params.nameWithHost, res))) + if (!(yield (0, shared_1.doesVideoChannelNameWithHostExist)(req.params.nameWithHost, res))) return; if (res.locals.videoChannel.Actor.isOwned() === false) { return res.fail({ @@ -74,12 +74,12 @@ const videoChannelsUpdateValidator = [ ]; exports.videoChannelsUpdateValidator = videoChannelsUpdateValidator; const videoChannelsRemoveValidator = [ - express_validator_1.param('nameWithHost').exists().withMessage('Should have an video channel name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('nameWithHost').exists().withMessage('Should have an video channel name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoChannelsRemove parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoChannelNameWithHostExist(req.params.nameWithHost, res))) + if (!(yield (0, shared_1.doesVideoChannelNameWithHostExist)(req.params.nameWithHost, res))) return; if (!checkUserCanDeleteVideoChannel(res.locals.oauth.token.User, res.locals.videoChannel, res)) return; @@ -90,46 +90,46 @@ const videoChannelsRemoveValidator = [ ]; exports.videoChannelsRemoveValidator = videoChannelsRemoveValidator; const videoChannelsNameWithHostValidator = [ - express_validator_1.param('nameWithHost').exists().withMessage('Should have an video channel name with host'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('nameWithHost').exists().withMessage('Should have an video channel name with host'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoChannelNameWithHostExist(req.params.nameWithHost, res))) + if (!(yield (0, shared_1.doesVideoChannelNameWithHostExist)(req.params.nameWithHost, res))) return; return next(); }) ]; exports.videoChannelsNameWithHostValidator = videoChannelsNameWithHostValidator; const localVideoChannelValidator = [ - express_validator_1.param('name').custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid video channel name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.param)('name').custom(video_channels_1.isVideoChannelDisplayNameValid).withMessage('Should have a valid video channel name'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking localVideoChannelValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesLocalVideoChannelNameExist(req.params.name, res))) + if (!(yield (0, shared_1.doesLocalVideoChannelNameExist)(req.params.name, res))) return; return next(); }) ]; exports.localVideoChannelValidator = localVideoChannelValidator; const videoChannelStatsValidator = [ - express_validator_1.query('withStats') + (0, express_validator_1.query)('withStats') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid stats flag'), (req, res, next) => { - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.videoChannelStatsValidator = videoChannelStatsValidator; const videoChannelsListValidator = [ - express_validator_1.query('search').optional().not().isEmpty().withMessage('Should have a valid search'), + (0, express_validator_1.query)('search').optional().not().isEmpty().withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking video channels search query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } @@ -153,7 +153,7 @@ function checkUserCanDeleteVideoChannel(user, videoChannel, res) { return true; } function checkVideoChannelIsNotTheLastOne(res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const count = yield video_channel_1.VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id); if (count <= 1) { res.fail({ diff --git a/dist/server/middlewares/validators/videos/video-comments.js b/dist/server/middlewares/validators/videos/video-comments.js index c242c8f6..39f0c13d 100644 --- a/dist/server/middlewares/validators/videos/video-comments.js +++ b/dist/server/middlewares/validators/videos/video-comments.js @@ -11,65 +11,65 @@ const moderation_1 = require("../../../lib/moderation"); const hooks_1 = require("../../../lib/plugins/hooks"); const shared_1 = require("../shared"); const listVideoCommentsValidator = [ - express_validator_1.query('isLocal') + (0, express_validator_1.query)('isLocal') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid) .withMessage('Should have a valid is local boolean'), - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .custom(misc_1.exists).withMessage('Should have a valid search'), - express_validator_1.query('searchAccount') + (0, express_validator_1.query)('searchAccount') .optional() .custom(misc_1.exists).withMessage('Should have a valid account search'), - express_validator_1.query('searchVideo') + (0, express_validator_1.query)('searchVideo') .optional() .custom(misc_1.exists).withMessage('Should have a valid video search'), (req, res, next) => { logger_1.logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.listVideoCommentsValidator = listVideoCommentsValidator; const listVideoCommentThreadsValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking listVideoCommentThreads parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'only-video'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'only-video'))) return; return next(); }) ]; exports.listVideoCommentThreadsValidator = listVideoCommentThreadsValidator; const listVideoThreadCommentsValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('threadId') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('threadId') .custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid threadId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'only-video'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'only-video'))) return; - if (!(yield shared_1.doesVideoCommentThreadExist(req.params.threadId, res.locals.onlyVideo, res))) + if (!(yield (0, shared_1.doesVideoCommentThreadExist)(req.params.threadId, res.locals.onlyVideo, res))) return; return next(); }) ]; exports.listVideoThreadCommentsValidator = listVideoThreadCommentsValidator; const addVideoCommentThreadValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.body('text') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.body)('text') .custom(video_comments_1.isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return; @@ -80,18 +80,18 @@ const addVideoCommentThreadValidator = [ ]; exports.addVideoCommentThreadValidator = addVideoCommentThreadValidator; const addVideoCommentReplyValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('commentId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), - express_validator_1.body('text').custom(video_comments_1.isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('commentId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), + (0, express_validator_1.body)('text').custom(video_comments_1.isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return; - if (!(yield shared_1.doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res))) + if (!(yield (0, shared_1.doesVideoCommentExist)(req.params.commentId, res.locals.videoAll, res))) return; if (!(yield isVideoCommentAccepted(req, res, res.locals.videoAll, true))) return; @@ -100,31 +100,31 @@ const addVideoCommentReplyValidator = [ ]; exports.addVideoCommentReplyValidator = addVideoCommentReplyValidator; const videoCommentGetValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('commentId') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('commentId') .custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'id'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'id'))) return; - if (!(yield shared_1.doesVideoCommentExist(req.params.commentId, res.locals.videoId, res))) + if (!(yield (0, shared_1.doesVideoCommentExist)(req.params.commentId, res.locals.videoId, res))) return; return next(); }) ]; exports.videoCommentGetValidator = videoCommentGetValidator; const removeVideoCommentValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.param('commentId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.param)('commentId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; - if (!(yield shared_1.doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res))) + if (!(yield (0, shared_1.doesVideoCommentExist)(req.params.commentId, res.locals.videoAll, res))) return; if (!checkUserCanDeleteVideoComment(res.locals.oauth.token.User, res.locals.videoCommentFull, res)) return; @@ -163,7 +163,7 @@ function checkUserCanDeleteVideoComment(user, videoComment, res) { return true; } function isVideoCommentAccepted(req, res, video, isReply) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const acceptParameters = { video, commentBody: req.body, diff --git a/dist/server/middlewares/validators/videos/video-imports.js b/dist/server/middlewares/validators/videos/video-imports.js index 8df3fde1..4ebdba82 100644 --- a/dist/server/middlewares/validators/videos/video-imports.js +++ b/dist/server/middlewares/validators/videos/video-imports.js @@ -15,58 +15,58 @@ const config_1 = require("../../../initializers/config"); const constants_1 = require("../../../initializers/constants"); const shared_1 = require("../shared"); const videos_2 = require("./videos"); -const videoImportAddValidator = videos_2.getCommonVideoEditAttributes().concat([ - express_validator_1.body('channelId') +const videoImportAddValidator = (0, videos_2.getCommonVideoEditAttributes)().concat([ + (0, express_validator_1.body)('channelId') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.isIdValid).withMessage('Should have correct video channel id'), - express_validator_1.body('targetUrl') + (0, express_validator_1.body)('targetUrl') .optional() .custom(video_imports_1.isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'), - express_validator_1.body('magnetUri') + (0, express_validator_1.body)('magnetUri') .optional() .custom(videos_1.isVideoMagnetUriValid).withMessage('Should have a valid video magnet URI'), - express_validator_1.body('torrentfile') - .custom((value, { req }) => video_imports_1.isVideoImportTorrentFile(req.files)) + (0, express_validator_1.body)('torrentfile') + .custom((value, { req }) => (0, video_imports_1.isVideoImportTorrentFile)(req.files)) .withMessage('This torrent file is not supported or too large. Please, make sure it is of the following type: ' + constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.EXTNAME.join(', ')), - express_validator_1.body('name') + (0, express_validator_1.body)('name') .optional() .custom(videos_1.isVideoNameValid).withMessage(`Should have a video name between ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { var _a; logger_1.logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body }); const user = res.locals.oauth.token.User; const torrentFile = ((_a = req.files) === null || _a === void 0 ? void 0 : _a['torrentfile']) ? req.files['torrentfile'][0] : undefined; - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); if (config_1.CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true && req.body.targetUrl) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.CONFLICT_409, message: 'HTTP import is not enabled on this instance.' }); } if (config_1.CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED !== true && (req.body.magnetUri || torrentFile)) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.CONFLICT_409, message: 'Torrent/magnet URI import is not enabled on this instance.' }); } - if (!(yield shared_1.doesVideoChannelOfAccountExist(req.body.channelId, user, res))) - return express_utils_1.cleanUpReqFiles(req); + if (!(yield (0, shared_1.doesVideoChannelOfAccountExist)(req.body.channelId, user, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ message: 'Should have a magnetUri or a targetUrl or a torrent file.' }); } if (!(yield isImportAccepted(req, res))) - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]); exports.videoImportAddValidator = videoImportAddValidator; function isImportAccepted(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = req.body; const hookName = body.targetUrl ? 'filter:api.video.pre-import-url.accept.result' diff --git a/dist/server/middlewares/validators/videos/video-live.js b/dist/server/middlewares/validators/videos/video-live.js index f1a3eab7..fe2773c7 100644 --- a/dist/server/middlewares/validators/videos/video-live.js +++ b/dist/server/middlewares/validators/videos/video-live.js @@ -17,15 +17,15 @@ const config_1 = require("../../../initializers/config"); const shared_1 = require("../shared"); const videos_2 = require("./videos"); const videoLiveGetValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoLiveGetValidator parameters', { parameters: req.params, user: res.locals.oauth.token.User.username }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'all'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'all'))) return; const user = res.locals.oauth.token.User; - if (!shared_1.checkUserCanManageVideo(user, res.locals.videoAll, 19, res, false)) + if (!(0, shared_1.checkUserCanManageVideo)(user, res.locals.videoAll, 19, res, false)) return; const videoLive = yield video_live_1.VideoLiveModel.loadByVideoId(res.locals.videoAll.id); if (!videoLive) { @@ -39,26 +39,26 @@ const videoLiveGetValidator = [ }) ]; exports.videoLiveGetValidator = videoLiveGetValidator; -const videoLiveAddValidator = videos_2.getCommonVideoEditAttributes().concat([ - express_validator_1.body('channelId') +const videoLiveAddValidator = (0, videos_2.getCommonVideoEditAttributes)().concat([ + (0, express_validator_1.body)('channelId') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.isIdValid).withMessage('Should have correct video channel id'), - express_validator_1.body('name') + (0, express_validator_1.body)('name') .custom(videos_1.isVideoNameValid).withMessage(`Should have a video name between ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`), - express_validator_1.body('saveReplay') + (0, express_validator_1.body)('saveReplay') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid saveReplay attribute'), - express_validator_1.body('permanentLive') + (0, express_validator_1.body)('permanentLive') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid permanentLive attribute'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); if (config_1.CONFIG.LIVE.ENABLED !== true) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.FORBIDDEN_403, message: 'Live is not enabled on this instance', @@ -66,7 +66,7 @@ const videoLiveAddValidator = videos_2.getCommonVideoEditAttributes().concat([ }); } if (config_1.CONFIG.LIVE.ALLOW_REPLAY !== true && req.body.saveReplay === true) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.FORBIDDEN_403, message: 'Saving live replay is not enabled on this instance', @@ -74,16 +74,16 @@ const videoLiveAddValidator = videos_2.getCommonVideoEditAttributes().concat([ }); } if (req.body.permanentLive && req.body.saveReplay) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ message: 'Cannot set this live as permanent while saving its replay' }); } const user = res.locals.oauth.token.User; - if (!(yield shared_1.doesVideoChannelOfAccountExist(req.body.channelId, user, res))) - return express_utils_1.cleanUpReqFiles(req); + if (!(yield (0, shared_1.doesVideoChannelOfAccountExist)(req.body.channelId, user, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); if (config_1.CONFIG.LIVE.MAX_INSTANCE_LIVES !== -1) { const totalInstanceLives = yield video_1.VideoModel.countLocalLives(); if (totalInstanceLives >= config_1.CONFIG.LIVE.MAX_INSTANCE_LIVES) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.FORBIDDEN_403, message: 'Cannot create this live because the max instance lives limit is reached.', @@ -94,7 +94,7 @@ const videoLiveAddValidator = videos_2.getCommonVideoEditAttributes().concat([ if (config_1.CONFIG.LIVE.MAX_USER_LIVES !== -1) { const totalUserLives = yield video_1.VideoModel.countLivesOfAccount(user.Account.id); if (totalUserLives >= config_1.CONFIG.LIVE.MAX_USER_LIVES) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ status: models_1.HttpStatusCode.FORBIDDEN_403, message: 'Cannot create this live because the max user lives limit is reached.', @@ -103,19 +103,19 @@ const videoLiveAddValidator = videos_2.getCommonVideoEditAttributes().concat([ } } if (!(yield isLiveVideoAccepted(req, res))) - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]); exports.videoLiveAddValidator = videoLiveAddValidator; const videoLiveUpdateValidator = [ - express_validator_1.body('saveReplay') + (0, express_validator_1.body)('saveReplay') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid saveReplay attribute'), (req, res, next) => { logger_1.logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; if (req.body.permanentLive && req.body.saveReplay) { return res.fail({ message: 'Cannot set this live as permanent while saving its replay' }); @@ -130,14 +130,14 @@ const videoLiveUpdateValidator = [ return res.fail({ message: 'Cannot update a live that has already started' }); } const user = res.locals.oauth.token.User; - if (!shared_1.checkUserCanManageVideo(user, res.locals.videoAll, 19, res)) + if (!(0, shared_1.checkUserCanManageVideo)(user, res.locals.videoAll, 19, res)) return; return next(); } ]; exports.videoLiveUpdateValidator = videoLiveUpdateValidator; function isLiveVideoAccepted(req, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const acceptParameters = { liveVideoBody: req.body, user: res.locals.oauth.token.User diff --git a/dist/server/middlewares/validators/videos/video-ownership-changes.js b/dist/server/middlewares/validators/videos/video-ownership-changes.js index 6036aabd..5020bffc 100644 --- a/dist/server/middlewares/validators/videos/video-ownership-changes.js +++ b/dist/server/middlewares/validators/videos/video-ownership-changes.js @@ -11,14 +11,14 @@ const account_1 = require("@server/models/account/account"); const models_1 = require("@shared/models"); const shared_1 = require("../shared"); const videosChangeOwnershipValidator = [ - shared_1.isValidVideoIdParam('videoId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking changeOwnership parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res))) return; - if (!shared_1.checkUserCanManageVideo(res.locals.oauth.token.User, res.locals.videoAll, 22, res)) + if (!(0, shared_1.checkUserCanManageVideo)(res.locals.oauth.token.User, res.locals.videoAll, 22, res)) return; const nextOwner = yield account_1.AccountModel.loadLocalByName(req.body.username); if (!nextOwner) { @@ -31,15 +31,15 @@ const videosChangeOwnershipValidator = [ ]; exports.videosChangeOwnershipValidator = videosChangeOwnershipValidator; const videosTerminateChangeOwnershipValidator = [ - express_validator_1.param('id') + (0, express_validator_1.param)('id') .custom(misc_1.isIdValid).withMessage('Should have a valid id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking changeOwnership parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesChangeVideoOwnershipExist(req.params.id, res))) + if (!(yield (0, shared_1.doesChangeVideoOwnershipExist)(req.params.id, res))) return; - if (!video_ownership_1.checkUserCanTerminateOwnershipChange(res.locals.oauth.token.User, res.locals.videoChangeOwnership, res)) + if (!(0, video_ownership_1.checkUserCanTerminateOwnershipChange)(res.locals.oauth.token.User, res.locals.videoChangeOwnership, res)) return; const videoChangeOwnership = res.locals.videoChangeOwnership; if (videoChangeOwnership.status !== "WAITING") { @@ -54,9 +54,9 @@ const videosTerminateChangeOwnershipValidator = [ ]; exports.videosTerminateChangeOwnershipValidator = videosTerminateChangeOwnershipValidator; const videosAcceptChangeOwnershipValidator = [ - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { const body = req.body; - if (!(yield shared_1.doesVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res))) + if (!(yield (0, shared_1.doesVideoChannelOfAccountExist)(body.channelId, res.locals.oauth.token.User, res))) return; const videoChangeOwnership = res.locals.videoChangeOwnership; const video = videoChangeOwnership.Video; @@ -67,7 +67,7 @@ const videosAcceptChangeOwnershipValidator = [ ]; exports.videosAcceptChangeOwnershipValidator = videosAcceptChangeOwnershipValidator; function checkCanAccept(video, res) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (video.isLive) { if (video.state !== 4) { res.fail({ @@ -79,7 +79,7 @@ function checkCanAccept(video, res) { return true; } const user = res.locals.oauth.token.User; - if (!(yield user_1.isAbleToUploadVideo(user.id, video.getMaxQualityFile().size))) { + if (!(yield (0, user_1.isAbleToUploadVideo)(user.id, video.getMaxQualityFile().size))) { res.fail({ status: models_1.HttpStatusCode.PAYLOAD_TOO_LARGE_413, message: 'The user video quota is exceeded with this video.', diff --git a/dist/server/middlewares/validators/videos/video-playlists.js b/dist/server/middlewares/validators/videos/video-playlists.js index 17de82ed..36e2a258 100644 --- a/dist/server/middlewares/validators/videos/video-playlists.js +++ b/dist/server/middlewares/validators/videos/video-playlists.js @@ -14,18 +14,18 @@ const video_playlist_element_1 = require("../../../models/video/video-playlist-e const auth_1 = require("../../auth"); const shared_1 = require("../shared"); const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ - express_validator_1.body('displayName') + (0, express_validator_1.body)('displayName') .custom(video_playlists_1.isVideoPlaylistNameValid).withMessage('Should have a valid display name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); const body = req.body; - if (body.videoChannelId && !(yield shared_1.doesVideoChannelIdExist(body.videoChannelId, res))) - return express_utils_1.cleanUpReqFiles(req); + if (body.videoChannelId && !(yield (0, shared_1.doesVideoChannelIdExist)(body.videoChannelId, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); if (!body.videoChannelId && (body.privacy === 1 || body.privacy === 2)) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ message: 'Cannot set "public" or "unlisted" a playlist that is not assigned to a channel.' }); } return next(); @@ -33,45 +33,45 @@ const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ ]); exports.videoPlaylistsAddValidator = videoPlaylistsAddValidator; const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([ - shared_1.isValidPlaylistIdParam('playlistId'), - express_validator_1.body('displayName') + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (0, express_validator_1.body)('displayName') .optional() .custom(video_playlists_1.isVideoPlaylistNameValid).withMessage('Should have a valid display name'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res, 'all'))) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res, 'all'))) + return (0, express_utils_1.cleanUpReqFiles)(req); const videoPlaylist = getPlaylist(res); if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, 15, res)) { - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); } const body = req.body; const newPrivacy = body.privacy || videoPlaylist.privacy; if (newPrivacy === 1 && ((!videoPlaylist.videoChannelId && !body.videoChannelId) || body.videoChannelId === null)) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ message: 'Cannot set "public" a playlist that is not assigned to a channel.' }); } if (videoPlaylist.type === 2) { - express_utils_1.cleanUpReqFiles(req); + (0, express_utils_1.cleanUpReqFiles)(req); return res.fail({ message: 'Cannot update a watch later playlist.' }); } - if (body.videoChannelId && !(yield shared_1.doesVideoChannelIdExist(body.videoChannelId, res))) - return express_utils_1.cleanUpReqFiles(req); + if (body.videoChannelId && !(yield (0, shared_1.doesVideoChannelIdExist)(body.videoChannelId, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]); exports.videoPlaylistsUpdateValidator = videoPlaylistsUpdateValidator; const videoPlaylistsDeleteValidator = [ - shared_1.isValidPlaylistIdParam('playlistId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsDeleteValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res))) + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res))) return; const videoPlaylist = getPlaylist(res); if (videoPlaylist.type === 2) { @@ -86,16 +86,16 @@ const videoPlaylistsDeleteValidator = [ exports.videoPlaylistsDeleteValidator = videoPlaylistsDeleteValidator; const videoPlaylistsGetValidator = (fetchType) => { return [ - shared_1.isValidPlaylistIdParam('playlistId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res, fetchType))) + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res, fetchType))) return; const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary; if (videoPlaylist.privacy === 2) { - if (misc_1.isUUIDValid(req.params.playlistId)) + if ((0, misc_1.isUUIDValid)(req.params.playlistId)) return next(); return res.fail({ status: http_error_codes_1.HttpStatusCode.NOT_FOUND_404, @@ -103,7 +103,7 @@ const videoPlaylistsGetValidator = (fetchType) => { }); } if (videoPlaylist.privacy === 3) { - yield auth_1.authenticatePromiseIfNeeded(req, res); + yield (0, auth_1.authenticatePromiseIfNeeded)(req, res); const user = res.locals.oauth ? res.locals.oauth.token.User : null; if (!user || (videoPlaylist.OwnerAccount.id !== user.Account.id && !user.hasRight(18))) { @@ -120,33 +120,33 @@ const videoPlaylistsGetValidator = (fetchType) => { }; exports.videoPlaylistsGetValidator = videoPlaylistsGetValidator; const videoPlaylistsSearchValidator = [ - express_validator_1.query('search').optional().not().isEmpty().withMessage('Should have a valid search'), + (0, express_validator_1.query)('search').optional().not().isEmpty().withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking videoPlaylists search query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.videoPlaylistsSearchValidator = videoPlaylistsSearchValidator; const videoPlaylistsAddVideoValidator = [ - shared_1.isValidPlaylistIdParam('playlistId'), - express_validator_1.body('videoId') + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (0, express_validator_1.body)('videoId') .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'), - express_validator_1.body('startTimestamp') + (0, express_validator_1.body)('startTimestamp') .optional() .custom(video_playlists_1.isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), - express_validator_1.body('stopTimestamp') + (0, express_validator_1.body)('stopTimestamp') .optional() .custom(video_playlists_1.isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res, 'all'))) + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res, 'all'))) return; - if (!(yield shared_1.doesVideoExist(req.body.videoId, res, 'only-video'))) + if (!(yield (0, shared_1.doesVideoExist)(req.body.videoId, res, 'only-video'))) return; const videoPlaylist = getPlaylist(res); if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, 18, res)) { @@ -157,21 +157,21 @@ const videoPlaylistsAddVideoValidator = [ ]; exports.videoPlaylistsAddVideoValidator = videoPlaylistsAddVideoValidator; const videoPlaylistsUpdateOrRemoveVideoValidator = [ - shared_1.isValidPlaylistIdParam('playlistId'), - express_validator_1.param('playlistElementId') + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (0, express_validator_1.param)('playlistElementId') .customSanitizer(misc_1.toCompleteUUID) .custom(misc_1.isIdValid).withMessage('Should have an element id/uuid'), - express_validator_1.body('startTimestamp') + (0, express_validator_1.body)('startTimestamp') .optional() .custom(video_playlists_1.isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), - express_validator_1.body('stopTimestamp') + (0, express_validator_1.body)('stopTimestamp') .optional() .custom(video_playlists_1.isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res, 'all'))) + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res, 'all'))) return; const videoPlaylist = getPlaylist(res); const videoPlaylistElement = yield video_playlist_element_1.VideoPlaylistElementModel.loadById(req.params.playlistElementId); @@ -190,12 +190,12 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [ ]; exports.videoPlaylistsUpdateOrRemoveVideoValidator = videoPlaylistsUpdateOrRemoveVideoValidator; const videoPlaylistElementAPGetValidator = [ - shared_1.isValidPlaylistIdParam('playlistId'), - express_validator_1.param('playlistElementId') + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (0, express_validator_1.param)('playlistElementId') .custom(misc_1.isIdValid).withMessage('Should have an playlist element id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const playlistElementId = parseInt(req.params.playlistElementId + '', 10); const playlistId = req.params.playlistId; @@ -219,19 +219,19 @@ const videoPlaylistElementAPGetValidator = [ ]; exports.videoPlaylistElementAPGetValidator = videoPlaylistElementAPGetValidator; const videoPlaylistsReorderVideosValidator = [ - shared_1.isValidPlaylistIdParam('playlistId'), - express_validator_1.body('startPosition') + (0, shared_1.isValidPlaylistIdParam)('playlistId'), + (0, express_validator_1.body)('startPosition') .isInt({ min: 1 }).withMessage('Should have a valid start position'), - express_validator_1.body('insertAfterPosition') + (0, express_validator_1.body)('insertAfterPosition') .isInt({ min: 0 }).withMessage('Should have a valid insert after position'), - express_validator_1.body('reorderLength') + (0, express_validator_1.body)('reorderLength') .optional() .isInt({ min: 1 }).withMessage('Should have a valid range length'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoPlaylistExist(req.params.playlistId, res, 'all'))) + if (!(yield (0, shared_1.doesVideoPlaylistExist)(req.params.playlistId, res, 'all'))) return; const videoPlaylist = getPlaylist(res); if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, 18, res)) @@ -253,24 +253,24 @@ const videoPlaylistsReorderVideosValidator = [ ]; exports.videoPlaylistsReorderVideosValidator = videoPlaylistsReorderVideosValidator; const commonVideoPlaylistFiltersValidator = [ - express_validator_1.query('playlistType') + (0, express_validator_1.query)('playlistType') .optional() .custom(video_playlists_1.isVideoPlaylistTypeValid).withMessage('Should have a valid playlist type'), (req, res, next) => { logger_1.logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } ]; exports.commonVideoPlaylistFiltersValidator = commonVideoPlaylistFiltersValidator; const doVideosInPlaylistExistValidator = [ - express_validator_1.query('videoIds') + (0, express_validator_1.query)('videoIds') .customSanitizer(misc_1.toIntArray) - .custom(v => misc_1.isArrayOf(v, misc_1.isIdValid)).withMessage('Should have a valid video ids array'), + .custom(v => (0, misc_1.isArrayOf)(v, misc_1.isIdValid)).withMessage('Should have a valid video ids array'), (req, res, next) => { logger_1.logger.debug('Checking areVideosInPlaylistExistValidator parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } @@ -278,19 +278,19 @@ const doVideosInPlaylistExistValidator = [ exports.doVideosInPlaylistExistValidator = doVideosInPlaylistExistValidator; function getCommonPlaylistEditAttributes() { return [ - express_validator_1.body('thumbnailfile') - .custom((value, { req }) => videos_1.isVideoImage(req.files, 'thumbnailfile')) + (0, express_validator_1.body)('thumbnailfile') + .custom((value, { req }) => (0, videos_1.isVideoImage)(req.files, 'thumbnailfile')) .withMessage('This thumbnail file is not supported or too large. Please, make sure it is of the following type: ' + constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.IMAGE.EXTNAME.join(', ')), - express_validator_1.body('description') + (0, express_validator_1.body)('description') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(video_playlists_1.isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), - express_validator_1.body('privacy') + (0, express_validator_1.body)('privacy') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(video_playlists_1.isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), - express_validator_1.body('videoChannelId') + (0, express_validator_1.body)('videoChannelId') .optional() .customSanitizer(misc_1.toIntOrNull) ]; diff --git a/dist/server/middlewares/validators/videos/video-rates.js b/dist/server/middlewares/validators/videos/video-rates.js index 22b27ee4..8422dac7 100644 --- a/dist/server/middlewares/validators/videos/video-rates.js +++ b/dist/server/middlewares/validators/videos/video-rates.js @@ -12,13 +12,13 @@ const logger_1 = require("../../../helpers/logger"); const account_video_rate_1 = require("../../../models/account/account-video-rate"); const shared_1 = require("../shared"); const videoUpdateRateValidator = [ - shared_1.isValidVideoIdParam('id'), - express_validator_1.body('rating').custom(videos_1.isVideoRatingTypeValid).withMessage('Should have a valid rate type'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('id'), + (0, express_validator_1.body)('rating').custom(videos_1.isVideoRatingTypeValid).withMessage('Should have a valid rate type'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoRate parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.id, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.id, res))) return; return next(); }) @@ -26,11 +26,11 @@ const videoUpdateRateValidator = [ exports.videoUpdateRateValidator = videoUpdateRateValidator; const getAccountVideoRateValidatorFactory = function (rateType) { return [ - express_validator_1.param('name').custom(accounts_1.isAccountNameValid).withMessage('Should have a valid account name'), - express_validator_1.param('videoId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid videoId'), - (req, res, next) => tslib_1.__awaiter(this, void 0, void 0, function* () { + (0, express_validator_1.param)('name').custom(accounts_1.isAccountNameValid).withMessage('Should have a valid account name'), + (0, express_validator_1.param)('videoId').custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid videoId'), + (req, res, next) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { logger_1.logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const rate = yield account_video_rate_1.AccountVideoRateModel.loadLocalAndPopulateVideo(rateType, req.params.name, +req.params.videoId); if (!rate) { @@ -46,10 +46,10 @@ const getAccountVideoRateValidatorFactory = function (rateType) { }; exports.getAccountVideoRateValidatorFactory = getAccountVideoRateValidatorFactory; const videoRatingValidator = [ - express_validator_1.query('rating').optional().custom(video_rates_1.isRatingValid).withMessage('Value must be one of "like" or "dislike"'), + (0, express_validator_1.query)('rating').optional().custom(video_rates_1.isRatingValid).withMessage('Value must be one of "like" or "dislike"'), (req, res, next) => { logger_1.logger.debug('Checking rating parameter', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } diff --git a/dist/server/middlewares/validators/videos/video-shares.js b/dist/server/middlewares/validators/videos/video-shares.js index fd247a1f..367b9629 100644 --- a/dist/server/middlewares/validators/videos/video-shares.js +++ b/dist/server/middlewares/validators/videos/video-shares.js @@ -9,14 +9,14 @@ const logger_1 = require("../../../helpers/logger"); const video_share_1 = require("../../../models/video/video-share"); const shared_1 = require("../shared"); const videosShareValidator = [ - shared_1.isValidVideoIdParam('id'), - express_validator_1.param('actorId') + (0, shared_1.isValidVideoIdParam)('id'), + (0, express_validator_1.param)('actorId') .custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid actor id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoShare parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.id, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.id, res))) return; const video = res.locals.videoAll; const share = yield video_share_1.VideoShareModel.load(req.params.actorId, video.id); diff --git a/dist/server/middlewares/validators/videos/video-watch.js b/dist/server/middlewares/validators/videos/video-watch.js index a1e6e8d0..6543f5b4 100644 --- a/dist/server/middlewares/validators/videos/video-watch.js +++ b/dist/server/middlewares/validators/videos/video-watch.js @@ -8,15 +8,15 @@ const misc_1 = require("../../../helpers/custom-validators/misc"); const logger_1 = require("../../../helpers/logger"); const shared_1 = require("../shared"); const videoWatchingValidator = [ - shared_1.isValidVideoIdParam('videoId'), - express_validator_1.body('currentTime') + (0, shared_1.isValidVideoIdParam)('videoId'), + (0, express_validator_1.body)('currentTime') .customSanitizer(misc_1.toIntOrNull) .isInt().withMessage('Should have correct current time'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoWatching parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.videoId, res, 'id'))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.videoId, res, 'id'))) return; const user = res.locals.oauth.token.User; if (user.videosHistoryEnabled === false) { diff --git a/dist/server/middlewares/validators/videos/videos.js b/dist/server/middlewares/validators/videos/videos.js index 86c7db74..9bcc78ff 100644 --- a/dist/server/middlewares/validators/videos/videos.js +++ b/dist/server/middlewares/validators/videos/videos.js @@ -23,23 +23,23 @@ const video_2 = require("../../../models/video/video"); const auth_1 = require("../../auth"); const shared_1 = require("../shared"); const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([ - express_validator_1.body('videofile') - .custom((value, { req }) => misc_1.isFileFieldValid(req.files, 'videofile')) + (0, express_validator_1.body)('videofile') + .custom((value, { req }) => (0, misc_1.isFileFieldValid)(req.files, 'videofile')) .withMessage('Should have a file'), - express_validator_1.body('name') + (0, express_validator_1.body)('name') .trim() .custom(videos_1.isVideoNameValid).withMessage(`Should have a video name between ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`), - express_validator_1.body('channelId') + (0, express_validator_1.body)('channelId') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.isIdValid).withMessage('Should have correct video channel id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); const videoFile = req.files['videofile'][0]; const user = res.locals.oauth.token.User; if (!(yield commonVideoChecksPass({ req, res, user, videoFileSize: videoFile.size, files: req.files }))) { - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); } try { if (!videoFile.duration) @@ -51,21 +51,21 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([ status: http_error_codes_1.HttpStatusCode.UNPROCESSABLE_ENTITY_422, message: 'Video file unreadable.' }); - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); } if (!(yield isVideoAccepted(req, res, videoFile))) - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]); exports.videosAddLegacyValidator = videosAddLegacyValidator; const videosAddResumableValidator = [ - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { const user = res.locals.oauth.token.User; const body = req.body; - const file = Object.assign(Object.assign({}, body), { duration: undefined, path: upload_1.getResumableUploadPath(body.id), filename: body.metadata.filename }); - const cleanup = () => utils_1.deleteFileAndCatch(file.path); - if (!(yield shared_1.doesVideoChannelOfAccountExist(file.metadata.channelId, user, res))) + const file = Object.assign(Object.assign({}, body), { duration: undefined, path: (0, upload_1.getResumableUploadPath)(body.id), filename: body.metadata.filename }); + const cleanup = () => (0, utils_1.deleteFileAndCatch)(file.path); + if (!(yield (0, shared_1.doesVideoChannelOfAccountExist)(file.metadata.channelId, user, res))) return cleanup(); try { if (!file.duration) @@ -87,25 +87,25 @@ const videosAddResumableValidator = [ ]; exports.videosAddResumableValidator = videosAddResumableValidator; const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ - express_validator_1.body('filename') + (0, express_validator_1.body)('filename') .isString() .exists() .withMessage('Should have a valid filename'), - express_validator_1.body('name') + (0, express_validator_1.body)('name') .trim() .custom(videos_1.isVideoNameValid).withMessage(`Should have a video name between ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`), - express_validator_1.body('channelId') + (0, express_validator_1.body)('channelId') .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.isIdValid).withMessage('Should have correct video channel id'), - express_validator_1.header('x-upload-content-length') + (0, express_validator_1.header)('x-upload-content-length') .isNumeric() .exists() .withMessage('Should specify the file length'), - express_validator_1.header('x-upload-content-type') + (0, express_validator_1.header)('x-upload-content-type') .isString() .exists() .withMessage('Should specify the file mimetype'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { var _a; const videoFileMetadata = { mimetype: req.headers['x-upload-content-type'], @@ -113,13 +113,13 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ originalname: req.body.name }; const user = res.locals.oauth.token.User; - const cleanup = () => express_utils_1.cleanUpReqFiles(req); + const cleanup = () => (0, express_utils_1.cleanUpReqFiles)(req); logger_1.logger.debug('Checking videosAddResumableInitValidator parameters and headers', { parameters: req.body, headers: req.headers, files: req.files }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return cleanup(); const files = { videofile: [videoFileMetadata] }; if (!(yield commonVideoChecksPass({ req, res, user, videoFileSize: videoFileMetadata.size, files }))) @@ -132,35 +132,35 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ ]); exports.videosAddResumableInitValidator = videosAddResumableInitValidator; const videosUpdateValidator = getCommonVideoEditAttributes().concat([ - shared_1.isValidVideoIdParam('id'), - express_validator_1.body('name') + (0, shared_1.isValidVideoIdParam)('id'), + (0, express_validator_1.body)('name') .optional() .trim() .custom(videos_1.isVideoNameValid).withMessage(`Should have a video name between ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`), - express_validator_1.body('channelId') + (0, express_validator_1.body)('channelId') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(misc_1.isIdValid).withMessage('Should have correct video channel id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosUpdate parameters', { parameters: req.body }); - if (shared_1.areValidationErrors(req, res)) - return express_utils_1.cleanUpReqFiles(req); + if ((0, shared_1.areValidationErrors)(req, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); if (areErrorsInScheduleUpdate(req, res)) - return express_utils_1.cleanUpReqFiles(req); - if (!(yield shared_1.doesVideoExist(req.params.id, res))) - return express_utils_1.cleanUpReqFiles(req); + return (0, express_utils_1.cleanUpReqFiles)(req); + if (!(yield (0, shared_1.doesVideoExist)(req.params.id, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); const user = res.locals.oauth.token.User; - if (!shared_1.checkUserCanManageVideo(user, res.locals.videoAll, 17, res)) - return express_utils_1.cleanUpReqFiles(req); - if (req.body.channelId && !(yield shared_1.doesVideoChannelOfAccountExist(req.body.channelId, user, res))) - return express_utils_1.cleanUpReqFiles(req); + if (!(0, shared_1.checkUserCanManageVideo)(user, res.locals.videoAll, 17, res)) + return (0, express_utils_1.cleanUpReqFiles)(req); + if (req.body.channelId && !(yield (0, shared_1.doesVideoChannelOfAccountExist)(req.body.channelId, user, res))) + return (0, express_utils_1.cleanUpReqFiles)(req); return next(); }) ]); exports.videosUpdateValidator = videosUpdateValidator; function checkVideoFollowConstraints(req, res, next) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const video = video_1.getVideoWithAttributes(res); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const video = (0, video_1.getVideoWithAttributes)(res); if (video.isOwned() === true) return next(); if (res.locals.oauth) { @@ -169,7 +169,7 @@ function checkVideoFollowConstraints(req, res, next) { } if (config_1.CONFIG.SEARCH.REMOTE_URI.ANONYMOUS === true) return next(); - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); if ((yield video_2.VideoModel.checkVideoHasInstanceFollow(video.id, serverActor.id)) === true) return next(); return res.fail({ @@ -185,18 +185,18 @@ function checkVideoFollowConstraints(req, res, next) { exports.checkVideoFollowConstraints = checkVideoFollowConstraints; const videosCustomGetValidator = (fetchType, authenticateInQuery = false) => { return [ - shared_1.isValidVideoIdParam('id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosGet parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.id, res, fetchType))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.id, res, fetchType))) return; if (fetchType === 'only-immutable-attributes') return next(); - const video = video_1.getVideoWithAttributes(res); + const video = (0, video_1.getVideoWithAttributes)(res); if (video.requiresAuth()) { - yield auth_1.authenticatePromiseIfNeeded(req, res, authenticateInQuery); + yield (0, auth_1.authenticatePromiseIfNeeded)(req, res, authenticateInQuery); const user = res.locals.oauth ? res.locals.oauth.token.User : null; if (!user || !user.canGetVideo(video)) { return res.fail({ @@ -209,7 +209,7 @@ const videosCustomGetValidator = (fetchType, authenticateInQuery = false) => { if (video.privacy === 1) return next(); if (video.privacy === 2) { - if (misc_1.isUUIDValid(req.params.id)) + if ((0, misc_1.isUUIDValid)(req.params.id)) return next(); return res.fail({ status: http_error_codes_1.HttpStatusCode.NOT_FOUND_404, @@ -225,40 +225,40 @@ exports.videosGetValidator = videosGetValidator; const videosDownloadValidator = videosCustomGetValidator('all', true); exports.videosDownloadValidator = videosDownloadValidator; const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concat([ - shared_1.isValidVideoIdParam('id'), - express_validator_1.param('videoFileId') + (0, shared_1.isValidVideoIdParam)('id'), + (0, express_validator_1.param)('videoFileId') .custom(misc_1.isIdValid).not().isEmpty().withMessage('Should have a valid videoFileId'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videoFileMetadataGet parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoFileOfVideoExist(+req.params.videoFileId, req.params.id, res))) + if (!(yield (0, shared_1.doesVideoFileOfVideoExist)(+req.params.videoFileId, req.params.id, res))) return; return next(); }) ]); exports.videoFileMetadataGetValidator = videoFileMetadataGetValidator; const videosRemoveValidator = [ - shared_1.isValidVideoIdParam('id'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, shared_1.isValidVideoIdParam)('id'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking videosRemove parameters', { parameters: req.params }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - if (!(yield shared_1.doesVideoExist(req.params.id, res))) + if (!(yield (0, shared_1.doesVideoExist)(req.params.id, res))) return; - if (!shared_1.checkUserCanManageVideo(res.locals.oauth.token.User, res.locals.videoAll, 13, res)) + if (!(0, shared_1.checkUserCanManageVideo)(res.locals.oauth.token.User, res.locals.videoAll, 13, res)) return; return next(); }) ]; exports.videosRemoveValidator = videosRemoveValidator; const videosOverviewValidator = [ - express_validator_1.query('page') + (0, express_validator_1.query)('page') .optional() .isInt({ min: 1, max: constants_1.OVERVIEWS.VIDEOS.SAMPLES_COUNT }) .withMessage('Should have a valid pagination'), (req, res, next) => { - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; return next(); } @@ -266,69 +266,69 @@ const videosOverviewValidator = [ exports.videosOverviewValidator = videosOverviewValidator; function getCommonVideoEditAttributes() { return [ - express_validator_1.body('thumbnailfile') - .custom((value, { req }) => videos_1.isVideoImage(req.files, 'thumbnailfile')).withMessage('This thumbnail file is not supported or too large. Please, make sure it is of the following type: ' + + (0, express_validator_1.body)('thumbnailfile') + .custom((value, { req }) => (0, videos_1.isVideoImage)(req.files, 'thumbnailfile')).withMessage('This thumbnail file is not supported or too large. Please, make sure it is of the following type: ' + constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')), - express_validator_1.body('previewfile') - .custom((value, { req }) => videos_1.isVideoImage(req.files, 'previewfile')).withMessage('This preview file is not supported or too large. Please, make sure it is of the following type: ' + + (0, express_validator_1.body)('previewfile') + .custom((value, { req }) => (0, videos_1.isVideoImage)(req.files, 'previewfile')).withMessage('This preview file is not supported or too large. Please, make sure it is of the following type: ' + constants_1.CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')), - express_validator_1.body('category') + (0, express_validator_1.body)('category') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(videos_1.isVideoCategoryValid).withMessage('Should have a valid category'), - express_validator_1.body('licence') + (0, express_validator_1.body)('licence') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(videos_1.isVideoLicenceValid).withMessage('Should have a valid licence'), - express_validator_1.body('language') + (0, express_validator_1.body)('language') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoLanguageValid).withMessage('Should have a valid language'), - express_validator_1.body('nsfw') + (0, express_validator_1.body)('nsfw') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid NSFW attribute'), - express_validator_1.body('waitTranscoding') + (0, express_validator_1.body)('waitTranscoding') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid wait transcoding attribute'), - express_validator_1.body('privacy') + (0, express_validator_1.body)('privacy') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoPrivacyValid).withMessage('Should have correct video privacy'), - express_validator_1.body('description') + (0, express_validator_1.body)('description') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoDescriptionValid).withMessage('Should have a valid description'), - express_validator_1.body('support') + (0, express_validator_1.body)('support') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoSupportValid).withMessage('Should have a valid support text'), - express_validator_1.body('tags') + (0, express_validator_1.body)('tags') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoTagsValid) .withMessage(`Should have an array of up to ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.TAGS.max} tags between ` + `${constants_1.CONSTRAINTS_FIELDS.VIDEOS.TAG.min} and ${constants_1.CONSTRAINTS_FIELDS.VIDEOS.TAG.max} characters each`), - express_validator_1.body('commentsEnabled') + (0, express_validator_1.body)('commentsEnabled') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have comments enabled boolean'), - express_validator_1.body('downloadEnabled') + (0, express_validator_1.body)('downloadEnabled') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have downloading enabled boolean'), - express_validator_1.body('originallyPublishedAt') + (0, express_validator_1.body)('originallyPublishedAt') .optional() .customSanitizer(misc_1.toValueOrNull) .custom(videos_1.isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), - express_validator_1.body('scheduleUpdate') + (0, express_validator_1.body)('scheduleUpdate') .optional() .customSanitizer(misc_1.toValueOrNull), - express_validator_1.body('scheduleUpdate.updateAt') + (0, express_validator_1.body)('scheduleUpdate.updateAt') .optional() .custom(misc_1.isDateValid).withMessage('Should have a schedule update date that conforms to ISO 8601'), - express_validator_1.body('scheduleUpdate.privacy') + (0, express_validator_1.body)('scheduleUpdate.privacy') .optional() .customSanitizer(misc_1.toIntOrNull) .custom(videos_1.isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy') @@ -336,46 +336,46 @@ function getCommonVideoEditAttributes() { } exports.getCommonVideoEditAttributes = getCommonVideoEditAttributes; const commonVideosFiltersValidator = [ - express_validator_1.query('categoryOneOf') + (0, express_validator_1.query)('categoryOneOf') .optional() .customSanitizer(misc_1.toArray) .custom(search_1.isNumberArray).withMessage('Should have a valid one of category array'), - express_validator_1.query('licenceOneOf') + (0, express_validator_1.query)('licenceOneOf') .optional() .customSanitizer(misc_1.toArray) .custom(search_1.isNumberArray).withMessage('Should have a valid one of licence array'), - express_validator_1.query('languageOneOf') + (0, express_validator_1.query)('languageOneOf') .optional() .customSanitizer(misc_1.toArray) .custom(search_1.isStringArray).withMessage('Should have a valid one of language array'), - express_validator_1.query('tagsOneOf') + (0, express_validator_1.query)('tagsOneOf') .optional() .customSanitizer(misc_1.toArray) .custom(search_1.isStringArray).withMessage('Should have a valid one of tags array'), - express_validator_1.query('tagsAllOf') + (0, express_validator_1.query)('tagsAllOf') .optional() .customSanitizer(misc_1.toArray) .custom(search_1.isStringArray).withMessage('Should have a valid all of tags array'), - express_validator_1.query('nsfw') + (0, express_validator_1.query)('nsfw') .optional() .custom(search_1.isBooleanBothQueryValid).withMessage('Should have a valid NSFW attribute'), - express_validator_1.query('isLive') + (0, express_validator_1.query)('isLive') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid live boolean'), - express_validator_1.query('filter') + (0, express_validator_1.query)('filter') .optional() .custom(videos_1.isVideoFilterValid).withMessage('Should have a valid filter attribute'), - express_validator_1.query('skipCount') + (0, express_validator_1.query)('skipCount') .optional() .customSanitizer(misc_1.toBooleanOrNull) .custom(misc_1.isBooleanValid).withMessage('Should have a valid skip count boolean'), - express_validator_1.query('search') + (0, express_validator_1.query)('search') .optional() .custom(misc_1.exists).withMessage('Should have a valid search'), (req, res, next) => { logger_1.logger.debug('Checking commons video filters query', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; const user = res.locals.oauth ? res.locals.oauth.token.User : undefined; if ((req.query.filter === 'all-local' || req.query.filter === 'all') && @@ -401,13 +401,13 @@ function areErrorsInScheduleUpdate(req, res) { return false; } function commonVideoChecksPass(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { req, res, user, videoFileSize, files } = parameters; if (areErrorsInScheduleUpdate(req, res)) return false; - if (!(yield shared_1.doesVideoChannelOfAccountExist(req.body.channelId, user, res))) + if (!(yield (0, shared_1.doesVideoChannelOfAccountExist)(req.body.channelId, user, res))) return false; - if (!videos_1.isVideoFileMimeTypeValid(files)) { + if (!(0, videos_1.isVideoFileMimeTypeValid)(files)) { res.fail({ status: http_error_codes_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, message: 'This file is not supported. Please, make sure it is of the following type: ' + @@ -415,7 +415,7 @@ function commonVideoChecksPass(parameters) { }); return false; } - if (!videos_1.isVideoFileSizeValid(videoFileSize.toString())) { + if (!(0, videos_1.isVideoFileSizeValid)(videoFileSize.toString())) { res.fail({ status: http_error_codes_1.HttpStatusCode.PAYLOAD_TOO_LARGE_413, message: 'This file is too large. It exceeds the maximum file size authorized.', @@ -423,7 +423,7 @@ function commonVideoChecksPass(parameters) { }); return false; } - if ((yield user_1.isAbleToUploadVideo(user.id, videoFileSize)) === false) { + if ((yield (0, user_1.isAbleToUploadVideo)(user.id, videoFileSize)) === false) { res.fail({ status: http_error_codes_1.HttpStatusCode.PAYLOAD_TOO_LARGE_413, message: 'The user video quota is exceeded with this video.', @@ -435,7 +435,7 @@ function commonVideoChecksPass(parameters) { }); } function isVideoAccepted(req, res, videoFile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const acceptParameters = { videoBody: req.body, videoFile, @@ -455,8 +455,8 @@ function isVideoAccepted(req, res, videoFile) { } exports.isVideoAccepted = isVideoAccepted; function addDurationToVideo(videoFile) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const duration = yield ffprobe_utils_1.getDurationFromVideoFile(videoFile.path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const duration = yield (0, ffprobe_utils_1.getDurationFromVideoFile)(videoFile.path); if (isNaN(duration)) throw new Error(`Couldn't get video duration`); videoFile.duration = duration; diff --git a/dist/server/middlewares/validators/webfinger.js b/dist/server/middlewares/validators/webfinger.js index 10ef30d0..ca70528d 100644 --- a/dist/server/middlewares/validators/webfinger.js +++ b/dist/server/middlewares/validators/webfinger.js @@ -10,12 +10,12 @@ const logger_1 = require("../../helpers/logger"); const actor_1 = require("../../models/actor/actor"); const shared_1 = require("./shared"); const webfingerValidator = [ - express_validator_1.query('resource').custom(webfinger_1.isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'), - (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { + (0, express_validator_1.query)('resource').custom(webfinger_1.isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'), + (req, res, next) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { logger_1.logger.debug('Checking webfinger parameters', { parameters: req.query }); - if (shared_1.areValidationErrors(req, res)) + if ((0, shared_1.areValidationErrors)(req, res)) return; - const nameWithHost = express_utils_1.getHostWithPort(req.query.resource.substr(5)); + const nameWithHost = (0, express_utils_1.getHostWithPort)(req.query.resource.substr(5)); const [name] = nameWithHost.split('@'); const actor = yield actor_1.ActorModel.loadLocalUrlByName(name); if (!actor) { diff --git a/dist/server/models/abuse/abuse-message.js b/dist/server/models/abuse/abuse-message.js index 648619e9..43b136ad 100644 --- a/dist/server/models/abuse/abuse-message.js +++ b/dist/server/models/abuse/abuse-message.js @@ -12,7 +12,7 @@ let AbuseMessageModel = AbuseMessageModel_1 = class AbuseMessageModel extends se static listForApi(abuseId) { const options = { where: { abuseId }, - order: utils_1.getSort('createdAt'), + order: (0, utils_1.getSort)('createdAt'), include: [ { model: account_1.AccountModel.scope(account_1.ScopeNames.SUMMARY), @@ -44,57 +44,57 @@ let AbuseMessageModel = AbuseMessageModel_1 = class AbuseMessageModel extends se }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('AbuseMessage', value => utils_1.throwIfNotValid(value, abuses_1.isAbuseMessageValid, 'message')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.TEXT), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('AbuseMessage', value => (0, utils_1.throwIfNotValid)(value, abuses_1.isAbuseMessageValid, 'message')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT), + (0, tslib_1.__metadata)("design:type", String) ], AbuseMessageModel.prototype, "message", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], AbuseMessageModel.prototype, "byModerator", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AbuseMessageModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AbuseMessageModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AbuseMessageModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'accountId', allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AbuseMessageModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => abuse_1.AbuseModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => abuse_1.AbuseModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AbuseMessageModel.prototype, "abuseId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => abuse_1.AbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => abuse_1.AbuseModel, { foreignKey: { name: 'abuseId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", abuse_1.AbuseModel) + (0, tslib_1.__metadata)("design:type", abuse_1.AbuseModel) ], AbuseMessageModel.prototype, "Abuse", void 0); -AbuseMessageModel = AbuseMessageModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +AbuseMessageModel = AbuseMessageModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'abuseMessage', indexes: [ { diff --git a/dist/server/models/abuse/abuse-query-builder.js b/dist/server/models/abuse/abuse-query-builder.js index 84746074..5d6285e7 100644 --- a/dist/server/models/abuse/abuse-query-builder.js +++ b/dist/server/models/abuse/abuse-query-builder.js @@ -17,7 +17,7 @@ function buildAbuseListQuery(options, type) { 'LEFT JOIN "videoComment" ON "commentAbuse"."videoCommentId" = "videoComment"."id"' ]; if (options.serverAccountId || options.userAccountId) { - whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + utils_1.buildBlockedAccountSQL([options.serverAccountId, options.userAccountId]) + ')'); + whereAnd.push('"abuse"."reporterAccountId" NOT IN (' + (0, utils_1.buildBlockedAccountSQL)([options.serverAccountId, options.userAccountId]) + ')'); } if (options.reporterAccountId) { whereAnd.push('"abuse"."reporterAccountId" = :reporterAccountId'); @@ -87,11 +87,11 @@ function buildAbuseListQuery(options, type) { const order = buildAbuseOrder(options.sort); suffix += `${order} `; } - if (misc_1.exists(options.count)) { + if ((0, misc_1.exists)(options.count)) { const count = parseInt(options.count + '', 10); suffix += `LIMIT ${count} `; } - if (misc_1.exists(options.start)) { + if ((0, misc_1.exists)(options.start)) { const start = parseInt(options.start + '', 10); suffix += `OFFSET ${start} `; } @@ -106,6 +106,6 @@ function buildAbuseListQuery(options, type) { } exports.buildAbuseListQuery = buildAbuseListQuery; function buildAbuseOrder(value) { - const { direction, field } = utils_1.buildDirectionAndField(value); + const { direction, field } = (0, utils_1.buildDirectionAndField)(value); return `ORDER BY "abuse"."${field}" ${direction}`; } diff --git a/dist/server/models/abuse/abuse.js b/dist/server/models/abuse/abuse.js index e67978d9..4036e672 100644 --- a/dist/server/models/abuse/abuse.js +++ b/dist/server/models/abuse/abuse.js @@ -83,7 +83,7 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. return AbuseModel_1.findOne(query); } static listForAdminApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { start, count, sort, search, user, serverAccountId, state, videoIs, predefinedReason, searchReportee, searchVideo, filter, searchVideoChannel, searchReporter, id } = parameters; const userAccountId = user ? user.Account.id : undefined; const predefinedReasonId = predefinedReason ? core_utils_1.abusePredefinedReasonsMap[predefinedReason] : undefined; @@ -112,7 +112,7 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. }); } static listForUserApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { start, count, sort, search, user, state, id } = parameters; const queryOptions = { start, @@ -239,8 +239,8 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. }; } static internalCountForApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { query, replacements } = abuse_query_builder_1.buildAbuseListQuery(parameters, 'count'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { query, replacements } = (0, abuse_query_builder_1.buildAbuseListQuery)(parameters, 'count'); const options = { type: sequelize_1.QueryTypes.SELECT, replacements @@ -252,8 +252,8 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. }); } static internalListForApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { query, replacements } = abuse_query_builder_1.buildAbuseListQuery(parameters, 'id'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const { query, replacements } = (0, abuse_query_builder_1.buildAbuseListQuery)(parameters, 'id'); const options = { type: sequelize_1.QueryTypes.SELECT, replacements @@ -264,7 +264,7 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. return []; return AbuseModel_1.scope(ScopeNames.FOR_API) .findAll({ - order: utils_1.getSort(parameters.sort), + order: (0, utils_1.getSort)(parameters.sort), where: { id: { [sequelize_1.Op.in]: ids @@ -277,54 +277,54 @@ let AbuseModel = AbuseModel_1 = class AbuseModel extends sequelize_typescript_1. return constants_1.ABUSE_STATES[id] || 'Unknown'; } static getPredefinedReasonsStrings(predefinedReasons) { - const invertedPredefinedReasons = lodash_1.invert(core_utils_1.abusePredefinedReasonsMap); + const invertedPredefinedReasons = (0, lodash_1.invert)(core_utils_1.abusePredefinedReasonsMap); return (predefinedReasons || []) .map(r => invertedPredefinedReasons[r]) .filter(v => !!v); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('AbuseReason', value => utils_1.throwIfNotValid(value, abuses_1.isAbuseReasonValid, 'reason')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ABUSES.REASON.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('AbuseReason', value => (0, utils_1.throwIfNotValid)(value, abuses_1.isAbuseReasonValid, 'reason')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ABUSES.REASON.max)), + (0, tslib_1.__metadata)("design:type", String) ], AbuseModel.prototype, "reason", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('AbuseState', value => utils_1.throwIfNotValid(value, abuses_1.isAbuseStateValid, 'state')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('AbuseState', value => (0, utils_1.throwIfNotValid)(value, abuses_1.isAbuseStateValid, 'state')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AbuseModel.prototype, "state", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('AbuseModerationComment', value => utils_1.throwIfNotValid(value, abuses_1.isAbuseModerationCommentValid, 'moderationComment', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ABUSES.MODERATION_COMMENT.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('AbuseModerationComment', value => (0, utils_1.throwIfNotValid)(value, abuses_1.isAbuseModerationCommentValid, 'moderationComment', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ABUSES.MODERATION_COMMENT.max)), + (0, tslib_1.__metadata)("design:type", String) ], AbuseModel.prototype, "moderationComment", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.INTEGER)), - tslib_1.__metadata("design:type", Array) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.INTEGER)), + (0, tslib_1.__metadata)("design:type", Array) ], AbuseModel.prototype, "predefinedReasons", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AbuseModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AbuseModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AbuseModel.prototype, "reporterAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'reporterAccountId', allowNull: true @@ -332,15 +332,15 @@ tslib_1.__decorate([ as: 'ReporterAccount', onDelete: 'set null' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AbuseModel.prototype, "ReporterAccount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AbuseModel.prototype, "flaggedAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'flaggedAccountId', allowNull: true @@ -348,36 +348,36 @@ tslib_1.__decorate([ as: 'FlaggedAccount', onDelete: 'set null' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AbuseModel.prototype, "FlaggedAccount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_comment_abuse_1.VideoCommentAbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_comment_abuse_1.VideoCommentAbuseModel, { foreignKey: { name: 'abuseId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_comment_abuse_1.VideoCommentAbuseModel) + (0, tslib_1.__metadata)("design:type", video_comment_abuse_1.VideoCommentAbuseModel) ], AbuseModel.prototype, "VideoCommentAbuse", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_abuse_1.VideoAbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_abuse_1.VideoAbuseModel, { foreignKey: { name: 'abuseId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_abuse_1.VideoAbuseModel) + (0, tslib_1.__metadata)("design:type", video_abuse_1.VideoAbuseModel) ], AbuseModel.prototype, "VideoAbuse", void 0); -AbuseModel = AbuseModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +AbuseModel = AbuseModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.FOR_API]: () => { return { attributes: { include: [ [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT count(*) ' + 'FROM "abuseMessage" ' + 'WHERE "abuseId" = "AbuseModel"."id"' + @@ -385,7 +385,7 @@ AbuseModel = AbuseModel_1 = tslib_1.__decorate([ 'countMessages' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT count(*) ' + 'FROM "videoAbuse" ' + 'WHERE "videoId" = "VideoAbuse"."videoId" AND "videoId" IS NOT NULL' + @@ -393,7 +393,7 @@ AbuseModel = AbuseModel_1 = tslib_1.__decorate([ 'countReportsForVideo' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT t.nth ' + 'FROM ( ' + 'SELECT id, ' + @@ -405,7 +405,7 @@ AbuseModel = AbuseModel_1 = tslib_1.__decorate([ 'nthReportForVideo' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT count("abuse"."id") ' + 'FROM "abuse" ' + 'WHERE "abuse"."reporterAccountId" = "AbuseModel"."reporterAccountId"' + @@ -413,7 +413,7 @@ AbuseModel = AbuseModel_1 = tslib_1.__decorate([ 'countReportsForReporter' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT count("abuse"."id") ' + 'FROM "abuse" ' + 'WHERE "abuse"."flaggedAccountId" = "AbuseModel"."flaggedAccountId"' + @@ -488,7 +488,7 @@ AbuseModel = AbuseModel_1 = tslib_1.__decorate([ }; } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'abuse', indexes: [ { diff --git a/dist/server/models/abuse/video-abuse.js b/dist/server/models/abuse/video-abuse.js index 538fc6e8..73387669 100644 --- a/dist/server/models/abuse/video-abuse.js +++ b/dist/server/models/abuse/video-abuse.js @@ -7,62 +7,62 @@ const video_1 = require("../video/video"); const abuse_1 = require("./abuse"); let VideoAbuseModel = class VideoAbuseModel extends sequelize_typescript_1.Model { }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoAbuseModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoAbuseModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoAbuseModel.prototype, "startAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoAbuseModel.prototype, "endAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.JSONB), - tslib_1.__metadata("design:type", Object) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSONB), + (0, tslib_1.__metadata)("design:type", Object) ], VideoAbuseModel.prototype, "deletedVideo", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => abuse_1.AbuseModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => abuse_1.AbuseModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoAbuseModel.prototype, "abuseId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => abuse_1.AbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => abuse_1.AbuseModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", abuse_1.AbuseModel) + (0, tslib_1.__metadata)("design:type", abuse_1.AbuseModel) ], VideoAbuseModel.prototype, "Abuse", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoAbuseModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoAbuseModel.prototype, "Video", void 0); -VideoAbuseModel = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoAbuseModel = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoAbuse', indexes: [ { diff --git a/dist/server/models/abuse/video-comment-abuse.js b/dist/server/models/abuse/video-comment-abuse.js index 9903813f..248618d4 100644 --- a/dist/server/models/abuse/video-comment-abuse.js +++ b/dist/server/models/abuse/video-comment-abuse.js @@ -7,44 +7,44 @@ const video_comment_1 = require("../video/video-comment"); const abuse_1 = require("./abuse"); let VideoCommentAbuseModel = class VideoCommentAbuseModel extends sequelize_typescript_1.Model { }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCommentAbuseModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCommentAbuseModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => abuse_1.AbuseModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => abuse_1.AbuseModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentAbuseModel.prototype, "abuseId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => abuse_1.AbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => abuse_1.AbuseModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", abuse_1.AbuseModel) + (0, tslib_1.__metadata)("design:type", abuse_1.AbuseModel) ], VideoCommentAbuseModel.prototype, "Abuse", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_comment_1.VideoCommentModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_comment_1.VideoCommentModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentAbuseModel.prototype, "videoCommentId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_comment_1.VideoCommentModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_comment_1.VideoCommentModel, { foreignKey: { allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", video_comment_1.VideoCommentModel) + (0, tslib_1.__metadata)("design:type", video_comment_1.VideoCommentModel) ], VideoCommentAbuseModel.prototype, "VideoComment", void 0); -VideoCommentAbuseModel = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoCommentAbuseModel = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'commentAbuse', indexes: [ { diff --git a/dist/server/models/account/account-blocklist.js b/dist/server/models/account/account-blocklist.js index ae56ffc9..a2802e5a 100644 --- a/dist/server/models/account/account-blocklist.js +++ b/dist/server/models/account/account-blocklist.js @@ -49,7 +49,7 @@ let AccountBlocklistModel = AccountBlocklistModel_1 = class AccountBlocklistMode const query = { offset: start, limit: count, - order: utils_1.getSort(sort) + order: (0, utils_1.getSort)(sort) }; const where = { accountId @@ -57,8 +57,8 @@ let AccountBlocklistModel = AccountBlocklistModel_1 = class AccountBlocklistMode if (search) { Object.assign(where, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(search, '$BlockedAccount.name$'), - utils_1.searchAttribute(search, '$BlockedAccount.Actor.url$') + (0, utils_1.searchAttribute)(search, '$BlockedAccount.name$'), + (0, utils_1.searchAttribute)(search, '$BlockedAccount.Actor.url$') ] }); } @@ -112,21 +112,21 @@ let AccountBlocklistModel = AccountBlocklistModel_1 = class AccountBlocklistMode }; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountBlocklistModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountBlocklistModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountBlocklistModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'accountId', allowNull: false @@ -134,15 +134,15 @@ tslib_1.__decorate([ as: 'ByAccount', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AccountBlocklistModel.prototype, "ByAccount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountBlocklistModel.prototype, "targetAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'targetAccountId', allowNull: false @@ -150,10 +150,10 @@ tslib_1.__decorate([ as: 'BlockedAccount', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AccountBlocklistModel.prototype, "BlockedAccount", void 0); -AccountBlocklistModel = AccountBlocklistModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +AccountBlocklistModel = AccountBlocklistModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_ACCOUNTS]: { include: [ { @@ -169,7 +169,7 @@ AccountBlocklistModel = AccountBlocklistModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'accountBlocklist', indexes: [ { diff --git a/dist/server/models/account/account-video-rate.js b/dist/server/models/account/account-video-rate.js index 1d44af97..91ad3b5a 100644 --- a/dist/server/models/account/account-video-rate.js +++ b/dist/server/models/account/account-video-rate.js @@ -47,7 +47,7 @@ let AccountVideoRateModel = AccountVideoRateModel_1 = class AccountVideoRateMode const query = { offset: options.start, limit: options.count, - order: utils_1.getSort(options.sort), + order: (0, utils_1.getSort)(options.sort), where: { accountId: options.accountId }, @@ -147,7 +147,7 @@ let AccountVideoRateModel = AccountVideoRateModel_1 = class AccountVideoRateMode return AccountVideoRateModel_1.findAndCountAll(query); } static cleanOldRatesOf(videoId, type, beforeUpdatedAt) { - return AccountVideoRateModel_1.sequelize.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () { + return AccountVideoRateModel_1.sequelize.transaction((t) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { where: { updatedAt: { @@ -156,7 +156,7 @@ let AccountVideoRateModel = AccountVideoRateModel_1 = class AccountVideoRateMode videoId, type, accountId: { - [sequelize_1.Op.notIn]: utils_1.buildLocalAccountIdsIn() + [sequelize_1.Op.notIn]: (0, utils_1.buildLocalAccountIdsIn)() } }, transaction: t @@ -172,55 +172,55 @@ let AccountVideoRateModel = AccountVideoRateModel_1 = class AccountVideoRateMode }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ENUM(...lodash_1.values(constants_1.VIDEO_RATE_TYPES))), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ENUM(...(0, lodash_1.values)(constants_1.VIDEO_RATE_TYPES))), + (0, tslib_1.__metadata)("design:type", String) ], AccountVideoRateModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('AccountVideoRateUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_RATES.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('AccountVideoRateUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_RATES.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], AccountVideoRateModel.prototype, "url", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountVideoRateModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountVideoRateModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountVideoRateModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], AccountVideoRateModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountVideoRateModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], AccountVideoRateModel.prototype, "Account", void 0); -AccountVideoRateModel = AccountVideoRateModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +AccountVideoRateModel = AccountVideoRateModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'accountVideoRate', indexes: [ { diff --git a/dist/server/models/account/account.js b/dist/server/models/account/account.js index c2d47bc6..80f0f872 100644 --- a/dist/server/models/account/account.js +++ b/dist/server/models/account/account.js @@ -28,13 +28,13 @@ var ScopeNames; })(ScopeNames = exports.ScopeNames || (exports.ScopeNames = {})); let AccountModel = AccountModel_1 = class AccountModel extends sequelize_typescript_1.Model { static sendDeleteIfOwned(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!instance.Actor) { instance.Actor = yield instance.$get('Actor', { transaction: options.transaction }); } yield actor_follow_1.ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction); if (instance.isOwned()) { - return send_delete_1.sendDeleteActor(instance.Actor, options.transaction); + return (0, send_delete_1.sendDeleteActor)(instance.Actor, options.transaction); } return undefined; }); @@ -126,7 +126,7 @@ let AccountModel = AccountModel_1 = class AccountModel extends sequelize_typescr const query = { offset: start, limit: count, - order: utils_1.getSort(sort) + order: (0, utils_1.getSort)(sort) }; return AccountModel_1.findAndCountAll(query) .then(({ rows, count }) => { @@ -161,7 +161,7 @@ let AccountModel = AccountModel_1 = class AccountModel extends sequelize_typescr const query = { attributes: [], offset: 0, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), include: [ { attributes: ['preferredUsername', 'serverId'], @@ -223,100 +223,100 @@ let AccountModel = AccountModel_1 = class AccountModel extends sequelize_typescr return this.BlockedAccounts && this.BlockedAccounts.length !== 0; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], AccountModel.prototype, "name", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('AccountDescription', value => utils_1.throwIfNotValid(value, accounts_1.isAccountDescriptionValid, 'description', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('AccountDescription', value => (0, utils_1.throwIfNotValid)(value, accounts_1.isAccountDescriptionValid, 'description', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max)), + (0, tslib_1.__metadata)("design:type", String) ], AccountModel.prototype, "description", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], AccountModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], AccountModel.prototype, "Actor", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], AccountModel.prototype, "User", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => application_1.ApplicationModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => application_1.ApplicationModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], AccountModel.prototype, "applicationId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => application_1.ApplicationModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => application_1.ApplicationModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", application_1.ApplicationModel) + (0, tslib_1.__metadata)("design:type", application_1.ApplicationModel) ], AccountModel.prototype, "Application", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_channel_1.VideoChannelModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_channel_1.VideoChannelModel, { foreignKey: { allowNull: false }, onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], AccountModel.prototype, "VideoChannels", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_playlist_1.VideoPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_playlist_1.VideoPlaylistModel, { foreignKey: { allowNull: false }, onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], AccountModel.prototype, "VideoPlaylists", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_comment_1.VideoCommentModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_comment_1.VideoCommentModel, { foreignKey: { allowNull: true }, onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], AccountModel.prototype, "VideoComments", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => account_blocklist_1.AccountBlocklistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => account_blocklist_1.AccountBlocklistModel, { foreignKey: { name: 'targetAccountId', allowNull: false @@ -324,16 +324,16 @@ tslib_1.__decorate([ as: 'BlockedAccounts', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], AccountModel.prototype, "BlockedAccounts", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [AccountModel, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [AccountModel, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], AccountModel, "sendDeleteIfOwned", null); -AccountModel = AccountModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +AccountModel = AccountModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: actor_1.ActorModel, @@ -341,7 +341,7 @@ AccountModel = AccountModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.SUMMARY]: (options = {}) => { var _a; const serverInclude = { @@ -398,7 +398,7 @@ AccountModel = AccountModel_1 = tslib_1.__decorate([ return query; } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'account', indexes: [ { diff --git a/dist/server/models/account/actor-custom-page.js b/dist/server/models/account/actor-custom-page.js index 3b03c702..339ea62b 100644 --- a/dist/server/models/account/actor-custom-page.js +++ b/dist/server/models/account/actor-custom-page.js @@ -8,8 +8,8 @@ const actor_1 = require("../actor/actor"); const application_1 = require("../application/application"); let ActorCustomPageModel = ActorCustomPageModel_1 = class ActorCustomPageModel extends sequelize_typescript_1.Model { static updateInstanceHomepage(content) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); return ActorCustomPageModel_1.upsert({ content, actorId: serverActor.id, @@ -18,8 +18,8 @@ let ActorCustomPageModel = ActorCustomPageModel_1 = class ActorCustomPageModel e }); } static loadInstanceHomepage() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); return ActorCustomPageModel_1.findOne({ where: { actorId: serverActor.id @@ -33,41 +33,41 @@ let ActorCustomPageModel = ActorCustomPageModel_1 = class ActorCustomPageModel e }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.TEXT), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT), + (0, tslib_1.__metadata)("design:type", String) ], ActorCustomPageModel.prototype, "content", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ActorCustomPageModel.prototype, "type", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorCustomPageModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorCustomPageModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorCustomPageModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { name: 'actorId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], ActorCustomPageModel.prototype, "Actor", void 0); -ActorCustomPageModel = ActorCustomPageModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ActorCustomPageModel = ActorCustomPageModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'actorCustomPage', indexes: [ { diff --git a/dist/server/models/actor/actor-follow.js b/dist/server/models/actor/actor-follow.js index 2e7225ee..94d20bc4 100644 --- a/dist/server/models/actor/actor-follow.js +++ b/dist/server/models/actor/actor-follow.js @@ -48,7 +48,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque return ActorFollowModel_1.destroy(query); } static removeBadActorFollows() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const actorFollows = yield ActorFollowModel_1.listBadActorFollows(); const actorFollowsRemovePromises = actorFollows.map(actorFollow => actorFollow.destroy()); yield Promise.all(actorFollowsRemovePromises); @@ -59,7 +59,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque } static isFollowedBy(actorId, followerActorId) { const query = 'SELECT 1 FROM "actorFollow" WHERE "actorId" = $followerActorId AND "targetActorId" = $actorId LIMIT 1'; - return query_1.doesExist(query, { actorId, followerActorId }); + return (0, query_1.doesExist)(query, { actorId, followerActorId }); } static loadByActorAndTarget(actorId, targetActorId, t) { const query = { @@ -189,8 +189,8 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque if (search) { Object.assign(followWhere, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(options.search, '$ActorFollowing.preferredUsername$'), - utils_1.searchAttribute(options.search, '$ActorFollowing.Server.host$') + (0, utils_1.searchAttribute)(options.search, '$ActorFollowing.preferredUsername$'), + (0, utils_1.searchAttribute)(options.search, '$ActorFollowing.Server.host$') ] }); } @@ -201,7 +201,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque distinct: true, offset: start, limit: count, - order: utils_1.getFollowsSort(sort), + order: (0, utils_1.getFollowsSort)(sort), where: followWhere, include: [ { @@ -241,8 +241,8 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque if (search) { Object.assign(followWhere, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(search, '$ActorFollower.preferredUsername$'), - utils_1.searchAttribute(search, '$ActorFollower.Server.host$') + (0, utils_1.searchAttribute)(search, '$ActorFollower.preferredUsername$'), + (0, utils_1.searchAttribute)(search, '$ActorFollower.Server.host$') ] }); } @@ -253,7 +253,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque distinct: true, offset: start, limit: count, - order: utils_1.getFollowsSort(sort), + order: (0, utils_1.getFollowsSort)(sort), where: followWhere, include: [ { @@ -294,8 +294,8 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque if (options.search) { Object.assign(where, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(options.search, '$ActorFollowing.preferredUsername$'), - utils_1.searchAttribute(options.search, '$ActorFollowing.VideoChannel.name$') + (0, utils_1.searchAttribute)(options.search, '$ActorFollowing.preferredUsername$'), + (0, utils_1.searchAttribute)(options.search, '$ActorFollowing.VideoChannel.name$') ] }); } @@ -304,7 +304,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque distinct: true, offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), where, include: [ { @@ -352,8 +352,8 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque }); } static keepUnfollowedInstance(hosts) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const followerId = (yield application_1.getServerActor()).id; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const followerId = (yield (0, application_1.getServerActor)()).id; const query = { attributes: ['id'], where: { @@ -385,7 +385,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque }; const res = yield ActorFollowModel_1.findAll(query); const followedHosts = res.map(row => row.ActorFollowing.Server.host); - return lodash_1.difference(hosts, followedHosts); + return (0, lodash_1.difference)(hosts, followedHosts); }); } static listAcceptedFollowerUrlsForAP(actorIds, t, start, count) { @@ -398,8 +398,8 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque return ActorFollowModel_1.createListAcceptedFollowForApiQuery('following', actorIds, t, start, count); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const totalInstanceFollowing = yield ActorFollowModel_1.count({ where: { actorId: serverActor.id @@ -430,11 +430,11 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque return ActorFollowModel_1.sequelize.query(query, options); } static updateScoreByFollowingServers(serverIds, value, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (serverIds.length === 0) return; - const me = yield application_1.getServerActor(); - const serverIdsString = utils_1.createSafeIn(ActorFollowModel_1.sequelize, serverIds); + const me = yield (0, application_1.getServerActor)(); + const serverIdsString = (0, utils_1.createSafeIn)(ActorFollowModel_1.sequelize, serverIds); const query = `UPDATE "actorFollow" SET "score" = LEAST("score" + ${value}, ${constants_1.ACTOR_FOLLOW_SCORE.MAX}) ` + 'WHERE id IN (' + 'SELECT "actorFollow"."id" FROM "actorFollow" ' + @@ -450,7 +450,7 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque }); } static createListAcceptedFollowForApiQuery(type, actorIds, t, start, count, columnUrl = 'url', distinct = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let firstJoin; let secondJoin; if (type === 'followers') { @@ -517,40 +517,40 @@ let ActorFollowModel = ActorFollowModel_1 = class ActorFollowModel extends seque }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ENUM(...lodash_1.values(constants_1.FOLLOW_STATES))), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ENUM(...(0, lodash_1.values)(constants_1.FOLLOW_STATES))), + (0, tslib_1.__metadata)("design:type", String) ], ActorFollowModel.prototype, "state", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(constants_1.ACTOR_FOLLOW_SCORE.BASE), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(constants_1.ACTOR_FOLLOW_SCORE.BASE), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Max(constants_1.ACTOR_FOLLOW_SCORE.MAX), + (0, sequelize_typescript_1.Max)(constants_1.ACTOR_FOLLOW_SCORE.MAX), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorFollowModel.prototype, "score", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorFollowUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorFollowUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorFollowModel.prototype, "url", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorFollowModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorFollowModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorFollowModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { name: 'actorId', allowNull: false @@ -558,15 +558,15 @@ tslib_1.__decorate([ as: 'ActorFollower', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], ActorFollowModel.prototype, "ActorFollower", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorFollowModel.prototype, "targetActorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { name: 'targetActorId', allowNull: false @@ -574,23 +574,23 @@ tslib_1.__decorate([ as: 'ActorFollowing', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], ActorFollowModel.prototype, "ActorFollowing", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterCreate, sequelize_typescript_1.AfterUpdate, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [ActorFollowModel, Object]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [ActorFollowModel, Object]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], ActorFollowModel, "incrementFollowerAndFollowingCount", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [ActorFollowModel, Object]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [ActorFollowModel, Object]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], ActorFollowModel, "decrementFollowerAndFollowingCount", null); -ActorFollowModel = ActorFollowModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ActorFollowModel = ActorFollowModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'actorFollow', indexes: [ { diff --git a/dist/server/models/actor/actor-image.js b/dist/server/models/actor/actor-image.js index cef6afc9..1259bcce 100644 --- a/dist/server/models/actor/actor-image.js +++ b/dist/server/models/actor/actor-image.js @@ -34,70 +34,70 @@ let ActorImageModel = ActorImageModel_1 = class ActorImageModel extends sequeliz } getStaticPath() { if (this.type === 1) { - return path_1.join(constants_1.LAZY_STATIC_PATHS.AVATARS, this.filename); + return (0, path_1.join)(constants_1.LAZY_STATIC_PATHS.AVATARS, this.filename); } - return path_1.join(constants_1.LAZY_STATIC_PATHS.BANNERS, this.filename); + return (0, path_1.join)(constants_1.LAZY_STATIC_PATHS.BANNERS, this.filename); } getPath() { - return path_1.join(config_1.CONFIG.STORAGE.ACTOR_IMAGES, this.filename); + return (0, path_1.join)(config_1.CONFIG.STORAGE.ACTOR_IMAGES, this.filename); } removeImage() { - const imagePath = path_1.join(config_1.CONFIG.STORAGE.ACTOR_IMAGES, this.filename); - return fs_extra_1.remove(imagePath); + const imagePath = (0, path_1.join)(config_1.CONFIG.STORAGE.ACTOR_IMAGES, this.filename); + return (0, fs_extra_1.remove)(imagePath); } isOwned() { return !this.fileUrl; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ActorImageModel.prototype, "filename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorImageModel.prototype, "height", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorImageModel.prototype, "width", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorImageFileUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'fileUrl', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorImageFileUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'fileUrl', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ActorImageModel.prototype, "fileUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], ActorImageModel.prototype, "onDisk", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorImageModel.prototype, "type", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorImageModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorImageModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [ActorImageModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [ActorImageModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], ActorImageModel, "removeFilesAndSendDelete", null); -ActorImageModel = ActorImageModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ActorImageModel = ActorImageModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'actorImage', indexes: [ { diff --git a/dist/server/models/actor/actor.js b/dist/server/models/actor/actor.js index ca7e32f8..3f48c793 100644 --- a/dist/server/models/actor/actor.js +++ b/dist/server/models/actor/actor.js @@ -190,7 +190,7 @@ let ActorModel = ActorModel_1 = class ActorModel extends sequelize_typescript_1. columnOfCount = 'actorId'; } return ActorModel_1.update({ - [columnToUpdate]: sequelize_1.literal(`(SELECT COUNT(*) FROM "actorFollow" WHERE "${columnOfCount}" = ${sanitizedOfId})`) + [columnToUpdate]: (0, sequelize_1.literal)(`(SELECT COUNT(*) FROM "actorFollow" WHERE "${columnOfCount}" = ${sanitizedOfId})`) }, { where, transaction }); } static loadAccountActorByVideoId(videoId, transaction) { @@ -256,7 +256,7 @@ let ActorModel = ActorModel_1 = class ActorModel extends sequelize_typescript_1. let icon; let image; if (this.avatarId) { - const extension = core_utils_1.getLowercaseExtension(this.Avatar.filename); + const extension = (0, core_utils_1.getLowercaseExtension)(this.Avatar.filename); icon = { type: 'Image', mediaType: constants_1.MIMETYPES.IMAGE.EXT_MIMETYPE[extension], @@ -267,7 +267,7 @@ let ActorModel = ActorModel_1 = class ActorModel extends sequelize_typescript_1. } if (this.bannerId) { const banner = this.Banner; - const extension = core_utils_1.getLowercaseExtension(banner.filename); + const extension = (0, core_utils_1.getLowercaseExtension)(banner.filename); image = { type: 'Image', mediaType: constants_1.MIMETYPES.IMAGE.EXT_MIMETYPE[extension], @@ -299,7 +299,7 @@ let ActorModel = ActorModel_1 = class ActorModel extends sequelize_typescript_1. icon, image }; - return activitypub_1.activityPubContextify(json); + return (0, activitypub_1.activityPubContextify)(json); } getFollowerSharedInboxUrls(t) { const query = { @@ -361,108 +361,108 @@ let ActorModel = ActorModel_1 = class ActorModel extends sequelize_typescript_1. isOutdated() { if (this.isOwned()) return false; - return utils_1.isOutdated(this, constants_1.ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL); + return (0, utils_1.isOutdated)(this, constants_1.ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL); } getCreatedAt() { return this.remoteCreatedAt || this.createdAt; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ENUM(...lodash_1.values(constants_1.ACTIVITY_PUB_ACTOR_TYPES))), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ENUM(...(0, lodash_1.values)(constants_1.ACTIVITY_PUB_ACTOR_TYPES))), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('ActorPreferredUsername', value => utils_1.throwIfNotValid(value, actor_1.isActorPreferredUsernameValid, 'actor preferred username')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('ActorPreferredUsername', value => (0, utils_1.throwIfNotValid)(value, actor_1.isActorPreferredUsernameValid, 'actor preferred username')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "preferredUsername", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('ActorUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('ActorUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorPublicKey', value => utils_1.throwIfNotValid(value, actor_1.isActorPublicKeyValid, 'public key', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorPublicKey', value => (0, utils_1.throwIfNotValid)(value, actor_1.isActorPublicKeyValid, 'public key', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "publicKey", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorPublicKey', value => utils_1.throwIfNotValid(value, actor_1.isActorPrivateKeyValid, 'private key', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorPublicKey', value => (0, utils_1.throwIfNotValid)(value, actor_1.isActorPrivateKeyValid, 'private key', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "privateKey", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('ActorFollowersCount', value => utils_1.throwIfNotValid(value, actor_1.isActorFollowersCountValid, 'followers count')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('ActorFollowersCount', value => (0, utils_1.throwIfNotValid)(value, actor_1.isActorFollowersCountValid, 'followers count')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorModel.prototype, "followersCount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('ActorFollowersCount', value => utils_1.throwIfNotValid(value, actor_1.isActorFollowingCountValid, 'following count')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('ActorFollowersCount', value => (0, utils_1.throwIfNotValid)(value, actor_1.isActorFollowingCountValid, 'following count')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorModel.prototype, "followingCount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('ActorInboxUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'inbox url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('ActorInboxUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'inbox url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "inboxUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorOutboxUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'outbox url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorOutboxUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'outbox url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "outboxUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorSharedInboxUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'shared inbox url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorSharedInboxUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'shared inbox url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "sharedInboxUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorFollowersUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'followers url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorFollowersUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'followers url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "followersUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('ActorFollowingUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'following url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('ActorFollowingUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'following url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.ACTORS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ActorModel.prototype, "followingUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorModel.prototype, "remoteCreatedAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ActorModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_image_1.ActorImageModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_image_1.ActorImageModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorModel.prototype, "avatarId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_image_1.ActorImageModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_image_1.ActorImageModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorModel.prototype, "bannerId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_image_1.ActorImageModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_image_1.ActorImageModel, { foreignKey: { name: 'avatarId', allowNull: true @@ -471,10 +471,10 @@ tslib_1.__decorate([ onDelete: 'set null', hooks: true }), - tslib_1.__metadata("design:type", actor_image_1.ActorImageModel) + (0, tslib_1.__metadata)("design:type", actor_image_1.ActorImageModel) ], ActorModel.prototype, "Avatar", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_image_1.ActorImageModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_image_1.ActorImageModel, { foreignKey: { name: 'bannerId', allowNull: true @@ -483,10 +483,10 @@ tslib_1.__decorate([ onDelete: 'set null', hooks: true }), - tslib_1.__metadata("design:type", actor_image_1.ActorImageModel) + (0, tslib_1.__metadata)("design:type", actor_image_1.ActorImageModel) ], ActorModel.prototype, "Banner", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => actor_follow_1.ActorFollowModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => actor_follow_1.ActorFollowModel, { foreignKey: { name: 'actorId', allowNull: false @@ -494,10 +494,10 @@ tslib_1.__decorate([ as: 'ActorFollowings', onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], ActorModel.prototype, "ActorFollowing", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => actor_follow_1.ActorFollowModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => actor_follow_1.ActorFollowModel, { foreignKey: { name: 'targetActorId', allowNull: false @@ -505,44 +505,44 @@ tslib_1.__decorate([ as: 'ActorFollowers', onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], ActorModel.prototype, "ActorFollowers", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => server_1.ServerModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => server_1.ServerModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ActorModel.prototype, "serverId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => server_1.ServerModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => server_1.ServerModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", server_1.ServerModel) + (0, tslib_1.__metadata)("design:type", server_1.ServerModel) ], ActorModel.prototype, "Server", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => account_1.AccountModel, { foreignKey: { allowNull: true }, onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], ActorModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_channel_1.VideoChannelModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_channel_1.VideoChannelModel, { foreignKey: { allowNull: true }, onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", video_channel_1.VideoChannelModel) + (0, tslib_1.__metadata)("design:type", video_channel_1.VideoChannelModel) ], ActorModel.prototype, "VideoChannel", void 0); -ActorModel = ActorModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +ActorModel = ActorModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: server_1.ServerModel, @@ -555,7 +555,7 @@ ActorModel = ActorModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.FULL]: { include: [ { @@ -589,7 +589,7 @@ ActorModel = ActorModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'actor', indexes: [ { diff --git a/dist/server/models/application/application.js b/dist/server/models/application/application.js index fe2c6405..ef11ad5b 100644 --- a/dist/server/models/application/application.js +++ b/dist/server/models/application/application.js @@ -3,11 +3,11 @@ var ApplicationModel_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApplicationModel = exports.getServerActor = void 0; const tslib_1 = require("tslib"); -const memoizee_1 = tslib_1.__importDefault(require("memoizee")); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); const sequelize_typescript_1 = require("sequelize-typescript"); const account_1 = require("../account/account"); -exports.getServerActor = memoizee_1.default(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { +exports.getServerActor = (0, memoizee_1.default)(function () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const application = yield ApplicationModel.load(); if (!application) throw Error('Could not load Application from database.'); @@ -24,29 +24,29 @@ let ApplicationModel = ApplicationModel_1 = class ApplicationModel extends seque return ApplicationModel_1.findOne(); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ApplicationModel.prototype, "migrationVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ApplicationModel.prototype, "latestPeerTubeVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => account_1.AccountModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], ApplicationModel.prototype, "Account", void 0); -ApplicationModel = ApplicationModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +ApplicationModel = ApplicationModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: account_1.AccountModel, @@ -54,7 +54,7 @@ ApplicationModel = ApplicationModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'application', timestamps: false }) diff --git a/dist/server/models/image/image-redundancy.js b/dist/server/models/image/image-redundancy.js new file mode 100644 index 00000000..92859713 --- /dev/null +++ b/dist/server/models/image/image-redundancy.js @@ -0,0 +1,52 @@ +"use strict"; +var ImageRedundancyModel_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ImageRedundancyModel = void 0; +const tslib_1 = require("tslib"); +const sequelize_typescript_1 = require("sequelize-typescript"); +const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch")); +const path_1 = require("path"); +const config_1 = require("@server/initializers/config"); +let ImageRedundancyModel = ImageRedundancyModel_1 = class ImageRedundancyModel extends sequelize_typescript_1.Model { + static getImageRedundancyForActor(actorUrl) { + const query = { + where: { + actorUrl: actorUrl + }, + defaults: { + fromDate: new Date(0) + } + }; + return ImageRedundancyModel_1.findOrCreate(query); + } + static getImagesFromDate(imageRedundancy) { + const url = new URL((0, path_1.join)(imageRedundancy.actorUrl, 'api/v1/images')); + url.search = new URLSearchParams({ + order: '-createdAt', + limit: config_1.CONFIG.REDUNDANCY.IMAGES.NB_IMAGES_PER_REQ.toString(), + createdAt: imageRedundancy.fromDate.toISOString() + }).toString(); + return (0, node_fetch_1.default)(url); + } +}; +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageRedundancyModel.prototype, "actorUrl", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE), + (0, tslib_1.__metadata)("design:type", Date) +], ImageRedundancyModel.prototype, "fromDate", void 0); +ImageRedundancyModel = ImageRedundancyModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ + tableName: 'imageRedundancy', + indexes: [ + { fields: ['actorUrl'] }, + { fields: ['fromDate'] } + ] + }) +], ImageRedundancyModel); +exports.ImageRedundancyModel = ImageRedundancyModel; diff --git a/dist/server/models/image/image.js b/dist/server/models/image/image.js new file mode 100644 index 00000000..25c2317f --- /dev/null +++ b/dist/server/models/image/image.js @@ -0,0 +1,122 @@ +"use strict"; +var ImageModel_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ImageModel = void 0; +const tslib_1 = require("tslib"); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); +const sequelize_typescript_1 = require("sequelize-typescript"); +const shared_1 = require("../shared"); +const constants_1 = require("../../initializers/constants"); +const path_1 = require("path"); +const config_1 = require("@server/initializers/config"); +const webtorrent_1 = require("@server/helpers/webtorrent"); +const parse_torrent_1 = (0, tslib_1.__importDefault)(require("parse-torrent")); +const fs_extra_1 = require("fs-extra"); +let ImageModel = ImageModel_1 = class ImageModel extends sequelize_typescript_1.Model { + static doesInfohashExist(infoHash) { + const query = 'SELECT 1 FROM "image" WHERE "infoHash" = $infoHash LIMIT 1'; + return (0, shared_1.doesExist)(query, { infoHash }); + } + static getImageStaticUrl(imageId, imageName, webServUrl = constants_1.WEBSERVER.URL) { + return (0, path_1.join)(webServUrl, constants_1.STATIC_PATHS.IMAGES, imageId, imageName); + } + static getTorrentStaticUrl(imageId, webServUrl = constants_1.WEBSERVER.URL) { + return (0, path_1.join)(webServUrl, constants_1.STATIC_PATHS.TORRENTS, imageId + '.torrent'); + } + static getImageStaticPath(imageId, imageName) { + return (0, path_1.join)(config_1.CONFIG.STORAGE.IMAGES_DIR, imageId, imageName); + } + static getTorrentStaticPath(imageId) { + return (0, path_1.join)(config_1.CONFIG.STORAGE.TORRENTS_DIR, imageId + '.torrent'); + } + static generateTorrentForImage(imageId, destFolder) { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const torrentArgs = { + name: imageId, + createdBy: 'PeerTube', + announceList: [ + [constants_1.WEBSERVER.WS + '://' + constants_1.WEBSERVER.HOSTNAME + ':' + constants_1.WEBSERVER.PORT + '/tracker/socket'], + [constants_1.WEBSERVER.URL + '/tracker/announce'] + ], + urlList: [ + constants_1.WEBSERVER.URL + constants_1.STATIC_PATHS.IMAGES_WEBSEED + ] + }; + const torrentContent = yield (0, webtorrent_1.createTorrentPromise)(destFolder, torrentArgs); + const torrentPath = ImageModel_1.getTorrentStaticPath(imageId); + const parsedTorrent = (0, parse_torrent_1.default)(torrentContent); + yield (0, fs_extra_1.writeFile)(torrentPath, torrentContent); + return parsedTorrent.infoHash; + }); + } +}; +ImageModel.doesInfohashExistCached = (0, memoizee_1.default)(ImageModel_1.doesInfohashExist, { + promise: true, + max: constants_1.MEMOIZE_LENGTH.INFO_HASH_EXISTS, + maxAge: constants_1.MEMOIZE_TTL.INFO_HASH_EXISTS +}); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + sequelize_typescript_1.PrimaryKey, + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "id", void 0); +(0, tslib_1.__decorate)([ + sequelize_typescript_1.CreatedAt, + (0, tslib_1.__metadata)("design:type", Date) +], ImageModel.prototype, "createdAt", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "originalname", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "filename", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "thumbnailname", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", Number) +], ImageModel.prototype, "size", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "mimetype", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "extname", void 0); +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + sequelize_typescript_1.Column, + (0, tslib_1.__metadata)("design:type", String) +], ImageModel.prototype, "infoHash", void 0); +ImageModel = ImageModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ + tableName: 'image', + indexes: [ + { fields: ['id'], unique: true }, + { fields: ['createdAt'] }, + { fields: ['originalname'] }, + { fields: ['filename'] }, + { fields: ['thumbnailname'] }, + { fields: ['size'] }, + { fields: ['mimetype'] }, + { fields: ['extname'] }, + { fields: ['infoHash'] } + ] + }) +], ImageModel); +exports.ImageModel = ImageModel; diff --git a/dist/server/models/oauth/oauth-client.js b/dist/server/models/oauth/oauth-client.js index b6578737..34f0ffcd 100644 --- a/dist/server/models/oauth/oauth-client.js +++ b/dist/server/models/oauth/oauth-client.js @@ -22,40 +22,40 @@ let OAuthClientModel = OAuthClientModel_1 = class OAuthClientModel extends seque return OAuthClientModel_1.findOne(query); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], OAuthClientModel.prototype, "clientId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], OAuthClientModel.prototype, "clientSecret", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), - tslib_1.__metadata("design:type", Array) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), + (0, tslib_1.__metadata)("design:type", Array) ], OAuthClientModel.prototype, "grants", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), - tslib_1.__metadata("design:type", Array) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), + (0, tslib_1.__metadata)("design:type", Array) ], OAuthClientModel.prototype, "redirectUris", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthClientModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthClientModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => oauth_token_1.OAuthTokenModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => oauth_token_1.OAuthTokenModel, { onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], OAuthClientModel.prototype, "OAuthTokens", void 0); -OAuthClientModel = OAuthClientModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +OAuthClientModel = OAuthClientModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'oAuthClient', indexes: [ { diff --git a/dist/server/models/oauth/oauth-token.js b/dist/server/models/oauth/oauth-token.js index f8c76e44..7cd924c4 100644 --- a/dist/server/models/oauth/oauth-token.js +++ b/dist/server/models/oauth/oauth-token.js @@ -90,75 +90,75 @@ let OAuthTokenModel = OAuthTokenModel_1 = class OAuthTokenModel extends sequeliz return OAuthTokenModel_1.destroy(query); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], OAuthTokenModel.prototype, "accessToken", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthTokenModel.prototype, "accessTokenExpiresAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], OAuthTokenModel.prototype, "refreshToken", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthTokenModel.prototype, "refreshTokenExpiresAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], OAuthTokenModel.prototype, "authName", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthTokenModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], OAuthTokenModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], OAuthTokenModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], OAuthTokenModel.prototype, "User", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => oauth_client_1.OAuthClientModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => oauth_client_1.OAuthClientModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], OAuthTokenModel.prototype, "oAuthClientId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => oauth_client_1.OAuthClientModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => oauth_client_1.OAuthClientModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], OAuthTokenModel.prototype, "OAuthClients", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterUpdate, sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [OAuthTokenModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [OAuthTokenModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], OAuthTokenModel, "removeTokenCache", null); -OAuthTokenModel = OAuthTokenModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +OAuthTokenModel = OAuthTokenModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_USER]: { include: [ { @@ -182,7 +182,7 @@ OAuthTokenModel = OAuthTokenModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'oAuthToken', indexes: [ { diff --git a/dist/server/models/redundancy/video-redundancy.js b/dist/server/models/redundancy/video-redundancy.js index 5ee0ebae..e3fa170e 100644 --- a/dist/server/models/redundancy/video-redundancy.js +++ b/dist/server/models/redundancy/video-redundancy.js @@ -26,7 +26,7 @@ var ScopeNames; })(ScopeNames = exports.ScopeNames || (exports.ScopeNames = {})); let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel extends sequelize_typescript_1.Model { static removeFile(instance) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!instance.isOwned()) return; if (instance.videoFileId) { @@ -47,8 +47,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static loadLocalByFileId(videoFileId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const query = { where: { actorId: actor.id, @@ -59,8 +59,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static listLocalByVideoId(videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const queryStreamingPlaylist = { where: { actorId: actor.id @@ -108,8 +108,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static loadLocalByStreamingPlaylistId(videoStreamingPlaylistId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const query = { where: { actorId: actor.id, @@ -136,8 +136,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e return VideoRedundancyModel_1.findOne(query); } static isLocalByVideoUUIDExists(uuid) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const query = { raw: true, attributes: ['id'], @@ -167,22 +167,22 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static getVideoSample(p) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const rows = yield p; if (rows.length === 0) return undefined; const ids = rows.map(r => r.id); - const id = lodash_1.sample(ids); - return video_1.VideoModel.loadWithFiles(id, undefined, !core_utils_1.isTestInstance()); + const id = (0, lodash_1.sample)(ids); + return video_1.VideoModel.loadWithFiles(id, undefined, !(0, core_utils_1.isTestInstance)()); }); } static findMostViewToDuplicate(randomizedFactor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const peertubeActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const peertubeActor = yield (0, application_1.getServerActor)(); const query = { attributes: ['id', 'views'], limit: randomizedFactor, - order: utils_1.getVideoSort('-views'), + order: (0, utils_1.getVideoSort)('-views'), where: Object.assign({ privacy: 1, isLive: false }, this.buildVideoIdsForDuplication(peertubeActor)), include: [ VideoRedundancyModel_1.buildServerRedundancyInclude() @@ -192,14 +192,14 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static findTrendingToDuplicate(randomizedFactor) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const peertubeActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const peertubeActor = yield (0, application_1.getServerActor)(); const query = { attributes: ['id', 'views'], subQuery: false, group: 'VideoModel.id', limit: randomizedFactor, - order: utils_1.getVideoSort('-trending'), + order: (0, utils_1.getVideoSort)('-trending'), where: Object.assign({ privacy: 1, isLive: false }, this.buildVideoIdsForDuplication(peertubeActor)), include: [ VideoRedundancyModel_1.buildServerRedundancyInclude(), @@ -210,12 +210,12 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static findRecentlyAddedToDuplicate(randomizedFactor, minViews) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const peertubeActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const peertubeActor = yield (0, application_1.getServerActor)(); const query = { attributes: ['id', 'publishedAt'], limit: randomizedFactor, - order: utils_1.getVideoSort('-publishedAt'), + order: (0, utils_1.getVideoSort)('-publishedAt'), where: Object.assign({ privacy: 1, isLive: false, views: { [sequelize_1.Op.gte]: minViews } }, this.buildVideoIdsForDuplication(peertubeActor)), @@ -231,10 +231,10 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static loadOldestLocalExpired(strategy, expiresAfterMs) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const expiredDate = new Date(); expiredDate.setMilliseconds(expiredDate.getMilliseconds() - expiresAfterMs); - const actor = yield application_1.getServerActor(); + const actor = yield (0, application_1.getServerActor)(); const query = { where: { actorId: actor.id, @@ -248,8 +248,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static listLocalExpired() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const query = { where: { actorId: actor.id, @@ -262,8 +262,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static listRemoteExpired() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const query = { where: { actorId: { @@ -279,8 +279,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }); } static listLocalOfServer(serverId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const buildVideoInclude = () => ({ model: video_1.VideoModel, required: true, @@ -362,7 +362,7 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e [sequelize_1.Op.or]: [ { id: { - [sequelize_1.Op.in]: sequelize_1.literal('(' + + [sequelize_1.Op.in]: (0, sequelize_1.literal)('(' + 'SELECT "videoId" FROM "videoFile" ' + 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoFileId" = "videoFile".id' + redundancySqlSuffix + @@ -371,7 +371,7 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }, { id: { - [sequelize_1.Op.in]: sequelize_1.literal('(' + + [sequelize_1.Op.in]: (0, sequelize_1.literal)('(' + 'select "videoId" FROM "videoStreamingPlaylist" ' + 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoStreamingPlaylistId" = "videoStreamingPlaylist".id' + redundancySqlSuffix + @@ -386,7 +386,7 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e const findOptions = { offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), include: [ { required: false, @@ -426,8 +426,8 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e ]).then(([data, total]) => ({ total, data })); } static getStats(strategy) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const actor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const actor = yield (0, application_1.getServerActor)(); const sql = `WITH "tmp" AS ` + `(` + `SELECT "videoFile"."size" AS "videoFileSize", "videoStreamingFile"."size" AS "videoStreamingFileSize", ` + @@ -452,7 +452,7 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e replacements: { strategy, actorId: actor.id }, type: sequelize_1.QueryTypes.SELECT }).then(([row]) => ({ - totalUsed: utils_1.parseAggregateResult(row.totalUsed), + totalUsed: (0, utils_1.parseAggregateResult)(row.totalUsed), totalVideos: row.totalVideos, totalVideoFiles: row.totalVideoFiles })); @@ -546,7 +546,7 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }; } static buildVideoIdsForDuplication(peertubeActor) { - const notIn = sequelize_1.literal('(' + + const notIn = (0, sequelize_1.literal)('(' + `SELECT "videoFile"."videoId" AS "videoId" FROM "videoRedundancy" ` + `INNER JOIN "videoFile" ON "videoFile"."id" = "videoRedundancy"."videoFileId" ` + `WHERE "videoRedundancy"."actorId" = ${peertubeActor.id} ` + @@ -586,86 +586,86 @@ let VideoRedundancyModel = VideoRedundancyModel_1 = class VideoRedundancyModel e }; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoRedundancyModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoRedundancyModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoRedundancyModel.prototype, "expiresOn", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoRedundancyFileUrl', value => utils_1.throwIfNotValid(value, misc_1.isUrlValid, 'fileUrl')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoRedundancyFileUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isUrlValid, 'fileUrl')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoRedundancyModel.prototype, "fileUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoRedundancyUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoRedundancyUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoRedundancyModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoRedundancyModel.prototype, "strategy", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_file_1.VideoFileModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_file_1.VideoFileModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoRedundancyModel.prototype, "videoFileId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_file_1.VideoFileModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_file_1.VideoFileModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_file_1.VideoFileModel) + (0, tslib_1.__metadata)("design:type", video_file_1.VideoFileModel) ], VideoRedundancyModel.prototype, "VideoFile", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_streaming_playlist_1.VideoStreamingPlaylistModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_streaming_playlist_1.VideoStreamingPlaylistModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoRedundancyModel.prototype, "videoStreamingPlaylistId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_streaming_playlist_1.VideoStreamingPlaylistModel) + (0, tslib_1.__metadata)("design:type", video_streaming_playlist_1.VideoStreamingPlaylistModel) ], VideoRedundancyModel.prototype, "VideoStreamingPlaylist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoRedundancyModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], VideoRedundancyModel.prototype, "Actor", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoRedundancyModel]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoRedundancyModel]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoRedundancyModel, "removeFile", null); -VideoRedundancyModel = VideoRedundancyModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoRedundancyModel = VideoRedundancyModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_VIDEO]: { include: [ { @@ -691,7 +691,7 @@ VideoRedundancyModel = VideoRedundancyModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoRedundancy', indexes: [ { diff --git a/dist/server/models/server/plugin.js b/dist/server/models/server/plugin.js index 10f94e2f..f9aa7dac 100644 --- a/dist/server/models/server/plugin.js +++ b/dist/server/models/server/plugin.js @@ -89,7 +89,7 @@ let PluginModel = PluginModel_1 = class PluginModel extends sequelize_typescript static getData(pluginName, pluginType, key) { const query = { raw: true, - attributes: [[sequelize_1.json('storage.' + key), 'value']], + attributes: [[(0, sequelize_1.json)('storage.' + key), 'value']], where: { name: pluginName, type: pluginType @@ -127,7 +127,7 @@ let PluginModel = PluginModel_1 = class PluginModel extends sequelize_typescript const query = { offset: options.start, limit: options.count, - order: utils_1.getSort(options.sort), + order: (0, utils_1.getSort)(options.sort), where: { uninstalled } @@ -189,82 +189,82 @@ let PluginModel = PluginModel_1 = class PluginModel extends sequelize_typescript }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('PluginName', value => utils_1.throwIfNotValid(value, plugins_1.isPluginNameValid, 'name')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('PluginName', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginNameValid, 'name')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "name", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('PluginType', value => utils_1.throwIfNotValid(value, plugins_1.isPluginTypeValid, 'type')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('PluginType', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginTypeValid, 'type')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], PluginModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('PluginVersion', value => utils_1.throwIfNotValid(value, plugins_1.isPluginVersionValid, 'version')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('PluginVersion', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginVersionValid, 'version')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "version", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('PluginLatestVersion', value => utils_1.throwIfNotValid(value, plugins_1.isPluginVersionValid, 'version')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('PluginLatestVersion', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginVersionValid, 'version')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "latestVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], PluginModel.prototype, "enabled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], PluginModel.prototype, "uninstalled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "peertubeEngine", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('PluginDescription', value => utils_1.throwIfNotValid(value, plugins_1.isPluginDescriptionValid, 'description')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('PluginDescription', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginDescriptionValid, 'description')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "description", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('PluginHomepage', value => utils_1.throwIfNotValid(value, plugins_1.isPluginHomepage, 'homepage')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('PluginHomepage', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isPluginHomepage, 'homepage')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], PluginModel.prototype, "homepage", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.JSONB), - tslib_1.__metadata("design:type", Object) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSONB), + (0, tslib_1.__metadata)("design:type", Object) ], PluginModel.prototype, "settings", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.JSONB), - tslib_1.__metadata("design:type", Object) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSONB), + (0, tslib_1.__metadata)("design:type", Object) ], PluginModel.prototype, "storage", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], PluginModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], PluginModel.prototype, "updatedAt", void 0); -PluginModel = PluginModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +PluginModel = PluginModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ attributes: { exclude: ['storage'] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'plugin', indexes: [ { diff --git a/dist/server/models/server/server-blocklist.js b/dist/server/models/server/server-blocklist.js index bf653413..35a4e4d5 100644 --- a/dist/server/models/server/server-blocklist.js +++ b/dist/server/models/server/server-blocklist.js @@ -76,8 +76,8 @@ let ServerBlocklistModel = ServerBlocklistModel_1 = class ServerBlocklistModel e const query = { offset: start, limit: count, - order: utils_1.getSort(sort), - where: Object.assign({ accountId }, utils_1.searchAttribute(search, '$BlockedServer.host$')) + order: (0, utils_1.getSort)(sort), + where: Object.assign({ accountId }, (0, utils_1.searchAttribute)(search, '$BlockedServer.host$')) }; return ServerBlocklistModel_1 .scope([ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER]) @@ -94,45 +94,45 @@ let ServerBlocklistModel = ServerBlocklistModel_1 = class ServerBlocklistModel e }; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ServerBlocklistModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ServerBlocklistModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ServerBlocklistModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'accountId', allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], ServerBlocklistModel.prototype, "ByAccount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => server_1.ServerModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => server_1.ServerModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ServerBlocklistModel.prototype, "targetServerId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => server_1.ServerModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => server_1.ServerModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", server_1.ServerModel) + (0, tslib_1.__metadata)("design:type", server_1.ServerModel) ], ServerBlocklistModel.prototype, "BlockedServer", void 0); -ServerBlocklistModel = ServerBlocklistModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +ServerBlocklistModel = ServerBlocklistModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_ACCOUNT]: { include: [ { @@ -150,7 +150,7 @@ ServerBlocklistModel = ServerBlocklistModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'serverBlocklist', indexes: [ { diff --git a/dist/server/models/server/server.js b/dist/server/models/server/server.js index 222eac6d..c68a3116 100644 --- a/dist/server/models/server/server.js +++ b/dist/server/models/server/server.js @@ -27,7 +27,7 @@ let ServerModel = ServerModel_1 = class ServerModel extends sequelize_typescript return ServerModel_1.findOne(query); } static loadOrCreateByHost(host) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let server = yield ServerModel_1.loadByHost(host); if (!server) server = yield ServerModel_1.create({ host }); @@ -43,28 +43,28 @@ let ServerModel = ServerModel_1 = class ServerModel extends sequelize_typescript }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('Host', value => utils_1.throwIfNotValid(value, servers_1.isHostValid, 'valid host')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('Host', value => (0, utils_1.throwIfNotValid)(value, servers_1.isHostValid, 'valid host')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ServerModel.prototype, "host", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], ServerModel.prototype, "redundancyAllowed", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ServerModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ServerModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => actor_1.ActorModel, { foreignKey: { name: 'serverId', allowNull: true @@ -72,19 +72,19 @@ tslib_1.__decorate([ onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], ServerModel.prototype, "Actors", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => server_blocklist_1.ServerBlocklistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => server_blocklist_1.ServerBlocklistModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], ServerModel.prototype, "BlockedByAccounts", void 0); -ServerModel = ServerModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ServerModel = ServerModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'server', indexes: [ { diff --git a/dist/server/models/server/tracker.js b/dist/server/models/server/tracker.js index 3f3aa61e..a206c674 100644 --- a/dist/server/models/server/tracker.js +++ b/dist/server/models/server/tracker.js @@ -42,29 +42,29 @@ let TrackerModel = TrackerModel_1 = class TrackerModel extends sequelize_typescr return Promise.all(tasks); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], TrackerModel.prototype, "url", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], TrackerModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], TrackerModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsToMany(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsToMany)(() => video_1.VideoModel, { foreignKey: 'trackerId', through: () => video_tracker_1.VideoTrackerModel, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], TrackerModel.prototype, "Videos", void 0); -TrackerModel = TrackerModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +TrackerModel = TrackerModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'tracker', indexes: [ { diff --git a/dist/server/models/server/video-tracker.js b/dist/server/models/server/video-tracker.js index e4000e69..4ce4d121 100644 --- a/dist/server/models/server/video-tracker.js +++ b/dist/server/models/server/video-tracker.js @@ -7,26 +7,26 @@ const video_1 = require("../video/video"); const tracker_1 = require("./tracker"); let VideoTrackerModel = class VideoTrackerModel extends sequelize_typescript_1.Model { }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoTrackerModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoTrackerModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoTrackerModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => tracker_1.TrackerModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => tracker_1.TrackerModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoTrackerModel.prototype, "trackerId", void 0); -VideoTrackerModel = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoTrackerModel = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoTracker', indexes: [ { diff --git a/dist/server/models/shared/index.js b/dist/server/models/shared/index.js index a4fd0140..218d674f 100644 --- a/dist/server/models/shared/index.js +++ b/dist/server/models/shared/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./query"), exports); -tslib_1.__exportStar(require("./update"), exports); +(0, tslib_1.__exportStar)(require("./query"), exports); +(0, tslib_1.__exportStar)(require("./update"), exports); diff --git a/dist/server/models/user/user-notification-setting.js b/dist/server/models/user/user-notification-setting.js index e56227b7..d7f9060c 100644 --- a/dist/server/models/user/user-notification-setting.js +++ b/dist/server/models/user/user-notification-setting.js @@ -32,149 +32,149 @@ let UserNotificationSettingModel = class UserNotificationSettingModel extends se }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewVideoFromSubscription', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newVideoFromSubscription')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewVideoFromSubscription', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newVideoFromSubscription')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newVideoFromSubscription", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewCommentOnMyVideo', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newCommentOnMyVideo')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewCommentOnMyVideo', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newCommentOnMyVideo')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newCommentOnMyVideo", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingAbuseAsModerator', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'abuseAsModerator')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingAbuseAsModerator', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'abuseAsModerator')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "abuseAsModerator", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingVideoAutoBlacklistAsModerator', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingVideoAutoBlacklistAsModerator', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "videoAutoBlacklistAsModerator", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingBlacklistOnMyVideo', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'blacklistOnMyVideo')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingBlacklistOnMyVideo', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'blacklistOnMyVideo')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "blacklistOnMyVideo", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingMyVideoPublished', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'myVideoPublished')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingMyVideoPublished', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'myVideoPublished')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "myVideoPublished", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingMyVideoImportFinished', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'myVideoImportFinished')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingMyVideoImportFinished', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'myVideoImportFinished')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "myVideoImportFinished", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewUserRegistration', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newUserRegistration')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewUserRegistration', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newUserRegistration')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newUserRegistration", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewInstanceFollower', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newInstanceFollower')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewInstanceFollower', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newInstanceFollower')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newInstanceFollower", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewInstanceFollower', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'autoInstanceFollowing')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewInstanceFollower', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'autoInstanceFollowing')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "autoInstanceFollowing", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewFollow', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newFollow')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewFollow', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newFollow')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newFollow", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingCommentMention', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'commentMention')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingCommentMention', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'commentMention')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "commentMention", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingAbuseStateChange', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'abuseStateChange')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingAbuseStateChange', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'abuseStateChange')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "abuseStateChange", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingAbuseNewMessage', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'abuseNewMessage')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingAbuseNewMessage', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'abuseNewMessage')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "abuseNewMessage", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewPeerTubeVersion', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newPeerTubeVersion')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewPeerTubeVersion', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newPeerTubeVersion')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newPeerTubeVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationSettingNewPeerPluginVersion', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationSettingValid, 'newPluginVersion')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationSettingNewPeerPluginVersion', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationSettingValid, 'newPluginVersion')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "newPluginVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationSettingModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], UserNotificationSettingModel.prototype, "User", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserNotificationSettingModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserNotificationSettingModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterUpdate, sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [UserNotificationSettingModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [UserNotificationSettingModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], UserNotificationSettingModel, "removeTokenCache", null); -UserNotificationSettingModel = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +UserNotificationSettingModel = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'userNotificationSetting', indexes: [ { diff --git a/dist/server/models/user/user-notification.js b/dist/server/models/user/user-notification.js index afe09134..7b09b2ce 100644 --- a/dist/server/models/user/user-notification.js +++ b/dist/server/models/user/user-notification.js @@ -78,7 +78,7 @@ let UserNotificationModel = UserNotificationModel_1 = class UserNotificationMode const query = { offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), where }; if (unread !== undefined) @@ -223,7 +223,7 @@ let UserNotificationModel = UserNotificationModel_1 = class UserNotificationMode return { id: video.id, uuid: video.uuid, - shortUUID: uuid_1.uuidToShort(video.uuid), + shortUUID: (0, uuid_1.uuidToShort)(video.uuid), name: video.name }; } @@ -236,7 +236,7 @@ let UserNotificationModel = UserNotificationModel_1 = class UserNotificationMode ? { id: abuse.VideoCommentAbuse.VideoComment.Video.id, name: abuse.VideoCommentAbuse.VideoComment.Video.name, - shortUUID: uuid_1.uuidToShort(abuse.VideoCommentAbuse.VideoComment.Video.uuid), + shortUUID: (0, uuid_1.uuidToShort)(abuse.VideoCommentAbuse.VideoComment.Video.uuid), uuid: abuse.VideoCommentAbuse.VideoComment.Video.uuid } : undefined @@ -265,170 +265,170 @@ let UserNotificationModel = UserNotificationModel_1 = class UserNotificationMode }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserNotificationType', value => utils_1.throwIfNotValid(value, user_notifications_1.isUserNotificationTypeValid, 'type')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserNotificationType', value => (0, utils_1.throwIfNotValid)(value, user_notifications_1.isUserNotificationTypeValid, 'type')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserNotificationRead', value => utils_1.throwIfNotValid(value, misc_1.isBooleanValid, 'read')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserNotificationRead', value => (0, utils_1.throwIfNotValid)(value, misc_1.isBooleanValid, 'read')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserNotificationModel.prototype, "read", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserNotificationModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserNotificationModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], UserNotificationModel.prototype, "User", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], UserNotificationModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_comment_1.VideoCommentModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_comment_1.VideoCommentModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "commentId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_comment_1.VideoCommentModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_comment_1.VideoCommentModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_comment_1.VideoCommentModel) + (0, tslib_1.__metadata)("design:type", video_comment_1.VideoCommentModel) ], UserNotificationModel.prototype, "Comment", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => abuse_1.AbuseModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => abuse_1.AbuseModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "abuseId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => abuse_1.AbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => abuse_1.AbuseModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", abuse_1.AbuseModel) + (0, tslib_1.__metadata)("design:type", abuse_1.AbuseModel) ], UserNotificationModel.prototype, "Abuse", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_blacklist_1.VideoBlacklistModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_blacklist_1.VideoBlacklistModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "videoBlacklistId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_blacklist_1.VideoBlacklistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_blacklist_1.VideoBlacklistModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_blacklist_1.VideoBlacklistModel) + (0, tslib_1.__metadata)("design:type", video_blacklist_1.VideoBlacklistModel) ], UserNotificationModel.prototype, "VideoBlacklist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_import_1.VideoImportModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_import_1.VideoImportModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "videoImportId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_import_1.VideoImportModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_import_1.VideoImportModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_import_1.VideoImportModel) + (0, tslib_1.__metadata)("design:type", video_import_1.VideoImportModel) ], UserNotificationModel.prototype, "VideoImport", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], UserNotificationModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_follow_1.ActorFollowModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_follow_1.ActorFollowModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "actorFollowId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_follow_1.ActorFollowModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_follow_1.ActorFollowModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_follow_1.ActorFollowModel) + (0, tslib_1.__metadata)("design:type", actor_follow_1.ActorFollowModel) ], UserNotificationModel.prototype, "ActorFollow", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => plugin_1.PluginModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => plugin_1.PluginModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "pluginId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => plugin_1.PluginModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => plugin_1.PluginModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", plugin_1.PluginModel) + (0, tslib_1.__metadata)("design:type", plugin_1.PluginModel) ], UserNotificationModel.prototype, "Plugin", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => application_1.ApplicationModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => application_1.ApplicationModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserNotificationModel.prototype, "applicationId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => application_1.ApplicationModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => application_1.ApplicationModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", application_1.ApplicationModel) + (0, tslib_1.__metadata)("design:type", application_1.ApplicationModel) ], UserNotificationModel.prototype, "Application", void 0); -UserNotificationModel = UserNotificationModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +UserNotificationModel = UserNotificationModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_ALL]: { include: [ Object.assign(buildVideoInclude(false), { @@ -553,7 +553,7 @@ UserNotificationModel = UserNotificationModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'userNotification', indexes: [ { diff --git a/dist/server/models/user/user-video-history.js b/dist/server/models/user/user-video-history.js index e2aa8dc6..456bf77a 100644 --- a/dist/server/models/user/user-video-history.js +++ b/dist/server/models/user/user-video-history.js @@ -46,50 +46,50 @@ let UserVideoHistoryModel = UserVideoHistoryModel_1 = class UserVideoHistoryMode return UserVideoHistoryModel_1.destroy(query); } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserVideoHistoryModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserVideoHistoryModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.IsInt, sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserVideoHistoryModel.prototype, "currentTime", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserVideoHistoryModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], UserVideoHistoryModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserVideoHistoryModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], UserVideoHistoryModel.prototype, "User", void 0); -UserVideoHistoryModel = UserVideoHistoryModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +UserVideoHistoryModel = UserVideoHistoryModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'userVideoHistory', indexes: [ { diff --git a/dist/server/models/user/user.js b/dist/server/models/user/user.js index b1b88e0c..e2f57f06 100644 --- a/dist/server/models/user/user.js +++ b/dist/server/models/user/user.js @@ -34,7 +34,7 @@ var ScopeNames; let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Model { static cryptPasswordIfNeeded(instance) { if (instance.changed('password') && instance.password) { - return peertube_crypto_1.cryptPassword(instance.password) + return (0, peertube_crypto_1.cryptPassword)(instance.password) .then(hash => { instance.password = hash; return undefined; @@ -75,7 +75,7 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod attributes: { include: [ [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + UserModel_1.generateUserQuotaBaseSQL({ withSelect: false, whereUserId: '"UserModel"."id"' @@ -87,7 +87,7 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod }, offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), where }; return UserModel_1.findAndCountAll(query) @@ -101,7 +101,7 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod static listWithRight(right) { const roles = Object.keys(users_1.USER_ROLE_LABELS) .map(k => parseInt(k, 10)) - .filter(role => users_1.hasUserRight(role, right)); + .filter(role => (0, users_1.hasUserRight)(role, right)); const query = { where: { role: { @@ -200,7 +200,7 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod const query = { where: { [sequelize_1.Op.or]: [ - sequelize_1.where(sequelize_1.fn('lower', sequelize_1.col('username')), sequelize_1.fn('lower', username)), + (0, sequelize_1.where)((0, sequelize_1.fn)('lower', (0, sequelize_1.col)('username')), (0, sequelize_1.fn)('lower', username)), { email } ] } @@ -359,12 +359,12 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod }); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function getActiveUsers(days) { const query = { where: { [sequelize_1.Op.and]: [ - sequelize_1.literal(`"lastLoginDate" > NOW() - INTERVAL '${days}d'`) + (0, sequelize_1.literal)(`"lastLoginDate" > NOW() - INTERVAL '${days}d'`) ] } }; @@ -409,13 +409,13 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod return false; } hasRight(right) { - return users_1.hasUserRight(this.role, right); + return (0, users_1.hasUserRight)(this.role, right); } hasAdminFlag(flag) { return this.adminFlags & flag; } isPasswordMatch(password) { - return peertube_crypto_1.comparePassword(password, this.password); + return (0, peertube_crypto_1.comparePassword)(password, this.password); } toFormattedJSON(parameters = {}) { const videoQuotaUsed = this.get('videoQuotaUsed'); @@ -428,7 +428,7 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod id: this.id, username: this.username, email: this.email, - theme: theme_utils_1.getThemeOrDefault(this.theme, constants_1.DEFAULT_USER_THEME_NAME), + theme: (0, theme_utils_1.getThemeOrDefault)(this.theme, constants_1.DEFAULT_USER_THEME_NAME), pendingEmail: this.pendingEmail, emailVerified: this.emailVerified, nsfwPolicy: this.nsfwPolicy, @@ -500,225 +500,225 @@ let UserModel = UserModel_1 = class UserModel extends sequelize_typescript_1.Mod return Object.assign(formatted, { specialPlaylists }); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('UserPassword', value => utils_1.throwIfNotValid(value, users_2.isUserPasswordValid, 'user password', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('UserPassword', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserPasswordValid, 'user password', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "password", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('UserUsername', value => utils_1.throwIfNotValid(value, users_2.isUserUsernameValid, 'user name')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('UserUsername', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserUsernameValid, 'user name')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "username", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.IsEmail, - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(400)), - tslib_1.__metadata("design:type", String) + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(400)), + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "email", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.IsEmail, - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(400)), - tslib_1.__metadata("design:type", String) + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(400)), + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "pendingEmail", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserEmailVerified', value => utils_1.throwIfNotValid(value, users_2.isUserEmailVerifiedValid, 'email verified boolean', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserEmailVerified', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserEmailVerifiedValid, 'email verified boolean', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "emailVerified", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('UserNSFWPolicy', value => utils_1.throwIfNotValid(value, users_2.isUserNSFWPolicyValid, 'NSFW policy')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ENUM(...lodash_1.values(constants_1.NSFW_POLICY_TYPES))), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('UserNSFWPolicy', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserNSFWPolicyValid, 'NSFW policy')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ENUM(...(0, lodash_1.values)(constants_1.NSFW_POLICY_TYPES))), + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "nsfwPolicy", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(true), - sequelize_typescript_1.Is('UserWebTorrentEnabled', value => utils_1.throwIfNotValid(value, users_2.isUserWebTorrentEnabledValid, 'WebTorrent enabled')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(true), + (0, sequelize_typescript_1.Is)('UserWebTorrentEnabled', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserWebTorrentEnabledValid, 'WebTorrent enabled')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "webTorrentEnabled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(true), - sequelize_typescript_1.Is('UserVideosHistoryEnabled', value => utils_1.throwIfNotValid(value, users_2.isUserVideosHistoryEnabledValid, 'Videos history enabled')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(true), + (0, sequelize_typescript_1.Is)('UserVideosHistoryEnabled', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserVideosHistoryEnabledValid, 'Videos history enabled')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "videosHistoryEnabled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(true), - sequelize_typescript_1.Is('UserAutoPlayVideo', value => utils_1.throwIfNotValid(value, users_2.isUserAutoPlayVideoValid, 'auto play video boolean')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(true), + (0, sequelize_typescript_1.Is)('UserAutoPlayVideo', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserAutoPlayVideoValid, 'auto play video boolean')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "autoPlayVideo", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserAutoPlayNextVideo', value => utils_1.throwIfNotValid(value, users_2.isUserAutoPlayNextVideoValid, 'auto play next video boolean')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserAutoPlayNextVideo', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserAutoPlayNextVideoValid, 'auto play next video boolean')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "autoPlayNextVideo", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(true), - sequelize_typescript_1.Is('UserAutoPlayNextVideoPlaylist', value => utils_1.throwIfNotValid(value, users_2.isUserAutoPlayNextVideoPlaylistValid, 'auto play next video for playlists boolean')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(true), + (0, sequelize_typescript_1.Is)('UserAutoPlayNextVideoPlaylist', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserAutoPlayNextVideoPlaylistValid, 'auto play next video for playlists boolean')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "autoPlayNextVideoPlaylist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserVideoLanguages', value => utils_1.throwIfNotValid(value, users_2.isUserVideoLanguages, 'video languages')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), - tslib_1.__metadata("design:type", Array) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserVideoLanguages', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserVideoLanguages, 'video languages')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), + (0, tslib_1.__metadata)("design:type", Array) ], UserModel.prototype, "videoLanguages", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), - sequelize_typescript_1.Is('UserAdminFlags', value => utils_1.throwIfNotValid(value, users_2.isUserAdminFlagsValid, 'user admin flags')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), + (0, sequelize_typescript_1.Is)('UserAdminFlags', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserAdminFlagsValid, 'user admin flags')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserModel.prototype, "adminFlags", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserBlocked', value => utils_1.throwIfNotValid(value, users_2.isUserBlockedValid, 'blocked boolean')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserBlocked', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserBlockedValid, 'blocked boolean')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "blocked", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('UserBlockedReason', value => utils_1.throwIfNotValid(value, users_2.isUserBlockedReasonValid, 'blocked reason', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('UserBlockedReason', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserBlockedReasonValid, 'blocked reason', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "blockedReason", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('UserRole', value => utils_1.throwIfNotValid(value, users_2.isUserRoleValid, 'role')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('UserRole', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserRoleValid, 'role')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], UserModel.prototype, "role", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('UserVideoQuota', value => utils_1.throwIfNotValid(value, users_2.isUserVideoQuotaValid, 'video quota')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.BIGINT), - tslib_1.__metadata("design:type", Number) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('UserVideoQuota', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserVideoQuotaValid, 'video quota')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.BIGINT), + (0, tslib_1.__metadata)("design:type", Number) ], UserModel.prototype, "videoQuota", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('UserVideoQuotaDaily', value => utils_1.throwIfNotValid(value, users_2.isUserVideoQuotaDailyValid, 'video quota daily')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.BIGINT), - tslib_1.__metadata("design:type", Number) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('UserVideoQuotaDaily', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserVideoQuotaDailyValid, 'video quota daily')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.BIGINT), + (0, tslib_1.__metadata)("design:type", Number) ], UserModel.prototype, "videoQuotaDaily", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(constants_1.DEFAULT_USER_THEME_NAME), - sequelize_typescript_1.Is('UserTheme', value => utils_1.throwIfNotValid(value, plugins_1.isThemeNameValid, 'theme')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(constants_1.DEFAULT_USER_THEME_NAME), + (0, sequelize_typescript_1.Is)('UserTheme', value => (0, utils_1.throwIfNotValid)(value, plugins_1.isThemeNameValid, 'theme')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "theme", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserNoInstanceConfigWarningModal', value => utils_1.throwIfNotValid(value, users_2.isUserNoModal, 'no instance config warning modal')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserNoInstanceConfigWarningModal', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserNoModal, 'no instance config warning modal')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "noInstanceConfigWarningModal", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserNoWelcomeModal', value => utils_1.throwIfNotValid(value, users_2.isUserNoModal, 'no welcome modal')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserNoWelcomeModal', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserNoModal, 'no welcome modal')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "noWelcomeModal", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), - sequelize_typescript_1.Is('UserNoAccountSetupWarningModal', value => utils_1.throwIfNotValid(value, users_2.isUserNoModal, 'no account setup warning modal')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), + (0, sequelize_typescript_1.Is)('UserNoAccountSetupWarningModal', value => (0, utils_1.throwIfNotValid)(value, users_2.isUserNoModal, 'no account setup warning modal')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], UserModel.prototype, "noAccountSetupWarningModal", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "pluginAuth", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(sequelize_typescript_1.DataType.UUIDV4), - sequelize_typescript_1.IsUUID(4), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.UUID), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4), + (0, sequelize_typescript_1.IsUUID)(4), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID), + (0, tslib_1.__metadata)("design:type", String) ], UserModel.prototype, "feedToken", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserModel.prototype, "lastLoginDate", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], UserModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => account_1.AccountModel, { foreignKey: 'userId', onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], UserModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => user_notification_setting_1.UserNotificationSettingModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => user_notification_setting_1.UserNotificationSettingModel, { foreignKey: 'userId', onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", user_notification_setting_1.UserNotificationSettingModel) + (0, tslib_1.__metadata)("design:type", user_notification_setting_1.UserNotificationSettingModel) ], UserModel.prototype, "NotificationSetting", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_import_1.VideoImportModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_import_1.VideoImportModel, { foreignKey: 'userId', onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], UserModel.prototype, "VideoImports", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => oauth_token_1.OAuthTokenModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => oauth_token_1.OAuthTokenModel, { foreignKey: 'userId', onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], UserModel.prototype, "OAuthTokens", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeCreate, sequelize_typescript_1.BeforeUpdate, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [UserModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [UserModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], UserModel, "cryptPasswordIfNeeded", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterUpdate, sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [UserModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [UserModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], UserModel, "removeTokenCache", null); -UserModel = UserModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +UserModel = UserModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: account_1.AccountModel, @@ -730,7 +730,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.FOR_ME_API]: { include: [ { @@ -796,7 +796,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ attributes: { include: [ [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + UserModel_1.generateUserQuotaBaseSQL({ withSelect: false, whereUserId: '"UserModel"."id"' @@ -805,7 +805,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ 'videoQuotaUsed' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT COUNT("video"."id") ' + 'FROM "video" ' + 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + @@ -815,7 +815,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ 'videosCount' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + `SELECT concat_ws(':', "abuses", "acceptedAbuses") ` + 'FROM (' + 'SELECT COUNT("abuse"."id") AS "abuses", ' + @@ -828,7 +828,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ 'abusesCount' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT COUNT("abuse"."id") ' + 'FROM "abuse" ' + 'INNER JOIN "account" ON "account"."id" = "abuse"."reporterAccountId" ' + @@ -837,7 +837,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ 'abusesCreatedCount' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + 'SELECT COUNT("videoComment"."id") ' + 'FROM "videoComment" ' + 'INNER JOIN "account" ON "account"."id" = "videoComment"."accountId" ' + @@ -849,7 +849,7 @@ UserModel = UserModel_1 = tslib_1.__decorate([ } } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'user', indexes: [ { diff --git a/dist/server/models/utils.js b/dist/server/models/utils.js index 7f2663f9..1caddf50 100644 --- a/dist/server/models/utils.js +++ b/dist/server/models/utils.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.searchAttribute = exports.createSafeIn = exports.buildDirectionAndField = exports.getFollowsSort = exports.parseAggregateResult = exports.isOutdated = exports.buildWhereIdOrUUID = exports.buildTrigramSearchIndex = exports.buildServerIdsFollowedBy = exports.throwIfNotValid = exports.createSimilarityAttribute = exports.getBlacklistSort = exports.getVideoSort = exports.getCommentSort = exports.getSort = exports.buildLocalAccountIdsIn = exports.getPlaylistSort = exports.buildLocalActorIdsIn = exports.buildBlockedAccountSQLOptimized = exports.buildBlockedAccountSQL = void 0; const tslib_1 = require("tslib"); const sequelize_1 = require("sequelize"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); function getSort(value, lastSort = ['id', 'ASC']) { const { direction, field } = buildDirectionAndField(value); let finalField; @@ -70,7 +70,7 @@ exports.getVideoSort = getVideoSort; function getBlacklistSort(model, value, lastSort = ['id', 'ASC']) { const [firstSort] = getSort(value); if (model) - return [[sequelize_1.literal(`"${model}.${firstSort[0]}" ${firstSort[1]}`)], lastSort]; + return [[(0, sequelize_1.literal)(`"${model}.${firstSort[0]}" ${firstSort[1]}`)], lastSort]; return [firstSort, lastSort]; } exports.getBlacklistSort = getBlacklistSort; @@ -128,12 +128,12 @@ exports.buildBlockedAccountSQL = buildBlockedAccountSQL; function buildBlockedAccountSQLOptimized(columnNameJoin, blockerIds) { const blockerIdsString = blockerIds.join(', '); return [ - sequelize_1.literal(`NOT EXISTS (` + + (0, sequelize_1.literal)(`NOT EXISTS (` + ` SELECT 1 FROM "accountBlocklist" ` + ` WHERE "targetAccountId" = ${columnNameJoin} ` + ` AND "accountId" IN (${blockerIdsString})` + `)`), - sequelize_1.literal(`NOT EXISTS (` + + (0, sequelize_1.literal)(`NOT EXISTS (` + ` SELECT 1 FROM "account" ` + ` INNER JOIN "actor" ON account."actorId" = actor.id ` + ` INNER JOIN "serverBlocklist" ON "actor"."serverId" = "serverBlocklist"."targetServerId" ` + @@ -174,11 +174,11 @@ function createSafeIn(sequelize, stringArr) { } exports.createSafeIn = createSafeIn; function buildLocalAccountIdsIn() { - return sequelize_1.literal('(SELECT "account"."id" FROM "account" INNER JOIN "actor" ON "actor"."id" = "account"."actorId" AND "actor"."serverId" IS NULL)'); + return (0, sequelize_1.literal)('(SELECT "account"."id" FROM "account" INNER JOIN "actor" ON "actor"."id" = "account"."actorId" AND "actor"."serverId" IS NULL)'); } exports.buildLocalAccountIdsIn = buildLocalAccountIdsIn; function buildLocalActorIdsIn() { - return sequelize_1.literal('(SELECT "actor"."id" FROM "actor" WHERE "actor"."serverId" IS NULL)'); + return (0, sequelize_1.literal)('(SELECT "actor"."id" FROM "actor" WHERE "actor"."serverId" IS NULL)'); } exports.buildLocalActorIdsIn = buildLocalActorIdsIn; function buildDirectionAndField(value) { diff --git a/dist/server/models/video/formatter/video-format-utils.js b/dist/server/models/video/formatter/video-format-utils.js index 5a19dfcb..69fb2530 100644 --- a/dist/server/models/video/formatter/video-format-utils.js +++ b/dist/server/models/video/formatter/video-format-utils.js @@ -9,11 +9,11 @@ const constants_1 = require("../../../initializers/constants"); const url_1 = require("../../../lib/activitypub/url"); const video_caption_1 = require("../video-caption"); function videoModelToFormattedJSON(video, options) { - const userHistory = misc_1.isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined; + const userHistory = (0, misc_1.isArray)(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined; const videoObject = { id: video.id, uuid: video.uuid, - shortUUID: uuid_1.uuidToShort(video.uuid), + shortUUID: (0, uuid_1.uuidToShort)(video.uuid), name: video.name, category: { id: video.category, @@ -112,11 +112,11 @@ function videoModelToFormattedDetailsJSON(video) { } exports.videoModelToFormattedDetailsJSON = videoModelToFormattedDetailsJSON; function streamingPlaylistsModelToFormattedJSON(video, playlists) { - if (misc_1.isArray(playlists) === false) + if ((0, misc_1.isArray)(playlists) === false) return []; return playlists .map(playlist => { - const redundancies = misc_1.isArray(playlist.RedundancyVideos) + const redundancies = (0, misc_1.isArray)(playlist.RedundancyVideos) ? playlist.RedundancyVideos.map(r => ({ baseUrl: r.fileUrl })) : []; const files = videoFilesModelToFormattedJSON(video, playlist.VideoFiles); @@ -152,7 +152,7 @@ function videoFilesModelToFormattedJSON(video, videoFiles, includeMagnet = true) label: videoFile.resolution === 0 ? 'Audio' : `${videoFile.resolution}p` }, magnetUri: includeMagnet && videoFile.hasTorrent() - ? webtorrent_1.generateMagnetUri(video, videoFile, trackerUrls) + ? (0, webtorrent_1.generateMagnetUri)(video, videoFile, trackerUrls) : undefined, size: videoFile.size, fps: videoFile.fps, @@ -160,7 +160,7 @@ function videoFilesModelToFormattedJSON(video, videoFiles, includeMagnet = true) torrentDownloadUrl: videoFile.getTorrentDownloadUrl(), fileUrl: videoFile.getFileUrl(video), fileDownloadUrl: videoFile.getFileDownloadUrl(video), - metadataUrl: (_a = videoFile.metadataUrl) !== null && _a !== void 0 ? _a : video_urls_1.getLocalVideoFileMetadataUrl(video, videoFile) + metadataUrl: (_a = videoFile.metadataUrl) !== null && _a !== void 0 ? _a : (0, video_urls_1.getLocalVideoFileMetadataUrl)(video, videoFile) }; }); } @@ -183,7 +183,7 @@ function addVideoFilesInAPAcc(acc, video, files) { type: 'Link', rel: ['metadata', constants_1.MIMETYPES.VIDEO.EXT_MIMETYPE[file.extname]], mediaType: 'application/json', - href: video_urls_1.getLocalVideoFileMetadataUrl(video, file), + href: (0, video_urls_1.getLocalVideoFileMetadataUrl)(video, file), height: file.resolution, fps: file.fps }); @@ -197,7 +197,7 @@ function addVideoFilesInAPAcc(acc, video, files) { acc.push({ type: 'Link', mediaType: 'application/x-bittorrent;x-scheme-handler/magnet', - href: webtorrent_1.generateMagnetUri(video, file, trackerUrls), + href: (0, webtorrent_1.generateMagnetUri)(video, file, trackerUrls), height: file.resolution }); } @@ -317,10 +317,10 @@ function videoModelToActivityPubObject(video) { height: i.height })), url, - likes: url_1.getLocalVideoLikesActivityPubUrl(video), - dislikes: url_1.getLocalVideoDislikesActivityPubUrl(video), - shares: url_1.getLocalVideoSharesActivityPubUrl(video), - comments: url_1.getLocalVideoCommentsActivityPubUrl(video), + likes: (0, url_1.getLocalVideoLikesActivityPubUrl)(video), + dislikes: (0, url_1.getLocalVideoDislikesActivityPubUrl)(video), + shares: (0, url_1.getLocalVideoSharesActivityPubUrl)(video), + comments: (0, url_1.getLocalVideoCommentsActivityPubUrl)(video), attributedTo: [ { type: 'Person', diff --git a/dist/server/models/video/schedule-video-update.js b/dist/server/models/video/schedule-video-update.js index 041b83c1..5e9988c7 100644 --- a/dist/server/models/video/schedule-video-update.js +++ b/dist/server/models/video/schedule-video-update.js @@ -47,42 +47,42 @@ let ScheduleVideoUpdateModel = ScheduleVideoUpdateModel_1 = class ScheduleVideoU }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ScheduleVideoUpdateModel.prototype, "updateAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ScheduleVideoUpdateModel.prototype, "privacy", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ScheduleVideoUpdateModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ScheduleVideoUpdateModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ScheduleVideoUpdateModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], ScheduleVideoUpdateModel.prototype, "Video", void 0); -ScheduleVideoUpdateModel = ScheduleVideoUpdateModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ScheduleVideoUpdateModel = ScheduleVideoUpdateModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'scheduleVideoUpdate', indexes: [ { diff --git a/dist/server/models/video/sql/shared/abstract-videos-model-query-builder.js b/dist/server/models/video/sql/shared/abstract-videos-model-query-builder.js index 732f7dbf..4a5390a2 100644 --- a/dist/server/models/video/sql/shared/abstract-videos-model-query-builder.js +++ b/dist/server/models/video/sql/shared/abstract-videos-model-query-builder.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractVideosModelQueryBuilder = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const abstract_videos_query_builder_1 = require("./abstract-videos-query-builder"); const video_tables_1 = require("./video-tables"); class AbstractVideosModelQueryBuilder extends abstract_videos_query_builder_1.AbstractVideosQueryBuilder { diff --git a/dist/server/models/video/sql/video-model-get-query-builder.js b/dist/server/models/video/sql/video-model-get-query-builder.js index 9e8dc4a7..d154d2ae 100644 --- a/dist/server/models/video/sql/video-model-get-query-builder.js +++ b/dist/server/models/video/sql/video-model-get-query-builder.js @@ -15,7 +15,7 @@ class VideosModelGetQueryBuilder { this.videoModelBuilder = new video_model_builder_1.VideoModelBuilder('get', new video_tables_1.VideoTables('get')); } queryVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [videoRows, webtorrentFilesRows, streamingPlaylistFilesRows] = yield Promise.all([ this.videoQueryBuilder.queryVideos(options), VideosModelGetQueryBuilder.videoFilesInclude.has(options.type) diff --git a/dist/server/models/video/sql/videos-id-list-query-builder.js b/dist/server/models/video/sql/videos-id-list-query-builder.js index 19b469e6..10c6a0c7 100644 --- a/dist/server/models/video/sql/videos-id-list-query-builder.js +++ b/dist/server/models/video/sql/videos-id-list-query-builder.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.VideosIdListQueryBuilder = void 0; const tslib_1 = require("tslib"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("@server/helpers/custom-validators/misc"); const constants_1 = require("@server/initializers/constants"); const utils_1 = require("@server/models/utils"); @@ -136,13 +136,13 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV this.setCountAttribute(); } else { - if (misc_1.exists(options.sort)) { + if ((0, misc_1.exists)(options.sort)) { this.setSort(options.sort); } - if (misc_1.exists(options.count)) { + if ((0, misc_1.exists)(options.count)) { this.setLimit(options.count); } - if (misc_1.exists(options.start)) { + if ((0, misc_1.exists)(options.start)) { this.setOffset(options.start); } } @@ -238,7 +238,7 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV this.and.push('EXISTS (' + ' SELECT 1 FROM "videoTag" ' + ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' + - ' WHERE lower("tag"."name") IN (' + utils_1.createSafeIn(this.sequelize, tagsOneOfLower) + ') ' + + ' WHERE lower("tag"."name") IN (' + (0, utils_1.createSafeIn)(this.sequelize, tagsOneOfLower) + ') ' + ' AND "video"."id" = "videoTag"."videoId"' + ')'); } @@ -247,13 +247,13 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV this.and.push('EXISTS (' + ' SELECT 1 FROM "videoTag" ' + ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' + - ' WHERE lower("tag"."name") IN (' + utils_1.createSafeIn(this.sequelize, tagsAllOfLower) + ') ' + + ' WHERE lower("tag"."name") IN (' + (0, utils_1.createSafeIn)(this.sequelize, tagsAllOfLower) + ') ' + ' AND "video"."id" = "videoTag"."videoId" ' + ' GROUP BY "videoTag"."videoId" HAVING COUNT(*) = ' + tagsAllOfLower.length + ')'); } whereUUIDs(uuids) { - this.and.push('"video"."uuid" IN (' + utils_1.createSafeIn(this.sequelize, uuids) + ')'); + this.and.push('"video"."uuid" IN (' + (0, utils_1.createSafeIn)(this.sequelize, uuids) + ')'); } whereCategoryOneOf(categoryOneOf) { this.and.push('"video"."category" IN (:categoryOneOf)'); @@ -271,7 +271,7 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV this.replacements.languageOneOf = languages; languagesQueryParts.push('EXISTS (' + ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' + - ' IN (' + utils_1.createSafeIn(this.sequelize, languages) + ') AND ' + + ' IN (' + (0, utils_1.createSafeIn)(this.sequelize, languages) + ') AND ' + ' "videoCaption"."videoId" = "video"."id"' + ')'); } @@ -298,7 +298,7 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV const blockerIds = [serverAccountId]; if (user) blockerIds.push(user.Account.id); - const inClause = utils_1.createSafeIn(this.sequelize, blockerIds); + const inClause = (0, utils_1.createSafeIn)(this.sequelize, blockerIds); this.and.push('NOT EXISTS (' + ' SELECT 1 FROM "accountBlocklist" ' + ' WHERE "accountBlocklist"."accountId" IN (' + inClause + ') ' + @@ -403,7 +403,7 @@ class VideosIdListQueryBuilder extends abstract_videos_query_builder_1.AbstractV this.sort = this.buildOrder(sort); } buildOrder(value) { - const { direction, field } = utils_1.buildDirectionAndField(value); + const { direction, field } = (0, utils_1.buildDirectionAndField)(value); if (field.match(/^[a-zA-Z."]+$/) === null) throw new Error('Invalid sort column ' + field); if (field.toLowerCase() === 'random') diff --git a/dist/server/models/video/tag.js b/dist/server/models/video/tag.js index 8f3e99e8..b40fb906 100644 --- a/dist/server/models/video/tag.js +++ b/dist/server/models/video/tag.js @@ -46,30 +46,30 @@ let TagModel = TagModel_1 = class TagModel extends sequelize_typescript_1.Model .then(data => data.map(d => d.name)); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoTag', value => utils_1.throwIfNotValid(value, videos_1.isVideoTagValid, 'tag')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoTag', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoTagValid, 'tag')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], TagModel.prototype, "name", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], TagModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], TagModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsToMany(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsToMany)(() => video_1.VideoModel, { foreignKey: 'tagId', through: () => video_tag_1.VideoTagModel, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], TagModel.prototype, "Videos", void 0); -TagModel = TagModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +TagModel = TagModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'tag', timestamps: false, indexes: [ @@ -79,7 +79,7 @@ TagModel = TagModel_1 = tslib_1.__decorate([ }, { name: 'tag_lower_name', - fields: [sequelize_1.fn('lower', sequelize_1.col('name'))] + fields: [(0, sequelize_1.fn)('lower', (0, sequelize_1.col)('name'))] } ] }) diff --git a/dist/server/models/video/thumbnail.js b/dist/server/models/video/thumbnail.js index bf2179c2..195a0101 100644 --- a/dist/server/models/video/thumbnail.js +++ b/dist/server/models/video/thumbnail.js @@ -14,7 +14,7 @@ const video_1 = require("./video"); const video_playlist_1 = require("./video-playlist"); let ThumbnailModel = ThumbnailModel_1 = class ThumbnailModel extends sequelize_typescript_1.Model { static removeOldFile(instance, options) { - return database_utils_1.afterCommitIfTransaction(options.transaction, () => instance.removePreviousFilenameIfNeeded()); + return (0, database_utils_1.afterCommitIfTransaction)(options.transaction, () => instance.removePreviousFilenameIfNeeded()); } static removeFiles(instance) { logger_1.logger.info('Removing %s file %s.', ThumbnailModel_1.types[instance.type].label, instance.filename); @@ -47,7 +47,7 @@ let ThumbnailModel = ThumbnailModel_1 = class ThumbnailModel extends sequelize_t } static buildPath(type, filename) { const directory = ThumbnailModel_1.types[type].directory; - return path_1.join(directory, filename); + return (0, path_1.join)(directory, filename); } getFileUrl(video) { const staticPath = ThumbnailModel_1.types[this.type].staticPath + this.filename; @@ -62,13 +62,13 @@ let ThumbnailModel = ThumbnailModel_1 = class ThumbnailModel extends sequelize_t return ThumbnailModel_1.buildPath(this.type, this.previousThumbnailFilename); } removeThumbnail() { - return fs_extra_1.remove(this.getPath()); + return (0, fs_extra_1.remove)(this.getPath()); } removePreviousFilenameIfNeeded() { if (!this.previousThumbnailFilename) return; const previousPath = this.getPreviousPath(); - fs_extra_1.remove(previousPath) + (0, fs_extra_1.remove)(previousPath) .catch(err => logger_1.logger.error('Cannot remove previous thumbnail file %s.', previousPath, { err })); this.previousThumbnailFilename = undefined; } @@ -85,89 +85,89 @@ ThumbnailModel.types = { staticPath: constants_1.LAZY_STATIC_PATHS.PREVIEWS } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], ThumbnailModel.prototype, "filename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ThumbnailModel.prototype, "height", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ThumbnailModel.prototype, "width", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ThumbnailModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], ThumbnailModel.prototype, "fileUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], ThumbnailModel.prototype, "automaticallyGenerated", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ThumbnailModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], ThumbnailModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_playlist_1.VideoPlaylistModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_playlist_1.VideoPlaylistModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], ThumbnailModel.prototype, "videoPlaylistId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_playlist_1.VideoPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_playlist_1.VideoPlaylistModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_playlist_1.VideoPlaylistModel) + (0, tslib_1.__metadata)("design:type", video_playlist_1.VideoPlaylistModel) ], ThumbnailModel.prototype, "VideoPlaylist", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ThumbnailModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], ThumbnailModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeCreate, sequelize_typescript_1.BeforeUpdate, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [ThumbnailModel, Object]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [ThumbnailModel, Object]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], ThumbnailModel, "removeOldFile", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [ThumbnailModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [ThumbnailModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], ThumbnailModel, "removeFiles", null); -ThumbnailModel = ThumbnailModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +ThumbnailModel = ThumbnailModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'thumbnail', indexes: [ { diff --git a/dist/server/models/video/video-blacklist.js b/dist/server/models/video/video-blacklist.js index 90add174..e6d7972b 100644 --- a/dist/server/models/video/video-blacklist.js +++ b/dist/server/models/video/video-blacklist.js @@ -17,7 +17,7 @@ let VideoBlacklistModel = VideoBlacklistModel_1 = class VideoBlacklistModel exte return { offset: start, limit: count, - order: utils_1.getBlacklistSort(sort.sortModel, sort.sortValue) + order: (0, utils_1.getBlacklistSort)(sort.sortModel, sort.sortValue) }; } const countQuery = buildBaseQuery(); @@ -26,7 +26,7 @@ let VideoBlacklistModel = VideoBlacklistModel_1 = class VideoBlacklistModel exte { model: video_1.VideoModel, required: true, - where: utils_1.searchAttribute(search, 'name'), + where: (0, utils_1.searchAttribute)(search, 'name'), include: [ { model: video_channel_1.VideoChannelModel.scope({ method: [video_channel_1.ScopeNames.SUMMARY, { withAccount: true }] }), @@ -74,48 +74,48 @@ let VideoBlacklistModel = VideoBlacklistModel_1 = class VideoBlacklistModel exte }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('VideoBlacklistReason', value => utils_1.throwIfNotValid(value, video_blacklist_1.isVideoBlacklistReasonValid, 'reason', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('VideoBlacklistReason', value => (0, utils_1.throwIfNotValid)(value, video_blacklist_1.isVideoBlacklistReasonValid, 'reason', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoBlacklistModel.prototype, "reason", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoBlacklistModel.prototype, "unfederated", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoBlacklistType', value => utils_1.throwIfNotValid(value, video_blacklist_1.isVideoBlacklistTypeValid, 'type')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoBlacklistType', value => (0, utils_1.throwIfNotValid)(value, video_blacklist_1.isVideoBlacklistTypeValid, 'type')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoBlacklistModel.prototype, "type", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoBlacklistModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoBlacklistModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoBlacklistModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoBlacklistModel.prototype, "Video", void 0); -VideoBlacklistModel = VideoBlacklistModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoBlacklistModel = VideoBlacklistModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoBlacklist', indexes: [ { diff --git a/dist/server/models/video/video-caption.js b/dist/server/models/video/video-caption.js index 4f2324cb..679e7cc2 100644 --- a/dist/server/models/video/video-caption.js +++ b/dist/server/models/video/video-caption.js @@ -19,7 +19,7 @@ var ScopeNames; })(ScopeNames = exports.ScopeNames || (exports.ScopeNames = {})); let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends sequelize_typescript_1.Model { static removeFiles(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!instance.Video) { instance.Video = yield instance.$get('Video', { transaction: options.transaction }); } @@ -39,7 +39,7 @@ let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends se const videoInclude = { model: video_1.VideoModel.unscoped(), attributes: ['id', 'remote', 'uuid'], - where: utils_1.buildWhereIdOrUUID(videoId) + where: (0, utils_1.buildWhereIdOrUUID)(videoId) }; const query = { where: { @@ -67,7 +67,7 @@ let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends se return VideoCaptionModel_1.findOne(query); } static insertOrReplaceLanguage(caption, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const existing = yield VideoCaptionModel_1.loadByVideoIdAndLanguage(caption.videoId, caption.language, transaction); if (existing) yield existing.destroy({ transaction }); @@ -97,7 +97,7 @@ let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends se return VideoCaptionModel_1.destroy(query); } static generateCaptionName(language) { - return `${uuid_1.buildUUID()}-${language}.vtt`; + return `${(0, uuid_1.buildUUID)()}-${language}.vtt`; } isOwned() { return this.Video.remote === false; @@ -112,10 +112,10 @@ let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends se }; } getCaptionStaticPath() { - return path_1.join(constants_1.LAZY_STATIC_PATHS.VIDEO_CAPTIONS, this.filename); + return (0, path_1.join)(constants_1.LAZY_STATIC_PATHS.VIDEO_CAPTIONS, this.filename); } removeCaptionFile() { - return fs_extra_1.remove(config_1.CONFIG.STORAGE.CAPTIONS_DIR + this.filename); + return (0, fs_extra_1.remove)(config_1.CONFIG.STORAGE.CAPTIONS_DIR + this.filename); } getFileUrl(video) { if (!this.Video) @@ -130,52 +130,52 @@ let VideoCaptionModel = VideoCaptionModel_1 = class VideoCaptionModel extends se return this.filename === other.filename; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCaptionModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCaptionModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoCaptionLanguage', value => utils_1.throwIfNotValid(value, video_captions_1.isVideoCaptionLanguageValid, 'language')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoCaptionLanguage', value => (0, utils_1.throwIfNotValid)(value, video_captions_1.isVideoCaptionLanguageValid, 'language')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoCaptionModel.prototype, "language", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoCaptionModel.prototype, "filename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.COMMONS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoCaptionModel.prototype, "fileUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCaptionModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoCaptionModel.prototype, "Video", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoCaptionModel, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoCaptionModel, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoCaptionModel, "removeFiles", null); -VideoCaptionModel = VideoCaptionModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoCaptionModel = VideoCaptionModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_VIDEO_UUID_AND_REMOTE]: { include: [ { @@ -186,7 +186,7 @@ VideoCaptionModel = VideoCaptionModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoCaption', indexes: [ { diff --git a/dist/server/models/video/video-change-ownership.js b/dist/server/models/video/video-change-ownership.js index 978cda9d..60e52f18 100644 --- a/dist/server/models/video/video-change-ownership.js +++ b/dist/server/models/video/video-change-ownership.js @@ -17,7 +17,7 @@ let VideoChangeOwnershipModel = VideoChangeOwnershipModel_1 = class VideoChangeO const query = { offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), where: { nextOwnerAccountId: nextOwnerId } @@ -42,65 +42,65 @@ let VideoChangeOwnershipModel = VideoChangeOwnershipModel_1 = class VideoChangeO }; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoChangeOwnershipModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoChangeOwnershipModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoChangeOwnershipModel.prototype, "status", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoChangeOwnershipModel.prototype, "initiatorAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'initiatorAccountId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], VideoChangeOwnershipModel.prototype, "Initiator", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoChangeOwnershipModel.prototype, "nextOwnerAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { name: 'nextOwnerAccountId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], VideoChangeOwnershipModel.prototype, "NextOwner", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoChangeOwnershipModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoChangeOwnershipModel.prototype, "Video", void 0); -VideoChangeOwnershipModel = VideoChangeOwnershipModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoChangeOwnershipModel = VideoChangeOwnershipModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoChangeOwnership', indexes: [ { @@ -114,7 +114,7 @@ VideoChangeOwnershipModel = VideoChangeOwnershipModel_1 = tslib_1.__decorate([ } ] }), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_ACCOUNTS]: { include: [ { diff --git a/dist/server/models/video/video-channel.js b/dist/server/models/video/video-channel.js index 464a5ed6..453af2ea 100644 --- a/dist/server/models/video/video-channel.js +++ b/dist/server/models/video/video-channel.js @@ -30,13 +30,13 @@ var ScopeNames; })(ScopeNames = exports.ScopeNames || (exports.ScopeNames = {})); let VideoChannelModel = VideoChannelModel_1 = class VideoChannelModel extends sequelize_typescript_1.Model { static sendDeleteIfOwned(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!instance.Actor) { instance.Actor = yield instance.$get('Actor', { transaction: options.transaction }); } yield actor_follow_1.ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction); if (instance.Actor.isOwned()) { - return send_1.sendDeleteActor(instance.Actor, options.transaction); + return (0, send_1.sendDeleteActor)(instance.Actor, options.transaction); } return undefined; }); @@ -50,7 +50,7 @@ let VideoChannelModel = VideoChannelModel_1 = class VideoChannelModel extends se return VideoChannelModel_1.count(query); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function getActiveVideoChannels(days) { const options = { type: sequelize_1.QueryTypes.SELECT, @@ -90,7 +90,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; const query = { attributes: [], offset: 0, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), include: [ { attributes: ['preferredUsername', 'serverId'], @@ -110,7 +110,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; const query = { offset: parameters.start, limit: parameters.count, - order: utils_1.getSort(parameters.sort) + order: (0, utils_1.getSort)(parameters.sort) }; return VideoChannelModel_1 .scope({ @@ -122,12 +122,12 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; }); } static searchForApi(options) { - let attributesInclude = [sequelize_1.literal('0 as similarity')]; + let attributesInclude = [(0, sequelize_1.literal)('0 as similarity')]; let where; if (options.search) { const escapedSearch = VideoChannelModel_1.sequelize.escape(options.search); const escapedLikeSearch = VideoChannelModel_1.sequelize.escape('%' + options.search + '%'); - attributesInclude = [utils_1.createSimilarityAttribute('VideoChannelModel.name', options.search)]; + attributesInclude = [(0, utils_1.createSimilarityAttribute)('VideoChannelModel.name', options.search)]; where = { [sequelize_1.Op.or]: [ sequelize_typescript_1.Sequelize.literal('lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'), @@ -141,12 +141,12 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; }, offset: options.start, limit: options.count, - order: utils_1.getSort(options.sort), + order: (0, utils_1.getSort)(options.sort), where }; return VideoChannelModel_1 .scope({ - method: [ScopeNames.FOR_API, core_utils_1.pick(options, ['actorId', 'host', 'handles'])] + method: [ScopeNames.FOR_API, (0, core_utils_1.pick)(options, ['actorId', 'host', 'handles'])] }) .findAndCountAll(query) .then(({ rows, count }) => { @@ -167,7 +167,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; const query = { offset: options.start, limit: options.count, - order: utils_1.getSort(options.sort), + order: (0, utils_1.getSort)(options.sort), include: [ { model: account_1.AccountModel, @@ -342,66 +342,66 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`; return this.Actor.isOutdated(); } setAsUpdated(transaction) { - return shared_1.setAsUpdated('videoChannel', this.id, transaction); + return (0, shared_1.setAsUpdated)('videoChannel', this.id, transaction); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoChannelName', value => utils_1.throwIfNotValid(value, video_channels_1.isVideoChannelDisplayNameValid, 'name')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoChannelName', value => (0, utils_1.throwIfNotValid)(value, video_channels_1.isVideoChannelDisplayNameValid, 'name')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoChannelModel.prototype, "name", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoChannelDescription', value => utils_1.throwIfNotValid(value, video_channels_1.isVideoChannelDescriptionValid, 'description', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoChannelDescription', value => (0, utils_1.throwIfNotValid)(value, video_channels_1.isVideoChannelDescriptionValid, 'description', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoChannelModel.prototype, "description", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoChannelSupport', value => utils_1.throwIfNotValid(value, video_channels_1.isVideoChannelSupportValid, 'support', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoChannelSupport', value => (0, utils_1.throwIfNotValid)(value, video_channels_1.isVideoChannelSupportValid, 'support', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoChannelModel.prototype, "support", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoChannelModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoChannelModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoChannelModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], VideoChannelModel.prototype, "Actor", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoChannelModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { allowNull: false } }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], VideoChannelModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_1.VideoModel, { foreignKey: { name: 'channelId', allowNull: false @@ -409,26 +409,26 @@ tslib_1.__decorate([ onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoChannelModel.prototype, "Videos", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_playlist_1.VideoPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_playlist_1.VideoPlaylistModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoChannelModel.prototype, "VideoPlaylists", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoChannelModel, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoChannelModel, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoChannelModel, "sendDeleteIfOwned", null); -VideoChannelModel = VideoChannelModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +VideoChannelModel = VideoChannelModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: actor_1.ActorModel, @@ -436,9 +436,9 @@ VideoChannelModel = VideoChannelModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.FOR_API]: (options) => { - const inQueryInstanceFollow = utils_1.buildServerIdsFollowedBy(options.actorId); + const inQueryInstanceFollow = (0, utils_1.buildServerIdsFollowedBy)(options.actorId); const whereActorAnd = [ { [sequelize_1.Op.or]: [ @@ -604,11 +604,11 @@ VideoChannelModel = VideoChannelModel_1 = tslib_1.__decorate([ attributes: { include: [ [ - sequelize_1.literal('(SELECT COUNT(*) FROM "video" WHERE "channelId" = "VideoChannelModel"."id")'), + (0, sequelize_1.literal)('(SELECT COUNT(*) FROM "video" WHERE "channelId" = "VideoChannelModel"."id")'), 'videosCount' ], [ - sequelize_1.literal('(' + + (0, sequelize_1.literal)('(' + `SELECT string_agg(concat_ws('|', t.day, t.views), ',') ` + 'FROM ( ' + 'WITH ' + @@ -633,10 +633,10 @@ VideoChannelModel = VideoChannelModel_1 = tslib_1.__decorate([ }; } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoChannel', indexes: [ - utils_1.buildTrigramSearchIndex('video_channel_name_trigram', 'name'), + (0, utils_1.buildTrigramSearchIndex)('video_channel_name_trigram', 'name'), { fields: ['accountId'] }, diff --git a/dist/server/models/video/video-comment.js b/dist/server/models/video/video-comment.js index f440c792..120a9ae5 100644 --- a/dist/server/models/video/video-comment.js +++ b/dist/server/models/video/video-comment.js @@ -97,28 +97,28 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se if (search) { Object.assign(where, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(search, 'text'), - utils_1.searchAttribute(search, '$Account.Actor.preferredUsername$'), - utils_1.searchAttribute(search, '$Account.name$'), - utils_1.searchAttribute(search, '$Video.name$') + (0, utils_1.searchAttribute)(search, 'text'), + (0, utils_1.searchAttribute)(search, '$Account.Actor.preferredUsername$'), + (0, utils_1.searchAttribute)(search, '$Account.name$'), + (0, utils_1.searchAttribute)(search, '$Video.name$') ] }); } if (searchAccount) { Object.assign(whereActor, { [sequelize_1.Op.or]: [ - utils_1.searchAttribute(searchAccount, '$Account.Actor.preferredUsername$'), - utils_1.searchAttribute(searchAccount, '$Account.name$') + (0, utils_1.searchAttribute)(searchAccount, '$Account.Actor.preferredUsername$'), + (0, utils_1.searchAttribute)(searchAccount, '$Account.name$') ] }); } if (searchVideo) { - Object.assign(whereVideo, utils_1.searchAttribute(searchVideo, 'name')); + Object.assign(whereVideo, (0, utils_1.searchAttribute)(searchVideo, 'name')); } const query = { offset: start, limit: count, - order: utils_1.getCommentSort(sort), + order: (0, utils_1.getCommentSort)(sort), where, include: [ { @@ -150,18 +150,18 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }); } static listThreadsForApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, isVideoOwned, start, count, sort, user } = parameters; const blockerAccountIds = yield VideoCommentModel_1.buildBlockerAccountIds({ videoId, user, isVideoOwned }); const accountBlockedWhere = { accountId: { - [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + utils_1.buildBlockedAccountSQL(blockerAccountIds) + ')') + [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + (0, utils_1.buildBlockedAccountSQL)(blockerAccountIds) + ')') } }; const queryList = { offset: start, limit: count, - order: utils_1.getCommentSort(sort), + order: (0, utils_1.getCommentSort)(sort), where: { [sequelize_1.Op.and]: [ { @@ -199,7 +199,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }); } static listThreadCommentsForApi(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, threadId, user, isVideoOwned } = parameters; const blockerAccountIds = yield VideoCommentModel_1.buildBlockerAccountIds({ videoId, user, isVideoOwned }); const query = { @@ -217,7 +217,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se [sequelize_1.Op.or]: [ { accountId: { - [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + utils_1.buildBlockedAccountSQL(blockerAccountIds) + ')') + [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + (0, utils_1.buildBlockedAccountSQL)(blockerAccountIds) + ')') } }, { @@ -265,7 +265,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se .findAll(query); } static listAndCountByVideoForAP(video, start, count, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const blockerAccountIds = yield VideoCommentModel_1.buildBlockerAccountIds({ videoId: video.id, isVideoOwned: video.isOwned() @@ -277,7 +277,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se where: { videoId: video.id, accountId: { - [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + utils_1.buildBlockedAccountSQL(blockerAccountIds) + ')') + [sequelize_1.Op.notIn]: sequelize_1.Sequelize.literal('(' + (0, utils_1.buildBlockedAccountSQL)(blockerAccountIds) + ')') } }, transaction: t @@ -286,10 +286,10 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }); } static listForFeed(parameters) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const { start, count, videoId, accountId, videoChannelId } = parameters; - const whereAnd = utils_1.buildBlockedAccountSQLOptimized('"VideoCommentModel"."accountId"', [serverActor.Account.id, '"Video->VideoChannel"."accountId"']); + const whereAnd = (0, utils_1.buildBlockedAccountSQLOptimized)('"VideoCommentModel"."accountId"', [serverActor.Account.id, '"Video->VideoChannel"."accountId"']); if (accountId) { whereAnd.push({ accountId @@ -368,7 +368,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se .findAll(query); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalLocalVideoComments = yield VideoCommentModel_1.count({ include: [ { @@ -411,7 +411,7 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }, videoId, accountId: { - [sequelize_1.Op.notIn]: utils_1.buildLocalAccountIdsIn() + [sequelize_1.Op.notIn]: (0, utils_1.buildLocalAccountIdsIn)() }, deletedAt: null } @@ -448,16 +448,16 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se const firstMentionRegex = new RegExp(`^${mentionRegex} `, 'g'); const endMentionRegex = new RegExp(` ${mentionRegex}$`, 'g'); const remoteMentionsRegex = new RegExp(' ' + remoteMention + ' ', 'g'); - result = result.concat(regexp_1.regexpCapture(this.text, firstMentionRegex) - .map(([, username1, username2]) => username1 || username2), regexp_1.regexpCapture(this.text, endMentionRegex) - .map(([, username1, username2]) => username1 || username2), regexp_1.regexpCapture(this.text, remoteMentionsRegex) + result = result.concat((0, regexp_1.regexpCapture)(this.text, firstMentionRegex) + .map(([, username1, username2]) => username1 || username2), (0, regexp_1.regexpCapture)(this.text, endMentionRegex) + .map(([, username1, username2]) => username1 || username2), (0, regexp_1.regexpCapture)(this.text, remoteMentionsRegex) .map(([, username]) => username)); if (this.isOwned()) { const localMentionsRegex = new RegExp(' ' + localMention + ' ', 'g'); - result = result.concat(regexp_1.regexpCapture(this.text, localMentionsRegex) + result = result.concat((0, regexp_1.regexpCapture)(this.text, localMentionsRegex) .map(([, username]) => username)); } - return lodash_1.uniq(result); + return (0, lodash_1.uniq)(result); } toFormattedJSON() { return { @@ -541,9 +541,9 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }; } static buildBlockerAccountIds(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, user, isVideoOwned } = options; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const blockerAccountIds = [serverActor.Account.id]; if (user) blockerAccountIds.push(user.Account.id); @@ -555,37 +555,37 @@ let VideoCommentModel = VideoCommentModel_1 = class VideoCommentModel extends se }); } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCommentModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoCommentModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.DATE), - tslib_1.__metadata("design:type", Date) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE), + (0, tslib_1.__metadata)("design:type", Date) ], VideoCommentModel.prototype, "deletedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoCommentUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoCommentUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoCommentModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.TEXT), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT), + (0, tslib_1.__metadata)("design:type", String) ], VideoCommentModel.prototype, "text", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => VideoCommentModel_1), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => VideoCommentModel_1), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentModel.prototype, "originCommentId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => VideoCommentModel_1, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => VideoCommentModel_1, { foreignKey: { name: 'originCommentId', allowNull: true @@ -593,15 +593,15 @@ tslib_1.__decorate([ as: 'OriginVideoComment', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", VideoCommentModel) + (0, tslib_1.__metadata)("design:type", VideoCommentModel) ], VideoCommentModel.prototype, "OriginVideoComment", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => VideoCommentModel_1), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => VideoCommentModel_1), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentModel.prototype, "inReplyToCommentId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => VideoCommentModel_1, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => VideoCommentModel_1, { foreignKey: { name: 'inReplyToCommentId', allowNull: true @@ -609,55 +609,55 @@ tslib_1.__decorate([ as: 'InReplyToVideoComment', onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", VideoCommentModel) + (0, tslib_1.__metadata)("design:type", VideoCommentModel) ], VideoCommentModel.prototype, "InReplyToVideoComment", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoCommentModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoCommentModel.prototype, "accountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], VideoCommentModel.prototype, "Account", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_comment_abuse_1.VideoCommentAbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_comment_abuse_1.VideoCommentAbuseModel, { foreignKey: { name: 'videoCommentId', allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoCommentModel.prototype, "CommentAbuses", void 0); -VideoCommentModel = VideoCommentModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoCommentModel = VideoCommentModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.ATTRIBUTES_FOR_API]: (blockerAccountIds) => { return { attributes: { include: [ [ sequelize_1.Sequelize.literal('(' + - 'WITH "blocklist" AS (' + utils_1.buildBlockedAccountSQL(blockerAccountIds) + ')' + + 'WITH "blocklist" AS (' + (0, utils_1.buildBlockedAccountSQL)(blockerAccountIds) + ')' + 'SELECT COUNT("replies"."id") ' + 'FROM "videoComment" AS "replies" ' + 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' + @@ -733,7 +733,7 @@ VideoCommentModel = VideoCommentModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoComment', indexes: [ { diff --git a/dist/server/models/video/video-file.js b/dist/server/models/video/video-file.js index 99604b4c..4d8a2b88 100644 --- a/dist/server/models/video/video-file.js +++ b/dist/server/models/video/video-file.js @@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.VideoFileModel = exports.ScopeNames = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); -const memoizee_1 = tslib_1.__importDefault(require("memoizee")); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); const path_1 = require("path"); const sequelize_1 = require("sequelize"); const sequelize_typescript_1 = require("sequelize-typescript"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const activitypub_1 = require("@server/helpers/activitypub"); const logger_1 = require("@server/helpers/logger"); const video_1 = require("@server/helpers/video"); @@ -30,29 +30,29 @@ var ScopeNames; let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_typescript_1.Model { static doesInfohashExist(infoHash) { const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'; - return shared_1.doesExist(query, { infoHash }); + return (0, shared_1.doesExist)(query, { infoHash }); } static doesVideoExistForVideoFile(id, videoIdOrUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoFile = yield VideoFileModel_1.loadWithVideoOrPlaylist(id, videoIdOrUUID); return !!videoFile; }); } static doesOwnedTorrentFileExist(filename) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = 'SELECT 1 FROM "videoFile" ' + 'LEFT JOIN "video" "webtorrent" ON "webtorrent"."id" = "videoFile"."videoId" AND "webtorrent"."remote" IS FALSE ' + 'LEFT JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' + 'LEFT JOIN "video" "hlsVideo" ON "hlsVideo"."id" = "videoStreamingPlaylist"."videoId" AND "hlsVideo"."remote" IS FALSE ' + 'WHERE "torrentFilename" = $filename AND ("hlsVideo"."id" IS NOT NULL OR "webtorrent"."id" IS NOT NULL) LIMIT 1'; - return shared_1.doesExist(query, { filename }); + return (0, shared_1.doesExist)(query, { filename }); }); } static doesOwnedWebTorrentVideoFileExist(filename) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = 'SELECT 1 FROM "videoFile" INNER JOIN "video" ON "video"."id" = "videoFile"."videoId" AND "video"."remote" IS FALSE ' + `WHERE "filename" = $filename AND "storage" = ${0} LIMIT 1`; - return shared_1.doesExist(query, { filename }); + return (0, shared_1.doesExist)(query, { filename }); }); } static loadByFilename(filename) { @@ -151,11 +151,11 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t VideoFileModel_1.aggregate('size', 'SUM', webtorrentFilesQuery), VideoFileModel_1.aggregate('size', 'SUM', hlsFilesQuery) ]).then(([webtorrentResult, hlsResult]) => ({ - totalLocalVideoFilesSize: utils_1.parseAggregateResult(webtorrentResult) + utils_1.parseAggregateResult(hlsResult) + totalLocalVideoFilesSize: (0, utils_1.parseAggregateResult)(webtorrentResult) + (0, utils_1.parseAggregateResult)(hlsResult) })); } static customUpsert(videoFile, mode, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const baseWhere = { fps: videoFile.fps, resolution: videoFile.resolution @@ -188,7 +188,7 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t return this.VideoStreamingPlaylist; } getVideo() { - return video_1.extractVideo(this.getVideoOrStreamingPlaylist()); + return (0, video_1.extractVideo)(this.getVideoOrStreamingPlaylist()); } isAudio() { return !!constants_1.MIMETYPES.AUDIO.EXT_MIMETYPE[this.extname]; @@ -201,9 +201,9 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t } getObjectStorageUrl() { if (this.isHLS()) { - return object_storage_1.getHLSPublicFileUrl(this.fileUrl); + return (0, object_storage_1.getHLSPublicFileUrl)(this.fileUrl); } - return object_storage_1.getWebTorrentPublicFileUrl(this.fileUrl); + return (0, object_storage_1.getWebTorrentPublicFileUrl)(this.fileUrl); } getFileUrl(video) { if (this.storage === 1) { @@ -217,16 +217,16 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t } getFileStaticPath(video) { if (this.isHLS()) - return path_1.join(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, video.uuid, this.filename); - return path_1.join(constants_1.STATIC_PATHS.WEBSEED, this.filename); + return (0, path_1.join)(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, video.uuid, this.filename); + return (0, path_1.join)(constants_1.STATIC_PATHS.WEBSEED, this.filename); } getFileDownloadUrl(video) { const path = this.isHLS() - ? path_1.join(constants_1.STATIC_DOWNLOAD_PATHS.HLS_VIDEOS, `${video.uuid}-${this.resolution}-fragmented${this.extname}`) - : path_1.join(constants_1.STATIC_DOWNLOAD_PATHS.VIDEOS, `${video.uuid}-${this.resolution}${this.extname}`); + ? (0, path_1.join)(constants_1.STATIC_DOWNLOAD_PATHS.HLS_VIDEOS, `${video.uuid}-${this.resolution}-fragmented${this.extname}`) + : (0, path_1.join)(constants_1.STATIC_DOWNLOAD_PATHS.VIDEOS, `${video.uuid}-${this.resolution}${this.extname}`); if (video.isOwned()) return constants_1.WEBSERVER.URL + path; - return activitypub_1.buildRemoteVideoBaseUrl(video, path); + return (0, activitypub_1.buildRemoteVideoBaseUrl)(video, path); } getRemoteTorrentUrl(video) { if (video.isOwned()) @@ -241,18 +241,18 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t getTorrentStaticPath() { if (!this.torrentFilename) return null; - return path_1.join(constants_1.LAZY_STATIC_PATHS.TORRENTS, this.torrentFilename); + return (0, path_1.join)(constants_1.LAZY_STATIC_PATHS.TORRENTS, this.torrentFilename); } getTorrentDownloadUrl() { if (!this.torrentFilename) return null; - return constants_1.WEBSERVER.URL + path_1.join(constants_1.STATIC_DOWNLOAD_PATHS.TORRENTS, this.torrentFilename); + return constants_1.WEBSERVER.URL + (0, path_1.join)(constants_1.STATIC_DOWNLOAD_PATHS.TORRENTS, this.torrentFilename); } removeTorrent() { if (!this.torrentFilename) return null; - const torrentPath = paths_1.getFSTorrentFilePath(this); - return fs_extra_1.remove(torrentPath) + const torrentPath = (0, paths_1.getFSTorrentFilePath)(this); + return (0, fs_extra_1.remove)(torrentPath) .catch(err => logger_1.logger.warn('Cannot delete torrent %s.', torrentPath, { err })); } hasSameUniqueKeysThan(other) { @@ -271,131 +271,131 @@ let VideoFileModel = VideoFileModel_1 = class VideoFileModel extends sequelize_t return VideoFileModel_1.findOne(query); } }; -VideoFileModel.doesInfohashExistCached = memoizee_1.default(VideoFileModel_1.doesInfohashExist, { +VideoFileModel.doesInfohashExistCached = (0, memoizee_1.default)(VideoFileModel_1.doesInfohashExist, { promise: true, max: constants_1.MEMOIZE_LENGTH.INFO_HASH_EXISTS, maxAge: constants_1.MEMOIZE_TTL.INFO_HASH_EXISTS }); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoFileModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoFileModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoFileResolution', value => utils_1.throwIfNotValid(value, videos_1.isVideoFileResolutionValid, 'resolution')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoFileResolution', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoFileResolutionValid, 'resolution')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "resolution", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoFileSize', value => utils_1.throwIfNotValid(value, videos_1.isVideoFileSizeValid, 'size')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.BIGINT), - tslib_1.__metadata("design:type", Number) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoFileSize', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoFileSizeValid, 'size')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.BIGINT), + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "size", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoFileExtname', value => utils_1.throwIfNotValid(value, videos_1.isVideoFileExtnameValid, 'extname')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoFileExtname', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoFileExtnameValid, 'extname')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "extname", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('VideoFileInfohash', value => utils_1.throwIfNotValid(value, videos_1.isVideoFileInfoHashValid, 'info hash', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('VideoFileInfohash', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoFileInfoHashValid, 'info hash', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "infoHash", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(-1), - sequelize_typescript_1.Is('VideoFileFPS', value => utils_1.throwIfNotValid(value, videos_1.isVideoFPSResolutionValid, 'fps')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(-1), + (0, sequelize_typescript_1.Is)('VideoFileFPS', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoFPSResolutionValid, 'fps')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "fps", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.JSONB), - tslib_1.__metadata("design:type", Object) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSONB), + (0, tslib_1.__metadata)("design:type", Object) ], VideoFileModel.prototype, "metadata", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "metadataUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "fileUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "filename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "torrentUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoFileModel.prototype, "torrentFilename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_2.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_2.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "storage", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_2.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_2.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_2.VideoModel) + (0, tslib_1.__metadata)("design:type", video_2.VideoModel) ], VideoFileModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_streaming_playlist_1.VideoStreamingPlaylistModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_streaming_playlist_1.VideoStreamingPlaylistModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoFileModel.prototype, "videoStreamingPlaylistId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_streaming_playlist_1.VideoStreamingPlaylistModel) + (0, tslib_1.__metadata)("design:type", video_streaming_playlist_1.VideoStreamingPlaylistModel) ], VideoFileModel.prototype, "VideoStreamingPlaylist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_redundancy_1.VideoRedundancyModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_redundancy_1.VideoRedundancyModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoFileModel.prototype, "RedundancyVideos", void 0); -VideoFileModel = VideoFileModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +VideoFileModel = VideoFileModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ attributes: { exclude: ['metadata'] } })), - sequelize_typescript_1.Scopes(() => ({ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_VIDEO]: { include: [ { @@ -432,7 +432,7 @@ VideoFileModel = VideoFileModel_1 = tslib_1.__decorate([ } } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoFile', indexes: [ { diff --git a/dist/server/models/video/video-import.js b/dist/server/models/video/video-import.js index 3a0c747a..b3fdc1d1 100644 --- a/dist/server/models/video/video-import.js +++ b/dist/server/models/video/video-import.js @@ -14,7 +14,7 @@ const video_1 = require("./video"); let VideoImportModel = VideoImportModel_1 = class VideoImportModel extends sequelize_typescript_1.Model { static deleteVideoIfFailed(instance, options) { if (instance.state === 3) { - return database_utils_1.afterCommitIfTransaction(options.transaction, () => instance.Video.destroy()); + return (0, database_utils_1.afterCommitIfTransaction)(options.transaction, () => instance.Video.destroy()); } return undefined; } @@ -33,7 +33,7 @@ let VideoImportModel = VideoImportModel_1 = class VideoImportModel extends seque ], offset: start, limit: count, - order: utils_1.getSort(sort), + order: (0, utils_1.getSort)(sort), where: { userId } @@ -76,83 +76,83 @@ let VideoImportModel = VideoImportModel_1 = class VideoImportModel extends seque return constants_1.VIDEO_IMPORT_STATES[id] || 'Unknown'; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoImportModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoImportModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoImportTargetUrl', value => utils_1.throwIfNotValid(value, video_imports_1.isVideoImportTargetUrlValid, 'targetUrl', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoImportTargetUrl', value => (0, utils_1.throwIfNotValid)(value, video_imports_1.isVideoImportTargetUrlValid, 'targetUrl', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoImportModel.prototype, "targetUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoImportMagnetUri', value => utils_1.throwIfNotValid(value, videos_1.isVideoMagnetUriValid, 'magnetUri', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoImportMagnetUri', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoMagnetUriValid, 'magnetUri', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoImportModel.prototype, "magnetUri", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_NAME.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_NAME.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoImportModel.prototype, "torrentName", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoImportState', value => utils_1.throwIfNotValid(value, video_imports_1.isVideoImportStateValid, 'state')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoImportState', value => (0, utils_1.throwIfNotValid)(value, video_imports_1.isVideoImportStateValid, 'state')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoImportModel.prototype, "state", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.TEXT), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT), + (0, tslib_1.__metadata)("design:type", String) ], VideoImportModel.prototype, "error", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => user_1.UserModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => user_1.UserModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoImportModel.prototype, "userId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => user_1.UserModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => user_1.UserModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", user_1.UserModel) + (0, tslib_1.__metadata)("design:type", user_1.UserModel) ], VideoImportModel.prototype, "User", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoImportModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoImportModel.prototype, "Video", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.AfterUpdate, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoImportModel, Object]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoImportModel, Object]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], VideoImportModel, "deleteVideoIfFailed", null); -VideoImportModel = VideoImportModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +VideoImportModel = VideoImportModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: user_1.UserModel.unscoped(), @@ -168,7 +168,7 @@ VideoImportModel = VideoImportModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoImport', indexes: [ { diff --git a/dist/server/models/video/video-job-info.js b/dist/server/models/video/video-job-info.js index cd130897..7799b1d8 100644 --- a/dist/server/models/video/video-job-info.js +++ b/dist/server/models/video/video-job-info.js @@ -14,7 +14,7 @@ let VideoJobInfoModel = VideoJobInfoModel_1 = class VideoJobInfoModel extends se return VideoJobInfoModel_1.findOne({ where, transaction }); } static increaseOrCreate(videoUUID, column) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { type: sequelize_1.QueryTypes.SELECT, bind: { videoUUID } }; const [{ pendingMove }] = yield VideoJobInfoModel_1.sequelize.query(` INSERT INTO "videoJobInfo" ("videoId", "${column}", "createdAt", "updatedAt") @@ -35,7 +35,7 @@ let VideoJobInfoModel = VideoJobInfoModel_1 = class VideoJobInfoModel extends se }); } static decrease(videoUUID, column) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { type: sequelize_1.QueryTypes.SELECT, bind: { videoUUID } }; const [{ pendingMove }] = yield VideoJobInfoModel_1.sequelize.query(` UPDATE @@ -53,45 +53,45 @@ let VideoJobInfoModel = VideoJobInfoModel_1 = class VideoJobInfoModel extends se }); } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoJobInfoModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoJobInfoModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoJobInfoModel.prototype, "pendingMove", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoJobInfoModel.prototype, "pendingTranscode", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Unique, sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoJobInfoModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoJobInfoModel.prototype, "Video", void 0); -VideoJobInfoModel = VideoJobInfoModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoJobInfoModel = VideoJobInfoModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoJobInfo', indexes: [ { diff --git a/dist/server/models/video/video-live.js b/dist/server/models/video/video-live.js index 480becd6..49defb1f 100644 --- a/dist/server/models/video/video-live.js +++ b/dist/server/models/video/video-live.js @@ -73,45 +73,45 @@ let VideoLiveModel = VideoLiveModel_1 = class VideoLiveModel extends sequelize_t }; } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING), + (0, tslib_1.__metadata)("design:type", String) ], VideoLiveModel.prototype, "streamKey", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoLiveModel.prototype, "saveReplay", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoLiveModel.prototype, "permanentLive", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoLiveModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoLiveModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoLiveModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoLiveModel.prototype, "Video", void 0); -VideoLiveModel = VideoLiveModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.DefaultScope(() => ({ +VideoLiveModel = VideoLiveModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.DefaultScope)(() => ({ include: [ { model: video_1.VideoModel, @@ -125,7 +125,7 @@ VideoLiveModel = VideoLiveModel_1 = tslib_1.__decorate([ } ] })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoLive', indexes: [ { diff --git a/dist/server/models/video/video-playlist-element.js b/dist/server/models/video/video-playlist-element.js index c1ad7e4f..959f7cdc 100644 --- a/dist/server/models/video/video-playlist-element.js +++ b/dist/server/models/video/video-playlist-element.js @@ -5,7 +5,7 @@ exports.VideoPlaylistElementModel = void 0; const tslib_1 = require("tslib"); const sequelize_1 = require("sequelize"); const sequelize_typescript_1 = require("sequelize-typescript"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const misc_1 = require("../../helpers/custom-validators/activitypub/misc"); const constants_1 = require("../../initializers/constants"); const utils_1 = require("../utils"); @@ -39,7 +39,7 @@ let VideoPlaylistElementModel = VideoPlaylistElementModel_1 = class VideoPlaylis const findQuery = { offset: options.start, limit: options.count, - order: utils_1.getSort('position'), + order: (0, utils_1.getSort)('position'), where: { videoPlaylistId: options.videoPlaylistId }, @@ -97,7 +97,7 @@ let VideoPlaylistElementModel = VideoPlaylistElementModel_1 = class VideoPlaylis attributes: ['url'], offset: start, limit: count, - order: utils_1.getSort('position'), + order: (0, utils_1.getSort)('position'), where: { videoPlaylistId }, @@ -111,7 +111,7 @@ let VideoPlaylistElementModel = VideoPlaylistElementModel_1 = class VideoPlaylis } static loadFirstElementWithVideoThumbnail(videoPlaylistId) { const query = { - order: utils_1.getSort('position'), + order: (0, utils_1.getSort)('position'), where: { videoPlaylistId }, @@ -209,72 +209,72 @@ let VideoPlaylistElementModel = VideoPlaylistElementModel_1 = class VideoPlaylis return base; } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoPlaylistElementModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoPlaylistElementModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('VideoPlaylistUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('VideoPlaylistUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoPlaylistElementModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(1), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(1), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(1), + (0, sequelize_typescript_1.Min)(1), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistElementModel.prototype, "position", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(0), + (0, sequelize_typescript_1.Min)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistElementModel.prototype, "startTimestamp", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(0), + (0, sequelize_typescript_1.Min)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistElementModel.prototype, "stopTimestamp", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_playlist_1.VideoPlaylistModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_playlist_1.VideoPlaylistModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistElementModel.prototype, "videoPlaylistId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_playlist_1.VideoPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_playlist_1.VideoPlaylistModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_playlist_1.VideoPlaylistModel) + (0, tslib_1.__metadata)("design:type", video_playlist_1.VideoPlaylistModel) ], VideoPlaylistElementModel.prototype, "VideoPlaylist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistElementModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoPlaylistElementModel.prototype, "Video", void 0); -VideoPlaylistElementModel = VideoPlaylistElementModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoPlaylistElementModel = VideoPlaylistElementModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoPlaylistElement', indexes: [ { diff --git a/dist/server/models/video/video-playlist.js b/dist/server/models/video/video-playlist.js index 07f7aca6..415e71a5 100644 --- a/dist/server/models/video/video-playlist.js +++ b/dist/server/models/video/video-playlist.js @@ -36,13 +36,13 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends const query = { offset: options.start, limit: options.count, - order: utils_1.getPlaylistSort(options.sort) + order: (0, utils_1.getPlaylistSort)(options.sort) }; const scopes = [ { method: [ ScopeNames.AVAILABLE_FOR_LIST, - Object.assign(Object.assign({}, core_utils_1.pick(options, ['type', 'followerActorId', 'accountId', 'videoChannelId', 'listMyPlaylists', 'search', 'host', 'uuids'])), { withVideos: options.withVideos || false }) + Object.assign(Object.assign({}, (0, core_utils_1.pick)(options, ['type', 'followerActorId', 'accountId', 'videoChannelId', 'listMyPlaylists', 'search', 'host', 'uuids'])), { withVideos: options.withVideos || false }) ] }, ScopeNames.WITH_VIDEOS_LENGTH, @@ -112,7 +112,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends .then(e => !!e); } static loadWithAccountAndChannelSummary(id, transaction) { - const where = utils_1.buildWhereIdOrUUID(id); + const where = (0, utils_1.buildWhereIdOrUUID)(id); const query = { where, transaction @@ -122,7 +122,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends .findOne(query); } static loadWithAccountAndChannel(id, transaction) { - const where = utils_1.buildWhereIdOrUUID(id); + const where = (0, utils_1.buildWhereIdOrUUID)(id); const query = { where, transaction @@ -165,7 +165,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends return VideoPlaylistModel_1.update({ privacy: 3, videoChannelId: null }, query); } setAndSaveThumbnail(thumbnail, t) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { thumbnail.videoPlaylistId = this.id; this.Thumbnail = yield thumbnail.save({ transaction: t }); }); @@ -178,7 +178,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends } generateThumbnailName() { const extension = '.jpg'; - return 'playlist-' + uuid_1.buildUUID() + extension; + return 'playlist-' + (0, uuid_1.buildUUID)() + extension; } getThumbnailUrl() { if (!this.hasThumbnail()) @@ -188,16 +188,16 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends getThumbnailStaticPath() { if (!this.hasThumbnail()) return null; - return path_1.join(constants_1.STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename); + return (0, path_1.join)(constants_1.STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename); } getWatchStaticPath() { - return core_utils_1.buildPlaylistWatchPath({ shortUUID: uuid_1.uuidToShort(this.uuid) }); + return (0, core_utils_1.buildPlaylistWatchPath)({ shortUUID: (0, uuid_1.uuidToShort)(this.uuid) }); } getEmbedStaticPath() { - return core_utils_1.buildPlaylistEmbedPath(this); + return (0, core_utils_1.buildPlaylistEmbedPath)(this); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalLocalPlaylists = yield VideoPlaylistModel_1.count({ include: [ { @@ -224,7 +224,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends }); } setAsRefreshed() { - return shared_1.setAsUpdated('videoPlaylist', this.id); + return (0, shared_1.setAsUpdated)('videoPlaylist', this.id); } setVideosLength(videosLength) { this.set('videosLength', videosLength, { raw: true }); @@ -235,13 +235,13 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends isOutdated() { if (this.isOwned()) return false; - return utils_1.isOutdated(this, constants_1.ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL); + return (0, utils_1.isOutdated)(this, constants_1.ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL); } toFormattedJSON() { return { id: this.id, uuid: this.uuid, - shortUUID: uuid_1.uuidToShort(this.uuid), + shortUUID: (0, uuid_1.uuidToShort)(this.uuid), isLocal: this.isOwned(), url: this.url, displayName: this.name, @@ -279,7 +279,7 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends height: constants_1.THUMBNAILS_SIZE.height }; } - return activitypub_1.activityPubCollectionPagination(this.url, handler, page) + return (0, activitypub_1.activityPubCollectionPagination)(this.url, handler, page) .then(o => { return Object.assign(o, { type: 'Playlist', @@ -294,91 +294,91 @@ let VideoPlaylistModel = VideoPlaylistModel_1 = class VideoPlaylistModel extends }); } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoPlaylistModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoPlaylistModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoPlaylistName', value => utils_1.throwIfNotValid(value, video_playlists_1.isVideoPlaylistNameValid, 'name')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoPlaylistName', value => (0, utils_1.throwIfNotValid)(value, video_playlists_1.isVideoPlaylistNameValid, 'name')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoPlaylistModel.prototype, "name", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('VideoPlaylistDescription', value => utils_1.throwIfNotValid(value, video_playlists_1.isVideoPlaylistDescriptionValid, 'description', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.DESCRIPTION.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('VideoPlaylistDescription', value => (0, utils_1.throwIfNotValid)(value, video_playlists_1.isVideoPlaylistDescriptionValid, 'description', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.DESCRIPTION.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoPlaylistModel.prototype, "description", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoPlaylistPrivacy', value => utils_1.throwIfNotValid(value, video_playlists_1.isVideoPlaylistPrivacyValid, 'privacy')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoPlaylistPrivacy', value => (0, utils_1.throwIfNotValid)(value, video_playlists_1.isVideoPlaylistPrivacyValid, 'privacy')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistModel.prototype, "privacy", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoPlaylistUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoPlaylistUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoPlaylistModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(sequelize_typescript_1.DataType.UUIDV4), - sequelize_typescript_1.IsUUID(4), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.UUID), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4), + (0, sequelize_typescript_1.IsUUID)(4), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID), + (0, tslib_1.__metadata)("design:type", String) ], VideoPlaylistModel.prototype, "uuid", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(1), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(1), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => account_1.AccountModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => account_1.AccountModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistModel.prototype, "ownerAccountId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => account_1.AccountModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => account_1.AccountModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", account_1.AccountModel) + (0, tslib_1.__metadata)("design:type", account_1.AccountModel) ], VideoPlaylistModel.prototype, "OwnerAccount", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_channel_1.VideoChannelModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_channel_1.VideoChannelModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoPlaylistModel.prototype, "videoChannelId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_channel_1.VideoChannelModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_channel_1.VideoChannelModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_channel_1.VideoChannelModel) + (0, tslib_1.__metadata)("design:type", video_channel_1.VideoChannelModel) ], VideoPlaylistModel.prototype, "VideoChannel", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_playlist_element_1.VideoPlaylistElementModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_playlist_element_1.VideoPlaylistElementModel, { foreignKey: { name: 'videoPlaylistId', allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoPlaylistModel.prototype, "VideoPlaylistElements", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => thumbnail_1.ThumbnailModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => thumbnail_1.ThumbnailModel, { foreignKey: { name: 'videoPlaylistId', allowNull: true @@ -386,10 +386,10 @@ tslib_1.__decorate([ onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", thumbnail_1.ThumbnailModel) + (0, tslib_1.__metadata)("design:type", thumbnail_1.ThumbnailModel) ], VideoPlaylistModel.prototype, "Thumbnail", void 0); -VideoPlaylistModel = VideoPlaylistModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoPlaylistModel = VideoPlaylistModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_THUMBNAIL]: { include: [ { @@ -402,7 +402,7 @@ VideoPlaylistModel = VideoPlaylistModel_1 = tslib_1.__decorate([ attributes: { include: [ [ - sequelize_1.literal(`(${getVideoLengthSelect()})`), + (0, sequelize_1.literal)(`(${getVideoLengthSelect()})`), 'videosLength' ] ] @@ -461,10 +461,10 @@ VideoPlaylistModel = VideoPlaylistModel_1 = tslib_1.__decorate([ } ]; if (options.followerActorId) { - const inQueryInstanceFollow = utils_1.buildServerIdsFollowedBy(options.followerActorId); + const inQueryInstanceFollow = (0, utils_1.buildServerIdsFollowedBy)(options.followerActorId); whereActorOr.push({ serverId: { - [sequelize_1.Op.in]: sequelize_1.literal(inQueryInstanceFollow) + [sequelize_1.Op.in]: (0, sequelize_1.literal)(inQueryInstanceFollow) } }); } @@ -493,13 +493,13 @@ VideoPlaylistModel = VideoPlaylistModel_1 = tslib_1.__decorate([ }); } if (options.withVideos === true) { - whereAnd.push(sequelize_1.literal(`(${getVideoLengthSelect()}) != 0`)); + whereAnd.push((0, sequelize_1.literal)(`(${getVideoLengthSelect()}) != 0`)); } - let attributesInclude = [sequelize_1.literal('0 as similarity')]; + let attributesInclude = [(0, sequelize_1.literal)('0 as similarity')]; if (options.search) { const escapedSearch = VideoPlaylistModel_1.sequelize.escape(options.search); const escapedLikeSearch = VideoPlaylistModel_1.sequelize.escape('%' + options.search + '%'); - attributesInclude = [utils_1.createSimilarityAttribute('VideoPlaylistModel.name', options.search)]; + attributesInclude = [(0, utils_1.createSimilarityAttribute)('VideoPlaylistModel.name', options.search)]; whereAnd.push({ [sequelize_1.Op.or]: [ sequelize_1.Sequelize.literal('lower(immutable_unaccent("VideoPlaylistModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'), @@ -530,10 +530,10 @@ VideoPlaylistModel = VideoPlaylistModel_1 = tslib_1.__decorate([ }; } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoPlaylist', indexes: [ - utils_1.buildTrigramSearchIndex('video_playlist_name_trigram', 'name'), + (0, utils_1.buildTrigramSearchIndex)('video_playlist_name_trigram', 'name'), { fields: ['ownerAccountId'] }, diff --git a/dist/server/models/video/video-share.js b/dist/server/models/video/video-share.js index b3e22abb..34853f0e 100644 --- a/dist/server/models/video/video-share.js +++ b/dist/server/models/video/video-share.js @@ -54,7 +54,7 @@ let VideoShareModel = VideoShareModel_1 = class VideoShareModel extends sequeliz const query = { where: { [sequelize_1.Op.and]: [ - sequelize_1.literal(`EXISTS (` + + (0, sequelize_1.literal)(`EXISTS (` + ` SELECT 1 FROM "videoShare" ` + ` INNER JOIN "video" ON "videoShare"."videoId" = "video"."id" ` + ` INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ` + @@ -73,7 +73,7 @@ let VideoShareModel = VideoShareModel_1 = class VideoShareModel extends sequeliz const query = { where: { [sequelize_1.Op.and]: [ - sequelize_1.literal(`EXISTS (` + + (0, sequelize_1.literal)(`EXISTS (` + ` SELECT 1 FROM "videoShare" ` + ` INNER JOIN "video" ON "videoShare"."videoId" = "video"."id" ` + ` WHERE "videoShare"."actorId" = "ActorModel"."id" AND "video"."channelId" = ${safeChannelId} ` + @@ -113,57 +113,57 @@ let VideoShareModel = VideoShareModel_1 = class VideoShareModel extends sequeliz }, videoId, actorId: { - [sequelize_1.Op.notIn]: utils_1.buildLocalActorIdsIn() + [sequelize_1.Op.notIn]: (0, utils_1.buildLocalActorIdsIn)() } } }; return VideoShareModel_1.destroy(query); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoShareUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_SHARE.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoShareUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEO_SHARE.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoShareModel.prototype, "url", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoShareModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoShareModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => actor_1.ActorModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => actor_1.ActorModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoShareModel.prototype, "actorId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => actor_1.ActorModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => actor_1.ActorModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", actor_1.ActorModel) + (0, tslib_1.__metadata)("design:type", actor_1.ActorModel) ], VideoShareModel.prototype, "Actor", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoShareModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoShareModel.prototype, "Video", void 0); -VideoShareModel = VideoShareModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoShareModel = VideoShareModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.FULL]: { include: [ { @@ -185,7 +185,7 @@ VideoShareModel = VideoShareModel_1 = tslib_1.__decorate([ ] } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'videoShare', indexes: [ { diff --git a/dist/server/models/video/video-streaming-playlist.js b/dist/server/models/video/video-streaming-playlist.js index 4275c442..368fc59a 100644 --- a/dist/server/models/video/video-streaming-playlist.js +++ b/dist/server/models/video/video-streaming-playlist.js @@ -3,7 +3,7 @@ var VideoStreamingPlaylistModel_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.VideoStreamingPlaylistModel = void 0; const tslib_1 = require("tslib"); -const memoizee_1 = tslib_1.__importDefault(require("memoizee")); +const memoizee_1 = (0, tslib_1.__importDefault)(require("memoizee")); const path_1 = require("path"); const sequelize_1 = require("sequelize"); const sequelize_typescript_1 = require("sequelize-typescript"); @@ -21,12 +21,12 @@ const video_1 = require("./video"); let VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = class VideoStreamingPlaylistModel extends sequelize_typescript_1.Model { static doesInfohashExist(infoHash) { const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE $infoHash = ANY("p2pMediaLoaderInfohashes") LIMIT 1'; - return shared_1.doesExist(query, { infoHash }); + return (0, shared_1.doesExist)(query, { infoHash }); } static buildP2PMediaLoaderInfoHashes(playlistUrl, files) { const hashes = []; for (let i = 0; i < files.length; i++) { - hashes.push(core_utils_1.sha1(`${constants_1.P2P_MEDIA_LOADER_PEER_VERSION}${playlistUrl}+V${i}`)); + hashes.push((0, core_utils_1.sha1)(`${constants_1.P2P_MEDIA_LOADER_PEER_VERSION}${playlistUrl}+V${i}`)); } return hashes; } @@ -67,7 +67,7 @@ let VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = class VideoStr return VideoStreamingPlaylistModel_1.findOne(options); } static loadOrGenerate(video) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let playlist = yield VideoStreamingPlaylistModel_1.loadHLSPlaylistByVideo(video.id); if (!playlist) playlist = new VideoStreamingPlaylistModel_1(); @@ -80,7 +80,7 @@ let VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = class VideoStr } getMasterPlaylistUrl(video) { if (this.storage === 1) { - return object_storage_1.getHLSPublicFileUrl(this.playlistUrl); + return (0, object_storage_1.getHLSPublicFileUrl)(this.playlistUrl); } if (video.isOwned()) return constants_1.WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid); @@ -88,7 +88,7 @@ let VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = class VideoStr } getSha256SegmentsUrl(video) { if (this.storage === 1) { - return object_storage_1.getHLSPublicFileUrl(this.segmentsSha256Url); + return (0, object_storage_1.getHLSPublicFileUrl)(this.segmentsSha256Url); } if (video.isOwned()) return constants_1.WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid, video.isLive); @@ -107,106 +107,106 @@ let VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = class VideoStr this.videoId === other.videoId; } getMasterPlaylistStaticPath(videoUUID) { - return path_1.join(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename); + return (0, path_1.join)(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename); } getSha256SegmentsStaticPath(videoUUID, isLive) { if (isLive) - return path_1.join('/live', 'segments-sha256', videoUUID); - return path_1.join(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.segmentsSha256Filename); + return (0, path_1.join)('/live', 'segments-sha256', videoUUID); + return (0, path_1.join)(constants_1.STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.segmentsSha256Filename); } }; -VideoStreamingPlaylistModel.doesInfohashExistCached = memoizee_1.default(VideoStreamingPlaylistModel_1.doesInfohashExist, { +VideoStreamingPlaylistModel.doesInfohashExistCached = (0, memoizee_1.default)(VideoStreamingPlaylistModel_1.doesInfohashExist, { promise: true, max: constants_1.MEMOIZE_LENGTH.INFO_HASH_EXISTS, maxAge: constants_1.MEMOIZE_TTL.INFO_HASH_EXISTS }); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoStreamingPlaylistModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoStreamingPlaylistModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoStreamingPlaylistModel.prototype, "type", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoStreamingPlaylistModel.prototype, "playlistFilename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('PlaylistUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'playlist url', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('PlaylistUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'playlist url', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoStreamingPlaylistModel.prototype, "playlistUrl", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoStreamingPlaylistInfoHashes', value => utils_1.throwIfNotValid(value, v => misc_2.isArrayOf(v, videos_1.isVideoFileInfoHashValid), 'info hashes')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), - tslib_1.__metadata("design:type", Array) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoStreamingPlaylistInfoHashes', value => (0, utils_1.throwIfNotValid)(value, v => (0, misc_2.isArrayOf)(v, videos_1.isVideoFileInfoHashValid), 'info hashes')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.STRING)), + (0, tslib_1.__metadata)("design:type", Array) ], VideoStreamingPlaylistModel.prototype, "p2pMediaLoaderInfohashes", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoStreamingPlaylistModel.prototype, "p2pMediaLoaderPeerVersion", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoStreamingPlaylistModel.prototype, "segmentsSha256Filename", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Is('VideoStreamingSegmentsSha256Url', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'segments sha256 url', true)), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Is)('VideoStreamingSegmentsSha256Url', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'segments sha256 url', true)), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoStreamingPlaylistModel.prototype, "segmentsSha256Url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoStreamingPlaylistModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoStreamingPlaylistModel.prototype, "storage", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoStreamingPlaylistModel.prototype, "Video", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_file_1.VideoFileModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_file_1.VideoFileModel, { foreignKey: { allowNull: true }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoStreamingPlaylistModel.prototype, "VideoFiles", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_redundancy_1.VideoRedundancyModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_redundancy_1.VideoRedundancyModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoStreamingPlaylistModel.prototype, "RedundancyVideos", void 0); -VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoStreamingPlaylistModel = VideoStreamingPlaylistModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoStreamingPlaylist', indexes: [ { diff --git a/dist/server/models/video/video-tag.js b/dist/server/models/video/video-tag.js index edf1a7b5..71ebd3db 100644 --- a/dist/server/models/video/video-tag.js +++ b/dist/server/models/video/video-tag.js @@ -7,26 +7,26 @@ const tag_1 = require("./tag"); const video_1 = require("./video"); let VideoTagModel = class VideoTagModel extends sequelize_typescript_1.Model { }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoTagModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoTagModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoTagModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => tag_1.TagModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => tag_1.TagModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoTagModel.prototype, "tagId", void 0); -VideoTagModel = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoTagModel = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoTag', indexes: [ { diff --git a/dist/server/models/video/video-view.js b/dist/server/models/video/video-view.js index 05216409..8b46043b 100644 --- a/dist/server/models/video/video-view.js +++ b/dist/server/models/video/video-view.js @@ -14,48 +14,48 @@ let VideoViewModel = VideoViewModel_1 = class VideoViewModel extends sequelize_t [sequelize_1.Op.lt]: beforeDate }, videoId: { - [sequelize_1.Op.in]: sequelize_1.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)') + [sequelize_1.Op.in]: (0, sequelize_1.literal)('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)') } } }; return VideoViewModel_1.destroy(query); } }; -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoViewModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.DATE), - tslib_1.__metadata("design:type", Date) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE), + (0, tslib_1.__metadata)("design:type", Date) ], VideoViewModel.prototype, "startDate", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.DATE), - tslib_1.__metadata("design:type", Date) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE), + (0, tslib_1.__metadata)("design:type", Date) ], VideoViewModel.prototype, "endDate", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoViewModel.prototype, "views", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_1.VideoModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoViewModel.prototype, "videoId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_1.VideoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel, { foreignKey: { allowNull: false }, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", video_1.VideoModel) + (0, tslib_1.__metadata)("design:type", video_1.VideoModel) ], VideoViewModel.prototype, "Video", void 0); -VideoViewModel = VideoViewModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Table({ +VideoViewModel = VideoViewModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Table)({ tableName: 'videoView', updatedAt: false, indexes: [ diff --git a/dist/server/models/video/video.js b/dist/server/models/video/video.js index 56a98982..83936726 100644 --- a/dist/server/models/video/video.js +++ b/dist/server/models/video/video.js @@ -3,7 +3,7 @@ var VideoModel_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.VideoModel = exports.ScopeNames = void 0; const tslib_1 = require("tslib"); -const bluebird_1 = tslib_1.__importDefault(require("bluebird")); +const bluebird_1 = (0, tslib_1.__importDefault)(require("bluebird")); const fs_extra_1 = require("fs-extra"); const lodash_1 = require("lodash"); const path_1 = require("path"); @@ -76,7 +76,7 @@ var ScopeNames; })(ScopeNames = exports.ScopeNames || (exports.ScopeNames = {})); let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1.Model { static sendDelete(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!instance.isOwned()) return undefined; if (!instance.VideoChannel) { @@ -88,11 +88,11 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. transaction: options.transaction })); } - return send_1.sendDeleteVideo(instance, options.transaction); + return (0, send_1.sendDeleteVideo)(instance, options.transaction); }); } static removeFiles(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const tasks = []; logger_1.logger.info('Removing files of video %s.', instance.url); if (instance.isOwned()) { @@ -126,7 +126,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. model_cache_1.ModelCache.Instance.invalidateCache('video', instance.id); } static saveEssentialDataToAbuses(instance, options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const tasks = []; if (!Array.isArray(instance.VideoAbuses)) { instance.VideoAbuses = yield instance.$get('VideoAbuses', { transaction: options.transaction }); @@ -169,12 +169,12 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. distinct: true, offset: start, limit: count, - order: utils_1.getVideoSort('-createdAt', ['Tags', 'name', 'ASC']), + order: (0, utils_1.getVideoSort)('-createdAt', ['Tags', 'name', 'ASC']), where: { id: { [sequelize_1.Op.in]: sequelize_1.Sequelize.literal('(' + rawQuery + ')') }, - [sequelize_1.Op.or]: video_1.getPrivaciesForFederation() + [sequelize_1.Op.or]: (0, video_1.getPrivaciesForFederation)() }, include: [ { @@ -261,7 +261,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. }); } static listPublishedLiveUUIDs() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { attributes: ['uuid'], where: { @@ -275,7 +275,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. }); } static meVideoViews(username, startDate) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startDateWhere = startDate ? `AND "video"."createdAt" > '${startDate}'` : null; const videoViewsQuery = `SELECT SUM("video"."views") FROM "account" @@ -303,7 +303,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. offset: start, limit: count, where, - order: utils_1.getVideoSort(sort), + order: (0, utils_1.getVideoSort)(sort), include: [ { model: video_channel_1.VideoChannelModel, @@ -340,7 +340,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. }); } static listForApi(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if ((options.filter === 'all-local' || options.filter === 'all') && !options.user.hasRight(20)) { throw new Error('Try to filter all-local but no user has not the see all videos right'); } @@ -352,11 +352,11 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. trendingAlgorithm = 'hot'; if (options.sort.endsWith('best')) trendingAlgorithm = 'best'; - const serverActor = yield application_1.getServerActor(); + const serverActor = yield (0, application_1.getServerActor)(); const followerActorId = options.followerActorId !== undefined ? options.followerActorId : serverActor.id; - const queryOptions = Object.assign(Object.assign({}, core_utils_1.pick(options, [ + const queryOptions = Object.assign(Object.assign({}, (0, core_utils_1.pick)(options, [ 'start', 'count', 'sort', @@ -382,9 +382,9 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. }); } static searchAndPopulateAccountAndServer(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); - const queryOptions = Object.assign(Object.assign({}, core_utils_1.pick(options, [ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); + const queryOptions = Object.assign(Object.assign({}, (0, core_utils_1.pick)(options, [ 'includeLocalVideos', 'nsfw', 'isLive', @@ -486,7 +486,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. static loadImmutableAttributes(id, t) { const fun = () => { const query = { - where: utils_1.buildWhereIdOrUUID(id), + where: (0, utils_1.buildWhereIdOrUUID)(id), transaction: t }; return VideoModel_1.scope(ScopeNames.WITH_IMMUTABLE_ATTRIBUTES).findOne(query); @@ -541,7 +541,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. return queryBuilder.queryVideo({ id, transaction, type: 'api', userId }); } static getStats() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const totalLocalVideos = yield VideoModel_1.count({ where: { remote: false @@ -558,7 +558,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. start: 0, count: 0, sort: '-publishedAt', - nsfw: express_utils_1.buildNSFWFilter(), + nsfw: (0, express_utils_1.buildNSFWFilter)(), includeLocalVideos: true, withFiles: false }); @@ -625,8 +625,8 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. .then(videos => videos.map(v => v.id)); } static getRandomFieldSamples(field, threshold, count) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const serverActor = yield application_1.getServerActor(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const serverActor = yield (0, application_1.getServerActor)(); const followerActorId = serverActor.id; const queryOptions = { attributes: [`"${field}"`], @@ -658,7 +658,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. }; } static getAvailableForApi(options, countVideos = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function getCount() { if (countVideos !== true) return Promise.resolve(undefined); @@ -716,7 +716,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. return Array.isArray(this.VideoFiles) === true && this.VideoFiles.length !== 0; } addAndSaveThumbnail(thumbnail, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { thumbnail.videoId = this.id; const savedThumbnail = yield thumbnail.save({ transaction }); if (Array.isArray(this.Thumbnails) === false) @@ -743,55 +743,55 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. return this.remote === false; } getWatchStaticPath() { - return core_utils_1.buildVideoWatchPath({ shortUUID: uuid_1.uuidToShort(this.uuid) }); + return (0, core_utils_1.buildVideoWatchPath)({ shortUUID: (0, uuid_1.uuidToShort)(this.uuid) }); } getEmbedStaticPath() { - return core_utils_1.buildVideoEmbedPath(this); + return (0, core_utils_1.buildVideoEmbedPath)(this); } getMiniatureStaticPath() { const thumbnail = this.getMiniature(); if (!thumbnail) return null; - return path_1.join(constants_1.STATIC_PATHS.THUMBNAILS, thumbnail.filename); + return (0, path_1.join)(constants_1.STATIC_PATHS.THUMBNAILS, thumbnail.filename); } getPreviewStaticPath() { const preview = this.getPreview(); if (!preview) return null; - return path_1.join(constants_1.LAZY_STATIC_PATHS.PREVIEWS, preview.filename); + return (0, path_1.join)(constants_1.LAZY_STATIC_PATHS.PREVIEWS, preview.filename); } toFormattedJSON(options) { - return video_format_utils_1.videoModelToFormattedJSON(this, options); + return (0, video_format_utils_1.videoModelToFormattedJSON)(this, options); } toFormattedDetailsJSON() { - return video_format_utils_1.videoModelToFormattedDetailsJSON(this); + return (0, video_format_utils_1.videoModelToFormattedDetailsJSON)(this); } getFormattedVideoFilesJSON(includeMagnet = true) { let files = []; if (Array.isArray(this.VideoFiles)) { - const result = video_format_utils_1.videoFilesModelToFormattedJSON(this, this.VideoFiles, includeMagnet); + const result = (0, video_format_utils_1.videoFilesModelToFormattedJSON)(this, this.VideoFiles, includeMagnet); files = files.concat(result); } for (const p of (this.VideoStreamingPlaylists || [])) { - const result = video_format_utils_1.videoFilesModelToFormattedJSON(this, p.VideoFiles, includeMagnet); + const result = (0, video_format_utils_1.videoFilesModelToFormattedJSON)(this, p.VideoFiles, includeMagnet); files = files.concat(result); } return files; } toActivityPubObject() { - return video_format_utils_1.videoModelToActivityPubObject(this); + return (0, video_format_utils_1.videoModelToActivityPubObject)(this); } getTruncatedDescription() { if (!this.description) return null; const maxLength = constants_1.CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max; - return core_utils_2.peertubeTruncate(this.description, { length: maxLength }); + return (0, core_utils_2.peertubeTruncate)(this.description, { length: maxLength }); } getMaxQualityResolution() { const file = this.getMaxQualityFile(); const videoOrPlaylist = file.getVideoOrStreamingPlaylist(); return video_path_manager_1.VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, file, originalFilePath => { - return ffprobe_utils_1.getVideoFileResolution(originalFilePath); + return (0, ffprobe_utils_1.getVideoFileResolution)(originalFilePath); }); } getDescriptionAPIPath() { @@ -818,20 +818,20 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. const filePath = isRedundancy ? video_path_manager_1.VideoPathManager.Instance.getFSRedundancyVideoFilePath(this, videoFile) : video_path_manager_1.VideoPathManager.Instance.getFSVideoFileOutputPath(this, videoFile); - const promises = [fs_extra_1.remove(filePath)]; + const promises = [(0, fs_extra_1.remove)(filePath)]; if (!isRedundancy) promises.push(videoFile.removeTorrent()); if (videoFile.storage === 1) { - promises.push(object_storage_1.removeWebTorrentObjectStorage(videoFile)); + promises.push((0, object_storage_1.removeWebTorrentObjectStorage)(videoFile)); } return Promise.all(promises); } removeStreamingPlaylistFiles(streamingPlaylist, isRedundancy = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const directoryPath = isRedundancy - ? paths_1.getHLSRedundancyDirectory(this) - : paths_1.getHLSDirectory(this); - yield fs_extra_1.remove(directoryPath); + ? (0, paths_1.getHLSRedundancyDirectory)(this) + : (0, paths_1.getHLSDirectory)(this); + yield (0, fs_extra_1.remove)(directoryPath); if (isRedundancy !== true) { const streamingPlaylistWithFiles = streamingPlaylist; streamingPlaylistWithFiles.Video = this; @@ -840,7 +840,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. } yield Promise.all(streamingPlaylistWithFiles.VideoFiles.map(file => file.removeTorrent())); if (streamingPlaylist.storage === 1) { - yield object_storage_1.removeHLSObjectStorage(streamingPlaylist, this); + yield (0, object_storage_1.removeHLSObjectStorage)(streamingPlaylist, this); } } }); @@ -848,19 +848,19 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. isOutdated() { if (this.isOwned()) return false; - return utils_1.isOutdated(this, constants_1.ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL); + return (0, utils_1.isOutdated)(this, constants_1.ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL); } hasPrivacyForFederation() { - return video_1.isPrivacyForFederation(this.privacy); + return (0, video_1.isPrivacyForFederation)(this.privacy); } hasStateForFederation() { - return video_1.isStateForFederation(this.state); + return (0, video_1.isStateForFederation)(this.state); } isNewVideo(newPrivacy) { - return this.hasPrivacyForFederation() === false && video_1.isPrivacyForFederation(newPrivacy) === true; + return this.hasPrivacyForFederation() === false && (0, video_1.isPrivacyForFederation)(newPrivacy) === true; } setAsRefreshed() { - return shared_1.setAsUpdated('video', this.id); + return (0, shared_1.setAsUpdated)('video', this.id); } requiresAuth() { return this.privacy === 3 || this.privacy === 4 || !!this.VideoBlacklist; @@ -877,7 +877,7 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. this.privacy === 4; } setNewState(newState, isNewVideo, transaction) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.state === newState) throw new Error('Cannot use same state ' + newState); this.state = newState; @@ -900,190 +900,190 @@ let VideoModel = VideoModel_1 = class VideoModel extends sequelize_typescript_1. return this.Trackers.map(t => t.url); } }; -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(sequelize_typescript_1.DataType.UUIDV4), - sequelize_typescript_1.IsUUID(4), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.UUID), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4), + (0, sequelize_typescript_1.IsUUID)(4), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID), + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "uuid", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoName', value => utils_1.throwIfNotValid(value, videos_1.isVideoNameValid, 'name')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoName', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoNameValid, 'name')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", String) + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "name", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "category", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "licence", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "language", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoPrivacy', value => utils_1.throwIfNotValid(value, videos_1.isVideoPrivacyValid, 'privacy')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoPrivacy', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoPrivacyValid, 'privacy')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "privacy", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoNSFW', value => utils_1.throwIfNotValid(value, misc_2.isBooleanValid, 'NSFW boolean')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoNSFW', value => (0, utils_1.throwIfNotValid)(value, misc_2.isBooleanValid, 'NSFW boolean')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "nsfw", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoDescription', value => utils_1.throwIfNotValid(value, videos_1.isVideoDescriptionValid, 'description', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoDescription', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoDescriptionValid, 'description', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "description", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoSupport', value => utils_1.throwIfNotValid(value, videos_1.isVideoSupportValid, 'support', true)), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoSupport', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoSupportValid, 'support', true)), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "support", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoDuration', value => utils_1.throwIfNotValid(value, videos_1.isVideoDurationValid, 'duration')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoDuration', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoDurationValid, 'duration')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "duration", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(0), + (0, sequelize_typescript_1.Min)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "views", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(0), + (0, sequelize_typescript_1.Min)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "likes", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.IsInt, - sequelize_typescript_1.Min(0), + (0, sequelize_typescript_1.Min)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "dislikes", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "remote", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "isLive", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Is('VideoUrl', value => utils_1.throwIfNotValid(value, misc_1.isActivityPubUrlValid, 'url')), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), - tslib_1.__metadata("design:type", String) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Is)('VideoUrl', value => (0, utils_1.throwIfNotValid)(value, misc_1.isActivityPubUrlValid, 'url')), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(constants_1.CONSTRAINTS_FIELDS.VIDEOS.URL.max)), + (0, tslib_1.__metadata)("design:type", String) ], VideoModel.prototype, "url", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "commentsEnabled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "downloadEnabled", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Boolean) + (0, tslib_1.__metadata)("design:type", Boolean) ], VideoModel.prototype, "waitTranscoding", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Is('VideoState', value => utils_1.throwIfNotValid(value, videos_1.isVideoStateValid, 'state')), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Is)('VideoState', value => (0, utils_1.throwIfNotValid)(value, videos_1.isVideoStateValid, 'state')), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "state", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.CreatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoModel.prototype, "createdAt", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.UpdatedAt, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoModel.prototype, "updatedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(sequelize_typescript_1.DataType.NOW), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.NOW), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Date) + (0, tslib_1.__metadata)("design:type", Date) ], VideoModel.prototype, "publishedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(true), - sequelize_typescript_1.Default(null), - sequelize_typescript_1.Column(sequelize_typescript_1.DataType.DOUBLE), - tslib_1.__metadata("design:type", Date) +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(true), + (0, sequelize_typescript_1.Default)(null), + (0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DOUBLE), + (0, tslib_1.__metadata)("design:type", Date) ], VideoModel.prototype, "originallyPublishedAt", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.AllowNull(false), - sequelize_typescript_1.Default(0), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.AllowNull)(false), + (0, sequelize_typescript_1.Default)(0), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "aspectRatio", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.ForeignKey(() => video_channel_1.VideoChannelModel), +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.ForeignKey)(() => video_channel_1.VideoChannelModel), sequelize_typescript_1.Column, - tslib_1.__metadata("design:type", Number) + (0, tslib_1.__metadata)("design:type", Number) ], VideoModel.prototype, "channelId", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsTo(() => video_channel_1.VideoChannelModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsTo)(() => video_channel_1.VideoChannelModel, { foreignKey: { allowNull: true }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_channel_1.VideoChannelModel) + (0, tslib_1.__metadata)("design:type", video_channel_1.VideoChannelModel) ], VideoModel.prototype, "VideoChannel", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsToMany(() => tag_1.TagModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsToMany)(() => tag_1.TagModel, { foreignKey: 'videoId', through: () => video_tag_1.VideoTagModel, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "Tags", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.BelongsToMany(() => tracker_1.TrackerModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.BelongsToMany)(() => tracker_1.TrackerModel, { foreignKey: 'videoId', through: () => video_tracker_1.VideoTrackerModel, onDelete: 'CASCADE' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "Trackers", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => thumbnail_1.ThumbnailModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => thumbnail_1.ThumbnailModel, { foreignKey: { name: 'videoId', allowNull: true @@ -1091,30 +1091,30 @@ tslib_1.__decorate([ hooks: true, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "Thumbnails", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_playlist_element_1.VideoPlaylistElementModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_playlist_element_1.VideoPlaylistElementModel, { foreignKey: { name: 'videoId', allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoPlaylistElements", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_abuse_1.VideoAbuseModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_abuse_1.VideoAbuseModel, { foreignKey: { name: 'videoId', allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoAbuses", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_file_1.VideoFileModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_file_1.VideoFileModel, { foreignKey: { name: 'videoId', allowNull: true @@ -1122,10 +1122,10 @@ tslib_1.__decorate([ hooks: true, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoFiles", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_streaming_playlist_1.VideoStreamingPlaylistModel, { foreignKey: { name: 'videoId', allowNull: false @@ -1133,30 +1133,30 @@ tslib_1.__decorate([ hooks: true, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoStreamingPlaylists", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_share_1.VideoShareModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_share_1.VideoShareModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoShares", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => account_video_rate_1.AccountVideoRateModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => account_video_rate_1.AccountVideoRateModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "AccountVideoRates", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_comment_1.VideoCommentModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_comment_1.VideoCommentModel, { foreignKey: { name: 'videoId', allowNull: false @@ -1164,70 +1164,70 @@ tslib_1.__decorate([ onDelete: 'cascade', hooks: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoComments", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_view_1.VideoViewModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_view_1.VideoViewModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoViews", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => user_video_history_1.UserVideoHistoryModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => user_video_history_1.UserVideoHistoryModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "UserVideoHistories", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => schedule_video_update_1.ScheduleVideoUpdateModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => schedule_video_update_1.ScheduleVideoUpdateModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", schedule_video_update_1.ScheduleVideoUpdateModel) + (0, tslib_1.__metadata)("design:type", schedule_video_update_1.ScheduleVideoUpdateModel) ], VideoModel.prototype, "ScheduleVideoUpdate", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_blacklist_1.VideoBlacklistModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_blacklist_1.VideoBlacklistModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_blacklist_1.VideoBlacklistModel) + (0, tslib_1.__metadata)("design:type", video_blacklist_1.VideoBlacklistModel) ], VideoModel.prototype, "VideoBlacklist", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_live_1.VideoLiveModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_live_1.VideoLiveModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_live_1.VideoLiveModel) + (0, tslib_1.__metadata)("design:type", video_live_1.VideoLiveModel) ], VideoModel.prototype, "VideoLive", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_import_1.VideoImportModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_import_1.VideoImportModel, { foreignKey: { name: 'videoId', allowNull: true }, onDelete: 'set null' }), - tslib_1.__metadata("design:type", video_import_1.VideoImportModel) + (0, tslib_1.__metadata)("design:type", video_import_1.VideoImportModel) ], VideoModel.prototype, "VideoImport", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasMany(() => video_caption_1.VideoCaptionModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasMany)(() => video_caption_1.VideoCaptionModel, { foreignKey: { name: 'videoId', allowNull: false @@ -1236,50 +1236,50 @@ tslib_1.__decorate([ hooks: true, ['separate']: true }), - tslib_1.__metadata("design:type", Array) + (0, tslib_1.__metadata)("design:type", Array) ], VideoModel.prototype, "VideoCaptions", void 0); -tslib_1.__decorate([ - sequelize_typescript_1.HasOne(() => video_job_info_1.VideoJobInfoModel, { +(0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.HasOne)(() => video_job_info_1.VideoJobInfoModel, { foreignKey: { name: 'videoId', allowNull: false }, onDelete: 'cascade' }), - tslib_1.__metadata("design:type", video_job_info_1.VideoJobInfoModel) + (0, tslib_1.__metadata)("design:type", video_job_info_1.VideoJobInfoModel) ], VideoModel.prototype, "VideoJobInfo", void 0); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [Object, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [Object, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoModel, "sendDelete", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoModel, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoModel, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoModel, "removeFiles", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], VideoModel, "stopLiveIfNeeded", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoModel]), - tslib_1.__metadata("design:returntype", void 0) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoModel]), + (0, tslib_1.__metadata)("design:returntype", void 0) ], VideoModel, "invalidateCache", null); -tslib_1.__decorate([ +(0, tslib_1.__decorate)([ sequelize_typescript_1.BeforeDestroy, - tslib_1.__metadata("design:type", Function), - tslib_1.__metadata("design:paramtypes", [VideoModel, Object]), - tslib_1.__metadata("design:returntype", Promise) + (0, tslib_1.__metadata)("design:type", Function), + (0, tslib_1.__metadata)("design:paramtypes", [VideoModel, Object]), + (0, tslib_1.__metadata)("design:returntype", Promise) ], VideoModel, "saveEssentialDataToAbuses", null); -VideoModel = VideoModel_1 = tslib_1.__decorate([ - sequelize_typescript_1.Scopes(() => ({ +VideoModel = VideoModel_1 = (0, tslib_1.__decorate)([ + (0, sequelize_typescript_1.Scopes)(() => ({ [ScopeNames.WITH_IMMUTABLE_ATTRIBUTES]: { attributes: ['id', 'url', 'uuid', 'remote'] }, @@ -1466,10 +1466,10 @@ VideoModel = VideoModel_1 = tslib_1.__decorate([ }; } })), - sequelize_typescript_1.Table({ + (0, sequelize_typescript_1.Table)({ tableName: 'video', indexes: [ - utils_1.buildTrigramSearchIndex('video_name_trigram', 'name'), + (0, utils_1.buildTrigramSearchIndex)('video_name_trigram', 'name'), { fields: ['createdAt'] }, { fields: [ diff --git a/dist/server/tests/api/activitypub/cleaner.js b/dist/server/tests/api/activitypub/cleaner.js index bcf4b1f8..2512c476 100644 --- a/dist/server/tests/api/activitypub/cleaner.js +++ b/dist/server/tests/api/activitypub/cleaner.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test AP cleaner', function () { @@ -12,36 +12,36 @@ describe('Test AP cleaner', function () { let videoUUID3; let videoUUIDs; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = { federation: { videos: { cleanup_remote_interactions: true } } }; - servers = yield extra_utils_1.createMultipleServers(3, config); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); yield Promise.all([ - extra_utils_1.doubleFollow(servers[0], servers[1]), - extra_utils_1.doubleFollow(servers[1], servers[2]), - extra_utils_1.doubleFollow(servers[0], servers[2]) + (0, extra_utils_1.doubleFollow)(servers[0], servers[1]), + (0, extra_utils_1.doubleFollow)(servers[1], servers[2]), + (0, extra_utils_1.doubleFollow)(servers[0], servers[2]) ]); videoUUID1 = (yield servers[0].videos.quickUpload({ name: 'server 1' })).uuid; videoUUID2 = (yield servers[1].videos.quickUpload({ name: 'server 2' })).uuid; videoUUID3 = (yield servers[2].videos.quickUpload({ name: 'server 3' })).uuid; videoUUIDs = [videoUUID1, videoUUID2, videoUUID3]; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { for (const uuid of videoUUIDs) { yield server.videos.rate({ id: uuid, rating: 'like' }); yield server.comments.createThread({ videoId: uuid, text: 'comment' }); } } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the correct likes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { for (const uuid of videoUUIDs) { const video = yield server.videos.get({ id: uuid }); @@ -52,14 +52,14 @@ describe('Test AP cleaner', function () { }); }); it('Should destroy server 3 internal likes and correctly clean them', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[2].sql.deleteAll('accountVideoRate'); for (const uuid of videoUUIDs) { yield servers[2].sql.setVideoField(uuid, 'likes', '0'); } - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); { const video = yield servers[0].videos.get({ id: videoUUID1 }); expect(video.likes).to.equal(2); @@ -73,14 +73,14 @@ describe('Test AP cleaner', function () { }); }); it('Should update rates to dislikes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); for (const server of servers) { for (const uuid of videoUUIDs) { yield server.videos.rate({ id: uuid, rating: 'dislike' }); } } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { for (const uuid of videoUUIDs) { const video = yield server.videos.get({ id: uuid }); @@ -91,14 +91,14 @@ describe('Test AP cleaner', function () { }); }); it('Should destroy server 3 internal dislikes and correctly clean them', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[2].sql.deleteAll('accountVideoRate'); for (const uuid of videoUUIDs) { yield servers[2].sql.setVideoField(uuid, 'dislikes', '0'); } - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); { const video = yield servers[0].videos.get({ id: videoUUID1 }); expect(video.likes).to.equal(0); @@ -112,27 +112,27 @@ describe('Test AP cleaner', function () { }); }); it('Should destroy server 3 internal shares and correctly clean them', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const preCount = yield servers[0].sql.getCount('videoShare'); expect(preCount).to.equal(6); yield servers[2].sql.deleteAll('videoShare'); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); const postCount = yield servers[0].sql.getCount('videoShare'); expect(postCount).to.equal(6); }); }); it('Should destroy server 3 internal comments and correctly clean them', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const { total } = yield servers[0].comments.listThreads({ videoId: videoUUID1 }); expect(total).to.equal(3); } yield servers[2].sql.deleteAll('videoComment'); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); { const { total } = yield servers[0].comments.listThreads({ videoId: videoUUID1 }); expect(total).to.equal(2); @@ -140,10 +140,10 @@ describe('Test AP cleaner', function () { }); }); it('Should correctly update rate URLs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); function check(like, ofServerUrl, urlSuffix, remote) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'`; const res = yield servers[0].sql.selectQuery(query); @@ -154,14 +154,14 @@ describe('Test AP cleaner', function () { }); } function checkLocal() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startsWith = 'http://' + servers[0].host + '%'; yield check(startsWith, servers[0].url, '', 'false'); yield check(startsWith, servers[0].url, '', 'true'); }); } function checkRemote(suffix) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startsWith = 'http://' + servers[1].host + '%'; yield check(startsWith, servers[1].url, suffix, 'false'); yield check(startsWith, servers[1].url, '', 'true'); @@ -172,18 +172,18 @@ describe('Test AP cleaner', function () { { const query = `UPDATE "accountVideoRate" SET url = url || 'stan'`; yield servers[1].sql.updateQuery(query); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); } yield checkLocal(); yield checkRemote('stan'); }); }); it('Should correctly update comment URLs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); function check(like, ofServerUrl, urlSuffix, remote) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'`; const res = yield servers[0].sql.selectQuery(query); @@ -194,14 +194,14 @@ describe('Test AP cleaner', function () { }); } function checkLocal() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startsWith = 'http://' + servers[0].host + '%'; yield check(startsWith, servers[0].url, '', 'false'); yield check(startsWith, servers[0].url, '', 'true'); }); } function checkRemote(suffix) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const startsWith = 'http://' + servers[1].host + '%'; yield check(startsWith, servers[1].url, suffix, 'false'); yield check(startsWith, servers[1].url, '', 'true'); @@ -210,16 +210,16 @@ describe('Test AP cleaner', function () { { const query = `UPDATE "videoComment" SET url = url || 'kyle'`; yield servers[1].sql.updateQuery(query); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); } yield checkLocal(); yield checkRemote('kyle'); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/activitypub/client.js b/dist/server/tests/api/activitypub/client.js index 62f7218b..a37bbe98 100644 --- a/dist/server/tests/api/activitypub/client.js +++ b/dist/server/tests/api/activitypub/client.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -11,8 +11,8 @@ describe('Test activitypub', function () { let video; let playlist; function testAccount(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeActivityPubGetRequest(servers[0].url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeActivityPubGetRequest)(servers[0].url, path); const object = res.body; expect(object.type).to.equal('Person'); expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root'); @@ -21,8 +21,8 @@ describe('Test activitypub', function () { }); } function testChannel(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeActivityPubGetRequest(servers[0].url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeActivityPubGetRequest)(servers[0].url, path); const object = res.body; expect(object.type).to.equal('Group'); expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-channels/root_channel'); @@ -31,8 +31,8 @@ describe('Test activitypub', function () { }); } function testVideo(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeActivityPubGetRequest(servers[0].url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeActivityPubGetRequest)(servers[0].url, path); const object = res.body; expect(object.type).to.equal('Video'); expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid); @@ -40,8 +40,8 @@ describe('Test activitypub', function () { }); } function testPlaylist(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeActivityPubGetRequest(servers[0].url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeActivityPubGetRequest)(servers[0].url, path); const object = res.body; expect(object.type).to.equal('Playlist'); expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-playlists/' + playlist.uuid); @@ -49,11 +49,11 @@ describe('Test activitypub', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); { video = yield servers[0].videos.quickUpload({ name: 'video' }); } @@ -61,23 +61,23 @@ describe('Test activitypub', function () { const attributes = { displayName: 'playlist', privacy: 1, videoChannelId: servers[0].store.channel.id }; playlist = yield servers[0].playlists.create({ attributes }); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should return the account object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testAccount('/accounts/root'); yield testAccount('/a/root'); }); }); it('Should return the channel object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testChannel('/video-channels/root_channel'); yield testChannel('/c/root_channel'); }); }); it('Should return the video object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testVideo('/videos/watch/' + video.id); yield testVideo('/videos/watch/' + video.uuid); yield testVideo('/videos/watch/' + video.shortUUID); @@ -87,7 +87,7 @@ describe('Test activitypub', function () { }); }); it('Should return the playlist object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testPlaylist('/video-playlists/' + playlist.id); yield testPlaylist('/video-playlists/' + playlist.uuid); yield testPlaylist('/video-playlists/' + playlist.shortUUID); @@ -100,14 +100,14 @@ describe('Test activitypub', function () { }); }); it('Should redirect to the origin video object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, models_1.HttpStatusCode.FOUND_302); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeActivityPubGetRequest)(servers[1].url, '/videos/watch/' + video.uuid, models_1.HttpStatusCode.FOUND_302); expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/activitypub/fetch.js b/dist/server/tests/api/activitypub/fetch.js index 10406e76..f68e7c98 100644 --- a/dist/server/tests/api/activitypub/fetch.js +++ b/dist/server/tests/api/activitypub/fetch.js @@ -2,16 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test ActivityPub fetcher', function () { let servers; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); const user = { username: 'user1', password: 'password' }; for (const server of servers) { yield server.users.create({ username: user.username, password: user.password }); @@ -32,10 +32,10 @@ describe('Test ActivityPub fetcher', function () { }); }); it('Should add only the video with a valid actor URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.waitJobs)(servers); { const { total, data } = yield servers[0].videos.list({ sort: 'createdAt' }); expect(total).to.equal(3); @@ -51,9 +51,9 @@ describe('Test ActivityPub fetcher', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/activitypub/helpers.js b/dist/server/tests/api/activitypub/helpers.js index 7b8f6d6f..5116bdb4 100644 --- a/dist/server/tests/api/activitypub/helpers.js +++ b/dist/server/tests/api/activitypub/helpers.js @@ -10,136 +10,136 @@ const peertube_crypto_1 = require("../../../helpers/peertube-crypto"); describe('Test activity pub helpers', function () { describe('When checking the Linked Signature', function () { it('Should fail with an invalid Mastodon signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/create-bad-signature.json')); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/create-bad-signature.json')); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/public-key.json')).publicKey; const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' }; - const result = yield peertube_crypto_1.isJsonLDSignatureVerified(fromActor, body); - chai_1.expect(result).to.be.false; + const result = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(fromActor, body); + (0, chai_1.expect)(result).to.be.false; }); }); it('Should fail with an invalid public key', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/create.json')); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/create.json')); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/bad-public-key.json')).publicKey; const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' }; - const result = yield peertube_crypto_1.isJsonLDSignatureVerified(fromActor, body); - chai_1.expect(result).to.be.false; + const result = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(fromActor, body); + (0, chai_1.expect)(result).to.be.false; }); }); it('Should succeed with a valid Mastodon signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/create.json')); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/create.json')); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/public-key.json')).publicKey; const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' }; - const result = yield peertube_crypto_1.isJsonLDSignatureVerified(fromActor, body); - chai_1.expect(result).to.be.true; + const result = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(fromActor, body); + (0, chai_1.expect)(result).to.be.true; }); }); it('Should fail with an invalid PeerTube signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const keys = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')); - const body = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const keys = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/invalid-keys.json')); + const body = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/announce-without-context.json')); const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }; - const signedBody = yield activitypub_1.buildSignedActivity(actorSignature, body); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(actorSignature, body); const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' }; - const result = yield peertube_crypto_1.isJsonLDSignatureVerified(fromActor, signedBody); - chai_1.expect(result).to.be.false; + const result = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(fromActor, signedBody); + (0, chai_1.expect)(result).to.be.false; }); }); it('Should succeed with a valid PeerTube signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const keys = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/keys.json')); - const body = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const keys = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/keys.json')); + const body = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/announce-without-context.json')); const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }; - const signedBody = yield activitypub_1.buildSignedActivity(actorSignature, body); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(actorSignature, body); const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' }; - const result = yield peertube_crypto_1.isJsonLDSignatureVerified(fromActor, signedBody); - chai_1.expect(result).to.be.true; + const result = yield (0, peertube_crypto_1.isJsonLDSignatureVerified)(fromActor, signedBody); + (0, chai_1.expect)(result).to.be.true; }); }); }); describe('When checking HTTP signature', function () { it('Should fail with an invalid http signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const req = extra_utils_1.buildRequestStub(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const req = (0, extra_utils_1.buildRequestStub)(); req.method = 'POST'; req.url = '/accounts/ronan/inbox'; - const mastodonObject = lodash_1.cloneDeep(require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/bad-http-signature.json'))); + const mastodonObject = (0, lodash_1.cloneDeep)(require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/bad-http-signature.json'))); req.body = mastodonObject.body; req.headers = mastodonObject.headers; - const parsed = peertube_crypto_1.parseHTTPSignature(req, 3600 * 1000 * 365 * 10); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey; + const parsed = (0, peertube_crypto_1.parseHTTPSignature)(req, 3600 * 1000 * 365 * 10); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/public-key.json')).publicKey; const actor = { publicKey }; - const verified = peertube_crypto_1.isHTTPSignatureVerified(parsed, actor); - chai_1.expect(verified).to.be.false; + const verified = (0, peertube_crypto_1.isHTTPSignatureVerified)(parsed, actor); + (0, chai_1.expect)(verified).to.be.false; }); }); it('Should fail with an invalid public key', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const req = extra_utils_1.buildRequestStub(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const req = (0, extra_utils_1.buildRequestStub)(); req.method = 'POST'; req.url = '/accounts/ronan/inbox'; - const mastodonObject = lodash_1.cloneDeep(require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))); + const mastodonObject = (0, lodash_1.cloneDeep)(require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/http-signature.json'))); req.body = mastodonObject.body; req.headers = mastodonObject.headers; - const parsed = peertube_crypto_1.parseHTTPSignature(req, 3600 * 1000 * 365 * 10); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey; + const parsed = (0, peertube_crypto_1.parseHTTPSignature)(req, 3600 * 1000 * 365 * 10); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/bad-public-key.json')).publicKey; const actor = { publicKey }; - const verified = peertube_crypto_1.isHTTPSignatureVerified(parsed, actor); - chai_1.expect(verified).to.be.false; + const verified = (0, peertube_crypto_1.isHTTPSignatureVerified)(parsed, actor); + (0, chai_1.expect)(verified).to.be.false; }); }); it('Should fail because of clock skew', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const req = extra_utils_1.buildRequestStub(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const req = (0, extra_utils_1.buildRequestStub)(); req.method = 'POST'; req.url = '/accounts/ronan/inbox'; - const mastodonObject = lodash_1.cloneDeep(require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))); + const mastodonObject = (0, lodash_1.cloneDeep)(require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/http-signature.json'))); req.body = mastodonObject.body; req.headers = mastodonObject.headers; let errored = false; try { - peertube_crypto_1.parseHTTPSignature(req); + (0, peertube_crypto_1.parseHTTPSignature)(req); } catch (_a) { errored = true; } - chai_1.expect(errored).to.be.true; + (0, chai_1.expect)(errored).to.be.true; }); }); it('Should with a scheme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const req = extra_utils_1.buildRequestStub(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const req = (0, extra_utils_1.buildRequestStub)(); req.method = 'POST'; req.url = '/accounts/ronan/inbox'; - const mastodonObject = lodash_1.cloneDeep(require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))); + const mastodonObject = (0, lodash_1.cloneDeep)(require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/http-signature.json'))); req.body = mastodonObject.body; req.headers = mastodonObject.headers; req.headers = 'Signature ' + mastodonObject.headers; let errored = false; try { - peertube_crypto_1.parseHTTPSignature(req, 3600 * 1000 * 365 * 10); + (0, peertube_crypto_1.parseHTTPSignature)(req, 3600 * 1000 * 365 * 10); } catch (_a) { errored = true; } - chai_1.expect(errored).to.be.true; + (0, chai_1.expect)(errored).to.be.true; }); }); it('Should succeed with a valid signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const req = extra_utils_1.buildRequestStub(); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const req = (0, extra_utils_1.buildRequestStub)(); req.method = 'POST'; req.url = '/accounts/ronan/inbox'; - const mastodonObject = lodash_1.cloneDeep(require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))); + const mastodonObject = (0, lodash_1.cloneDeep)(require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/http-signature.json'))); req.body = mastodonObject.body; req.headers = mastodonObject.headers; - const parsed = peertube_crypto_1.parseHTTPSignature(req, 3600 * 1000 * 365 * 10); - const publicKey = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey; + const parsed = (0, peertube_crypto_1.parseHTTPSignature)(req, 3600 * 1000 * 365 * 10); + const publicKey = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/mastodon/public-key.json')).publicKey; const actor = { publicKey }; - const verified = peertube_crypto_1.isHTTPSignatureVerified(parsed, actor); - chai_1.expect(verified).to.be.true; + const verified = (0, peertube_crypto_1.isHTTPSignatureVerified)(parsed, actor); + (0, chai_1.expect)(verified).to.be.true; }); }); }); diff --git a/dist/server/tests/api/activitypub/refresher.js b/dist/server/tests/api/activitypub/refresher.js index 45e0cca9..c5b8524e 100644 --- a/dist/server/tests/api/activitypub/refresher.js +++ b/dist/server/tests/api/activitypub/refresher.js @@ -12,11 +12,11 @@ describe('Test AP refresher', function () { let playlistUUID1; let playlistUUID2; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2, { transcoding: { enabled: false } }); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2, { transcoding: { enabled: false } }); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); { videoUUID1 = (yield servers[1].videos.quickUpload({ name: 'video1' })).uuid; videoUUID2 = (yield servers[1].videos.quickUpload({ name: 'video2' })).uuid; @@ -38,30 +38,30 @@ describe('Test AP refresher', function () { const created = yield servers[1].playlists.create({ attributes }); playlistUUID2 = created.uuid; } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('Videos refresher', function () { it('Should remove a deleted remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); yield servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f'); yield servers[0].videos.get({ id: videoUUID1 }); yield servers[0].videos.get({ id: videoUUID2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].videos.get({ id: videoUUID1, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield servers[0].videos.get({ id: videoUUID2 }); }); }); it('Should not update a remote video if the remote instance is down', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(70000); - yield extra_utils_1.killallServers([servers[1]]); + yield (0, extra_utils_1.killallServers)([servers[1]]); yield servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e'); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); yield servers[0].videos.get({ id: videoUUID3 }); - yield extra_utils_1.waitJobs([servers[0]]); + yield (0, extra_utils_1.waitJobs)([servers[0]]); yield servers[1].run(); yield servers[0].videos.get({ id: videoUUID3 }); }); @@ -69,15 +69,15 @@ describe('Test AP refresher', function () { }); describe('Actors refresher', function () { it('Should remove a deleted actor', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const command = servers[0].accounts; - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); const to = 'http://localhost:' + servers[1].port + '/accounts/user2'; yield servers[1].sql.setActorField(to, 'preferredUsername', 'toto'); yield command.get({ accountName: 'user1@localhost:' + servers[1].port }); yield command.get({ accountName: 'user2@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: models_1.HttpStatusCode.OK_200 }); yield command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); @@ -85,22 +85,22 @@ describe('Test AP refresher', function () { }); describe('Playlist refresher', function () { it('Should remove a deleted playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); yield servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e'); yield servers[0].playlists.get({ playlistId: playlistUUID1 }); yield servers[0].playlists.get({ playlistId: playlistUUID2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: models_1.HttpStatusCode.OK_200 }); yield servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/activitypub/security.js b/dist/server/tests/api/activitypub/security.js index 099fcf1a..3d5d9b75 100644 --- a/dist/server/tests/api/activitypub/security.js +++ b/dist/server/tests/api/activitypub/security.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const activitypub_1 = require("@server/helpers/activitypub"); const peertube_crypto_1 = require("@server/helpers/peertube-crypto"); const constants_1 = require("@server/initializers/constants"); @@ -26,7 +26,7 @@ function setUpdatedAtOfServer(onServer, ofServer, updatedAt) { ]); } function getAnnounceWithoutContext(server) { - const json = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')); + const json = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/announce-without-context.json')); const result = {}; for (const key of Object.keys(json)) { if (Array.isArray(json[key])) { @@ -41,8 +41,8 @@ function getAnnounceWithoutContext(server) { describe('Test ActivityPub security', function () { let servers; let url; - const keys = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/keys.json')); - const invalidKeys = require(extra_utils_1.buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')); + const keys = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/keys.json')); + const invalidKeys = require((0, extra_utils_1.buildAbsoluteFixturePath)('./ap-json/peertube/invalid-keys.json')); const baseHttpSignature = () => ({ algorithm: constants_1.HTTP_SIGNATURE.ALGORITHM, authorizationHeaderName: constants_1.HTTP_SIGNATURE.HEADER_NAME, @@ -51,26 +51,26 @@ describe('Test ActivityPub security', function () { headers: constants_1.HTTP_SIGNATURE.HEADERS_TO_SIGN }); before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(3); + servers = yield (0, extra_utils_1.createMultipleServers)(3); url = servers[0].url + '/inbox'; yield setKeysOfServer(servers[0], servers[1], keys.publicKey, null); yield setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey); const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }; const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey }; - yield activitypub_2.makeFollowRequest(to, by); + yield (0, activitypub_2.makeFollowRequest)(to, by); }); }); describe('When checking HTTP signature', function () { it('Should fail with an invalid digest', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); const headers = { - Digest: peertube_crypto_1.buildDigest({ hello: 'coucou' }) + Digest: (0, peertube_crypto_1.buildDigest)({ hello: 'coucou' }) }; try { - yield activitypub_2.makePOSTAPRequest(url, body, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, body, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -79,12 +79,12 @@ describe('Test ActivityPub security', function () { }); }); it('Should fail with an invalid date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'; try { - yield activitypub_2.makePOSTAPRequest(url, body, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, body, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -93,13 +93,13 @@ describe('Test ActivityPub security', function () { }); }); it('Should fail with bad keys', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey); yield setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey); - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); try { - yield activitypub_2.makePOSTAPRequest(url, body, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, body, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -108,11 +108,11 @@ describe('Test ActivityPub security', function () { }); }); it('Should reject requests without appropriate signed headers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey); yield setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey); - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); const signatureOptions = baseHttpSignature(); const badHeadersMatrix = [ ['(request-target)', 'date', 'digest'], @@ -122,7 +122,7 @@ describe('Test ActivityPub security', function () { for (const badHeaders of badHeadersMatrix) { signatureOptions.headers = badHeaders; try { - yield activitypub_2.makePOSTAPRequest(url, body, signatureOptions, headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, body, signatureOptions, headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -132,24 +132,24 @@ describe('Test ActivityPub security', function () { }); }); it('Should succeed with a valid HTTP signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); - const { statusCode } = yield activitypub_2.makePOSTAPRequest(url, body, baseHttpSignature(), headers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); + const { statusCode } = yield (0, activitypub_2.makePOSTAPRequest)(url, body, baseHttpSignature(), headers); expect(statusCode).to.equal(models_1.HttpStatusCode.NO_CONTENT_204); }); }); it('Should refresh the actor keys', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey); yield setUpdatedAtOfServer(servers[0], servers[1], '2015-07-17 22:00:00+00'); - yield extra_utils_1.killallServers([servers[1]]); + yield (0, extra_utils_1.killallServers)([servers[1]]); yield servers[1].run(); - const body = activitypub_1.activityPubContextify(getAnnounceWithoutContext(servers[1])); - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); + const body = (0, activitypub_1.activityPubContextify)(getAnnounceWithoutContext(servers[1])); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); try { - yield activitypub_2.makePOSTAPRequest(url, body, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, body, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -161,28 +161,28 @@ describe('Test ActivityPub security', function () { }); describe('When checking Linked Data Signature', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey); yield setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey); yield setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey); const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }; const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey }; - yield activitypub_2.makeFollowRequest(to, by); + yield (0, activitypub_2.makeFollowRequest)(to, by); }); }); it('Should fail with bad keys', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey); yield setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey); const body = getAnnounceWithoutContext(servers[1]); body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'; const signer = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }; - const signedBody = yield activitypub_1.buildSignedActivity(signer, body); - const headers = activitypub_http_utils_1.buildGlobalHeaders(signedBody); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(signer, body); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(signedBody); try { - yield activitypub_2.makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, signedBody, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -191,18 +191,18 @@ describe('Test ActivityPub security', function () { }); }); it('Should fail with an altered body', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey); yield setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey); const body = getAnnounceWithoutContext(servers[1]); body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'; const signer = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }; - const signedBody = yield activitypub_1.buildSignedActivity(signer, body); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(signer, body); signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube'; - const headers = activitypub_http_utils_1.buildGlobalHeaders(signedBody); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(signedBody); try { - yield activitypub_2.makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, signedBody, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -211,29 +211,29 @@ describe('Test ActivityPub security', function () { }); }); it('Should succeed with a valid signature', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const body = getAnnounceWithoutContext(servers[1]); body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'; const signer = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }; - const signedBody = yield activitypub_1.buildSignedActivity(signer, body); - const headers = activitypub_http_utils_1.buildGlobalHeaders(signedBody); - const { statusCode } = yield activitypub_2.makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(signer, body); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(signedBody); + const { statusCode } = yield (0, activitypub_2.makePOSTAPRequest)(url, signedBody, baseHttpSignature(), headers); expect(statusCode).to.equal(models_1.HttpStatusCode.NO_CONTENT_204); }); }); it('Should refresh the actor keys', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); yield setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey); const body = getAnnounceWithoutContext(servers[1]); body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'; const signer = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }; - const signedBody = yield activitypub_1.buildSignedActivity(signer, body); - const headers = activitypub_http_utils_1.buildGlobalHeaders(signedBody); + const signedBody = yield (0, activitypub_1.buildSignedActivity)(signer, body); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(signedBody); try { - yield activitypub_2.makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers); + yield (0, activitypub_2.makePOSTAPRequest)(url, signedBody, baseHttpSignature(), headers); expect(true, 'Did not throw').to.be.false; } catch (err) { @@ -243,9 +243,9 @@ describe('Test ActivityPub security', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/check-params/abuses.js b/dist/server/tests/api/check-params/abuses.js index 74809e25..ee156d74 100644 --- a/dist/server/tests/api/check-params/abuses.js +++ b/dist/server/tests/api/check-params/abuses.js @@ -13,10 +13,10 @@ describe('Test abuses API validators', function () { let messageId; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); userToken = yield server.users.generateUserAndToken('user_1'); userToken2 = yield server.users.generateUserAndToken('user_2'); server.store.videoCreated = yield server.videos.upload(); @@ -26,23 +26,23 @@ describe('Test abuses API validators', function () { describe('When listing abuses for admins', function () { const path = basePath; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -50,8 +50,8 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, @@ -60,34 +60,34 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a bad id filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { id: 'toto' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { id: 'toto' } }); }); }); it('Should fail with a bad filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { filter: 'toto' } }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { filter: 'videos' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { filter: 'toto' } }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { filter: 'videos' } }); }); }); it('Should fail with bad predefined reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { predefinedReason: 'violentOrRepulsives' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { predefinedReason: 'violentOrRepulsives' } }); }); }); it('Should fail with a bad state filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { state: 'toto' } }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { state: 0 } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { state: 'toto' } }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { state: 0 } }); }); }); it('Should fail with a bad videoIs filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query: { videoIs: 'toto' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query: { videoIs: 'toto' } }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { id: 13, predefinedReason: 'violentOrRepulsive', @@ -95,30 +95,30 @@ describe('Test abuses API validators', function () { state: 2, videoIs: 'deleted' }; - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When listing abuses for users', function () { const path = '/api/v1/users/me/abuses'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, userToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, userToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, userToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -126,44 +126,44 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a bad id filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, query: { id: 'toto' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, query: { id: 'toto' } }); }); }); it('Should fail with a bad state filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, query: { state: 'toto' } }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, query: { state: 0 } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, query: { state: 'toto' } }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, query: { state: 0 } }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { id: 13, state: 2 }; - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When reporting an abuse', function () { const path = basePath; it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should fail with a wrong video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: 'blabla' }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path, token: userToken, fields }); }); }); it('Should fail with an unknown video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: 42 }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, @@ -173,15 +173,15 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a wrong comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { comment: { id: 'blabla' }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path, token: userToken, fields }); }); }); it('Should fail with an unknown comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { comment: { id: 42 }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, @@ -191,15 +191,15 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a wrong account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { account: { id: 'blabla' }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path, token: userToken, fields }); }); }); it('Should fail with an unknown account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { account: { id: 42 }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, @@ -209,9 +209,9 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with not account, comment or video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, @@ -221,27 +221,27 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a reason too short', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id }, reason: 'h' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should fail with a too big reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id }, reason: 'super'.repeat(605) }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should succeed with the correct parameters (basic)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.shortUUID }, reason: 'my super reason' }; - const res = yield extra_utils_1.makePostBodyRequest({ + const res = yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, @@ -252,25 +252,25 @@ describe('Test abuses API validators', function () { }); }); it('Should fail with a wrong predefined reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: server.store.videoCreated, reason: 'my super reason', predefinedReasons: ['wrongPredefinedReason'] }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should fail with negative timestamps', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id, startAt: -1 }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should fail mith misordered startAt/endAt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields }); }); }); it('Should succeed with the corret parameters (advanced)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { video: { id: server.store.videoCreated.id, @@ -280,40 +280,40 @@ describe('Test abuses API validators', function () { reason: 'my super reason', predefinedReasons: ['serverRules'] }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When updating an abuse', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ token: 'blabla', abuseId, body: {}, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ token: userToken, abuseId, body: {}, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad abuse id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ abuseId: 45, body: {}, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a bad state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { state: 5 }; yield command.update({ abuseId, body, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with a bad moderation comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { moderationComment: 'b'.repeat(3001) }; yield command.update({ abuseId, body, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { state: 3 }; yield command.update({ abuseId, body }); }); @@ -322,27 +322,27 @@ describe('Test abuses API validators', function () { describe('When creating an abuse message', function () { const message = 'my super message'; it('Should fail with an invalid abuse id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addMessage({ token: userToken2, abuseId: 888, message, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addMessage({ token: 'fake_token', abuseId, message, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with an invalid logged in user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addMessage({ token: userToken2, abuseId, message, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with an invalid message', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addMessage({ token: userToken, abuseId, message: 'a'.repeat(5000), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should suceed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield command.addMessage({ token: userToken, abuseId, message }); messageId = res.body.abuseMessage.id; }); @@ -350,71 +350,71 @@ describe('Test abuses API validators', function () { }); describe('When listing abuse messages', function () { it('Should fail with an invalid abuse id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.listMessages({ token: userToken, abuseId: 888, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.listMessages({ token: 'fake_token', abuseId, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with an invalid logged in user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.listMessages({ token: userToken2, abuseId, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.listMessages({ token: userToken, abuseId }); }); }); }); describe('When deleting an abuse message', function () { it('Should fail with an invalid abuse id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.deleteMessage({ token: userToken, abuseId: 888, messageId, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with an invalid message id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.deleteMessage({ token: userToken, abuseId, messageId: 888, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.deleteMessage({ token: 'fake_token', abuseId, messageId, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with an invalid logged in user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.deleteMessage({ token: userToken2, abuseId, messageId, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.deleteMessage({ token: userToken, abuseId, messageId }); }); }); }); describe('When deleting a video abuse', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ token: 'blabla', abuseId, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ token: userToken, abuseId, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad abuse id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ abuseId: 45, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ abuseId }); }); }); @@ -423,37 +423,37 @@ describe('Test abuses API validators', function () { let remoteAbuseId; let anotherServer; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - anotherServer = yield extra_utils_1.createSingleServer(2); - yield extra_utils_1.setAccessTokensToServers([anotherServer]); - yield extra_utils_1.doubleFollow(anotherServer, server); + anotherServer = yield (0, extra_utils_1.createSingleServer)(2); + yield (0, extra_utils_1.setAccessTokensToServers)([anotherServer]); + yield (0, extra_utils_1.doubleFollow)(anotherServer, server); const server2VideoId = yield anotherServer.videos.getId({ uuid: server.store.videoCreated.uuid }); yield anotherServer.abuses.report({ reason: 'remote server', videoId: server2VideoId }); - yield extra_utils_1.waitJobs([server, anotherServer]); + yield (0, extra_utils_1.waitJobs)([server, anotherServer]); const body = yield command.getAdminList({ sort: '-createdAt' }); remoteAbuseId = body.data[0].id; }); }); it('Should fail when listing abuse messages of a remote abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.listMessages({ abuseId: remoteAbuseId, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail when creating abuse message of a remote abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addMessage({ abuseId: remoteAbuseId, message: 'message', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([anotherServer]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([anotherServer]); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/accounts.js b/dist/server/tests/api/check-params/accounts.js index 9734d1af..475c28fb 100644 --- a/dist/server/tests/api/check-params/accounts.js +++ b/dist/server/tests/api/check-params/accounts.js @@ -8,38 +8,38 @@ describe('Test accounts API validators', function () { const path = '/api/v1/accounts/'; let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); + server = yield (0, extra_utils_1.createSingleServer)(1); }); }); describe('When listing accounts', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); }); describe('When getting an account', function () { it('Should return 404 with a non existing name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.accounts.get({ accountName: 'arfaze', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/blocklist.js b/dist/server/tests/api/check-params/blocklist.js index c0576744..9f856a13 100644 --- a/dist/server/tests/api/check-params/blocklist.js +++ b/dist/server/tests/api/check-params/blocklist.js @@ -9,15 +9,15 @@ describe('Test blocklist API validators', function () { let server; let userAccessToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); server = servers[0]; const user = { username: 'user1', password: 'password' }; yield server.users.create({ username: user.username, password: user.password }); userAccessToken = yield server.login.getAccessToken(user); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('When managing user blocklist', function () { @@ -25,8 +25,8 @@ describe('Test blocklist API validators', function () { const path = '/api/v1/users/me/blocklist/accounts'; describe('When listing blocked accounts', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -34,25 +34,25 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); }); describe('When blocking an account', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { accountName: 'user1' }, @@ -61,8 +61,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -72,8 +72,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail to block ourselves', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -83,8 +83,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -96,8 +96,8 @@ describe('Test blocklist API validators', function () { }); describe('When unblocking an account', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -105,8 +105,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown account block', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user2', token: server.accessToken, @@ -115,8 +115,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1', token: server.accessToken, @@ -130,8 +130,8 @@ describe('Test blocklist API validators', function () { const path = '/api/v1/users/me/blocklist/servers'; describe('When listing blocked servers', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -139,25 +139,25 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); }); describe('When blocking a server', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { host: 'localhost:9002' }, @@ -166,8 +166,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with an unknown server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -177,8 +177,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with our own server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -188,8 +188,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -201,8 +201,8 @@ describe('Test blocklist API validators', function () { }); describe('When unblocking a server', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:' + servers[1].port, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -210,8 +210,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown server block', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:9004', token: server.accessToken, @@ -220,8 +220,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:' + servers[1].port, token: server.accessToken, @@ -237,8 +237,8 @@ describe('Test blocklist API validators', function () { const path = '/api/v1/server/blocklist/accounts'; describe('When listing blocked accounts', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -246,8 +246,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: userAccessToken, path, @@ -256,25 +256,25 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); }); describe('When blocking an account', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { accountName: 'user1' }, @@ -283,8 +283,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: userAccessToken, path, @@ -294,8 +294,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -305,8 +305,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail to block ourselves', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -316,8 +316,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -329,8 +329,8 @@ describe('Test blocklist API validators', function () { }); describe('When unblocking an account', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -338,8 +338,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1', token: userAccessToken, @@ -348,8 +348,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown account block', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user2', token: server.accessToken, @@ -358,8 +358,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1', token: server.accessToken, @@ -373,8 +373,8 @@ describe('Test blocklist API validators', function () { const path = '/api/v1/server/blocklist/servers'; describe('When listing blocked servers', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -382,8 +382,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: userAccessToken, path, @@ -392,25 +392,25 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); }); describe('When blocking a server', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { host: 'localhost:' + servers[1].port }, @@ -419,8 +419,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: userAccessToken, path, @@ -430,8 +430,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with an unknown server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -441,8 +441,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with our own server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -452,8 +452,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -465,8 +465,8 @@ describe('Test blocklist API validators', function () { }); describe('When unblocking a server', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:' + servers[1].port, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -474,8 +474,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with a user without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:' + servers[1].port, token: userAccessToken, @@ -484,8 +484,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should fail with an unknown server block', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:9004', token: server.accessToken, @@ -494,8 +494,8 @@ describe('Test blocklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:' + servers[1].port, token: server.accessToken, @@ -507,8 +507,8 @@ describe('Test blocklist API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/check-params/bulk.js b/dist/server/tests/api/check-params/bulk.js index 563ed007..ee890a06 100644 --- a/dist/server/tests/api/check-params/bulk.js +++ b/dist/server/tests/api/check-params/bulk.js @@ -8,10 +8,10 @@ describe('Test bulk API validators', function () { let server; let userAccessToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'password' }; yield server.users.create({ username: user.username, password: user.password }); userAccessToken = yield server.login.getAccessToken(user); @@ -20,8 +20,8 @@ describe('Test bulk API validators', function () { describe('When removing comments of', function () { const path = '/api/v1/bulk/remove-comments-of'; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { accountName: 'user1', scope: 'my-videos' }, @@ -30,8 +30,8 @@ describe('Test bulk API validators', function () { }); }); it('Should fail with an unknown account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -41,8 +41,8 @@ describe('Test bulk API validators', function () { }); }); it('Should fail with an invalid scope', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -52,8 +52,8 @@ describe('Test bulk API validators', function () { }); }); it('Should fail to delete comments of the instance without the appropriate rights', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: userAccessToken, path, @@ -63,8 +63,8 @@ describe('Test bulk API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path, @@ -75,8 +75,8 @@ describe('Test bulk API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/config.js b/dist/server/tests/api/check-params/config.js index aa0e5a4d..b9baa378 100644 --- a/dist/server/tests/api/check-params/config.js +++ b/dist/server/tests/api/check-params/config.js @@ -176,10 +176,10 @@ describe('Test config API validators', function () { } }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'password' @@ -190,8 +190,8 @@ describe('Test config API validators', function () { }); describe('When getting the configuration', function () { it('Should fail without token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -199,8 +199,8 @@ describe('Test config API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -211,8 +211,8 @@ describe('Test config API validators', function () { }); describe('When updating the configuration', function () { it('Should fail without token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: updateParams, @@ -221,8 +221,8 @@ describe('Test config API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: updateParams, @@ -232,9 +232,9 @@ describe('Test config API validators', function () { }); }); it('Should fail if it misses a key', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const newUpdateParams = lodash_1.omit(updateParams, 'admin.email'); - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const newUpdateParams = (0, lodash_1.omit)(updateParams, 'admin.email'); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: newUpdateParams, @@ -244,11 +244,11 @@ describe('Test config API validators', function () { }); }); it('Should fail with a bad default NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newUpdateParams = Object.assign(Object.assign({}, updateParams), { instance: { defaultNSFWPolicy: 'hello' } }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: newUpdateParams, @@ -258,13 +258,13 @@ describe('Test config API validators', function () { }); }); it('Should fail if email disabled and signup requires email verification', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newUpdateParams = Object.assign(Object.assign({}, updateParams), { signup: { enabled: true, limit: 5, requiresEmailVerification: true } }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: newUpdateParams, @@ -274,7 +274,7 @@ describe('Test config API validators', function () { }); }); it('Should fail with a disabled webtorrent & hls transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newUpdateParams = Object.assign(Object.assign({}, updateParams), { transcoding: { hls: { enabled: false @@ -283,7 +283,7 @@ describe('Test config API validators', function () { enabled: false } } }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: newUpdateParams, @@ -293,8 +293,8 @@ describe('Test config API validators', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: updateParams, @@ -306,8 +306,8 @@ describe('Test config API validators', function () { }); describe('When deleting the configuration', function () { it('Should fail without token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -315,8 +315,8 @@ describe('Test config API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: userAccessToken, @@ -326,8 +326,8 @@ describe('Test config API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/contact-form.js b/dist/server/tests/api/check-params/contact-form.js index ff95f5af..ede0d9f5 100644 --- a/dist/server/tests/api/check-params/contact-form.js +++ b/dist/server/tests/api/check-params/contact-form.js @@ -16,30 +16,30 @@ describe('Test contact form API validators', function () { let emailPort; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); emailPort = yield extra_utils_1.MockSmtpServer.Instance.collectEmails(emails); - server = yield extra_utils_1.createSingleServer(1); + server = yield (0, extra_utils_1.createSingleServer)(1); command = server.contactForm; }); }); it('Should not accept a contact form if emails are disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.send(Object.assign(Object.assign({}, defaultBody), { expectedStatus: models_1.HttpStatusCode.CONFLICT_409 })); }); }); it('Should not accept a contact form if it is disabled in the configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run({ smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }); yield command.send(Object.assign(Object.assign({}, defaultBody), { expectedStatus: models_1.HttpStatusCode.CONFLICT_409 })); }); }); it('Should not accept a contact form if from email is invalid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run({ smtp: { hostname: 'localhost', port: emailPort } }); yield command.send(Object.assign(Object.assign({}, defaultBody), { fromEmail: 'badEmail', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); yield command.send(Object.assign(Object.assign({}, defaultBody), { fromEmail: 'badEmail@', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); @@ -47,28 +47,28 @@ describe('Test contact form API validators', function () { }); }); it('Should not accept a contact form if from name is invalid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.send(Object.assign(Object.assign({}, defaultBody), { fromName: 'name'.repeat(100), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); yield command.send(Object.assign(Object.assign({}, defaultBody), { fromName: '', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); yield command.send(Object.assign(Object.assign({}, defaultBody), { fromName: undefined, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); }); }); it('Should not accept a contact form if body is invalid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.send(Object.assign(Object.assign({}, defaultBody), { body: 'body'.repeat(5000), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); yield command.send(Object.assign(Object.assign({}, defaultBody), { body: 'a', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); yield command.send(Object.assign(Object.assign({}, defaultBody), { body: undefined, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 })); }); }); it('Should accept a contact form with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.send(defaultBody); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/custom-pages.js b/dist/server/tests/api/check-params/custom-pages.js index b55e4834..aef121b6 100644 --- a/dist/server/tests/api/check-params/custom-pages.js +++ b/dist/server/tests/api/check-params/custom-pages.js @@ -9,10 +9,10 @@ describe('Test custom pages validators', function () { let server; let userAccessToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'password' }; yield server.users.create({ username: user.username, password: user.password }); userAccessToken = yield server.login.getAccessToken(user); @@ -20,8 +20,8 @@ describe('Test custom pages validators', function () { }); describe('When updating instance homepage', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: { content: 'super content' }, @@ -30,8 +30,8 @@ describe('Test custom pages validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: userAccessToken, @@ -41,8 +41,8 @@ describe('Test custom pages validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -54,8 +54,8 @@ describe('Test custom pages validators', function () { }); describe('When getting instance homapage', function () { it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -64,8 +64,8 @@ describe('Test custom pages validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/debug.js b/dist/server/tests/api/check-params/debug.js index 51da64a5..c1a522a0 100644 --- a/dist/server/tests/api/check-params/debug.js +++ b/dist/server/tests/api/check-params/debug.js @@ -9,10 +9,10 @@ describe('Test debug API validators', function () { let server; let userAccessToken = ''; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'my super password' @@ -23,8 +23,8 @@ describe('Test debug API validators', function () { }); describe('When getting debug endpoint', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -32,8 +32,8 @@ describe('Test debug API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -42,8 +42,8 @@ describe('Test debug API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -54,8 +54,8 @@ describe('Test debug API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/follows.js b/dist/server/tests/api/check-params/follows.js index 4149ea22..c2f2f489 100644 --- a/dist/server/tests/api/check-params/follows.js +++ b/dist/server/tests/api/check-params/follows.js @@ -7,24 +7,24 @@ const models_1 = require("@shared/models"); describe('Test server follows API validators', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); describe('When managing following', function () { let userAccessToken = null; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { userAccessToken = yield server.users.generateUserAndToken('user1'); }); }); describe('When adding follows', function () { const path = '/api/v1/server/following'; it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -33,8 +33,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if hosts is not composed by hosts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { hosts: ['localhost:9002', 'localhost:coucou'] }, @@ -44,8 +44,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if hosts is composed with http schemes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { hosts: ['localhost:9002', 'http://localhost:9003'] }, @@ -55,8 +55,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if hosts are not unique', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { urls: ['localhost:9002', 'localhost:9002'] }, @@ -66,8 +66,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if handles is not composed by handles', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { handles: ['hello@example.com', 'localhost:9001'] }, @@ -77,8 +77,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if handles are not unique', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { urls: ['hello@example.com', 'hello@example.com'] }, @@ -88,8 +88,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { hosts: ['localhost:9002'] }, @@ -99,8 +99,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { hosts: ['localhost:9002'] }, @@ -113,23 +113,23 @@ describe('Test server follows API validators', function () { describe('When listing followings', function () { const path = '/api/v1/server/following'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path); }); }); it('Should fail with an incorrect state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { @@ -139,8 +139,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an incorrect actor type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { @@ -150,8 +150,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, @@ -166,23 +166,23 @@ describe('Test server follows API validators', function () { describe('When listing followers', function () { const path = '/api/v1/server/followers'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path); }); }); it('Should fail with an incorrect actor type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { @@ -192,8 +192,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an incorrect state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { @@ -204,8 +204,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, @@ -219,8 +219,8 @@ describe('Test server follows API validators', function () { describe('When removing a follower', function () { const path = '/api/v1/server/followers'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/toto@localhost:9002', token: 'fake_token', @@ -229,8 +229,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/toto@localhost:9002', token: userAccessToken, @@ -239,8 +239,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an invalid follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/toto', token: server.accessToken, @@ -249,8 +249,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an unknown follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/toto@localhost:9003', token: server.accessToken, @@ -262,8 +262,8 @@ describe('Test server follows API validators', function () { describe('When accepting a follower', function () { const path = '/api/v1/server/followers'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9002/accept', token: 'fake_token', @@ -272,8 +272,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9002/accept', token: userAccessToken, @@ -282,8 +282,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an invalid follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto/accept', token: server.accessToken, @@ -292,8 +292,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an unknown follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9003/accept', token: server.accessToken, @@ -305,8 +305,8 @@ describe('Test server follows API validators', function () { describe('When rejecting a follower', function () { const path = '/api/v1/server/followers'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9002/reject', token: 'fake_token', @@ -315,8 +315,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9002/reject', token: userAccessToken, @@ -325,8 +325,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an invalid follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto/reject', token: server.accessToken, @@ -335,8 +335,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail with an unknown follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + '/toto@localhost:9003/reject', token: server.accessToken, @@ -348,8 +348,8 @@ describe('Test server follows API validators', function () { describe('When removing following', function () { const path = '/api/v1/server/following'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:9002', token: 'fake_token', @@ -358,8 +358,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/localhost:9002', token: userAccessToken, @@ -368,8 +368,8 @@ describe('Test server follows API validators', function () { }); }); it('Should fail if we do not follow this server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/example.com', token: server.accessToken, @@ -380,8 +380,8 @@ describe('Test server follows API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/jobs.js b/dist/server/tests/api/check-params/jobs.js index 1e40e802..193e6f1e 100644 --- a/dist/server/tests/api/check-params/jobs.js +++ b/dist/server/tests/api/check-params/jobs.js @@ -9,10 +9,10 @@ describe('Test jobs API validators', function () { let server; let userAccessToken = ''; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'my super password' @@ -23,8 +23,8 @@ describe('Test jobs API validators', function () { }); describe('When listing jobs', function () { it('Should fail with a bad state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path: path + 'ade' @@ -32,8 +32,8 @@ describe('Test jobs API validators', function () { }); }); it('Should fail with an incorrect job type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, @@ -44,23 +44,23 @@ describe('Test jobs API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -68,8 +68,8 @@ describe('Test jobs API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -79,8 +79,8 @@ describe('Test jobs API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/live.js b/dist/server/tests/api/check-params/live.js index 0bcdebc2..c2551166 100644 --- a/dist/server/tests/api/check-params/live.js +++ b/dist/server/tests/api/check-params/live.js @@ -14,10 +14,10 @@ describe('Test video lives API validator', function () { let videoIdNotLive; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.config.updateCustomSubConfig({ newConfig: { live: { @@ -64,61 +64,61 @@ describe('Test video lives API validator', function () { }; }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { name: 'super'.repeat(65) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { category: 125 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { licence: 125 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { language: 'a'.repeat(15) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(2500) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'channelId'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'channelId'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: 545454 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with another user channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'fake', password: 'fake_password' @@ -128,73 +128,73 @@ describe('Test video lives API validator', function () { const { videoChannels } = yield server.users.getMyInfo({ token: accessTokenUser }); const customChannelId = videoChannels[0].id; const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: customChannelId }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userAccessToken, fields }); }); }); it('Should fail with too many tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too low', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 't'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too big', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'my_super_tag_too_long_long_long_long_long_long'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + thumbnailfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with a big thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: extra_utils_1.buildAbsoluteFixturePath('preview-big.png') + thumbnailfile: (0, extra_utils_1.buildAbsoluteFixturePath)('preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with an incorrect preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + previewfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with a big preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: extra_utils_1.buildAbsoluteFixturePath('preview-big.png') + previewfile: (0, extra_utils_1.buildAbsoluteFixturePath)('preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with save replay and permanent live set to true', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { saveReplay: true, permanentLive: true }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - const res = yield extra_utils_1.makePostBodyRequest({ + const res = yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -205,7 +205,7 @@ describe('Test video lives API validator', function () { }); }); it('Should forbid if live is disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { live: { @@ -213,7 +213,7 @@ describe('Test video lives API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -223,7 +223,7 @@ describe('Test video lives API validator', function () { }); }); it('Should forbid to save replay if not enabled by the admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { saveReplay: true }); yield server.config.updateCustomSubConfig({ newConfig: { @@ -233,7 +233,7 @@ describe('Test video lives API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -243,7 +243,7 @@ describe('Test video lives API validator', function () { }); }); it('Should allow to save replay if enabled by the admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { saveReplay: true }); yield server.config.updateCustomSubConfig({ newConfig: { @@ -253,7 +253,7 @@ describe('Test video lives API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -263,7 +263,7 @@ describe('Test video lives API validator', function () { }); }); it('Should not allow live if max instance lives is reached', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { live: { @@ -272,7 +272,7 @@ describe('Test video lives API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -282,7 +282,7 @@ describe('Test video lives API validator', function () { }); }); it('Should not allow live if max user lives is reached', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { live: { @@ -292,7 +292,7 @@ describe('Test video lives API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -304,37 +304,37 @@ describe('Test video lives API validator', function () { }); describe('When getting live information', function () { it('Should fail without access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ token: '', videoId: video.id, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a bad access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ token: 'toto', videoId: video.id, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with access token of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ token: userAccessToken, videoId: video.id, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ videoId: 'toto', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with an unknown video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ videoId: 454555, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a non live video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ videoId: videoIdNotLive, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ videoId: video.id }); yield command.get({ videoId: video.uuid }); yield command.get({ videoId: video.shortUUID }); @@ -342,52 +342,52 @@ describe('Test video lives API validator', function () { }); }); describe('When updating live information', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { it('Should fail without access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ token: '', videoId: video.id, fields: {}, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a bad access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ token: 'toto', videoId: video.id, fields: {}, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with access token of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ token: userAccessToken, videoId: video.id, fields: {}, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ videoId: 'toto', fields: {}, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with an unknown video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ videoId: 454555, fields: {}, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a non live video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ videoId: videoIdNotLive, fields: {}, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with save replay and permanent live set to true', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { saveReplay: true, permanentLive: true }; yield command.update({ videoId: video.id, fields, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ videoId: video.id, fields: { saveReplay: false } }); yield command.update({ videoId: video.uuid, fields: { saveReplay: false } }); yield command.update({ videoId: video.shortUUID, fields: { saveReplay: false } }); }); }); it('Should fail to update replay status if replay is not allowed on the instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { live: { @@ -400,30 +400,30 @@ describe('Test video lives API validator', function () { }); }); it('Should fail to update a live if it has already started', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const live = yield command.get({ videoId: video.id }); - const ffmpegCommand = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey }); + const ffmpegCommand = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey }); yield command.waitUntilPublished({ videoId: video.id }); yield command.update({ videoId: video.id, fields: {}, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); it('Should fail to stream twice in the save live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const live = yield command.get({ videoId: video.id }); - const ffmpegCommand = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey }); + const ffmpegCommand = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey }); yield command.waitUntilPublished({ videoId: video.id }); yield command.runAndTestStreamError({ videoId: video.id, shouldHaveError: true }); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/logs.js b/dist/server/tests/api/check-params/logs.js index 3e46e61f..4104f76d 100644 --- a/dist/server/tests/api/check-params/logs.js +++ b/dist/server/tests/api/check-params/logs.js @@ -9,10 +9,10 @@ describe('Test logs API validators', function () { let server; let userAccessToken = ''; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'my super password' @@ -23,8 +23,8 @@ describe('Test logs API validators', function () { }); describe('When getting logs', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -32,8 +32,8 @@ describe('Test logs API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -42,8 +42,8 @@ describe('Test logs API validators', function () { }); }); it('Should fail with a missing startDate query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -52,8 +52,8 @@ describe('Test logs API validators', function () { }); }); it('Should fail with a bad startDate query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -63,8 +63,8 @@ describe('Test logs API validators', function () { }); }); it('Should fail with a bad endDate query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -74,8 +74,8 @@ describe('Test logs API validators', function () { }); }); it('Should fail with a bad level parameter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -85,8 +85,8 @@ describe('Test logs API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -97,8 +97,8 @@ describe('Test logs API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/plugins.js b/dist/server/tests/api/check-params/plugins.js index 9d97fb5d..5cdbfc76 100644 --- a/dist/server/tests/api/check-params/plugins.js +++ b/dist/server/tests/api/check-params/plugins.js @@ -14,10 +14,10 @@ describe('Test server plugins API validators', function () { const themeName = 'background-red'; let themeVersion; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'password' @@ -38,7 +38,7 @@ describe('Test server plugins API validators', function () { }); describe('With static plugin routes', function () { it('Should fail with an unknown plugin name/plugin version', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/plugins/' + pluginName + '/0.0.1/auth/fake-auth', '/plugins/' + pluginName + '/0.0.1/static/images/chocobo.png', @@ -48,13 +48,13 @@ describe('Test server plugins API validators', function () { '/themes/' + themeName + '/0.0.1/css/assets/style1.css' ]; for (const p of paths) { - yield extra_utils_1.makeGetRequest({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); } }); }); it('Should fail when requesting a plugin in the theme path', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -62,7 +62,7 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with invalid versions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/plugins/' + pluginName + '/0.0.1.1/auth/fake-auth', '/plugins/' + pluginName + '/0.0.1.1/static/images/chocobo.png', @@ -72,12 +72,12 @@ describe('Test server plugins API validators', function () { '/themes/' + themeName + '/0.a.1/css/assets/style1.css' ]; for (const p of paths) { - yield extra_utils_1.makeGetRequest({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); } }); }); it('Should fail with invalid paths', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/plugins/' + pluginName + '/' + npmVersion + '/static/images/../chocobo.png', '/plugins/' + pluginName + '/' + npmVersion + '/client-scripts/../client/common-client-plugin.js', @@ -86,18 +86,18 @@ describe('Test server plugins API validators', function () { '/themes/' + themeName + '/' + themeVersion + '/css/../assets/style1.css' ]; for (const p of paths) { - yield extra_utils_1.makeGetRequest({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); } }); }); it('Should fail with an unknown auth name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth'; - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with an unknown static file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/plugins/' + pluginName + '/' + npmVersion + '/static/fake/chocobo.png', '/plugins/' + pluginName + '/' + npmVersion + '/client-scripts/client/fake.js', @@ -105,13 +105,13 @@ describe('Test server plugins API validators', function () { '/themes/' + themeName + '/' + themeVersion + '/client-scripts/client/fake.js' ]; for (const p of paths) { - yield extra_utils_1.makeGetRequest({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); } }); }); it('Should fail with an unknown CSS file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -119,7 +119,7 @@ describe('Test server plugins API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/plugins/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', '/plugins/' + pluginName + '/' + npmVersion + '/client-scripts/client/common-client-plugin.js', @@ -128,10 +128,10 @@ describe('Test server plugins API validators', function () { '/themes/' + themeName + '/' + themeVersion + '/css/assets/style1.css' ]; for (const p of paths) { - yield extra_utils_1.makeGetRequest({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: p, expectedStatus: models_1.HttpStatusCode.OK_200 }); } const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth'; - yield extra_utils_1.makeGetRequest({ url: server.url, path: authPath, expectedStatus: models_1.HttpStatusCode.FOUND_302 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: authPath, expectedStatus: models_1.HttpStatusCode.FOUND_302 }); }); }); }); @@ -143,8 +143,8 @@ describe('Test server plugins API validators', function () { currentPeerTubeEngine: '1.2.3' }; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: 'fake_token', @@ -154,8 +154,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -165,24 +165,24 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an invalid plugin type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = Object.assign(Object.assign({}, baseQuery), { pluginType: 5 }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -191,9 +191,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an invalid current peertube engine', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = Object.assign(Object.assign({}, baseQuery), { currentPeerTubeEngine: '1.0' }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -202,8 +202,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -219,8 +219,8 @@ describe('Test server plugins API validators', function () { pluginType: models_1.PluginType.THEME }; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: 'fake_token', @@ -230,8 +230,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -241,24 +241,24 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an invalid plugin type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = Object.assign(Object.assign({}, baseQuery), { pluginType: 5 }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -267,8 +267,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -281,9 +281,9 @@ describe('Test server plugins API validators', function () { describe('When getting a plugin or the registered settings or public settings', function () { const path = '/api/v1/plugins/'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of [npmPlugin, `${npmPlugin}/registered-settings`]) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: 'fake_token', @@ -293,9 +293,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of [npmPlugin, `${npmPlugin}/registered-settings`]) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: userAccessToken, @@ -305,9 +305,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an invalid npm name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of ['toto', 'toto/registered-settings', 'toto/public-settings']) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: server.accessToken, @@ -315,7 +315,7 @@ describe('Test server plugins API validators', function () { }); } for (const suffix of ['peertube-plugin-TOTO', 'peertube-plugin-TOTO/registered-settings', 'peertube-plugin-TOTO/public-settings']) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: server.accessToken, @@ -325,9 +325,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an unknown plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of ['peertube-plugin-toto', 'peertube-plugin-toto/registered-settings', 'peertube-plugin-toto/public-settings']) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: server.accessToken, @@ -337,9 +337,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of [npmPlugin, `${npmPlugin}/registered-settings`, `${npmPlugin}/public-settings`]) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + suffix, token: server.accessToken, @@ -353,8 +353,8 @@ describe('Test server plugins API validators', function () { const path = '/api/v1/plugins/'; const settings = { setting1: 'value1' }; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + npmPlugin + '/settings', fields: { settings }, @@ -364,8 +364,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + npmPlugin + '/settings', fields: { settings }, @@ -375,15 +375,15 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an invalid npm name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'toto/settings', fields: { settings }, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'peertube-plugin-TOTO/settings', fields: { settings }, @@ -393,8 +393,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an unknown plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'peertube-plugin-toto/settings', fields: { settings }, @@ -404,8 +404,8 @@ describe('Test server plugins API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + npmPlugin + '/settings', fields: { settings }, @@ -418,9 +418,9 @@ describe('Test server plugins API validators', function () { describe('When installing/updating/uninstalling a plugin', function () { const path = '/api/v1/plugins/'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of ['install', 'update', 'uninstall']) { - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + suffix, fields: { npmName: npmPlugin }, @@ -431,9 +431,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of ['install', 'update', 'uninstall']) { - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + suffix, fields: { npmName: npmPlugin }, @@ -444,9 +444,9 @@ describe('Test server plugins API validators', function () { }); }); it('Should fail with an invalid npm name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const suffix of ['install', 'update', 'uninstall']) { - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + suffix, fields: { npmName: 'toto' }, @@ -455,7 +455,7 @@ describe('Test server plugins API validators', function () { }); } for (const suffix of ['install', 'update', 'uninstall']) { - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + suffix, fields: { npmName: 'peertube-plugin-TOTO' }, @@ -466,7 +466,7 @@ describe('Test server plugins API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const it = [ { suffix: 'install', status: models_1.HttpStatusCode.OK_200 }, @@ -474,7 +474,7 @@ describe('Test server plugins API validators', function () { { suffix: 'uninstall', status: models_1.HttpStatusCode.NO_CONTENT_204 } ]; for (const obj of it) { - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + obj.suffix, fields: { npmName: npmPlugin }, @@ -486,8 +486,8 @@ describe('Test server plugins API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/redundancy.js b/dist/server/tests/api/check-params/redundancy.js index d708b325..008b825a 100644 --- a/dist/server/tests/api/check-params/redundancy.js +++ b/dist/server/tests/api/check-params/redundancy.js @@ -10,11 +10,11 @@ describe('Test server redundancy API validators', function () { let videoIdLocal; let videoRemote; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); const user = { username: 'user1', password: 'password' @@ -23,7 +23,7 @@ describe('Test server redundancy API validators', function () { userAccessToken = yield servers[0].login.getAccessToken(user); videoIdLocal = (yield servers[0].videos.quickUpload({ name: 'video' })).id; const remoteUUID = (yield servers[1].videos.quickUpload({ name: 'video' })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); videoRemote = yield servers[0].videos.get({ id: remoteUUID }); }); }); @@ -36,43 +36,43 @@ describe('Test server redundancy API validators', function () { token = servers[0].accessToken; }); it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url, path, token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url, path, token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(url, path, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(url, path, servers[0].accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(url, path, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(url, path, servers[0].accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(url, path, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(url, path, servers[0].accessToken); }); }); it('Should fail with a bad target', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url, path, token, query: { target: 'bad target' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url, path, token, query: { target: 'bad target' } }); }); }); it('Should fail without target', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url, path, token }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url, path, token }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url, path, token, query: { target: 'my-videos' }, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); @@ -85,38 +85,38 @@ describe('Test server redundancy API validators', function () { token = servers[0].accessToken; }); it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail without a video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token }); }); }); it('Should fail with an incorrect video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token, fields: { videoId: 'peertube' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token, fields: { videoId: 'peertube' } }); }); }); it('Should fail with a not found video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token, fields: { videoId: 6565 }, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a local a video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url, path, token, fields: { videoId: videoIdLocal } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token, fields: { videoId: videoIdLocal } }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token, @@ -126,10 +126,10 @@ describe('Test server redundancy API validators', function () { }); }); it('Should fail if the video is already duplicated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.makePostBodyRequest)({ url, path, token, @@ -148,31 +148,31 @@ describe('Test server redundancy API validators', function () { token = servers[0].accessToken; }); it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url, path: path + '1', token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url, path: path + '1', token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with an incorrect video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ url, path: path + 'toto', token }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url, path: path + 'toto', token }); }); }); it('Should fail with a not found video redundancy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url, path: path + '454545', token, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); }); describe('When updating server redundancy', function () { const path = '/api/v1/server/redundancy'; it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: path + '/localhost:' + servers[1].port, fields: { redundancyAllowed: true }, @@ -182,8 +182,8 @@ describe('Test server redundancy API validators', function () { }); }); it('Should fail if the user is not an administrator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: path + '/localhost:' + servers[1].port, fields: { redundancyAllowed: true }, @@ -193,8 +193,8 @@ describe('Test server redundancy API validators', function () { }); }); it('Should fail if we do not follow this server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: path + '/example.com', fields: { redundancyAllowed: true }, @@ -204,8 +204,8 @@ describe('Test server redundancy API validators', function () { }); }); it('Should fail without de redundancyAllowed param', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: path + '/localhost:' + servers[1].port, fields: { blabla: true }, @@ -215,8 +215,8 @@ describe('Test server redundancy API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: path + '/localhost:' + servers[1].port, fields: { redundancyAllowed: true }, @@ -227,8 +227,8 @@ describe('Test server redundancy API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/check-params/search.js b/dist/server/tests/api/check-params/search.js index 4fe97922..0d4ca3e3 100644 --- a/dist/server/tests/api/check-params/search.js +++ b/dist/server/tests/api/check-params/search.js @@ -19,10 +19,10 @@ function updateSearchIndex(server, enabled, disableLocalSearch = false) { describe('Test videos API validator', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); describe('When searching videos', function () { @@ -31,119 +31,119 @@ describe('Test videos API validator', function () { search: 'coucou' }; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, null, query); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, null, query); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, null, query); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should fail with an invalid category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { categoryOneOf: ['aa', 'b'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery2 = Object.assign(Object.assign({}, query), { categoryOneOf: 'a' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with a valid category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { categoryOneOf: [1, 7] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery2 = Object.assign(Object.assign({}, query), { categoryOneOf: 1 }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should fail with an invalid licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { licenceOneOf: ['aa', 'b'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery2 = Object.assign(Object.assign({}, query), { licenceOneOf: 'a' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with a valid licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { licenceOneOf: [1, 2] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery2 = Object.assign(Object.assign({}, query), { licenceOneOf: 1 }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should succeed with a valid language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { languageOneOf: ['fr', 'en'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery2 = Object.assign(Object.assign({}, query), { languageOneOf: 'fr' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should succeed with valid tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { tagsOneOf: ['tag1', 'tag2'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery2 = Object.assign(Object.assign({}, query), { tagsOneOf: 'tag1' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery3 = Object.assign(Object.assign({}, query), { tagsAllOf: ['tag1', 'tag2'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery3, expectedStatus: models_1.HttpStatusCode.OK_200 }); const customQuery4 = Object.assign(Object.assign({}, query), { tagsAllOf: 'tag1' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery4, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should fail with invalid durations', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { durationMin: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery2 = Object.assign(Object.assign({}, query), { durationMax: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with invalid dates', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery1 = Object.assign(Object.assign({}, query), { startDate: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery2 = Object.assign(Object.assign({}, query), { endDate: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery2, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery3 = Object.assign(Object.assign({}, query), { originallyPublishedStartDate: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery3, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const customQuery4 = Object.assign(Object.assign({}, query), { originallyPublishedEndDate: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery4, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with an invalid host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery = Object.assign(Object.assign({}, query), { host: '6565' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with a host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery = Object.assign(Object.assign({}, query), { host: 'example.com' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); it('Should fail with invalid uuids', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery = Object.assign(Object.assign({}, query), { uuids: ['6565', 'dfd70b83-639f-4980-94af-304a56ab4b35'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with valid uuids', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery = Object.assign(Object.assign({}, query), { uuids: ['dfd70b83-639f-4980-94af-304a56ab4b35'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); @@ -154,34 +154,34 @@ describe('Test videos API validator', function () { host: 'example.com' }; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, null, query); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, null, query); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, null, query); }); }); it('Should fail with an invalid host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: Object.assign(Object.assign({}, query), { host: '6565' }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: Object.assign(Object.assign({}, query), { host: '6565' }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with invalid uuids', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const customQuery = Object.assign(Object.assign({}, query), { uuids: ['6565', 'dfd70b83-639f-4980-94af-304a56ab4b35'] }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); @@ -192,39 +192,39 @@ describe('Test videos API validator', function () { host: 'example.com' }; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, null, query); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, null, query); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, null, query); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, null, query); }); }); it('Should fail with an invalid host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: Object.assign(Object.assign({}, query), { host: '6565' }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: Object.assign(Object.assign({}, query), { host: '6565' }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with invalid handles', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: Object.assign(Object.assign({}, query), { handles: [''] }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: Object.assign(Object.assign({}, query), { handles: [''] }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('Search target', function () { it('Should fail/succeed depending on the search target', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const query = { search: 'coucou' }; const paths = [ @@ -235,33 +235,33 @@ describe('Test videos API validator', function () { for (const path of paths) { { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'hello' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); } { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: undefined }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); } { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'local' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); } { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'search-index' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); } yield updateSearchIndex(server, true, true); { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'local' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); } { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'search-index' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); } yield updateSearchIndex(server, true, false); { const customQuery = Object.assign(Object.assign({}, query), { searchTarget: 'local' }); - yield extra_utils_1.makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: customQuery, expectedStatus: models_1.HttpStatusCode.OK_200 }); } yield updateSearchIndex(server, false, false); } @@ -269,8 +269,8 @@ describe('Test videos API validator', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/services.js b/dist/server/tests/api/check-params/services.js index c8dd3f5b..39198564 100644 --- a/dist/server/tests/api/check-params/services.js +++ b/dist/server/tests/api/check-params/services.js @@ -8,11 +8,11 @@ describe('Test services API validators', function () { let server; let playlistUUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); server.store.videoCreated = yield server.videos.upload({ attributes: { name: 'my super name' } }); { const created = yield server.playlists.create({ @@ -28,61 +28,61 @@ describe('Test services API validators', function () { }); describe('Test oEmbed API validators', function () { it('Should fail with an invalid url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = 'hello.com'; yield checkParamEmbed(server, embedUrl); }); }); it('Should fail with an invalid host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = 'http://hello.com/videos/watch/' + server.store.videoCreated.uuid; yield checkParamEmbed(server, embedUrl); }); }); it('Should fail with an invalid element id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`; yield checkParamEmbed(server, embedUrl); }); }); it('Should fail with an unknown element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`; yield checkParamEmbed(server, embedUrl, models_1.HttpStatusCode.NOT_FOUND_404); }); }); it('Should fail with an invalid path', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.videoCreated.uuid}`; yield checkParamEmbed(server, embedUrl); }); }); it('Should fail with an invalid max height', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`; yield checkParamEmbed(server, embedUrl, models_1.HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' }); }); }); it('Should fail with an invalid max width', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`; yield checkParamEmbed(server, embedUrl, models_1.HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' }); }); }); it('Should fail with an invalid format', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`; yield checkParamEmbed(server, embedUrl, models_1.HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' }); }); }); it('Should fail with a non supported format', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`; yield checkParamEmbed(server, embedUrl, models_1.HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }); }); }); it('Should succeed with the correct params with a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}`; const query = { format: 'json', @@ -93,7 +93,7 @@ describe('Test services API validators', function () { }); }); it('Should succeed with the correct params with a playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}`; const query = { format: 'json', @@ -105,14 +105,14 @@ describe('Test services API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); function checkParamEmbed(server, embedUrl, expectedStatus = models_1.HttpStatusCode.BAD_REQUEST_400, query = {}) { const path = '/services/oembed'; - return extra_utils_1.makeGetRequest({ + return (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: Object.assign(query, { url: embedUrl }), diff --git a/dist/server/tests/api/check-params/upload-quota.js b/dist/server/tests/api/check-params/upload-quota.js index 5276f290..98668092 100644 --- a/dist/server/tests/api/check-params/upload-quota.js +++ b/dist/server/tests/api/check-params/upload-quota.js @@ -11,11 +11,11 @@ describe('Test upload quota', function () { let rootId; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); const user = yield server.users.getMyInfo(); rootId = user.id; yield server.users.update({ userId: rootId, videoQuota: 42 }); @@ -24,9 +24,9 @@ describe('Test upload quota', function () { }); describe('When having a video quota', function () { it('Should fail with a registered user having too many videos with legacy upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - const user = { username: 'registered' + core_utils_1.randomInt(1, 1500), password: 'password' }; + const user = { username: 'registered' + (0, core_utils_1.randomInt)(1, 1500), password: 'password' }; yield server.users.register(user); const userToken = yield server.login.getAccessToken(user); const attributes = { fixture: 'video_short2.webm' }; @@ -37,9 +37,9 @@ describe('Test upload quota', function () { }); }); it('Should fail with a registered user having too many videos with resumable upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - const user = { username: 'registered' + core_utils_1.randomInt(1, 1500), password: 'password' }; + const user = { username: 'registered' + (0, core_utils_1.randomInt)(1, 1500), password: 'password' }; yield server.users.register(user); const userToken = yield server.login.getAccessToken(user); const attributes = { fixture: 'video_short2.webm' }; @@ -50,7 +50,7 @@ describe('Test upload quota', function () { }); }); it('Should fail to import with HTTP/Torrent/magnet', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const baseAttributes = { channelId: server.store.channel.id, @@ -59,21 +59,21 @@ describe('Test upload quota', function () { yield server.imports.importVideo({ attributes: Object.assign(Object.assign({}, baseAttributes), { targetUrl: extra_utils_1.FIXTURE_URLS.goodVideo }) }); yield server.imports.importVideo({ attributes: Object.assign(Object.assign({}, baseAttributes), { magnetUri: extra_utils_1.FIXTURE_URLS.magnet }) }); yield server.imports.importVideo({ attributes: Object.assign(Object.assign({}, baseAttributes), { torrentfile: 'video-720p.torrent' }) }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const { total, data: videoImports } = yield server.imports.getMyVideoImports(); - chai_1.expect(total).to.equal(3); - chai_1.expect(videoImports).to.have.lengthOf(3); + (0, chai_1.expect)(total).to.equal(3); + (0, chai_1.expect)(videoImports).to.have.lengthOf(3); for (const videoImport of videoImports) { - chai_1.expect(videoImport.state.id).to.equal(3); - chai_1.expect(videoImport.error).not.to.be.undefined; - chai_1.expect(videoImport.error).to.contain('user video quota is exceeded'); + (0, chai_1.expect)(videoImport.state.id).to.equal(3); + (0, chai_1.expect)(videoImport.error).not.to.be.undefined; + (0, chai_1.expect)(videoImport.error).to.contain('user video quota is exceeded'); } }); }); }); describe('When having a daily video quota', function () { it('Should fail with a user having too many videos daily', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId: rootId, videoQuotaDaily: 42 }); yield command.upload({ expectedStatus: models_1.HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }); yield command.upload({ expectedStatus: models_1.HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }); @@ -82,7 +82,7 @@ describe('Test upload quota', function () { }); describe('When having an absolute and daily video quota', function () { it('Should fail if exceeding total quota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId: rootId, videoQuota: 42, @@ -93,7 +93,7 @@ describe('Test upload quota', function () { }); }); it('Should fail if exceeding daily quota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId: rootId, videoQuota: 1024 * 1024 * 1024, @@ -105,8 +105,8 @@ describe('Test upload quota', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/user-notifications.js b/dist/server/tests/api/check-params/user-notifications.js index 05136854..2ac6bce4 100644 --- a/dist/server/tests/api/check-params/user-notifications.js +++ b/dist/server/tests/api/check-params/user-notifications.js @@ -8,32 +8,32 @@ const models_1 = require("@shared/models"); describe('Test user notifications API validators', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); describe('When listing my notifications', function () { const path = '/api/v1/users/me/notifications'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect unread parameter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { @@ -45,8 +45,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -54,8 +54,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -67,8 +67,8 @@ describe('Test user notifications API validators', function () { describe('When marking as read my notifications', function () { const path = '/api/v1/users/me/notifications/read'; it('Should fail with wrong ids parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { @@ -77,7 +77,7 @@ describe('Test user notifications API validators', function () { token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { @@ -86,7 +86,7 @@ describe('Test user notifications API validators', function () { token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { @@ -98,8 +98,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { @@ -110,8 +110,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { @@ -126,8 +126,8 @@ describe('Test user notifications API validators', function () { describe('When marking as read my notifications', function () { const path = '/api/v1/users/me/notifications/read-all'; it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -135,8 +135,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -166,8 +166,8 @@ describe('Test user notifications API validators', function () { newPluginVersion: 1 }; it('Should fail with missing fields', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -177,10 +177,10 @@ describe('Test user notifications API validators', function () { }); }); it('Should fail with incorrect field values', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const fields = Object.assign(Object.assign({}, correctFields), { newCommentOnMyVideo: 15 }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -190,7 +190,7 @@ describe('Test user notifications API validators', function () { } { const fields = Object.assign(Object.assign({}, correctFields), { newCommentOnMyVideo: 'toto' }); - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields, @@ -201,8 +201,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields: correctFields, @@ -211,8 +211,8 @@ describe('Test user notifications API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -224,7 +224,7 @@ describe('Test user notifications API validators', function () { }); describe('When connecting to my notification socket', function () { it('Should fail with no token', function (next) { - const socket = socket_io_client_1.io(`http://localhost:${server.port}/user-notifications`, { reconnection: false }); + const socket = (0, socket_io_client_1.io)(`http://localhost:${server.port}/user-notifications`, { reconnection: false }); socket.once('connect_error', function () { socket.disconnect(); next(); @@ -235,7 +235,7 @@ describe('Test user notifications API validators', function () { }); }); it('Should fail with an invalid token', function (next) { - const socket = socket_io_client_1.io(`http://localhost:${server.port}/user-notifications`, { + const socket = (0, socket_io_client_1.io)(`http://localhost:${server.port}/user-notifications`, { query: { accessToken: 'bad_access_token' }, reconnection: false }); @@ -249,7 +249,7 @@ describe('Test user notifications API validators', function () { }); }); it('Should success with the correct token', function (next) { - const socket = socket_io_client_1.io(`http://localhost:${server.port}/user-notifications`, { + const socket = (0, socket_io_client_1.io)(`http://localhost:${server.port}/user-notifications`, { query: { accessToken: server.accessToken }, reconnection: false }); @@ -257,16 +257,16 @@ describe('Test user notifications API validators', function () { next(new Error('Error in connection: ' + err)); } socket.on('connect_error', errorListener); - socket.once('connect', () => tslib_1.__awaiter(this, void 0, void 0, function* () { + socket.once('connect', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { socket.disconnect(); - yield extra_utils_1.wait(500); + yield (0, extra_utils_1.wait)(500); next(); })); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/user-subscriptions.js b/dist/server/tests/api/check-params/user-subscriptions.js index a6e649fd..e8c9fb08 100644 --- a/dist/server/tests/api/check-params/user-subscriptions.js +++ b/dist/server/tests/api/check-params/user-subscriptions.js @@ -9,10 +9,10 @@ describe('Test user subscriptions API validators', function () { let server; let userAccessToken = ''; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'user1', password: 'my super password' @@ -23,23 +23,23 @@ describe('Test user subscriptions API validators', function () { }); describe('When listing my subscriptions', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -47,8 +47,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -60,23 +60,23 @@ describe('Test user subscriptions API validators', function () { describe('When listing my subscriptions videos', function () { const path = '/api/v1/users/me/subscriptions/videos'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -84,8 +84,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -96,8 +96,8 @@ describe('Test user subscriptions API validators', function () { }); describe('When adding a subscription', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, fields: { uri: 'user1_channel@localhost:' + server.port }, @@ -106,22 +106,22 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with bad URIs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields: { uri: 'root' }, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields: { uri: 'root@' }, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -131,23 +131,23 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields: { uri: 'user1_channel@localhost:' + server.port }, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); }); }); }); describe('When getting a subscription', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/user1_channel@localhost:' + server.port, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -155,20 +155,20 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with bad URIs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/root', token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/root@', token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/root@hello@', token: server.accessToken, @@ -177,8 +177,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with an unknown subscription', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/root1@localhost:' + server.port, token: server.accessToken, @@ -187,8 +187,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '/user1_channel@localhost:' + server.port, token: server.accessToken, @@ -200,8 +200,8 @@ describe('Test user subscriptions API validators', function () { describe('When checking if subscriptions exist', function () { const existPath = path + '/exist'; it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: existPath, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -209,15 +209,15 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with bad URIs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: existPath, query: { uris: 'toto' }, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: existPath, query: { 'uris[]': 1 }, @@ -227,8 +227,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: existPath, query: { 'uris[]': 'coucou@localhost:' + server.port }, @@ -240,8 +240,8 @@ describe('Test user subscriptions API validators', function () { }); describe('When removing a subscription', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1_channel@localhost:' + server.port, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -249,20 +249,20 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with bad URIs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/root', token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makeDeleteRequest({ + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/root@', token: server.accessToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield extra_utils_1.makeDeleteRequest({ + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/root@hello@', token: server.accessToken, @@ -271,8 +271,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should fail with an unknown subscription', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/root1@localhost:' + server.port, token: server.accessToken, @@ -281,8 +281,8 @@ describe('Test user subscriptions API validators', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '/user1_channel@localhost:' + server.port, token: server.accessToken, @@ -292,8 +292,8 @@ describe('Test user subscriptions API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/users.js b/dist/server/tests/api/check-params/users.js index 0c4b236f..dafe367a 100644 --- a/dist/server/tests/api/check-params/users.js +++ b/dist/server/tests/api/check-params/users.js @@ -18,19 +18,19 @@ describe('Test users API validators', function () { let emailPort; let overrideConfig; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const emails = []; emailPort = yield extra_utils_1.MockSmtpServer.Instance.collectEmails(emails); overrideConfig = { signup: { limit: 8 } }; { const res = yield Promise.all([ - extra_utils_1.createSingleServer(1, overrideConfig), - extra_utils_1.createSingleServer(2) + (0, extra_utils_1.createSingleServer)(1, overrideConfig), + (0, extra_utils_1.createSingleServer)(2) ]); server = res[0]; serverWithRegistrationDisabled = res[1]; - yield extra_utils_1.setAccessTokensToServers([server]); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); } { const user = { username: 'user1' }; @@ -59,23 +59,23 @@ describe('Test users API validators', function () { }); describe('When listing users', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -83,8 +83,8 @@ describe('Test users API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, @@ -104,70 +104,70 @@ describe('Test users API validators', function () { adminFlags: 1 }; it('Should fail with a too small username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: '' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a too long username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'super'.repeat(50) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a not lowercase username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'Toto' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'my username' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a missing email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'email'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'email'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { email: 'test_example.com' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a too small password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: 'bla' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a too long password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: 'super'.repeat(61) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with empty password and no smtp configured', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: '' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should succeed with no password on a server with smtp enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); const config = Object.assign(Object.assign({}, overrideConfig), { smtp: { hostname: 'localhost', port: emailPort } }); yield server.run(config); const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: '', username: 'create_password', email: 'create_password@example.com' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path, token: server.accessToken, @@ -177,14 +177,14 @@ describe('Test users API validators', function () { }); }); it('Should fail with invalid admin flags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { adminFlags: 'toto' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: 'super token', @@ -194,9 +194,9 @@ describe('Test users API validators', function () { }); }); it('Should fail if we add a user with the same username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'user1' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -206,9 +206,9 @@ describe('Test users API validators', function () { }); }); it('Should fail if we add a user with the same email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { email: 'user1@example.com' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -218,45 +218,45 @@ describe('Test users API validators', function () { }); }); it('Should fail without a videoQuota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'videoQuota'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'videoQuota'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a videoQuotaDaily', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'videoQuotaDaily'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'videoQuotaDaily'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid videoQuota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { videoQuota: -5 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid videoQuotaDaily', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { videoQuotaDaily: -7 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a user role', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'role'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'role'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid user role', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { role: 88989 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a "peertube" username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'peertube' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -266,10 +266,10 @@ describe('Test users API validators', function () { }); }); it('Should fail to create a moderator or an admin with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const role of [models_1.UserRole.MODERATOR, models_1.UserRole.ADMINISTRATOR]) { const fields = Object.assign(Object.assign({}, baseCorrectParams), { role }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: moderatorToken, @@ -280,9 +280,9 @@ describe('Test users API validators', function () { }); }); it('Should succeed to create a user with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'a4656', email: 'a4656@example.com', role: models_1.UserRole.USER }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: moderatorToken, @@ -292,8 +292,8 @@ describe('Test users API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -303,7 +303,7 @@ describe('Test users API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'user1' }; userToken = yield server.login.getAccessToken(user); const fields = { @@ -312,53 +312,53 @@ describe('Test users API validators', function () { password: 'my super password', videoQuota: 42000000 }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userToken, fields, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); }); describe('When updating my account', function () { it('Should fail with an invalid email attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'blabla' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: server.accessToken, fields }); }); }); it('Should fail with a too small password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'bla' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with a too long password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'super'.repeat(61) }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail without the current password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'super'.repeat(61) }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an invalid current password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'my super password fail', password: 'super'.repeat(61) }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, @@ -368,44 +368,44 @@ describe('Test users API validators', function () { }); }); it('Should fail with an invalid NSFW policy attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { nsfwPolicy: 'hello' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an invalid autoPlayVideo attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { autoPlayVideo: -1 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an invalid autoPlayNextVideo attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { autoPlayNextVideo: -1 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an invalid videosHistoryEnabled attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { videosHistoryEnabled: -1 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'my super password' }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: 'super token', @@ -415,20 +415,20 @@ describe('Test users API validators', function () { }); }); it('Should fail with a too long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { description: 'super'.repeat(201) }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an invalid videoLanguages attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const fields = { videoLanguages: 'toto' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); } { const languages = []; @@ -438,24 +438,24 @@ describe('Test users API validators', function () { const fields = { videoLanguages: languages }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); } }); }); it('Should fail with an invalid theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { theme: 'invalid' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with an unknown theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { theme: 'peertube-theme-unknown' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); }); }); it('Should fail with invalid no modal attributes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const keys = [ 'noInstanceConfigWarningModal', 'noAccountSetupWarningModal', @@ -465,12 +465,12 @@ describe('Test users API validators', function () { const fields = { [key]: -1 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'me', token: userToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, fields }); } }); }); it('Should succeed to change password with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'my super password', @@ -482,7 +482,7 @@ describe('Test users API validators', function () { noWelcomeModal: true, noAccountSetupWarningModal: true }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, @@ -492,12 +492,12 @@ describe('Test users API validators', function () { }); }); it('Should succeed without password change with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { nsfwPolicy: 'blur', autoPlayVideo: false }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'me', token: userToken, @@ -509,30 +509,30 @@ describe('Test users API validators', function () { }); describe('When updating my avatar', function () { it('Should fail without an incorrect input file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; const attaches = { - avatarfile: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + avatarfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }); }); }); it('Should fail with a big file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; const attaches = { - avatarfile: extra_utils_1.buildAbsoluteFixturePath('avatar-big.png') + avatarfile: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }); }); }); it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; const attaches = { - avatarfile: extra_utils_1.buildAbsoluteFixturePath('avatar.png') + avatarfile: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: path + '/me/avatar/pick', fields, @@ -542,12 +542,12 @@ describe('Test users API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; const attaches = { - avatarfile: extra_utils_1.buildAbsoluteFixturePath('avatar.png') + avatarfile: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, @@ -560,40 +560,40 @@ describe('Test users API validators', function () { }); describe('When managing my scoped tokens', function () { it('Should fail to get my scoped tokens with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyScopedTokens({ token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail to get my scoped tokens with a bad token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyScopedTokens({ token: 'bad', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should succeed to get my scoped tokens', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyScopedTokens(); }); }); it('Should fail to renew my scoped tokens with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.renewMyScopedTokens({ token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail to renew my scoped tokens with a bad token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should succeed to renew my scoped tokens', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.renewMyScopedTokens(); }); }); }); describe('When getting a user', function () { it('Should fail with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + userId, token: 'super token', @@ -602,73 +602,73 @@ describe('Test users API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When updating a user', function () { it('Should fail with an invalid email attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'blabla' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with an invalid emailVerified attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { emailVerified: 'yes' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with an invalid videoQuota attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { videoQuota: -90 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with an invalid user role attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { role: 54878 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with a too small password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'bla' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with a too long password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentPassword: 'password', password: 'super'.repeat(61) }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, fields }); }); }); it('Should fail with an non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { videoQuota: 42 }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: 'super token', @@ -678,25 +678,25 @@ describe('Test users API validators', function () { }); }); it('Should fail when updating root role', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { role: models_1.UserRole.MODERATOR }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + rootId, token: server.accessToken, fields }); }); }); it('Should fail with invalid admin flags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { adminFlags: 'toto' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail to update an admin with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { videoQuota: 42 }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + moderatorId, token: moderatorToken, @@ -706,11 +706,11 @@ describe('Test users API validators', function () { }); }); it('Should succeed to update a user with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { videoQuota: 42 }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: moderatorToken, @@ -720,14 +720,14 @@ describe('Test users API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'email@example.com', emailVerified: true, videoQuota: 42, role: models_1.UserRole.USER }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + userId, token: server.accessToken, @@ -739,12 +739,12 @@ describe('Test users API validators', function () { }); describe('When getting my information', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyInfo({ token: 'fake_token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyInfo({ token: userToken }); }); }); @@ -755,22 +755,22 @@ describe('Test users API validators', function () { command = server.users; }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.getMyRating({ token: 'fake_token', videoId: video.id, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with an incorrect video uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.getMyRating({ videoId: 'blabla', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with an unknown video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.getMyRating({ videoId: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.getMyRating({ videoId: video.id }); yield command.getMyRating({ videoId: video.uuid }); yield command.getMyRating({ videoId: video.shortUUID }); @@ -780,33 +780,33 @@ describe('Test users API validators', function () { describe('When retrieving my global ratings', function () { const path = '/api/v1/accounts/user1/ratings'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, userToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, userToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, userToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, userToken); }); }); it('Should fail with a unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, @@ -816,14 +816,14 @@ describe('Test users API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userToken, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When blocking/unblocking/removing user', function () { it('Should fail with an incorrect id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId: 'blabla', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }; yield server.users.remove(options); yield server.users.banUser({ userId: 'blabla', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); @@ -831,7 +831,7 @@ describe('Test users API validators', function () { }); }); it('Should fail with the root user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId: rootId, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }; yield server.users.remove(options); yield server.users.banUser(options); @@ -839,7 +839,7 @@ describe('Test users API validators', function () { }); }); it('Should return 404 with a non existing id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId: 4545454, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }; yield server.users.remove(options); yield server.users.banUser(options); @@ -847,7 +847,7 @@ describe('Test users API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId, token: userToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }; yield server.users.remove(options); yield server.users.banUser(options); @@ -855,7 +855,7 @@ describe('Test users API validators', function () { }); }); it('Should fail on a moderator with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId: moderatorId, token: moderatorToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }; yield server.users.remove(options); yield server.users.banUser(options); @@ -863,7 +863,7 @@ describe('Test users API validators', function () { }); }); it('Should succeed on a user with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const options = { userId, token: moderatorToken }; yield server.users.banUser(options); yield server.users.unbanUser(options); @@ -872,7 +872,7 @@ describe('Test users API validators', function () { }); describe('When deleting our account', function () { it('Should fail with with the root account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.deleteMe({ expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); @@ -886,51 +886,51 @@ describe('Test users API validators', function () { password: 'my super password' }; it('Should fail with a too small username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: '' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a too long username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'super'.repeat(50) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'my username' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a missing email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'email'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'email'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with an invalid email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { email: 'test_example.com' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a too small password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: 'bla' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a too long password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { password: 'super'.repeat(61) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail if we register a user with the same username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'root' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, @@ -940,9 +940,9 @@ describe('Test users API validators', function () { }); }); it('Should fail with a "peertube" username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { username: 'peertube' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, @@ -952,9 +952,9 @@ describe('Test users API validators', function () { }); }); it('Should fail if we register a user with the same email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { email: 'admin' + server.internalServerNumber + '@example.com' }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, @@ -964,36 +964,36 @@ describe('Test users API validators', function () { }); }); it('Should fail with a bad display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { displayName: 'a'.repeat(150) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a bad channel name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channel: { name: '[]azf', displayName: 'toto' } }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a bad channel display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channel: { name: 'toto', displayName: '' } }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with a channel name that is the same as username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }; const fields = Object.assign(Object.assign({}, baseCorrectParams), source); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, fields }); }); }); it('Should fail with an existing channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }; yield server.channels.create({ attributes }); const fields = Object.assign(Object.assign({}, baseCorrectParams), { channel: { name: 'existing_channel', displayName: 'toto' } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, @@ -1003,9 +1003,9 @@ describe('Test users API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channel: { name: 'super_channel', displayName: 'toto' } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: registrationPath, token: server.accessToken, @@ -1015,13 +1015,13 @@ describe('Test users API validators', function () { }); }); it('Should fail on a server with registration disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { username: 'user4', email: 'test4@example.com', password: 'my super password 4' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: serverWithRegistrationDisabled.url, path: registrationPath, token: serverWithRegistrationDisabled.accessToken, @@ -1033,7 +1033,7 @@ describe('Test users API validators', function () { }); describe('When registering multiple users on a server with users limit', function () { it('Should fail when after 3 registrations', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.register({ username: 'user42', expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); @@ -1041,21 +1041,21 @@ describe('Test users API validators', function () { describe('When asking a password reset', function () { const path = '/api/v1/users/ask-reset-password'; it('Should fail with a missing email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'hello' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should success with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'admin@example.com' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -1068,21 +1068,21 @@ describe('Test users API validators', function () { describe('When asking for an account verification email', function () { const path = '/api/v1/users/ask-send-verify-email'; it('Should fail with a missing email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an invalid email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'hello' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { email: 'admin@example.com' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -1093,9 +1093,9 @@ describe('Test users API validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server, serverWithRegistrationDisabled]); + yield (0, extra_utils_1.cleanupTests)([server, serverWithRegistrationDisabled]); }); }); }); diff --git a/dist/server/tests/api/check-params/video-blacklist.js b/dist/server/tests/api/check-params/video-blacklist.js index ad693482..ee50e601 100644 --- a/dist/server/tests/api/check-params/video-blacklist.js +++ b/dist/server/tests/api/check-params/video-blacklist.js @@ -13,11 +13,11 @@ describe('Test video blacklist API validators', function () { let userAccessToken2 = ''; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); { const username = 'user1'; const password = 'my super password'; @@ -41,38 +41,38 @@ describe('Test video blacklist API validators', function () { const { uuid } = yield servers[1].videos.upload(); remoteVideoUUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].blacklist; }); }); describe('When adding a video in blacklist', function () { const basePath = '/api/v1/videos/'; it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated + '/blacklist'; const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, fields }); }); }); it('Should fail with a wrong video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const wrongPath = '/api/v1/videos/blabla/blacklist'; const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: servers[0].url, path: wrongPath, token: servers[0].accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path: wrongPath, token: servers[0].accessToken, fields }); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated + '/blacklist'; const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated + '/blacklist'; const fields = {}; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: userAccessToken2, @@ -82,17 +82,17 @@ describe('Test video blacklist API validators', function () { }); }); it('Should fail with an invalid reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'; const fields = { reason: 'a'.repeat(305) }; - yield extra_utils_1.makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, fields }); }); }); it('Should fail to unfederate a remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + remoteVideoUUID + '/blacklist'; const fields = { unfederate: true }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, @@ -102,10 +102,10 @@ describe('Test video blacklist API validators', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'; const fields = {}; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, @@ -118,17 +118,17 @@ describe('Test video blacklist API validators', function () { describe('When updating a video in blacklist', function () { const basePath = '/api/v1/videos/'; it('Should fail with a wrong video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const wrongPath = '/api/v1/videos/blabla/blacklist'; const fields = {}; - yield extra_utils_1.makePutBodyRequest({ url: servers[0].url, path: wrongPath, token: servers[0].accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path: wrongPath, token: servers[0].accessToken, fields }); }); }); it('Should fail with a video not blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/' + notBlacklistedVideoId + '/blacklist'; const fields = {}; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, @@ -138,17 +138,17 @@ describe('Test video blacklist API validators', function () { }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated + '/blacklist'; const fields = {}; - yield extra_utils_1.makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated + '/blacklist'; const fields = {}; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path, token: userAccessToken2, @@ -158,17 +158,17 @@ describe('Test video blacklist API validators', function () { }); }); it('Should fail with an invalid reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'; const fields = { reason: 'a'.repeat(305) }; - yield extra_utils_1.makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, fields }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = basePath + servers[0].store.videoCreated.shortUUID + '/blacklist'; const fields = { reason: 'hello' }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: servers[0].url, path, token: servers[0].accessToken, @@ -180,12 +180,12 @@ describe('Test video blacklist API validators', function () { }); describe('When getting blacklisted video', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.get({ id: servers[0].store.videoCreated.uuid, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: userAccessToken2, id: servers[0].store.videoCreated.uuid, @@ -194,24 +194,24 @@ describe('Test video blacklist API validators', function () { }); }); it('Should succeed with the owner authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.videoCreated.uuid }); - chai_1.expect(video.blacklisted).to.be.true; + (0, chai_1.expect)(video.blacklisted).to.be.true; }); }); it('Should succeed with an admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = servers[0].store.videoCreated; for (const id of [video.id, video.uuid, video.shortUUID]) { const video = yield servers[0].videos.getWithToken({ id, expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(video.blacklisted).to.be.true; + (0, chai_1.expect)(video.blacklisted).to.be.true; } }); }); }); describe('When removing a video in blacklist', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ token: 'fake token', videoId: servers[0].store.videoCreated.uuid, @@ -220,7 +220,7 @@ describe('Test video blacklist API validators', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ token: userAccessToken2, videoId: servers[0].store.videoCreated.uuid, @@ -229,17 +229,17 @@ describe('Test video blacklist API validators', function () { }); }); it('Should fail with an incorrect id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ videoId: 'hello', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with a not blacklisted video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ videoId: notBlacklistedVideoId, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ videoId: servers[0].store.videoCreated.uuid, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); }); }); @@ -247,44 +247,44 @@ describe('Test video blacklist API validators', function () { describe('When listing videos in blacklist', function () { const basePath = '/api/v1/videos/blacklist/'; it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].blacklist.list({ token: 'fake token', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(servers[0].url, basePath, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(servers[0].url, basePath, servers[0].accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(servers[0].url, basePath, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(servers[0].url, basePath, servers[0].accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(servers[0].url, basePath, servers[0].accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(servers[0].url, basePath, servers[0].accessToken); }); }); it('Should fail with an invalid type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].blacklist.list({ type: 0, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].blacklist.list({ type: 1 }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/check-params/video-captions.js b/dist/server/tests/api/check-params/video-captions.js index 42f13f61..6b741ac2 100644 --- a/dist/server/tests/api/check-params/video-captions.js +++ b/dist/server/tests/api/check-params/video-captions.js @@ -10,10 +10,10 @@ describe('Test video captions API validator', function () { let userAccessToken; let video; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); video = yield server.videos.upload(); { const user = { @@ -28,11 +28,11 @@ describe('Test video captions API validator', function () { describe('When adding video caption', function () { const fields = {}; const attaches = { - captionfile: extra_utils_1.buildAbsoluteFixturePath('subtitle-good1.vtt') + captionfile: (0, extra_utils_1.buildAbsoluteFixturePath)('subtitle-good1.vtt') }; it('Should fail without a valid uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeUploadRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df563d0b06/captions/fr', @@ -43,8 +43,8 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with an unknown id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeUploadRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', @@ -56,9 +56,9 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with a missing language in path', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.uuid + '/captions'; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: captionPath, @@ -69,9 +69,9 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with an unknown language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.uuid + '/captions/15'; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: captionPath, @@ -82,9 +82,9 @@ describe('Test video captions API validator', function () { }); }); it('Should fail without access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.uuid + '/captions/fr'; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: captionPath, @@ -95,9 +95,9 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with a bad access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.uuid + '/captions/fr'; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: captionPath, @@ -109,7 +109,7 @@ describe('Test video captions API validator', function () { }); }); it('Should succeed with a valid captionfile extension and octet-stream mime type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.captions.add({ language: 'zh', videoId: video.uuid, @@ -119,9 +119,9 @@ describe('Test video captions API validator', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.uuid + '/captions/fr'; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ method: 'PUT', url: server.url, path: captionPath, @@ -135,13 +135,13 @@ describe('Test video captions API validator', function () { }); describe('When listing video captions', function () { it('Should fail without a valid uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df563d0b06/captions' }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df563d0b06/captions' }); }); }); it('Should fail with an unknown id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -149,15 +149,15 @@ describe('Test video captions API validator', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When deleting video caption', function () { it('Should fail without a valid uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df563d0b06/captions/fr', token: server.accessToken @@ -165,8 +165,8 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with an unknown id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', token: server.accessToken, @@ -175,8 +175,8 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with an invalid language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/16', token: server.accessToken @@ -184,33 +184,33 @@ describe('Test video captions API validator', function () { }); }); it('Should fail with a missing language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions'; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, token: server.accessToken }); }); }); it('Should fail with an unknown language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions/15'; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, token: server.accessToken }); }); }); it('Should fail without access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions/fr'; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path: captionPath, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a bad access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions/fr'; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions/fr'; - yield extra_utils_1.makeDeleteRequest({ + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, token: userAccessToken, @@ -219,9 +219,9 @@ describe('Test video captions API validator', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const captionPath = path + video.shortUUID + '/captions/fr'; - yield extra_utils_1.makeDeleteRequest({ + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: captionPath, token: server.accessToken, @@ -231,8 +231,8 @@ describe('Test video captions API validator', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/video-channels.js b/dist/server/tests/api/check-params/video-channels.js index 4a16223c..c8c5b9ae 100644 --- a/dist/server/tests/api/check-params/video-channels.js +++ b/dist/server/tests/api/check-params/video-channels.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); @@ -13,10 +13,10 @@ describe('Test video channels API validator', function () { let accessTokenUser; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const user = { username: 'fake', password: 'fake_password' @@ -30,46 +30,46 @@ describe('Test video channels API validator', function () { }); describe('When listing a video channels', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, videoChannelPath, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, videoChannelPath, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, videoChannelPath, server.accessToken); }); }); }); describe('When listing account video channels', function () { const accountChannelPath = '/api/v1/accounts/fake/video-channels'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, accountChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, accountChannelPath, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, accountChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, accountChannelPath, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, accountChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, accountChannelPath, server.accessToken); }); }); it('Should fail with a unknown account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.channels.listByAccount({ accountName: 'unknown', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: accountChannelPath, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -85,8 +85,8 @@ describe('Test video channels API validator', function () { support: 'super support text' }; it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: 'none', @@ -96,50 +96,50 @@ describe('Test video channels API validator', function () { }); }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail without a name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'name'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'name'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail with a bad name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { name: 'super name' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail without a name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'displayName'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'displayName'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { displayName: 'super'.repeat(25) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(201) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, @@ -149,8 +149,8 @@ describe('Test video channels API validator', function () { }); }); it('Should fail when adding a channel with the same username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: videoChannelPath, token: server.accessToken, @@ -169,13 +169,13 @@ describe('Test video channels API validator', function () { }; let path; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { path = videoChannelPath + '/super_channel'; }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: 'hi', @@ -185,8 +185,8 @@ describe('Test video channels API validator', function () { }); }); it('Should fail with another authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: accessTokenUser, @@ -196,32 +196,32 @@ describe('Test video channels API validator', function () { }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { displayName: 'super'.repeat(25) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(201) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad bulkVideosSupportUpdate field', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { bulkVideosSupportUpdate: 'super' }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePutBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -235,40 +235,40 @@ describe('Test video channels API validator', function () { const types = ['avatar', 'banner']; let path; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { path = videoChannelPath + '/super_channel'; }); }); it('Should fail with an incorrect input file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const type of types) { const fields = {}; const attaches = { - [type + 'file']: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + [type + 'file']: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }); } }); }); it('Should fail with a big file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const type of types) { const fields = {}; const attaches = { - [type + 'file']: extra_utils_1.buildAbsoluteFixturePath('avatar-big.png') + [type + 'file']: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }); } }); }); it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const type of types) { const fields = {}; const attaches = { - [type + 'file']: extra_utils_1.buildAbsoluteFixturePath('avatar.png') + [type + 'file']: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: `${path}/${type}/pick`, fields, @@ -279,13 +279,13 @@ describe('Test video channels API validator', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const type of types) { const fields = {}; const attaches = { - [type + 'file']: extra_utils_1.buildAbsoluteFixturePath('avatar.png') + [type + 'file']: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, @@ -299,8 +299,8 @@ describe('Test video channels API validator', function () { }); describe('When getting a video channel', function () { it('Should return the list of the video channels with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoChannelPath, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -309,8 +309,8 @@ describe('Test video channels API validator', function () { }); }); it('Should return 404 with an incorrect video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoChannelPath + '/super_channel2', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -318,8 +318,8 @@ describe('Test video channels API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoChannelPath + '/super_channel', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -329,34 +329,34 @@ describe('Test video channels API validator', function () { }); describe('When deleting a video channel', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ token: 'coucou', channelName: 'super_channel', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with another authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ token: accessTokenUser, channelName: 'super_channel', expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with an unknown video channel id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ channelName: 'super_channel2', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ channelName: 'super_channel' }); }); }); it('Should fail to delete the last user video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ channelName: 'root_channel', expectedStatus: models_1.HttpStatusCode.CONFLICT_409 }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/video-comments.js b/dist/server/tests/api/check-params/video-comments.js index 86d3eeb2..2327d5ed 100644 --- a/dist/server/tests/api/check-params/video-comments.js +++ b/dist/server/tests/api/check-params/video-comments.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -15,10 +15,10 @@ describe('Test video comments API validator', function () { let userAccessToken2; let commentId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); { video = yield server.videos.upload({ attributes: {} }); pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'; @@ -42,23 +42,23 @@ describe('Test video comments API validator', function () { }); describe('When listing video comment threads', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, pathThread, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, pathThread, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, pathThread, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, pathThread, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, pathThread, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, pathThread, server.accessToken); }); }); it('Should fail with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -68,8 +68,8 @@ describe('Test video comments API validator', function () { }); describe('When listing comments of a thread', function () { it('Should fail with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -77,8 +77,8 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with an incorrect thread id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -86,8 +86,8 @@ describe('Test video comments API validator', function () { }); }); it('Should success with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -97,11 +97,11 @@ describe('Test video comments API validator', function () { }); describe('When adding a video thread', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'text' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: 'none', @@ -111,34 +111,34 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathThread, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: server.accessToken, fields }); }); }); it('Should fail with a short comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: '' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathThread, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: server.accessToken, fields }); }); }); it('Should fail with a long comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'h'.repeat(10001) }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathThread, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads'; const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -148,11 +148,11 @@ describe('Test video comments API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: server.accessToken, @@ -164,11 +164,11 @@ describe('Test video comments API validator', function () { }); describe('When adding a comment to a thread', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'text' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathComment, token: 'none', @@ -178,34 +178,34 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathComment, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathComment, token: server.accessToken, fields }); }); }); it('Should fail with a short comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: '' }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathComment, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathComment, token: server.accessToken, fields }); }); }); it('Should fail with a long comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'h'.repeat(10001) }; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: pathComment, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathComment, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId; const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -215,12 +215,12 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with an incorrect comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/' + video.uuid + '/comments/124'; const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -230,11 +230,11 @@ describe('Test video comments API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathComment, token: server.accessToken, @@ -246,13 +246,13 @@ describe('Test video comments API validator', function () { }); describe('When removing video comments', function () { it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: pathComment, token: 'none', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: pathComment, token: userAccessToken, @@ -261,31 +261,31 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with an incorrect comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/' + video.uuid + '/comments/124'; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: server.accessToken, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should succeed with the same user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let commentToDelete; { const created = yield server.comments.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' }); commentToDelete = created.id; } const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: userAccessToken2, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); }); }); it('Should succeed with the owner of the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let commentToDelete; let anotherVideoUUID; { @@ -297,13 +297,13 @@ describe('Test video comments API validator', function () { commentToDelete = created.id; } const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete; - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); - yield extra_utils_1.makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: userAccessToken2, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, token: userAccessToken, expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path: pathComment, token: server.accessToken, @@ -314,14 +314,14 @@ describe('Test video comments API validator', function () { }); describe('When a video has comments disabled', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { video = yield server.videos.upload({ attributes: { commentsEnabled: false } }); pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'; }); }); it('Should return an empty thread list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: pathThread, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -332,11 +332,11 @@ describe('Test video comments API validator', function () { }); it('Should return an thread comments list'); it('Should return conflict on thread add', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { text: 'super comment' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: pathThread, token: server.accessToken, @@ -350,23 +350,23 @@ describe('Test video comments API validator', function () { describe('When listing admin comments threads', function () { const path = '/api/v1/videos/comments'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 @@ -374,8 +374,8 @@ describe('Test video comments API validator', function () { }); }); it('Should fail with a non admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: userAccessToken, @@ -384,8 +384,8 @@ describe('Test video comments API validator', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token: server.accessToken, @@ -401,8 +401,8 @@ describe('Test video comments API validator', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/video-imports.js b/dist/server/tests/api/check-params/video-imports.js index e7fa3616..2e06980a 100644 --- a/dist/server/tests/api/check-params/video-imports.js +++ b/dist/server/tests/api/check-params/video-imports.js @@ -11,10 +11,10 @@ describe('Test video imports API validator', function () { let userAccessToken = ''; let channelId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const username = 'user1'; const password = 'my super password'; yield server.users.create({ username: username, password: password }); @@ -28,23 +28,23 @@ describe('Test video imports API validator', function () { describe('When listing my video imports', function () { const myPath = '/api/v1/users/me/videos/imports'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, myPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, myPath, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, myPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, myPath, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, myPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, myPath, server.accessToken); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: myPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: myPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); }); }); }); @@ -69,15 +69,15 @@ describe('Test video imports API validator', function () { }; }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a target url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'targetUrl'); - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'targetUrl'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -87,61 +87,61 @@ describe('Test video imports API validator', function () { }); }); it('Should fail with a bad target url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { targetUrl: 'htt://hello' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { name: 'super'.repeat(65) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { category: 125 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { licence: 125 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { language: 'a'.repeat(15) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(2500) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'channelId'); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'channelId'); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a bad channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: 545454 }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with another user channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'fake', password: 'fake_password' @@ -151,83 +151,83 @@ describe('Test video imports API validator', function () { const { videoChannels } = yield server.users.getMyInfo({ token: accessTokenUser }); const customChannelId = videoChannels[0].id; const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: customChannelId }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: userAccessToken, fields }); }); }); it('Should fail with too many tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too low', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 't'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too big', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'my_super_tag_too_long_long_long_long_long_long'] }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + thumbnailfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with a big thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: extra_utils_1.buildAbsoluteFixturePath('preview-big.png') + thumbnailfile: (0, extra_utils_1.buildAbsoluteFixturePath)('preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with an incorrect preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: extra_utils_1.buildAbsoluteFixturePath('video_short.mp4') + previewfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with a big preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: extra_utils_1.buildAbsoluteFixturePath('preview-big.png') + previewfile: (0, extra_utils_1.buildAbsoluteFixturePath)('preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with an invalid torrent file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'targetUrl'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'targetUrl'); const attaches = { - torrentfile: extra_utils_1.buildAbsoluteFixturePath('avatar-big.png') + torrentfile: (0, extra_utils_1.buildAbsoluteFixturePath)('avatar-big.png') }; - yield extra_utils_1.makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }); + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, fields, attaches }); }); }); it('Should fail with an invalid magnet URI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - let fields = lodash_1.omit(baseCorrectParams, 'targetUrl'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + let fields = (0, lodash_1.omit)(baseCorrectParams, 'targetUrl'); fields = Object.assign(Object.assign({}, fields), { magnetUri: 'blabla' }); - yield extra_utils_1.makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -237,7 +237,7 @@ describe('Test video imports API validator', function () { }); }); it('Should forbid to import http videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { import: { @@ -252,7 +252,7 @@ describe('Test video imports API validator', function () { } } }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, @@ -262,7 +262,7 @@ describe('Test video imports API validator', function () { }); }); it('Should forbid to import torrent videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { import: { @@ -277,20 +277,20 @@ describe('Test video imports API validator', function () { } } }); - let fields = lodash_1.omit(baseCorrectParams, 'targetUrl'); + let fields = (0, lodash_1.omit)(baseCorrectParams, 'targetUrl'); fields = Object.assign(Object.assign({}, fields), { magnetUri: extra_utils_1.FIXTURE_URLS.magnet }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path, token: server.accessToken, fields, expectedStatus: models_1.HttpStatusCode.CONFLICT_409 }); - fields = lodash_1.omit(fields, 'magnetUri'); + fields = (0, lodash_1.omit)(fields, 'magnetUri'); const attaches = { - torrentfile: extra_utils_1.buildAbsoluteFixturePath('video-720p.torrent') + torrentfile: (0, extra_utils_1.buildAbsoluteFixturePath)('video-720p.torrent') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, path, token: server.accessToken, @@ -302,8 +302,8 @@ describe('Test video imports API validator', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/video-playlists.js b/dist/server/tests/api/check-params/video-playlists.js index 3202406e..5fc6762a 100644 --- a/dist/server/tests/api/check-params/video-playlists.js +++ b/dist/server/tests/api/check-params/video-playlists.js @@ -14,11 +14,11 @@ describe('Test video playlists API validator', function () { let elementId; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); userAccessToken = yield server.users.generateUserAndToken('user1'); videoId = (yield server.videos.quickUpload({ name: 'video 1' })).id; command = server.playlists; @@ -57,37 +57,37 @@ describe('Test video playlists API validator', function () { const accountPath = '/api/v1/accounts/root/video-playlists'; const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, globalPath, server.accessToken); - yield extra_utils_1.checkBadStartPagination(server.url, accountPath, server.accessToken); - yield extra_utils_1.checkBadStartPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, globalPath, server.accessToken); + yield (0, extra_utils_1.checkBadStartPagination)(server.url, accountPath, server.accessToken); + yield (0, extra_utils_1.checkBadStartPagination)(server.url, videoChannelPath, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, globalPath, server.accessToken); - yield extra_utils_1.checkBadCountPagination(server.url, accountPath, server.accessToken); - yield extra_utils_1.checkBadCountPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, globalPath, server.accessToken); + yield (0, extra_utils_1.checkBadCountPagination)(server.url, accountPath, server.accessToken); + yield (0, extra_utils_1.checkBadCountPagination)(server.url, videoChannelPath, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, globalPath, server.accessToken); - yield extra_utils_1.checkBadSortPagination(server.url, accountPath, server.accessToken); - yield extra_utils_1.checkBadSortPagination(server.url, videoChannelPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, globalPath, server.accessToken); + yield (0, extra_utils_1.checkBadSortPagination)(server.url, accountPath, server.accessToken); + yield (0, extra_utils_1.checkBadSortPagination)(server.url, videoChannelPath, server.accessToken); }); }); it('Should fail with a bad playlist type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: globalPath, query: { playlistType: 3 } }); - yield extra_utils_1.makeGetRequest({ url: server.url, path: accountPath, query: { playlistType: 3 } }); - yield extra_utils_1.makeGetRequest({ url: server.url, path: videoChannelPath, query: { playlistType: 3 } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: globalPath, query: { playlistType: 3 } }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: accountPath, query: { playlistType: 3 } }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoChannelPath, query: { playlistType: 3 } }); }); }); it('Should fail with a bad account parameter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountPath = '/api/v1/accounts/root2/video-playlists'; - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: accountPath, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404, @@ -96,9 +96,9 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with a bad video channel parameter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountPath = '/api/v1/video-channels/bad_channel/video-playlists'; - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: accountPath, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404, @@ -107,10 +107,10 @@ describe('Test video playlists API validator', function () { }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: globalPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); - yield extra_utils_1.makeGetRequest({ url: server.url, path: accountPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: globalPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: accountPath, expectedStatus: models_1.HttpStatusCode.OK_200, token: server.accessToken }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoChannelPath, expectedStatus: models_1.HttpStatusCode.OK_200, @@ -122,34 +122,34 @@ describe('Test video playlists API validator', function () { describe('When listing videos of a playlist', function () { const path = '/api/v1/video-playlists/'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path + playlist.shortUUID + '/videos', server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path + playlist.shortUUID + '/videos', server.accessToken); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When getting a video playlist', function () { it('Should fail with a bad id or uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ playlistId: 'toto', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with an unknown playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ playlistId: 42, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail to get an unlisted playlist with the number id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlist = yield command.create({ attributes: { displayName: 'super playlist', @@ -162,7 +162,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.get({ playlistId: playlist.uuid, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); @@ -175,62 +175,62 @@ describe('Test video playlists API validator', function () { return Object.assign(Object.assign({}, params), { playlistId: playlistId }); }; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail without displayName', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ displayName: undefined }); yield command.create(params); }); }); it('Should fail with an incorrect display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ displayName: 's'.repeat(300) }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail with an incorrect description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ description: 't' }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail with an incorrect privacy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ privacy: 45 }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail with an unknown video channel id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ videoChannelId: 42 }, { expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail with an incorrect thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ thumbnailfile: 'video_short.mp4' }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail with a thumbnail file too big', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ thumbnailfile: 'preview-big.png' }); yield command.create(params); yield command.update(getUpdate(params, playlist.shortUUID)); }); }); it('Should fail to set "public" a playlist not assigned to a channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ privacy: 1, videoChannelId: undefined }); const params2 = getBase({ privacy: 1, videoChannelId: 'null' }); const params3 = getBase({ privacy: undefined, videoChannelId: 'null' }); @@ -242,22 +242,22 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown playlist to update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update(getUpdate(getBase({}, { expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }), 42)); }); }); it('Should fail to update a playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update(getUpdate(getBase({}, { token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }), playlist.shortUUID)); }); }); it('Should fail to update the watch later playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update(getUpdate(getBase({}, { expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }), watchLaterPlaylistId)); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({}, { expectedStatus: models_1.HttpStatusCode.OK_200 }); yield command.create(params); @@ -274,19 +274,19 @@ describe('Test video playlists API validator', function () { return Object.assign({ attributes: Object.assign({ videoId, startTimestamp: 2, stopTimestamp: 3 }, attributes), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400, playlistId: playlist.id }, wrapper); }; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield command.addElement(params); }); }); it('Should fail with the playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); yield command.addElement(params); }); }); it('Should fail with an unknown or incorrect playlist id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({}, { playlistId: 'toto' }); yield command.addElement(params); @@ -298,13 +298,13 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown or incorrect video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ videoId: 42 }, { expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield command.addElement(params); }); }); it('Should fail with a bad start/stop timestamp', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ startTimestamp: -42 }); yield command.addElement(params); @@ -316,7 +316,7 @@ describe('Test video playlists API validator', function () { }); }); it('Succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { expectedStatus: models_1.HttpStatusCode.OK_200 }); const created = yield command.addElement(params); elementId = created.id; @@ -328,19 +328,19 @@ describe('Test video playlists API validator', function () { return Object.assign({ attributes: Object.assign({ startTimestamp: 1, stopTimestamp: 2 }, attributes), elementId, playlistId: playlist.id, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, wrapper); }; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield command.updateElement(params); }); }); it('Should fail with the playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); yield command.updateElement(params); }); }); it('Should fail with an unknown or incorrect playlist id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({}, { playlistId: 'toto' }); yield command.updateElement(params); @@ -352,7 +352,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown or incorrect playlistElement id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({}, { elementId: 'toto' }); yield command.updateElement(params); @@ -364,7 +364,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with a bad start/stop timestamp', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ startTimestamp: 'toto' }); yield command.updateElement(params); @@ -376,13 +376,13 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { elementId: 888, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield command.updateElement(params); }); }); it('Succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); yield command.updateElement(params); }); @@ -395,7 +395,7 @@ describe('Test video playlists API validator', function () { return Object.assign({ attributes: Object.assign({ startPosition: 1, insertAfterPosition: 2, reorderLength: 3 }, attributes), playlistId: playlist.shortUUID, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, wrapper); }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { videoId3 = (yield server.videos.quickUpload({ name: 'video 3' })).id; videoId4 = (yield server.videos.quickUpload({ name: 'video 4' })).id; for (const id of [videoId3, videoId4]) { @@ -404,19 +404,19 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield command.reorderElements(params); }); }); it('Should fail with the playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); yield command.reorderElements(params); }); }); it('Should fail with an invalid playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({}, { playlistId: 'toto' }); yield command.reorderElements(params); @@ -428,7 +428,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an invalid start position', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ startPosition: -1 }); yield command.reorderElements(params); @@ -444,7 +444,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an invalid insert after position', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ insertAfterPosition: 'toto' }); yield command.reorderElements(params); @@ -460,7 +460,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an invalid reorder length', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ reorderLength: 'toto' }); yield command.reorderElements(params); @@ -476,7 +476,7 @@ describe('Test video playlists API validator', function () { }); }); it('Succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({}, { expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); yield command.reorderElements(params); }); @@ -485,8 +485,8 @@ describe('Test video playlists API validator', function () { describe('When checking exists in playlist endpoint', function () { const path = '/api/v1/users/me/video-playlists/videos-exist'; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, query: { videoIds: [1, 2] }, @@ -495,20 +495,20 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with invalid video ids', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, query: { videoIds: 'toto' } }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, query: { videoIds: ['toto'] } }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, @@ -517,8 +517,8 @@ describe('Test video playlists API validator', function () { }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, @@ -533,19 +533,19 @@ describe('Test video playlists API validator', function () { return Object.assign({ elementId, playlistId: playlist.uuid, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, wrapper); }; it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ token: null, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield command.removeElement(params); }); }); it('Should fail with the playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ token: userAccessToken, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); yield command.removeElement(params); }); }); it('Should fail with an unknown or incorrect playlist id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ playlistId: 'toto' }); yield command.removeElement(params); @@ -557,7 +557,7 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown or incorrect video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const params = getBase({ elementId: 'toto' }); yield command.removeElement(params); @@ -569,13 +569,13 @@ describe('Test video playlists API validator', function () { }); }); it('Should fail with an unknown element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ elementId: 888, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield command.removeElement(params); }); }); it('Succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const params = getBase({ expectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }); yield command.removeElement(params); }); @@ -583,29 +583,29 @@ describe('Test video playlists API validator', function () { }); describe('When deleting a playlist', function () { it('Should fail with an unknown playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ playlistId: 42, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a playlist of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ token: userAccessToken, playlistId: playlist.uuid, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with the watch later playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ playlistId: watchLaterPlaylistId, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ playlistId: playlist.uuid }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/videos-filter.js b/dist/server/tests/api/check-params/videos-filter.js index b1394989..e75f6144 100644 --- a/dist/server/tests/api/check-params/videos-filter.js +++ b/dist/server/tests/api/check-params/videos-filter.js @@ -5,7 +5,7 @@ require("mocha"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); function testEndpoints(server, token, filter, expectedStatus) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/api/v1/video-channels/root_channel/videos', '/api/v1/accounts/root/videos', @@ -13,7 +13,7 @@ function testEndpoints(server, token, filter, expectedStatus) { '/api/v1/search/videos' ]; for (const path of paths) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token, @@ -30,11 +30,11 @@ describe('Test video filters validators', function () { let userAccessToken; let moderatorAccessToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); const user = { username: 'user1', password: 'my super password' }; yield server.users.create({ username: user.username, password: user.password }); userAccessToken = yield server.login.getAccessToken(user); @@ -45,37 +45,37 @@ describe('Test video filters validators', function () { }); describe('When setting a video filter', function () { it('Should fail with a bad filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testEndpoints(server, server.accessToken, 'bad-filter', models_1.HttpStatusCode.BAD_REQUEST_400); }); }); it('Should succeed with a good filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testEndpoints(server, server.accessToken, 'local', models_1.HttpStatusCode.OK_200); }); }); it('Should fail to list all-local/all with a simple user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testEndpoints(server, userAccessToken, 'all-local', models_1.HttpStatusCode.UNAUTHORIZED_401); yield testEndpoints(server, userAccessToken, 'all', models_1.HttpStatusCode.UNAUTHORIZED_401); }); }); it('Should succeed to list all-local/all with a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testEndpoints(server, moderatorAccessToken, 'all-local', models_1.HttpStatusCode.OK_200); yield testEndpoints(server, moderatorAccessToken, 'all', models_1.HttpStatusCode.OK_200); }); }); it('Should succeed to list all-local/all with an admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testEndpoints(server, server.accessToken, 'all-local', models_1.HttpStatusCode.OK_200); yield testEndpoints(server, server.accessToken, 'all', models_1.HttpStatusCode.OK_200); }); }); it('Should fail on the feeds endpoint with the all-local/all filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const filter of ['all', 'all-local']) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/feeds/videos.json', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401, @@ -87,8 +87,8 @@ describe('Test video filters validators', function () { }); }); it('Should succeed on the feeds endpoint with the local filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/feeds/videos.json', expectedStatus: models_1.HttpStatusCode.OK_200, @@ -100,8 +100,8 @@ describe('Test video filters validators', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/videos-history.js b/dist/server/tests/api/check-params/videos-history.js index 65b8979e..924a8706 100644 --- a/dist/server/tests/api/check-params/videos-history.js +++ b/dist/server/tests/api/check-params/videos-history.js @@ -10,26 +10,26 @@ describe('Test videos history API validator', function () { let watchingPath; let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { uuid } = yield server.videos.upload(); watchingPath = '/api/v1/videos/' + uuid + '/watching'; }); }); describe('When notifying a user is watching a video', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentTime: 5 }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: watchingPath, fields, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with an incorrect video id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentTime: 5 }; const path = '/api/v1/videos/blabla/watching'; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields, @@ -39,10 +39,10 @@ describe('Test videos history API validator', function () { }); }); it('Should fail with an unknown video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentTime: 5 }; const path = '/api/v1/videos/d91fff41-c24d-4508-8e13-3bd5902c3b02/watching'; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, fields, @@ -52,9 +52,9 @@ describe('Test videos history API validator', function () { }); }); it('Should fail with a bad current time', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentTime: 'hello' }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: watchingPath, fields, @@ -64,9 +64,9 @@ describe('Test videos history API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { currentTime: 5 }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: watchingPath, fields, @@ -78,36 +78,36 @@ describe('Test videos history API validator', function () { }); describe('When listing user videos history', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, myHistoryPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, myHistoryPath, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, myHistoryPath, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, myHistoryPath, server.accessToken); }); }); it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: myHistoryPath, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When removing user videos history', function () { it('Should fail with an unauthenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should fail with a bad beforeDate parameter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { beforeDate: '15' }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path: myHistoryRemove, @@ -117,9 +117,9 @@ describe('Test videos history API validator', function () { }); }); it('Should succeed with a valid beforeDate param', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { beforeDate: new Date().toISOString() }; - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path: myHistoryRemove, @@ -129,8 +129,8 @@ describe('Test videos history API validator', function () { }); }); it('Should succeed without body', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, token: server.accessToken, path: myHistoryRemove, @@ -140,8 +140,8 @@ describe('Test videos history API validator', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/videos-overviews.js b/dist/server/tests/api/check-params/videos-overviews.js index 4210161d..414fdb67 100644 --- a/dist/server/tests/api/check-params/videos-overviews.js +++ b/dist/server/tests/api/check-params/videos-overviews.js @@ -6,27 +6,27 @@ const extra_utils_1 = require("@shared/extra-utils"); describe('Test videos overview', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); + server = yield (0, extra_utils_1.createSingleServer)(1); }); }); describe('When getting videos overview', function () { it('Should fail with a bad pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.overviews.getVideos({ page: 0, expectedStatus: 400 }); yield server.overviews.getVideos({ page: 100, expectedStatus: 400 }); }); }); it('Should succeed with a good pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.overviews.getVideos({ page: 1 }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/check-params/videos.js b/dist/server/tests/api/check-params/videos.js index 50c7d560..68b6bd69 100644 --- a/dist/server/tests/api/check-params/videos.js +++ b/dist/server/tests/api/check-params/videos.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const path_1 = require("path"); const core_utils_1 = require("@shared/core-utils"); @@ -18,10 +18,10 @@ describe('Test videos API validator', function () { let channelName; let video; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const username = 'user1'; const password = 'my super password'; yield server.users.create({ username: username, password: password }); @@ -36,145 +36,145 @@ describe('Test videos API validator', function () { }); describe('When listing videos', function () { it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path); }); }); it('Should fail with a bad skipVideos query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, query: { skipCount: 'toto' } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, query: { skipCount: 'toto' } }); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, query: { skipCount: false } }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200, query: { skipCount: false } }); }); }); }); describe('When searching a video', function () { it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, - path: path_1.join(path, 'search'), + path: (0, path_1.join)(path, 'search'), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path_1.join(path, 'search', 'test')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, (0, path_1.join)(path, 'search', 'test')); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path_1.join(path, 'search', 'test')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, (0, path_1.join)(path, 'search', 'test')); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path_1.join(path, 'search', 'test')); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, (0, path_1.join)(path, 'search', 'test')); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When listing my videos', function () { const path = '/api/v1/users/me/videos'; it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When listing account videos', function () { let path; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { path = '/api/v1/accounts/' + accountName + '/videos'; }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When listing video channel videos', function () { let path; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { path = '/api/v1/video-channels/' + channelName + '/videos'; }); }); it('Should fail with a bad start pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadStartPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadStartPagination)(server.url, path, server.accessToken); }); }); it('Should fail with a bad count pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadCountPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadCountPagination)(server.url, path, server.accessToken); }); }); it('Should fail with an incorrect sort', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkBadSortPagination(server.url, path, server.accessToken); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkBadSortPagination)(server.url, path, server.accessToken); }); }); it('Should success with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 }); }); }); }); describe('When adding a video', function () { let baseCorrectParams; const baseCorrectAttaches = { - fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.webm') + fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.webm') }; before(function () { baseCorrectParams = { @@ -196,79 +196,79 @@ describe('Test videos API validator', function () { }); function runSuite(mode) { it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; const attaches = {}; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail without name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'name'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'name'); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { name: 'super'.repeat(65) }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { category: 125 }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { licence: 125 }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { language: 'a'.repeat(15) }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(2500) }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail without a channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fields = lodash_1.omit(baseCorrectParams, 'channelId'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fields = (0, lodash_1.omit)(baseCorrectParams, 'channelId'); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: 545454 }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with another user channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { - username: 'fake' + core_utils_1.randomInt(0, 1500), + username: 'fake' + (0, core_utils_1.randomInt)(0, 1500), password: 'fake_password' }; yield server.users.create({ username: user.username, password: user.password }); @@ -277,116 +277,116 @@ describe('Test videos API validator', function () { const customChannelId = videoChannels[0].id; const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: customChannelId }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, userAccessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, userAccessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with too many tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'] }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a tag length too low', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 't'] }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a tag length too big', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'my_super_tag_too_long_long_long_long_long_long'] }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad schedule update (miss updateAt)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { scheduleUpdate: { privacy: 1 } }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad schedule update (wrong updateAt)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { scheduleUpdate: { privacy: 1, updateAt: 'toto' } }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a bad originally published at attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { originallyPublishedAt: 'toto' }); const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail without an input file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = {}; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with an incorrect input file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; - let attaches = { fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.UNPROCESSABLE_ENTITY_422, mode); - attaches = { fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, mode); + let attaches = { fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }; + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.UNPROCESSABLE_ENTITY_422, mode); + attaches = { fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mkv') }; + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, mode); }); }); it('Should fail with an incorrect thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), - fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4'), + fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a big thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'preview-big.png'), - fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'preview-big.png'), + fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with an incorrect preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), - fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4'), + fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should fail with a big preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'preview-big.png'), - fixture: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'preview-big.png'), + fixture: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.BAD_REQUEST_400, mode); }); }); it('Should report the appropriate error', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { language: 'a'.repeat(15) }); const attaches = baseCorrectAttaches; const attributes = Object.assign(Object.assign({}, fields), attaches); - const body = yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, attributes, models_1.HttpStatusCode.BAD_REQUEST_400, mode); + const body = yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, attributes, models_1.HttpStatusCode.BAD_REQUEST_400, mode); const error = body; if (mode === 'legacy') { expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy'); @@ -403,20 +403,20 @@ describe('Test videos API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const fields = baseCorrectParams; { const attaches = baseCorrectAttaches; - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); } { - const attaches = Object.assign(Object.assign({}, baseCorrectAttaches), { videofile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') }); - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); + const attaches = Object.assign(Object.assign({}, baseCorrectAttaches), { videofile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); } { - const attaches = Object.assign(Object.assign({}, baseCorrectAttaches), { videofile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.ogv') }); - yield extra_utils_1.checkUploadVideoParam(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); + const attaches = Object.assign(Object.assign({}, baseCorrectAttaches), { videofile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.ogv') }); + yield (0, extra_utils_1.checkUploadVideoParam)(server, server.accessToken, Object.assign(Object.assign({}, fields), attaches), models_1.HttpStatusCode.OK_200, mode); } }); }); @@ -442,27 +442,27 @@ describe('Test videos API validator', function () { tags: ['tag1', 'tag2'] }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.list(); video = data[0]; }); }); it('Should fail with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = {}; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path, token: server.accessToken, fields }); }); }); it('Should fail without a valid uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'blabla', token: server.accessToken, fields }); }); }); it('Should fail with an unknown id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', token: server.accessToken, @@ -472,90 +472,90 @@ describe('Test videos API validator', function () { }); }); it('Should fail with a long name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { name: 'super'.repeat(65) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { category: 125 }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { licence: 125 }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad language', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { language: 'a'.repeat(15) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { description: 'super'.repeat(2500) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a long support text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { support: 'super'.repeat(201) }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { channelId: 545454 }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with too many tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'] }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too low', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 't'] }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a tag length too big', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { tags: ['tag1', 'my_super_tag_too_long_long_long_long_long_long'] }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad schedule update (miss updateAt)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { scheduleUpdate: { privacy: 1 } }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad schedule update (wrong updateAt)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { scheduleUpdate: { updateAt: 'toto', privacy: 1 } }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with a bad originally published at param', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { originallyPublishedAt: 'toto' }); - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); }); }); it('Should fail with an incorrect thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + thumbnailfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, method: 'PUT', path: path + video.shortUUID, @@ -566,12 +566,12 @@ describe('Test videos API validator', function () { }); }); it('Should fail with a big thumbnail file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - thumbnailfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'preview-big.png') + thumbnailfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, method: 'PUT', path: path + video.shortUUID, @@ -582,12 +582,12 @@ describe('Test videos API validator', function () { }); }); it('Should fail with an incorrect preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'video_short.mp4') + previewfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'video_short.mp4') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, method: 'PUT', path: path + video.shortUUID, @@ -598,12 +598,12 @@ describe('Test videos API validator', function () { }); }); it('Should fail with a big preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; const attaches = { - previewfile: path_1.join(extra_utils_1.root(), 'server', 'tests', 'fixtures', 'preview-big.png') + previewfile: (0, path_1.join)((0, extra_utils_1.root)(), 'server', 'tests', 'fixtures', 'preview-big.png') }; - yield extra_utils_1.makeUploadRequest({ + yield (0, extra_utils_1.makeUploadRequest)({ url: server.url, method: 'PUT', path: path + video.shortUUID, @@ -614,9 +614,9 @@ describe('Test videos API validator', function () { }); }); it('Should fail with a video of another user without the appropriate right', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: userAccessToken, @@ -627,9 +627,9 @@ describe('Test videos API validator', function () { }); it('Should fail with a video of another server'); it('Shoud report the appropriate error', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = Object.assign(Object.assign({}, baseCorrectParams), { licence: 125 }); - const res = yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); + const res = yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }); const error = res.body; expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo'); expect(error.type).to.equal('about:blank'); @@ -641,9 +641,9 @@ describe('Test videos API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = baseCorrectParams; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + video.shortUUID, token: server.accessToken, @@ -655,8 +655,8 @@ describe('Test videos API validator', function () { }); describe('When getting a video', function () { it('Should return the list of the videos with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -666,17 +666,17 @@ describe('Test videos API validator', function () { }); }); it('Should fail without a correct uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.get({ id: 'coucou', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should return 404 with an incorrect video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Shoud report the appropriate error', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.videos.get({ id: 'hi', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const error = body; expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo'); @@ -689,7 +689,7 @@ describe('Test videos API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.get({ id: video.shortUUID }); }); }); @@ -697,25 +697,25 @@ describe('Test videos API validator', function () { describe('When rating a video', function () { let videoId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.list(); videoId = data[0].id; }); }); it('Should fail without a valid uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { rating: 'like' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields }); }); }); it('Should fail with an unknown id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { rating: 'like' }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', token: server.accessToken, @@ -725,19 +725,19 @@ describe('Test videos API validator', function () { }); }); it('Should fail with a wrong rating', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { rating: 'likes' }; - yield extra_utils_1.makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields }); + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields }); }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fields = { rating: 'like' }; - yield extra_utils_1.makePutBodyRequest({ + yield (0, extra_utils_1.makePutBodyRequest)({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, @@ -749,8 +749,8 @@ describe('Test videos API validator', function () { }); describe('When removing a video', function () { it('Should have 404 with nothing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeDeleteRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeDeleteRequest)({ url: server.url, path, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 @@ -758,23 +758,23 @@ describe('Test videos API validator', function () { }); }); it('Should fail without a correct uuid', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ id: 'hello', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should fail with a video which does not exist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should fail with a video of another user without the appropriate right', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a video of another server'); it('Shoud report the appropriate error', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.videos.remove({ id: 'hello', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); const error = body; expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo'); @@ -787,14 +787,14 @@ describe('Test videos API validator', function () { }); }); it('Should succeed with the correct parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ id: video.uuid }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/live/live-constraints.js b/dist/server/tests/api/live/live-constraints.js index a837b70a..87c76107 100644 --- a/dist/server/tests/api/live/live-constraints.js +++ b/dist/server/tests/api/live/live-constraints.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Test live constraints', function () { @@ -11,7 +11,7 @@ describe('Test live constraints', function () { let userAccessToken; let userChannelId; function createLiveWrapper(saveReplay) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'user live', channelId: userChannelId, @@ -23,17 +23,17 @@ describe('Test live constraints', function () { }); } function checkSaveReplay(videoId, resolutions = [720]) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoId }); expect(video.isLive).to.be.false; expect(video.duration).to.be.greaterThan(0); } - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], videoId, resolutions); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], videoId, resolutions); }); } function waitUntilLivePublishedOnAllServers(videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { yield server.live.waitUntilPublished({ videoId }); } @@ -47,11 +47,11 @@ describe('Test live constraints', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -70,50 +70,50 @@ describe('Test live constraints', function () { userAccessToken = res.token; yield updateQuota({ total: 1, daily: -1 }); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should not have size limit if save replay is disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const userVideoLiveoId = yield createLiveWrapper(false); yield servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }); }); }); it('Should have size limit depending on user global quota if save replay is enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); const userVideoLiveoId = yield createLiveWrapper(true); yield servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }); yield waitUntilLivePublishedOnAllServers(userVideoLiveoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkSaveReplay(userVideoLiveoId); }); }); it('Should have size limit depending on user daily quota if save replay is enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); yield updateQuota({ total: -1, daily: 1 }); const userVideoLiveoId = yield createLiveWrapper(true); yield servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }); yield waitUntilLivePublishedOnAllServers(userVideoLiveoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkSaveReplay(userVideoLiveoId); }); }); it('Should succeed without quota limit', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); yield updateQuota({ total: 10 * 1000 * 1000, daily: -1 }); const userVideoLiveoId = yield createLiveWrapper(true); yield servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }); }); }); it('Should have max duration limit', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -131,13 +131,13 @@ describe('Test live constraints', function () { const userVideoLiveoId = yield createLiveWrapper(true); yield servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }); yield waitUntilLivePublishedOnAllServers(userVideoLiveoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkSaveReplay(userVideoLiveoId, [720, 480, 360, 240]); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/live/live-permanent.js b/dist/server/tests/api/live/live-permanent.js index d64a8284..9265339d 100644 --- a/dist/server/tests/api/live/live-permanent.js +++ b/dist/server/tests/api/live/live-permanent.js @@ -2,14 +2,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Permanent live', function () { let servers = []; let videoUUID; function createLiveWrapper(permanentLive) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { channelId: servers[0].store.channel.id, privacy: 1, @@ -22,7 +22,7 @@ describe('Permanent live', function () { }); } function checkVideoState(videoId, state) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoId }); expect(video.state.id).to.equal(state); @@ -30,12 +30,12 @@ describe('Permanent live', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -52,7 +52,7 @@ describe('Permanent live', function () { }); }); it('Should create a non permanent live and update it to be a permanent live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const videoUUID = yield createLiveWrapper(false); { @@ -67,32 +67,32 @@ describe('Permanent live', function () { }); }); it('Should create a permanent live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); videoUUID = yield createLiveWrapper(true); const live = yield servers[0].live.get({ videoId: videoUUID }); expect(live.permanentLive).to.be.true; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should stream into this permanent live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }); for (const server of servers) { yield server.live.waitUntilPublished({ videoId: videoUUID }); } yield checkVideoState(videoUUID, 1); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); yield servers[0].live.waitUntilWaiting({ videoId: videoUUID }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have cleaned up this live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id: videoUUID }); expect(videoDetails.streamingPlaylists).to.have.lengthOf(1); @@ -100,13 +100,13 @@ describe('Permanent live', function () { }); }); it('Should have set this live to waiting for live state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield checkVideoState(videoUUID, 4); }); }); it('Should be able to stream again in the permanent live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -128,12 +128,12 @@ describe('Permanent live', function () { yield checkVideoState(videoUUID, 1); const count = yield servers[0].live.countPlaylists({ videoUUID }); expect(count).to.equal(2); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/live/live-save-replay.js b/dist/server/tests/api/live/live-save-replay.js index 176294a2..4092bdfb 100644 --- a/dist/server/tests/api/live/live-save-replay.js +++ b/dist/server/tests/api/live/live-save-replay.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -11,11 +11,11 @@ describe('Save replay setting', function () { let liveVideoUUID; let ffmpegCommand; function createLiveWrapper(saveReplay) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (liveVideoUUID) { try { yield servers[0].videos.remove({ id: liveVideoUUID }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); } catch (_a) { } } @@ -30,7 +30,7 @@ describe('Save replay setting', function () { }); } function checkVideosExist(videoId, existsInList, expectedStatus) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const length = existsInList ? 1 : 0; const { data, total } = yield server.videos.list(); @@ -43,7 +43,7 @@ describe('Save replay setting', function () { }); } function checkVideoState(videoId, state) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoId }); expect(video.state.id).to.equal(state); @@ -51,12 +51,12 @@ describe('Save replay setting', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -74,117 +74,117 @@ describe('Save replay setting', function () { }); describe('With save replay disabled', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); }); }); it('Should correctly create and federate the "waiting for stream" live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); liveVideoUUID = yield createLiveWrapper(false); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 4); }); }); it('Should correctly have updated the live and federated it when streaming in the live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 1); }); }); it('Should correctly delete the video files after the stream ended', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); for (const server of servers) { yield server.live.waitUntilEnded({ videoId: liveVideoUUID }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 5); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, []); }); }); it('Should correctly terminate the stream on blacklist and delete the live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); liveVideoUUID = yield createLiveWrapper(false); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield Promise.all([ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), - extra_utils_1.testFfmpegStreamError(ffmpegCommand, true) + (0, extra_utils_1.testFfmpegStreamError)(ffmpegCommand, true) ]); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false); yield servers[0].videos.get({ id: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield servers[1].videos.get({ id: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, []); }); }); it('Should correctly terminate the stream on delete and delete the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); liveVideoUUID = yield createLiveWrapper(false); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield Promise.all([ - extra_utils_1.testFfmpegStreamError(ffmpegCommand, true), + (0, extra_utils_1.testFfmpegStreamError)(ffmpegCommand, true), servers[0].videos.remove({ id: liveVideoUUID }) ]); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false, models_1.HttpStatusCode.NOT_FOUND_404); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, []); }); }); }); describe('With save replay enabled', function () { it('Should correctly create and federate the "waiting for stream" live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); liveVideoUUID = yield createLiveWrapper(true); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 4); }); }); it('Should correctly have updated the live and federated it when streaming in the live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 1); }); }); it('Should correctly have saved the live and federated it after the streaming', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); - yield extra_utils_1.waitUntilLiveSavedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); + yield (0, extra_utils_1.waitUntilLiveSavedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield checkVideoState(liveVideoUUID, 1); }); }); it('Should update the saved live and correctly federate the updated attributes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: liveVideoUUID }); expect(video.name).to.equal('video updated'); @@ -193,53 +193,53 @@ describe('Save replay setting', function () { }); }); it('Should have cleaned up the live files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [720]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, [720]); }); }); it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); liveVideoUUID = yield createLiveWrapper(true); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield Promise.all([ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), - extra_utils_1.testFfmpegStreamError(ffmpegCommand, true) + (0, extra_utils_1.testFfmpegStreamError)(ffmpegCommand, true) ]); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false); yield servers[0].videos.get({ id: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield servers[1].videos.get({ id: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [720]); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, [720]); }); }); it('Should correctly terminate the stream on delete and delete the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); liveVideoUUID = yield createLiveWrapper(true); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, true, models_1.HttpStatusCode.OK_200); yield Promise.all([ servers[0].videos.remove({ id: liveVideoUUID }), - extra_utils_1.testFfmpegStreamError(ffmpegCommand, true) + (0, extra_utils_1.testFfmpegStreamError)(ffmpegCommand, true) ]); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); yield checkVideosExist(liveVideoUUID, false, models_1.HttpStatusCode.NOT_FOUND_404); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoUUID, []); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/live/live-socket-messages.js b/dist/server/tests/api/live/live-socket-messages.js index ccdf710b..e85dbed2 100644 --- a/dist/server/tests/api/live/live-socket-messages.js +++ b/dist/server/tests/api/live/live-socket-messages.js @@ -2,17 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Test live', function () { let servers = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -24,12 +24,12 @@ describe('Test live', function () { } } }); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('Live socket messages', function () { function createLiveWrapper() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'live video', channelId: servers[0].store.channel.id, @@ -40,12 +40,12 @@ describe('Test live', function () { }); } it('Should correctly send a message when the live starts and ends', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const localStateChanges = []; const remoteStateChanges = []; const liveVideoUUID = yield createLiveWrapper(); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const videoId = yield servers[0].videos.getId({ uuid: liveVideoUUID }); const localSocket = servers[0].socketIO.getLiveNotificationSocket(); @@ -59,17 +59,17 @@ describe('Test live', function () { remoteSocket.emit('subscribe', { videoId }); } const ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); for (const stateChanges of [localStateChanges, remoteStateChanges]) { expect(stateChanges).to.have.length.at.least(1); expect(stateChanges[stateChanges.length - 1]).to.equal(1); } - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); for (const server of servers) { yield server.live.waitUntilEnded({ videoId: liveVideoUUID }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const stateChanges of [localStateChanges, remoteStateChanges]) { expect(stateChanges).to.have.length.at.least(2); expect(stateChanges[stateChanges.length - 1]).to.equal(5); @@ -77,12 +77,12 @@ describe('Test live', function () { }); }); it('Should correctly send views change notification', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); let localLastVideoViews = 0; let remoteLastVideoViews = 0; const liveVideoUUID = yield createLiveWrapper(); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const videoId = yield servers[0].videos.getId({ uuid: liveVideoUUID }); const localSocket = servers[0].socketIO.getLiveNotificationSocket(); @@ -96,45 +96,45 @@ describe('Test live', function () { remoteSocket.emit('subscribe', { videoId }); } const ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); expect(localLastVideoViews).to.equal(0); expect(remoteLastVideoViews).to.equal(0); yield servers[0].videos.view({ id: liveVideoUUID }); yield servers[1].videos.view({ id: liveVideoUUID }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); expect(localLastVideoViews).to.equal(2); expect(remoteLastVideoViews).to.equal(2); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); it('Should not receive a notification after unsubscribe', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const stateChanges = []; const liveVideoUUID = yield createLiveWrapper(); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const videoId = yield servers[0].videos.getId({ uuid: liveVideoUUID }); const socket = servers[0].socketIO.getLiveNotificationSocket(); socket.on('state-change', data => stateChanges.push(data.state)); socket.emit('subscribe', { videoId }); const command = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoUUID); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoUUID); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); expect(stateChanges).to.have.lengthOf(1); socket.emit('unsubscribe', { videoId }); - yield extra_utils_1.stopFfmpeg(command); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.stopFfmpeg)(command); + yield (0, extra_utils_1.waitJobs)(servers); expect(stateChanges).to.have.lengthOf(1); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/live/live-views.js b/dist/server/tests/api/live/live-views.js index 01f123f3..667a66f5 100644 --- a/dist/server/tests/api/live/live-views.js +++ b/dist/server/tests/api/live/live-views.js @@ -2,17 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Test live', function () { let servers = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -24,14 +24,14 @@ describe('Test live', function () { } } }); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('Live views', function () { let liveVideoId; let command; function countViews(expected) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: liveVideoId }); expect(video.views).to.equal(expected); @@ -39,7 +39,7 @@ describe('Test live', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const liveAttributes = { name: 'live video', @@ -49,53 +49,53 @@ describe('Test live', function () { const live = yield servers[0].live.create({ fields: liveAttributes }); liveVideoId = live.uuid; command = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should display no views for a live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield countViews(0); }); }); it('Should view a live twice and display 1 view', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].videos.view({ id: liveVideoId }); yield servers[0].videos.view({ id: liveVideoId }); - yield extra_utils_1.wait(7000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(7000); + yield (0, extra_utils_1.waitJobs)(servers); yield countViews(1); }); }); it('Should wait and display 0 views', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(12000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(12000); + yield (0, extra_utils_1.waitJobs)(servers); yield countViews(0); }); }); it('Should view a live on a remote and on local and display 2 views', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].videos.view({ id: liveVideoId }); yield servers[1].videos.view({ id: liveVideoId }); yield servers[1].videos.view({ id: liveVideoId }); - yield extra_utils_1.wait(7000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(7000); + yield (0, extra_utils_1.waitJobs)(servers); yield countViews(2); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.stopFfmpeg(command); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.stopFfmpeg)(command); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/live/live.js b/dist/server/tests/api/live/live.js index 79bc84e6..768e2638 100644 --- a/dist/server/tests/api/live/live.js +++ b/dist/server/tests/api/live/live.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const path_1 = require("path"); const ffprobe_utils_1 = require("@server/helpers/ffprobe-utils"); const extra_utils_1 = require("@shared/extra-utils"); @@ -12,11 +12,11 @@ describe('Test live', function () { let servers = []; let commands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].config.updateCustomSubConfig({ newConfig: { live: { @@ -28,14 +28,14 @@ describe('Test live', function () { } } }); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); commands = servers.map(s => s.live); }); }); describe('Live creation, update and delete', function () { let liveVideoUUID; it('Should create a live with the appropriate parameters', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const attributes = { category: 1, @@ -57,7 +57,7 @@ describe('Test live', function () { }; const live = yield commands[0].create({ fields: attributes }); liveVideoUUID = live.uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: liveVideoUUID }); expect(video.category.id).to.equal(1); @@ -75,8 +75,8 @@ describe('Test live', function () { expect(video.commentsEnabled).to.be.false; expect(video.downloadEnabled).to.be.false; expect(video.privacy.id).to.equal(1); - yield extra_utils_1.testImage(server.url, 'video_short1-preview.webm', video.previewPath); - yield extra_utils_1.testImage(server.url, 'video_short1.webm', video.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'video_short1-preview.webm', video.previewPath); + yield (0, extra_utils_1.testImage)(server.url, 'video_short1.webm', video.thumbnailPath); const live = yield server.live.get({ videoId: liveVideoUUID }); if (server.url === servers[0].url) { expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live'); @@ -91,7 +91,7 @@ describe('Test live', function () { }); }); it('Should have a default preview and thumbnail', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const attributes = { name: 'default live thumbnail', @@ -101,18 +101,18 @@ describe('Test live', function () { }; const live = yield commands[0].create({ fields: attributes }); const videoId = live.uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoId }); expect(video.privacy.id).to.equal(2); expect(video.nsfw).to.be.true; - yield extra_utils_1.makeRawRequest(server.url + video.thumbnailPath, models_1.HttpStatusCode.OK_200); - yield extra_utils_1.makeRawRequest(server.url + video.previewPath, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(server.url + video.thumbnailPath, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(server.url + video.previewPath, models_1.HttpStatusCode.OK_200); } }); }); it('Should not have the live listed since nobody streams into', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(0); @@ -121,19 +121,19 @@ describe('Test live', function () { }); }); it('Should not be able to update a live of another server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[1].update({ videoId: liveVideoUUID, fields: { saveReplay: false }, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should update the live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[0].update({ videoId: liveVideoUUID, fields: { saveReplay: false } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Have the live updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const live = yield server.live.get({ videoId: liveVideoUUID }); if (server.url === servers[0].url) { @@ -149,14 +149,14 @@ describe('Test live', function () { }); }); it('Delete the live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].videos.remove({ id: liveVideoUUID }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the live deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { yield server.videos.get({ id: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield server.live.get({ videoId: liveVideoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); @@ -169,19 +169,19 @@ describe('Test live', function () { let liveVideoId; let vodVideoId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); vodVideoId = (yield servers[0].videos.quickUpload({ name: 'vod video' })).uuid; const liveOptions = { name: 'live', privacy: 1, channelId: servers[0].store.channel.id }; const live = yield commands[0].create({ fields: liveOptions }); liveVideoId = live.uuid; ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should only display lives', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield servers[0].videos.list({ isLive: true }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -189,7 +189,7 @@ describe('Test live', function () { }); }); it('Should not display lives', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield servers[0].videos.list({ isLive: false }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -197,24 +197,24 @@ describe('Test live', function () { }); }); it('Should display my lives', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].videos.listMyVideos({ isLive: true }); const result = data.every(v => v.isLive); expect(result).to.be.true; }); }); it('Should not display my lives', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listMyVideos({ isLive: false }); const result = data.every(v => !v.isLive); expect(result).to.be.true; }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.remove({ id: vodVideoId }); yield servers[0].videos.remove({ id: liveVideoId }); }); @@ -227,7 +227,7 @@ describe('Test live', function () { rtmpUrl = 'rtmp://' + servers[0].hostname + ':' + servers[0].rtmpPort + ''; }); function createLiveWrapper() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'user live', channelId: servers[0].store.channel.id, @@ -241,29 +241,29 @@ describe('Test live', function () { }); } it('Should not allow a stream without the appropriate path', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); liveVideo = yield createLiveWrapper(); - const command = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/bad-live', streamKey: liveVideo.streamKey }); - yield extra_utils_1.testFfmpegStreamError(command, true); + const command = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: rtmpUrl + '/bad-live', streamKey: liveVideo.streamKey }); + yield (0, extra_utils_1.testFfmpegStreamError)(command, true); }); }); it('Should not allow a stream without the appropriate stream key', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - const command = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: 'bad-stream-key' }); - yield extra_utils_1.testFfmpegStreamError(command, true); + const command = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: 'bad-stream-key' }); + yield (0, extra_utils_1.testFfmpegStreamError)(command, true); }); }); it('Should succeed with the correct params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - const command = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); - yield extra_utils_1.testFfmpegStreamError(command, false); + const command = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); + yield (0, extra_utils_1.testFfmpegStreamError)(command, false); }); }); it('Should list this live now someone stream into it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(1); @@ -275,28 +275,28 @@ describe('Test live', function () { }); }); it('Should not allow a stream on a live that was blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); liveVideo = yield createLiveWrapper(); yield servers[0].blacklist.add({ videoId: liveVideo.uuid }); - const command = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); - yield extra_utils_1.testFfmpegStreamError(command, true); + const command = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); + yield (0, extra_utils_1.testFfmpegStreamError)(command, true); }); }); it('Should not allow a stream on a live that was deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); liveVideo = yield createLiveWrapper(); yield servers[0].videos.remove({ id: liveVideo.uuid }); - const command = extra_utils_1.sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); - yield extra_utils_1.testFfmpegStreamError(command, true); + const command = (0, extra_utils_1.sendRTMPStream)({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }); + yield (0, extra_utils_1.testFfmpegStreamError)(command, true); }); }); }); describe('Live transcoding', function () { let liveVideoId; function createLiveWrapper(saveReplay) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'live video', channelId: servers[0].store.channel.id, @@ -308,7 +308,7 @@ describe('Test live', function () { }); } function testVideoResolutions(liveVideoId, resolutions) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { data } = yield server.videos.list(); expect(data.find(v => v.uuid === liveVideoId)).to.exist; @@ -317,7 +317,7 @@ describe('Test live', function () { const hlsPlaylist = video.streamingPlaylists.find(s => s.type === 1); expect(hlsPlaylist).to.exist; expect(hlsPlaylist.files).to.have.lengthOf(0); - yield extra_utils_1.checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }); + yield (0, extra_utils_1.checkResolutionsInMasterPlaylist)({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }); for (let i = 0; i < resolutions.length; i++) { const segmentNum = 3; const segmentName = `${i}-00000${segmentNum}.ts`; @@ -327,7 +327,7 @@ describe('Test live', function () { }); expect(subPlaylist).to.contain(segmentName); const baseUrlAndPath = servers[0].url + '/static/streaming-playlists/hls'; - yield extra_utils_1.checkLiveSegmentHash({ + yield (0, extra_utils_1.checkLiveSegmentHash)({ server, baseUrlSegment: baseUrlAndPath, videoUUID: video.uuid, @@ -361,36 +361,36 @@ describe('Test live', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield updateConf([]); }); }); it('Should enable transcoding without additional resolutions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); liveVideoId = yield createLiveWrapper(false); const ffmpegCommand = yield commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); yield testVideoResolutions(liveVideoId, [720]); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); it('Should enable transcoding with some resolutions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const resolutions = [240, 480]; yield updateConf(resolutions); liveVideoId = yield createLiveWrapper(false); const ffmpegCommand = yield commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); yield testVideoResolutions(liveVideoId, resolutions); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); it('Should correctly set the appropriate bitrate depending on the input', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); liveVideoId = yield createLiveWrapper(false); const ffmpegCommand = yield commands[0].sendRTMPStreamInVideo({ @@ -398,34 +398,34 @@ describe('Test live', function () { fixtureName: 'video_short.mp4', copyCodecs: true }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[0].videos.get({ id: liveVideoId }); const masterPlaylist = video.streamingPlaylists[0].playlistUrl; - const probe = yield ffprobe_utils_1.ffprobePromise(masterPlaylist); + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(masterPlaylist); const bitrates = probe.streams.map(s => parseInt(s.tags.variant_bitrate)); for (const bitrate of bitrates) { expect(bitrate).to.exist; expect(isNaN(bitrate)).to.be.false; expect(bitrate).to.be.below(61000000); } - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); }); }); it('Should enable transcoding with some resolutions and correctly save them', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(200000); const resolutions = [240, 360, 720]; yield updateConf(resolutions); liveVideoId = yield createLiveWrapper(true); const ffmpegCommand = yield commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); yield testVideoResolutions(liveVideoId, resolutions); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); yield commands[0].waitUntilEnded({ videoId: liveVideoId }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, liveVideoId); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, liveVideoId); const maxBitrateLimits = { 720: 6500 * 1000, 360: 1250 * 1000, @@ -442,10 +442,10 @@ describe('Test live', function () { expect(video.duration).to.be.greaterThan(1); expect(video.files).to.have.lengthOf(0); const hlsPlaylist = video.streamingPlaylists.find(s => s.type === 1); - yield extra_utils_1.makeRawRequest(hlsPlaylist.playlistUrl, models_1.HttpStatusCode.OK_200); - yield extra_utils_1.makeRawRequest(hlsPlaylist.segmentsSha256Url, models_1.HttpStatusCode.OK_200); - expect(path_1.basename(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8'); - expect(path_1.basename(hlsPlaylist.segmentsSha256Url)).to.not.equal('segments-sha256.json'); + yield (0, extra_utils_1.makeRawRequest)(hlsPlaylist.playlistUrl, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(hlsPlaylist.segmentsSha256Url, models_1.HttpStatusCode.OK_200); + expect((0, path_1.basename)(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8'); + expect((0, path_1.basename)(hlsPlaylist.segmentsSha256Url)).to.not.equal('segments-sha256.json'); expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length); for (const resolution of resolutions) { const file = hlsPlaylist.files.find(f => f.resolution.id === resolution); @@ -457,23 +457,23 @@ describe('Test live', function () { else { expect(file.fps).to.be.approximately(30, 2); } - const filename = path_1.basename(file.fileUrl); + const filename = (0, path_1.basename)(file.fileUrl); expect(filename).to.not.contain(video.uuid); - const segmentPath = servers[0].servers.buildDirectory(path_1.join('streaming-playlists', 'hls', video.uuid, filename)); - const probe = yield ffprobe_utils_1.ffprobePromise(segmentPath); - const videoStream = yield ffprobe_utils_1.getVideoStreamFromFile(segmentPath, probe); + const segmentPath = servers[0].servers.buildDirectory((0, path_1.join)('streaming-playlists', 'hls', video.uuid, filename)); + const probe = yield (0, ffprobe_utils_1.ffprobePromise)(segmentPath); + const videoStream = yield (0, ffprobe_utils_1.getVideoStreamFromFile)(segmentPath, probe); expect(probe.format.bit_rate).to.be.below(maxBitrateLimits[videoStream.height]); expect(probe.format.bit_rate).to.be.at.least(minBitrateLimits[videoStream.height]); - yield extra_utils_1.makeRawRequest(file.torrentUrl, models_1.HttpStatusCode.OK_200); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(file.torrentUrl, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } } }); }); it('Should correctly have cleaned up the live files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.checkLiveCleanupAfterSave(servers[0], liveVideoId, [240, 360, 720]); + yield (0, extra_utils_1.checkLiveCleanupAfterSave)(servers[0], liveVideoId, [240, 360, 720]); }); }); }); @@ -481,7 +481,7 @@ describe('Test live', function () { let liveVideoId; let liveVideoReplayId; function createLiveWrapper(saveReplay) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'live video', channelId: servers[0].store.channel.id, @@ -493,7 +493,7 @@ describe('Test live', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); liveVideoId = yield createLiveWrapper(false); liveVideoReplayId = yield createLiveWrapper(true); @@ -507,27 +507,27 @@ describe('Test live', function () { ]); yield commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoId, resolution: 0, segment: 2 }); yield commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, resolution: 0, segment: 2 }); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run(); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); }); }); it('Should cleanup lives', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield commands[0].waitUntilEnded({ videoId: liveVideoId }); }); }); it('Should save a live replay', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield commands[0].waitUntilPublished({ videoId: liveVideoReplayId }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/moderation/abuses.js b/dist/server/tests/api/moderation/abuses.js index de7f0b29..2e51fda8 100644 --- a/dist/server/tests/api/moderation/abuses.js +++ b/dist/server/tests/api/moderation/abuses.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test abuses', function () { @@ -11,17 +11,17 @@ describe('Test abuses', function () { let abuseServer2; let commands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); commands = servers.map(s => s.abuses); }); }); describe('Video abuses', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); { const attributes = { @@ -37,7 +37,7 @@ describe('Test abuses', function () { }; yield servers[1].videos.upload({ attributes }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].videos.list(); expect(data.length).to.equal(2); servers[0].store.videoCreated = data.find(video => video.name === 'my super name for server 1'); @@ -45,7 +45,7 @@ describe('Test abuses', function () { }); }); it('Should not have abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].getAdminList(); expect(body.total).to.equal(0); expect(body.data).to.be.an('array'); @@ -53,15 +53,15 @@ describe('Test abuses', function () { }); }); it('Should report abuse on a local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const reason = 'my super bad reason'; yield commands[0].report({ videoId: servers[0].store.videoCreated.id, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 1 video abuses on server 1 and 0 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getAdminList(); expect(body.total).to.equal(1); @@ -90,16 +90,16 @@ describe('Test abuses', function () { }); }); it('Should report abuse on a remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const reason = 'my super bad reason 2'; const videoId = yield servers[0].videos.getId({ uuid: servers[1].store.videoCreated.uuid }); yield commands[0].report({ videoId, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 2 video abuses on server 1 and 1 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getAdminList(); expect(body.total).to.equal(2); @@ -146,12 +146,12 @@ describe('Test abuses', function () { }); }); it('Should hide video abuses from blocked accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); { const videoId = yield servers[1].videos.getId({ uuid: servers[0].store.videoCreated.uuid }); yield commands[1].report({ videoId, reason: 'will mute this' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[0].getAdminList(); expect(body.total).to.equal(3); } @@ -171,7 +171,7 @@ describe('Test abuses', function () { }); }); it('Should hide video abuses from blocked servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverToBlock = servers[1].host; { yield servers[0].blocklist.addToServerBlocklist({ server: serverToBlock }); @@ -188,10 +188,10 @@ describe('Test abuses', function () { }); }); it('Should keep the video abuse when deleting the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[1].videos.remove({ id: abuseServer2.video.uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[1].getAdminList(); expect(body.total).to.equal(2, "wrong number of videos returned"); expect(body.data).to.have.lengthOf(2, "wrong number of videos returned"); @@ -203,7 +203,7 @@ describe('Test abuses', function () { }); }); it('Should include counts of reports from reporter and reportee', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const user = { username: 'user2', password: 'password' }; yield servers[0].users.create(Object.assign({}, user)); @@ -233,7 +233,7 @@ describe('Test abuses', function () { }); }); it('Should list predefined reasons as well as timestamps for the reported video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const reason5 = 'my super bad reason 5'; const predefinedReasons5 = ['violentOrRepulsive', 'captions']; @@ -255,10 +255,10 @@ describe('Test abuses', function () { }); }); it('Should delete the video abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[1].delete({ abuseId: abuseServer2.id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield commands[1].getAdminList(); expect(body.total).to.equal(1); @@ -272,10 +272,10 @@ describe('Test abuses', function () { }); }); it('Should list and filter video abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); function list(query) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].getAdminList(query); return body.data; }); @@ -302,7 +302,7 @@ describe('Test abuses', function () { }); describe('Comment abuses', function () { function getComment(server, videoIdArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoId = typeof videoIdArg === 'string' ? yield server.videos.getId({ uuid: videoIdArg }) : videoIdArg; @@ -311,26 +311,26 @@ describe('Test abuses', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); servers[0].store.videoCreated = yield servers[0].videos.quickUpload({ name: 'server 1' }); servers[1].store.videoCreated = yield servers[1].videos.quickUpload({ name: 'server 2' }); yield servers[0].comments.createThread({ videoId: servers[0].store.videoCreated.id, text: 'comment server 1' }); yield servers[1].comments.createThread({ videoId: servers[1].store.videoCreated.id, text: 'comment server 2' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should report abuse on a comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const comment = yield getComment(servers[0], servers[0].store.videoCreated.id); const reason = 'it is a bad comment'; yield commands[0].report({ commentId: comment.id, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 1 comment abuse on server 1 and 0 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const comment = yield getComment(servers[0], servers[0].store.videoCreated.id); const body = yield commands[0].getAdminList({ filter: 'comment' }); @@ -358,16 +358,16 @@ describe('Test abuses', function () { }); }); it('Should report abuse on a remote comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const comment = yield getComment(servers[0], servers[1].store.videoCreated.uuid); const reason = 'it is a really bad comment'; yield commands[0].report({ commentId: comment.id, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 2 comment abuses on server 1 and 1 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const commentServer2 = yield getComment(servers[0], servers[1].store.videoCreated.id); { const body = yield commands[0].getAdminList({ filter: 'comment' }); @@ -410,11 +410,11 @@ describe('Test abuses', function () { }); }); it('Should keep the comment abuse when deleting the comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const commentServer2 = yield getComment(servers[0], servers[1].store.videoCreated.id); yield servers[0].comments.delete({ videoId: servers[1].store.videoCreated.uuid, commentId: commentServer2.id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[0].getAdminList({ filter: 'comment' }); expect(body.total).to.equal(2); expect(body.data).to.have.lengthOf(2); @@ -426,10 +426,10 @@ describe('Test abuses', function () { }); }); it('Should delete the comment abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[1].delete({ abuseId: abuseServer2.id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield commands[1].getAdminList({ filter: 'comment' }); expect(body.total).to.equal(0); @@ -442,7 +442,7 @@ describe('Test abuses', function () { }); }); it('Should list and filter video abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getAdminList({ filter: 'comment', searchReportee: 'foo' }); expect(body.total).to.equal(0); @@ -469,25 +469,25 @@ describe('Test abuses', function () { return server.accounts.get({ accountName: targetName + '@' + targetServer.host }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); yield servers[0].users.create({ username: 'user_1', password: 'donald' }); const token = yield servers[1].users.generateUserAndToken('user_2'); yield servers[1].videos.upload({ token, attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should report abuse on an account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const account = yield getAccountFromServer(servers[0], 'user_1', servers[0]); const reason = 'it is a bad account'; yield commands[0].report({ accountId: account.id, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 1 account abuse on server 1 and 0 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getAdminList({ filter: 'account' }); expect(body.total).to.equal(1); @@ -509,16 +509,16 @@ describe('Test abuses', function () { }); }); it('Should report abuse on a remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const account = yield getAccountFromServer(servers[0], 'user_2', servers[1]); const reason = 'it is a really bad account'; yield commands[0].report({ accountId: account.id, reason }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 2 comment abuses on server 1 and 1 on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getAdminList({ filter: 'account' }); expect(body.total).to.equal(2); @@ -550,11 +550,11 @@ describe('Test abuses', function () { }); }); it('Should keep the account abuse when deleting the account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const account = yield getAccountFromServer(servers[1], 'user_2', servers[1]); yield servers[1].users.remove({ userId: account.userId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[0].getAdminList({ filter: 'account' }); expect(body.total).to.equal(2); expect(body.data).to.have.lengthOf(2); @@ -563,10 +563,10 @@ describe('Test abuses', function () { }); }); it('Should delete the account abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[1].delete({ abuseId: abuseServer2.id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield commands[1].getAdminList({ filter: 'account' }); expect(body.total).to.equal(0); @@ -582,14 +582,14 @@ describe('Test abuses', function () { }); describe('Common actions on abuses', function () { it('Should update the state of an abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[0].update({ abuseId: abuseServer1.id, body: { state: 2 } }); const body = yield commands[0].getAdminList({ id: abuseServer1.id }); expect(body.data[0].state.id).to.equal(2); }); }); it('Should add a moderation comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[0].update({ abuseId: abuseServer1.id, body: { state: 3, moderationComment: 'Valid' } }); const body = yield commands[0].getAdminList({ id: abuseServer1.id }); expect(body.data[0].state.id).to.equal(3); @@ -598,11 +598,11 @@ describe('Test abuses', function () { }); }); describe('My abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let abuseId1; let userAccessToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { userAccessToken = yield servers[0].users.generateUserAndToken('user_42'); yield commands[0].report({ token: userAccessToken, videoId: servers[0].store.videoCreated.id, reason: 'user reason 1' }); const videoId = yield servers[0].videos.getId({ uuid: servers[1].store.videoCreated.uuid }); @@ -610,7 +610,7 @@ describe('Test abuses', function () { }); }); it('Should correctly list my abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].getUserList({ token: userAccessToken, start: 0, count: 5, sort: 'createdAt' }); expect(body.total).to.equal(2); @@ -634,7 +634,7 @@ describe('Test abuses', function () { }); }); it('Should correctly filter my abuses by id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].getUserList({ token: userAccessToken, id: abuseId1 }); expect(body.total).to.equal(1); const abuses = body.data; @@ -642,7 +642,7 @@ describe('Test abuses', function () { }); }); it('Should correctly filter my abuses by search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].getUserList({ token: userAccessToken, search: 'server 2' }); expect(body.total).to.equal(1); const abuses = body.data; @@ -650,7 +650,7 @@ describe('Test abuses', function () { }); }); it('Should correctly filter my abuses by state', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[0].update({ abuseId: abuseId1, body: { state: 2 } }); const body = yield commands[0].getUserList({ token: userAccessToken, state: 2 }); expect(body.total).to.equal(1); @@ -661,20 +661,20 @@ describe('Test abuses', function () { }); }); describe('Abuse messages', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let abuseId; let userToken; let abuseMessageUserId; let abuseMessageModerationId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { userToken = yield servers[0].users.generateUserAndToken('user_43'); const body = yield commands[0].report({ token: userToken, videoId: servers[0].store.videoCreated.id, reason: 'user 43 reason 1' }); abuseId = body.abuse.id; }); }); it('Should create some messages on the abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[0].addMessage({ token: userToken, abuseId, message: 'message 1' }); yield commands[0].addMessage({ abuseId, message: 'message 2' }); yield commands[0].addMessage({ abuseId, message: 'message 3' }); @@ -682,7 +682,7 @@ describe('Test abuses', function () { }); }); it('Should have the correct messages count when listing abuses', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const results = yield Promise.all([ commands[0].getAdminList({ start: 0, count: 50 }), commands[0].getUserList({ token: userToken, start: 0, count: 50 }) @@ -695,7 +695,7 @@ describe('Test abuses', function () { }); }); it('Should correctly list messages of this abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const results = yield Promise.all([ commands[0].listMessages({ abuseId }), commands[0].listMessages({ token: userToken, abuseId }) @@ -721,7 +721,7 @@ describe('Test abuses', function () { }); }); it('Should delete messages', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield commands[0].deleteMessage({ abuseId, messageId: abuseMessageModerationId }); yield commands[0].deleteMessage({ token: userToken, abuseId, messageId: abuseMessageUserId }); const results = yield Promise.all([ @@ -739,8 +739,8 @@ describe('Test abuses', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/moderation/blocklist-notification.js b/dist/server/tests/api/moderation/blocklist-notification.js index 79761ba6..c9852406 100644 --- a/dist/server/tests/api/moderation/blocklist-notification.js +++ b/dist/server/tests/api/moderation/blocklist-notification.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function checkNotifications(server, token, expected) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.notifications.list({ token, start: 0, count: 10, unread: true }); expect(data).to.have.lengthOf(expected.length); for (const type of expected) { @@ -21,19 +21,19 @@ describe('Test blocklist', function () { let userToken2; let remoteUserToken; function resetState() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host }); yield servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host }); } catch (_a) { } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].notifications.markAsReadAll({ token: userToken1 }); yield servers[0].notifications.markAsReadAll({ token: userToken2 }); { const { uuid } = yield servers[0].videos.upload({ token: userToken1, attributes: { name: 'video' } }); videoUUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); } { yield servers[1].comments.createThread({ @@ -46,14 +46,14 @@ describe('Test blocklist', function () { yield servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host }); yield servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const user = { username: 'user1', password: 'password' }; yield servers[0].users.create({ @@ -75,36 +75,36 @@ describe('Test blocklist', function () { yield servers[1].users.create({ username: user.username, password: user.password }); remoteUserToken = yield servers[1].login.getAccessToken(user); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('User blocks another user', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield resetState(); }); }); it('Should have appropriate notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notifs = [2, 10]; yield checkNotifications(servers[0], userToken1, notifs); }); }); it('Should block an account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].blocklist.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have notifications from this account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkNotifications(servers[0], userToken1, []); }); }); it('Should have notifications of this account on user 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notifs = [11, 10]; yield checkNotifications(servers[0], userToken2, notifs); yield servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }); @@ -113,31 +113,31 @@ describe('Test blocklist', function () { }); describe('User blocks another server', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield resetState(); }); }); it('Should have appropriate notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notifs = [2, 10]; yield checkNotifications(servers[0], userToken1, notifs); }); }); it('Should block an account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].blocklist.addToMyBlocklist({ token: userToken1, server: servers[1].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have notifications from this account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkNotifications(servers[0], userToken1, []); }); }); it('Should have notifications of this account on user 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const notifs = [11, 10]; yield checkNotifications(servers[0], userToken2, notifs); yield servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, server: servers[1].host }); @@ -146,13 +146,13 @@ describe('Test blocklist', function () { }); describe('Server blocks a user', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield resetState(); }); }); it('Should have appropriate notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const notifs = [2, 10]; yield checkNotifications(servers[0], userToken1, notifs); @@ -164,14 +164,14 @@ describe('Test blocklist', function () { }); }); it('Should block an account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].blocklist.addToServerBlocklist({ account: 'user3@' + servers[1].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have notifications from this account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkNotifications(servers[0], userToken1, []); yield checkNotifications(servers[0], userToken2, []); yield servers[0].blocklist.removeFromServerBlocklist({ account: 'user3@' + servers[1].host }); @@ -180,13 +180,13 @@ describe('Test blocklist', function () { }); describe('Server blocks a server', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield resetState(); }); }); it('Should have appropriate notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const notifs = [2, 10]; yield checkNotifications(servers[0], userToken1, notifs); @@ -198,22 +198,22 @@ describe('Test blocklist', function () { }); }); it('Should block an account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].blocklist.addToServerBlocklist({ server: servers[1].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have notifications from this account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkNotifications(servers[0], userToken1, []); yield checkNotifications(servers[0], userToken2, []); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/moderation/blocklist.js b/dist/server/tests/api/moderation/blocklist.js index 9e83a3ee..994bd508 100644 --- a/dist/server/tests/api/moderation/blocklist.js +++ b/dist/server/tests/api/moderation/blocklist.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function checkAllVideos(server, token) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data } = yield server.videos.listWithToken({ token }); expect(data).to.have.lengthOf(5); @@ -18,7 +18,7 @@ function checkAllVideos(server, token) { }); } function checkAllComments(server, token, videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token }); const threads = data.filter(t => t.isDeleted === false); expect(threads).to.have.lengthOf(2); @@ -29,10 +29,10 @@ function checkAllComments(server, token, videoUUID) { }); } function checkCommentNotification(mainServer, comment, check) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = comment.server.comments; const { threadId, createdAt } = yield command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text }); - yield extra_utils_1.waitJobs([mainServer, comment.server]); + yield (0, extra_utils_1.waitJobs)([mainServer, comment.server]); const { data } = yield mainServer.notifications.list({ start: 0, count: 30 }); const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt); if (check === 'presence') @@ -40,7 +40,7 @@ function checkCommentNotification(mainServer, comment, check) { else expect(commentNotifications).to.have.lengthOf(0); yield command.delete({ token: comment.token, videoId: comment.videoUUID, commentId: threadId }); - yield extra_utils_1.waitJobs([mainServer, comment.server]); + yield (0, extra_utils_1.waitJobs)([mainServer, comment.server]); }); } describe('Test blocklist', function () { @@ -54,10 +54,10 @@ describe('Test blocklist', function () { let command; let commentsCommand; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); command = servers[0].blocklist; commentsCommand = servers.map(s => s.comments); { @@ -89,8 +89,8 @@ describe('Test blocklist', function () { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } }); videoUUID3 = uuid; } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.doubleFollow(servers[0], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[2]); { const created = yield commentsCommand[0].createThread({ videoId: videoUUID1, text: 'comment root 1' }); const reply = yield commentsCommand[0].addReply({ @@ -105,7 +105,7 @@ describe('Test blocklist', function () { const created = yield commentsCommand[0].createThread({ token: userToken1, videoId: videoUUID1, text: 'comment user 1' }); yield commentsCommand[0].addReply({ videoId: videoUUID1, toCommentId: created.id, text: 'comment root 1' }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); describe('User blocklist', function () { @@ -117,12 +117,12 @@ describe('Test blocklist', function () { return checkAllComments(servers[0], servers[0].accessToken, videoUUID1); }); it('Should block a remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToMyBlocklist({ account: 'user2@localhost:' + servers[1].port }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listWithToken(); expect(data).to.have.lengthOf(4); const v = data.find(v => v.name === 'video user 2'); @@ -130,12 +130,12 @@ describe('Test blocklist', function () { }); }); it('Should block a local account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToMyBlocklist({ account: 'user1' }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listWithToken(); expect(data).to.have.lengthOf(3); const v = data.find(v => v.name === 'video user 1'); @@ -143,7 +143,7 @@ describe('Test blocklist', function () { }); }); it('Should hide its comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield commentsCommand[0].listThreads({ token: servers[0].accessToken, videoId: videoUUID1, @@ -166,7 +166,7 @@ describe('Test blocklist', function () { }); }); it('Should not have notifications from blocked accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }; @@ -184,12 +184,12 @@ describe('Test blocklist', function () { }); }); it('Should list all the videos with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return checkAllVideos(servers[0], userToken1); }); }); it('Should list blocked accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.listMyAccountBlocklist({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(2); @@ -213,18 +213,18 @@ describe('Test blocklist', function () { }); }); it('Should not allow a remote blocked user to comment my videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); { yield commentsCommand[1].createThread({ token: userToken2, videoId: videoUUID3, text: 'comment user 2' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield commentsCommand[0].createThread({ token: servers[0].accessToken, videoId: videoUUID3, text: 'uploader' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const commentId = yield commentsCommand[1].findCommentId({ videoId: videoUUID3, text: 'uploader' }); const message = 'reply by user 2'; const reply = yield commentsCommand[1].addReply({ token: userToken2, videoId: videoUUID3, toCommentId: commentId, text: message }); yield commentsCommand[1].addReply({ videoId: videoUUID3, toCommentId: reply.id, text: 'another reply' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); } { const { data } = yield commentsCommand[1].listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }); @@ -250,12 +250,12 @@ describe('Test blocklist', function () { }); }); it('Should unblock the remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromMyBlocklist({ account: 'user2@localhost:' + servers[1].port }); }); }); it('Should display its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listWithToken(); expect(data).to.have.lengthOf(4); const v = data.find(v => v.name === 'video user 2'); @@ -263,7 +263,7 @@ describe('Test blocklist', function () { }); }); it('Should display its comments on my video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { data } = yield server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }); if (server.serverNumber === 3) { @@ -282,7 +282,7 @@ describe('Test blocklist', function () { }); }); it('Should unblock the local account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromMyBlocklist({ account: 'user1' }); }); }); @@ -290,7 +290,7 @@ describe('Test blocklist', function () { return checkAllComments(servers[0], servers[0].accessToken, videoUUID1); }); it('Should have a notification from a non blocked account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }; @@ -316,12 +316,12 @@ describe('Test blocklist', function () { return checkAllComments(servers[0], servers[0].accessToken, videoUUID1); }); it('Should block a remote server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToMyBlocklist({ server: 'localhost:' + servers[1].port }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listWithToken(); expect(data).to.have.lengthOf(3); const v1 = data.find(v => v.name === 'video user 2'); @@ -331,21 +331,21 @@ describe('Test blocklist', function () { }); }); it('Should list all the videos with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return checkAllVideos(servers[0], userToken1); }); }); it('Should hide its comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { id } = yield commentsCommand[1].createThread({ token: userToken2, videoId: videoUUID1, text: 'hidden comment 2' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkAllComments(servers[0], servers[0].accessToken, videoUUID1); yield commentsCommand[1].delete({ token: userToken2, videoId: videoUUID1, commentId: id }); }); }); it('Should not have notifications from blocked server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }; @@ -363,7 +363,7 @@ describe('Test blocklist', function () { }); }); it('Should list blocked servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listMyServerBlocklist({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(1); const block = body.data[0]; @@ -373,7 +373,7 @@ describe('Test blocklist', function () { }); }); it('Should unblock the remote server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }); }); }); @@ -384,7 +384,7 @@ describe('Test blocklist', function () { return checkAllComments(servers[0], servers[0].accessToken, videoUUID1); }); it('Should have notification from unblocked server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }; @@ -406,26 +406,26 @@ describe('Test blocklist', function () { describe('Server blocklist', function () { describe('When managing account blocklist', function () { it('Should list all videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllVideos(servers[0], token); } }); }); it('Should list the comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllComments(servers[0], token, videoUUID1); } }); }); it('Should block a remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToServerBlocklist({ account: 'user2@localhost:' + servers[1].port }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { const { data } = yield servers[0].videos.listWithToken({ token }); expect(data).to.have.lengthOf(4); @@ -435,12 +435,12 @@ describe('Test blocklist', function () { }); }); it('Should block a local account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToServerBlocklist({ account: 'user1' }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { const { data } = yield servers[0].videos.listWithToken({ token }); expect(data).to.have.lengthOf(3); @@ -450,7 +450,7 @@ describe('Test blocklist', function () { }); }); it('Should hide its comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { const { data } = yield commentsCommand[0].listThreads({ videoId: videoUUID1, count: 20, sort: '-createdAt', token }); const threads = data.filter(t => t.isDeleted === false); @@ -466,7 +466,7 @@ describe('Test blocklist', function () { }); }); it('Should not have notification from blocked accounts by instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }; @@ -484,7 +484,7 @@ describe('Test blocklist', function () { }); }); it('Should list blocked accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.listServerAccountBlocklist({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(2); @@ -508,12 +508,12 @@ describe('Test blocklist', function () { }); }); it('Should unblock the remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }); }); }); it('Should display its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { const { data } = yield servers[0].videos.listWithToken({ token }); expect(data).to.have.lengthOf(4); @@ -523,19 +523,19 @@ describe('Test blocklist', function () { }); }); it('Should unblock the local account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromServerBlocklist({ account: 'user1' }); }); }); it('Should display its comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllComments(servers[0], token, videoUUID1); } }); }); it('Should have notifications from unblocked accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); { const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }; @@ -555,26 +555,26 @@ describe('Test blocklist', function () { }); describe('When managing server blocklist', function () { it('Should list all videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllVideos(servers[0], token); } }); }); it('Should list the comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllComments(servers[0], token, videoUUID1); } }); }); it('Should block a remote server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }); }); }); it('Should hide its videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { const requests = [ servers[0].videos.list(), @@ -592,16 +592,16 @@ describe('Test blocklist', function () { }); }); it('Should hide its comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { id } = yield commentsCommand[1].createThread({ token: userToken2, videoId: videoUUID1, text: 'hidden comment 2' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkAllComments(servers[0], servers[0].accessToken, videoUUID1); yield commentsCommand[1].delete({ token: userToken2, videoId: videoUUID1, commentId: id }); }); }); it('Should not have notification from blocked instances by instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); { const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }; @@ -619,9 +619,9 @@ describe('Test blocklist', function () { { const now = new Date(); yield servers[1].follows.unfollow({ target: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].follows.follow({ hosts: [servers[0].host] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].notifications.list({ start: 0, count: 30 }); const commentNotifications = data.filter(n => { return n.type === 13 && n.createdAt >= now.toISOString(); @@ -631,7 +631,7 @@ describe('Test blocklist', function () { }); }); it('Should list blocked servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listServerServerBlocklist({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(1); const block = body.data[0]; @@ -641,26 +641,26 @@ describe('Test blocklist', function () { }); }); it('Should unblock the remote server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }); }); }); it('Should list all videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllVideos(servers[0], token); } }); }); it('Should list the comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const token of [userModeratorToken, servers[0].accessToken]) { yield checkAllComments(servers[0], token, videoUUID1); } }); }); it('Should have notification from unblocked instances', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); { const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }; @@ -678,9 +678,9 @@ describe('Test blocklist', function () { { const now = new Date(); yield servers[1].follows.unfollow({ target: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].follows.follow({ hosts: [servers[0].host] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].notifications.list({ start: 0, count: 30 }); const commentNotifications = data.filter(n => { return n.type === 13 && n.createdAt >= now.toISOString(); @@ -692,8 +692,8 @@ describe('Test blocklist', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/moderation/index.js b/dist/server/tests/api/moderation/index.js index aff16baa..090fc03f 100644 --- a/dist/server/tests/api/moderation/index.js +++ b/dist/server/tests/api/moderation/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuses"), exports); -tslib_1.__exportStar(require("./blocklist-notification"), exports); -tslib_1.__exportStar(require("./blocklist"), exports); -tslib_1.__exportStar(require("./video-blacklist"), exports); +(0, tslib_1.__exportStar)(require("./abuses"), exports); +(0, tslib_1.__exportStar)(require("./blocklist-notification"), exports); +(0, tslib_1.__exportStar)(require("./blocklist"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist"), exports); diff --git a/dist/server/tests/api/moderation/video-blacklist.js b/dist/server/tests/api/moderation/video-blacklist.js index ac52026a..077cf733 100644 --- a/dist/server/tests/api/moderation/video-blacklist.js +++ b/dist/server/tests/api/moderation/video-blacklist.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); @@ -12,7 +12,7 @@ describe('Test video blacklist', function () { let videoId; let command; function blacklistVideosOnServer(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.list(); for (const video of data) { yield server.blacklist.add({ videoId: video.id, reason: 'super reason' }); @@ -20,21 +20,21 @@ describe('Test video blacklist', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[1].videos.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } }); yield servers[1].videos.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].blacklist; yield blacklistVideosOnServer(servers[0]); }); }); describe('When listing/searching videos', function () { it('Should not have the video blacklisted in videos list/search on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(0); @@ -50,7 +50,7 @@ describe('Test video blacklist', function () { }); }); it('Should have the blacklisted video in videos list/search on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { total, data } = yield servers[1].videos.list(); expect(total).to.equal(2); @@ -68,7 +68,7 @@ describe('Test video blacklist', function () { }); describe('When listing manually blacklisted videos', function () { it('Should display all the blacklisted videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list(); expect(body.total).to.equal(2); const blacklistedVideos = body.data; @@ -81,7 +81,7 @@ describe('Test video blacklist', function () { }); }); it('Should display all the blacklisted videos when applying manual type filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ type: 1 }); expect(body.total).to.equal(2); const blacklistedVideos = body.data; @@ -90,7 +90,7 @@ describe('Test video blacklist', function () { }); }); it('Should display nothing when applying automatic type filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ type: 2 }); expect(body.total).to.equal(0); const blacklistedVideos = body.data; @@ -99,42 +99,42 @@ describe('Test video blacklist', function () { }); }); it('Should get the correct sort when sorting by descending id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: '-id' }); expect(body.total).to.equal(2); const blacklistedVideos = body.data; expect(blacklistedVideos).to.be.an('array'); expect(blacklistedVideos.length).to.equal(2); - const result = lodash_1.orderBy(body.data, ['id'], ['desc']); + const result = (0, lodash_1.orderBy)(body.data, ['id'], ['desc']); expect(blacklistedVideos).to.deep.equal(result); }); }); it('Should get the correct sort when sorting by descending video name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: '-name' }); expect(body.total).to.equal(2); const blacklistedVideos = body.data; expect(blacklistedVideos).to.be.an('array'); expect(blacklistedVideos.length).to.equal(2); - const result = lodash_1.orderBy(body.data, ['name'], ['desc']); + const result = (0, lodash_1.orderBy)(body.data, ['name'], ['desc']); expect(blacklistedVideos).to.deep.equal(result); }); }); it('Should get the correct sort when sorting by ascending creation date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: 'createdAt' }); expect(body.total).to.equal(2); const blacklistedVideos = body.data; expect(blacklistedVideos).to.be.an('array'); expect(blacklistedVideos.length).to.equal(2); - const result = lodash_1.orderBy(body.data, ['createdAt']); + const result = (0, lodash_1.orderBy)(body.data, ['createdAt']); expect(blacklistedVideos).to.deep.equal(result); }); }); }); describe('When updating blacklisted videos', function () { it('Should change the reason', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.update({ videoId, reason: 'my super reason updated' }); const body = yield command.list({ sort: '-name' }); const video = body.data.find(b => b.video.id === videoId); @@ -144,7 +144,7 @@ describe('Test video blacklist', function () { }); describe('When listing my videos', function () { it('Should display blacklisted videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield blacklistVideosOnServer(servers[1]); const { total, data } = yield servers[1].videos.listMyVideos(); expect(total).to.equal(2); @@ -160,7 +160,7 @@ describe('Test video blacklist', function () { let videoToRemove; let blacklist = []; it('Should not have any video in videos list on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(0); expect(data).to.be.an('array'); @@ -168,7 +168,7 @@ describe('Test video blacklist', function () { }); }); it('Should remove a video from the blacklist on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: '-name' }); videoToRemove = body.data[0]; blacklist = body.data.slice(1); @@ -176,7 +176,7 @@ describe('Test video blacklist', function () { }); }); it('Should have the ex-blacklisted video in videos list on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(1); expect(data).to.be.an('array'); @@ -186,7 +186,7 @@ describe('Test video blacklist', function () { }); }); it('Should not have the ex-blacklisted video in videos blacklist list on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: '-name' }); expect(body.total).to.equal(1); const videos = body.data; @@ -200,7 +200,7 @@ describe('Test video blacklist', function () { let video3UUID; let video4UUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'Video 3' } }); @@ -210,14 +210,14 @@ describe('Test video blacklist', function () { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'Video 4' } }); video4UUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should blacklist video 3 and keep it federated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.add({ videoId: video3UUID, reason: 'super reason', unfederate: false }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { data } = yield servers[0].videos.list(); expect(data.find(v => v.uuid === video3UUID)).to.be.undefined; @@ -229,10 +229,10 @@ describe('Test video blacklist', function () { }); }); it('Should unfederate the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.add({ videoId: video4UUID, reason: 'super reason', unfederate: true }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); expect(data.find(v => v.uuid === video4UUID)).to.be.undefined; @@ -240,10 +240,10 @@ describe('Test video blacklist', function () { }); }); it('Should have the video unfederated even after an Update AP message', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].videos.update({ id: video4UUID, attributes: { description: 'super description' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); expect(data.find(v => v.uuid === video4UUID)).to.be.undefined; @@ -251,7 +251,7 @@ describe('Test video blacklist', function () { }); }); it('Should have the correct video blacklist unfederate attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ sort: 'createdAt' }); const blacklistedVideos = body.data; const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID); @@ -261,10 +261,10 @@ describe('Test video blacklist', function () { }); }); it('Should remove the video from blacklist and refederate the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.remove({ videoId: video4UUID }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined; @@ -277,9 +277,9 @@ describe('Test video blacklist', function () { let userWithFlag; let channelOfUserWithoutFlag; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); const config = { auto_blacklist: { videos: { @@ -312,11 +312,11 @@ describe('Test video blacklist', function () { }); userWithFlag = yield servers[0].login.getAccessToken(user); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should auto blacklist a video on upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } }); const body = yield command.list({ type: 2 }); expect(body.total).to.equal(1); @@ -324,7 +324,7 @@ describe('Test video blacklist', function () { }); }); it('Should auto blacklist a video on URL import', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const attributes = { targetUrl: extra_utils_1.FIXTURE_URLS.goodVideo, @@ -338,7 +338,7 @@ describe('Test video blacklist', function () { }); }); it('Should auto blacklist a video on torrent import', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { magnetUri: extra_utils_1.FIXTURE_URLS.magnet, name: 'Torrent import', @@ -351,7 +351,7 @@ describe('Test video blacklist', function () { }); }); it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } }); const body = yield command.list({ type: 2 }); expect(body.total).to.equal(3); @@ -359,8 +359,8 @@ describe('Test video blacklist', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/notifications/admin-notifications.js b/dist/server/tests/api/notifications/admin-notifications.js index 153b16a1..565f10e4 100644 --- a/dist/server/tests/api/notifications/admin-notifications.js +++ b/dist/server/tests/api/notifications/admin-notifications.js @@ -13,7 +13,7 @@ describe('Test admin notifications', function () { let baseParams; let joinPeerTubeServer; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); joinPeerTubeServer = new extra_utils_1.MockJoinPeerTubeVersions(); const port = yield joinPeerTubeServer.initialize(); @@ -31,7 +31,7 @@ describe('Test admin notifications', function () { } } }; - const res = yield extra_utils_1.prepareNotificationsTest(1, config); + const res = yield (0, extra_utils_1.prepareNotificationsTest)(1, config); emails = res.emails; server = res.servers[0]; userNotifications = res.userNotifications; @@ -48,87 +48,87 @@ describe('Test admin notifications', function () { }); describe('Latest PeerTube version notification', function () { it('Should not send a notification to admins if there is not a new version', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); joinPeerTubeServer.setLatestVersion('1.4.2'); - yield extra_utils_1.wait(3000); - yield extra_utils_1.checkNewPeerTubeVersion(Object.assign(Object.assign({}, baseParams), { latestVersion: '1.4.2', checkType: 'absence' })); + yield (0, extra_utils_1.wait)(3000); + yield (0, extra_utils_1.checkNewPeerTubeVersion)(Object.assign(Object.assign({}, baseParams), { latestVersion: '1.4.2', checkType: 'absence' })); }); }); it('Should send a notification to admins on new plugin version', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); joinPeerTubeServer.setLatestVersion('15.4.2'); - yield extra_utils_1.wait(3000); - yield extra_utils_1.checkNewPeerTubeVersion(Object.assign(Object.assign({}, baseParams), { latestVersion: '15.4.2', checkType: 'presence' })); + yield (0, extra_utils_1.wait)(3000); + yield (0, extra_utils_1.checkNewPeerTubeVersion)(Object.assign(Object.assign({}, baseParams), { latestVersion: '15.4.2', checkType: 'presence' })); }); }); it('Should not send the same notification to admins', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(3000); - chai_1.expect(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(1); + yield (0, extra_utils_1.wait)(3000); + (0, chai_1.expect)(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(1); }); }); it('Should not have sent a notification to users', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - chai_1.expect(userNotifications.filter(n => n.type === 18)).to.have.lengthOf(0); + (0, chai_1.expect)(userNotifications.filter(n => n.type === 18)).to.have.lengthOf(0); }); }); it('Should send a new notification after a new release', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); joinPeerTubeServer.setLatestVersion('15.4.3'); - yield extra_utils_1.wait(3000); - yield extra_utils_1.checkNewPeerTubeVersion(Object.assign(Object.assign({}, baseParams), { latestVersion: '15.4.3', checkType: 'presence' })); - chai_1.expect(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(2); + yield (0, extra_utils_1.wait)(3000); + yield (0, extra_utils_1.checkNewPeerTubeVersion)(Object.assign(Object.assign({}, baseParams), { latestVersion: '15.4.3', checkType: 'presence' })); + (0, chai_1.expect)(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(2); }); }); }); describe('Latest plugin version notification', function () { it('Should not send a notification to admins if there is no new plugin version', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkNewPluginVersion(Object.assign(Object.assign({}, baseParams), { pluginType: models_1.PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'absence' })); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkNewPluginVersion)(Object.assign(Object.assign({}, baseParams), { pluginType: models_1.PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'absence' })); }); }); it('Should send a notification to admins on new plugin version', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield server.sql.setPluginVersion('hello-world', '0.0.1'); yield server.sql.setPluginLatestVersion('hello-world', '0.0.1'); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkNewPluginVersion(Object.assign(Object.assign({}, baseParams), { pluginType: models_1.PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'presence' })); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkNewPluginVersion)(Object.assign(Object.assign({}, baseParams), { pluginType: models_1.PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'presence' })); }); }); it('Should not send the same notification to admins', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(6000); - chai_1.expect(adminNotifications.filter(n => n.type === 17)).to.have.lengthOf(1); + yield (0, extra_utils_1.wait)(6000); + (0, chai_1.expect)(adminNotifications.filter(n => n.type === 17)).to.have.lengthOf(1); }); }); it('Should not have sent a notification to users', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - chai_1.expect(userNotifications.filter(n => n.type === 17)).to.have.lengthOf(0); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + (0, chai_1.expect)(userNotifications.filter(n => n.type === 17)).to.have.lengthOf(0); }); }); it('Should send a new notification after a new plugin release', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield server.sql.setPluginVersion('hello-world', '0.0.1'); yield server.sql.setPluginLatestVersion('hello-world', '0.0.1'); - yield extra_utils_1.wait(6000); - chai_1.expect(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(2); + yield (0, extra_utils_1.wait)(6000); + (0, chai_1.expect)(adminNotifications.filter(n => n.type === 18)).to.have.lengthOf(2); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/notifications/comments-notifications.js b/dist/server/tests/api/notifications/comments-notifications.js index 4c494269..25bc1867 100644 --- a/dist/server/tests/api/notifications/comments-notifications.js +++ b/dist/server/tests/api/notifications/comments-notifications.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test comments notifications', function () { @@ -15,9 +15,9 @@ describe('Test comments notifications', function () { 'world,

what do you think about peertube?'; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - const res = yield extra_utils_1.prepareNotificationsTest(2); + const res = yield (0, extra_utils_1.prepareNotificationsTest)(2); emails = res.emails; userToken = res.userAccessToken; servers = res.servers; @@ -35,96 +35,96 @@ describe('Test comments notifications', function () { }; }); it('Should not send a new comment notification after a comment on another video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); const created = yield servers[0].comments.createThread({ videoId: uuid, text: 'comment' }); const commentId = created.id; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); }); }); it('Should not send a new comment notification if I comment my own video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); const created = yield servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' }); const commentId = created.id; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); }); }); it('Should not send a new comment notification if the account is muted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); const created = yield servers[0].comments.createThread({ videoId: uuid, text: 'comment' }); const commentId = created.id; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'absence' })); yield servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }); }); }); it('Should send a new comment notification after a local comment on my video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); const created = yield servers[0].comments.createThread({ videoId: uuid, text: 'comment' }); const commentId = created.id; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'presence' })); }); }); it('Should send a new comment notification after a remote comment on my video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].comments.createThread({ videoId: uuid, text: 'comment' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].comments.listThreads({ videoId: uuid }); expect(data).to.have.lengthOf(1); const commentId = data[0].id; - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, checkType: 'presence' })); }); }); it('Should send a new comment notification after a local reply on my video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); const { id: threadId } = yield servers[0].comments.createThread({ videoId: uuid, text: 'comment' }); const { id: commentId } = yield servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId, checkType: 'presence' })); }); }); it('Should send a new comment notification after a remote reply on my video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const created = yield servers[1].comments.createThread({ videoId: uuid, text: 'comment' }); const threadId = created.id; yield servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].comments.listThreads({ videoId: uuid }); expect(data).to.have.lengthOf(1); const threadId = data[0].id; const tree = yield servers[0].comments.getThread({ videoId: uuid, threadId }); expect(tree.children).to.have.lengthOf(1); const commentId = tree.children[0].comment.id; - yield extra_utils_1.checkNewCommentOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewCommentOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId, checkType: 'presence' })); }); }); it('Should convert markdown in comment to html', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } }); yield servers[0].comments.createThread({ videoId: uuid, text: commentText }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const latestEmail = emails[emails.length - 1]; expect(latestEmail['html']).to.contain(expectedHtml); }); @@ -133,7 +133,7 @@ describe('Test comments notifications', function () { describe('Mention notifications', function () { let baseParams; const byAccountDisplayName = 'super root name'; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { baseParams = { server: servers[0], emails, @@ -144,95 +144,95 @@ describe('Test comments notifications', function () { yield servers[1].users.updateMe({ displayName: 'super root 2 name' }); })); it('Should not send a new mention comment notification if I mention the video owner', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }); const { id: commentId } = yield servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); }); }); it('Should not send a new mention comment notification if I mention myself', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); const { id: commentId } = yield servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); }); }); it('Should not send a new mention notification if the account is muted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); const { id: commentId } = yield servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })); yield servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }); }); }); it('Should not send a new mention notification if the remote account mention a local account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { id: threadId } = yield servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const byAccountDisplayName = 'super root 2 name'; - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'absence' })); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'absence' })); }); }); it('Should send a new mention notification after local comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); const { id: threadId } = yield servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'presence' })); const { id: commentId } = yield servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })); }); }); it('Should send a new mention notification after remote comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const text1 = `hello @user_1@localhost:${servers[0].port} 1`; const { id: server2ThreadId } = yield servers[1].comments.createThread({ videoId: uuid, text: text1 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].comments.listThreads({ videoId: uuid }); expect(data).to.have.lengthOf(1); const byAccountDisplayName = 'super root 2 name'; const threadId = data[0].id; - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' })); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' })); const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`; yield servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const tree = yield servers[0].comments.getThread({ videoId: uuid, threadId }); expect(tree.children).to.have.lengthOf(1); const commentId = tree.children[0].comment.id; - yield extra_utils_1.checkCommentMention(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })); + yield (0, extra_utils_1.checkCommentMention)(Object.assign(Object.assign({}, baseParams), { shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })); }); }); it('Should convert markdown in comment to html', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'super video' } }); const { id: threadId } = yield servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' }); yield servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const latestEmail = emails[emails.length - 1]; expect(latestEmail['html']).to.contain(expectedHtml); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/notifications/moderation-notifications.js b/dist/server/tests/api/notifications/moderation-notifications.js index bcb36639..8936020d 100644 --- a/dist/server/tests/api/notifications/moderation-notifications.js +++ b/dist/server/tests/api/notifications/moderation-notifications.js @@ -12,9 +12,9 @@ describe('Test moderation notifications', function () { let adminNotificationsServer2 = []; let emails = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - const res = yield extra_utils_1.prepareNotificationsTest(3); + const res = yield (0, extra_utils_1.prepareNotificationsTest)(3); emails = res.emails; userAccessToken = res.userAccessToken; servers = res.servers; @@ -34,83 +34,83 @@ describe('Test moderation notifications', function () { }; }); it('Should send a notification to moderators on local video abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); yield servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoAbuseForModerators(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); }); }); it('Should send a notification to moderators on remote video abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const videoId = yield servers[1].videos.getId({ uuid: video.uuid }); yield servers[1].abuses.report({ videoId, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoAbuseForModerators(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); }); }); it('Should send a notification to moderators on local comment abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); const comment = yield servers[0].comments.createThread({ token: userAccessToken, videoId: video.id, - text: 'comment abuse ' + uuid_1.buildUUID() + text: 'comment abuse ' + (0, uuid_1.buildUUID)() }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentAbuseForModerators(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); }); }); it('Should send a notification to moderators on remote comment abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); yield servers[0].comments.createThread({ token: userAccessToken, videoId: video.id, - text: 'comment abuse ' + uuid_1.buildUUID() + text: 'comment abuse ' + (0, uuid_1.buildUUID)() }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[1].comments.listThreads({ videoId: video.uuid }); const commentId = data[0].id; yield servers[1].abuses.report({ commentId, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewCommentAbuseForModerators(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewCommentAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })); }); }); it('Should send a notification to moderators on local account abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const username = 'user' + new Date().getTime(); const { account } = yield servers[0].users.create({ username, password: 'donald' }); const accountId = account.id; yield servers[0].abuses.report({ accountId, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewAccountAbuseForModerators(Object.assign(Object.assign({}, baseParams), { displayName: username, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewAccountAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { displayName: username, checkType: 'presence' })); }); }); it('Should send a notification to moderators on remote account abuse', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const username = 'user' + new Date().getTime(); const tmpToken = yield servers[0].users.generateUserAndToken(username); yield servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const account = yield servers[1].accounts.get({ accountName: username + '@' + servers[0].host }); yield servers[1].abuses.report({ accountId: account.id, reason: 'super reason' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewAccountAbuseForModerators(Object.assign(Object.assign({}, baseParams), { displayName: username, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewAccountAbuseForModerators)(Object.assign(Object.assign({}, baseParams), { displayName: username, checkType: 'presence' })); }); }); }); @@ -118,33 +118,33 @@ describe('Test moderation notifications', function () { let baseParams; let abuseId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { baseParams = { server: servers[0], emails, socketNotifications: userNotifications, token: userAccessToken }; - const name = 'abuse ' + uuid_1.buildUUID(); + const name = 'abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); const body = yield servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }); abuseId = body.abuse.id; }); }); it('Should send a notification to reporter if the abuse has been accepted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].abuses.update({ abuseId, body: { state: 3 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkAbuseStateChange(Object.assign(Object.assign({}, baseParams), { abuseId, state: 3, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkAbuseStateChange)(Object.assign(Object.assign({}, baseParams), { abuseId, state: 3, checkType: 'presence' })); }); }); it('Should send a notification to reporter if the abuse has been rejected', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].abuses.update({ abuseId, body: { state: 2 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkAbuseStateChange(Object.assign(Object.assign({}, baseParams), { abuseId, state: 2, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkAbuseStateChange)(Object.assign(Object.assign({}, baseParams), { abuseId, state: 2, checkType: 'presence' })); }); }); }); @@ -154,7 +154,7 @@ describe('Test moderation notifications', function () { let abuseId; let abuseId2; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { baseParamsUser = { server: servers[0], emails, @@ -167,7 +167,7 @@ describe('Test moderation notifications', function () { socketNotifications: adminNotifications, token: servers[0].accessToken }; - const name = 'abuse ' + uuid_1.buildUUID(); + const name = 'abuse ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); { const body = yield servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }); @@ -180,42 +180,42 @@ describe('Test moderation notifications', function () { }); }); it('Should send a notification to reporter on new message', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const message = 'my super message to users'; yield servers[0].abuses.addMessage({ abuseId, message }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewAbuseMessage(Object.assign(Object.assign({}, baseParamsUser), { abuseId, message, toEmail: 'user_1@example.com', checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewAbuseMessage)(Object.assign(Object.assign({}, baseParamsUser), { abuseId, message, toEmail: 'user_1@example.com', checkType: 'presence' })); }); }); it('Should not send a notification to the admin if sent by the admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const message = 'my super message that should not be sent to the admin'; yield servers[0].abuses.addMessage({ abuseId, message }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'; - yield extra_utils_1.checkNewAbuseMessage(Object.assign(Object.assign({}, baseParamsAdmin), { abuseId, message, toEmail, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewAbuseMessage)(Object.assign(Object.assign({}, baseParamsAdmin), { abuseId, message, toEmail, checkType: 'absence' })); }); }); it('Should send a notification to moderators', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const message = 'my super message to moderators'; yield servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'; - yield extra_utils_1.checkNewAbuseMessage(Object.assign(Object.assign({}, baseParamsAdmin), { abuseId: abuseId2, message, toEmail, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewAbuseMessage)(Object.assign(Object.assign({}, baseParamsAdmin), { abuseId: abuseId2, message, toEmail, checkType: 'presence' })); }); }); it('Should not send a notification to reporter if sent by the reporter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const message = 'my super message that should not be sent to reporter'; yield servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const toEmail = 'user_1@example.com'; - yield extra_utils_1.checkNewAbuseMessage(Object.assign(Object.assign({}, baseParamsUser), { abuseId: abuseId2, message, toEmail, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewAbuseMessage)(Object.assign(Object.assign({}, baseParamsUser), { abuseId: abuseId2, message, toEmail, checkType: 'absence' })); }); }); }); @@ -230,26 +230,26 @@ describe('Test moderation notifications', function () { }; }); it('Should send a notification to video owner on blacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); yield servers[0].blacklist.add({ videoId: uuid }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewBlacklistOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, videoName: name, blacklistType: 'blacklist' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewBlacklistOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, videoName: name, blacklistType: 'blacklist' })); }); }); it('Should send a notification to video owner on unblacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - const name = 'video for abuse ' + uuid_1.buildUUID(); + const name = 'video for abuse ' + (0, uuid_1.buildUUID)(); const { uuid, shortUUID } = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name } }); yield servers[0].blacklist.add({ videoId: uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].blacklist.remove({ videoId: uuid }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(500); - yield extra_utils_1.checkNewBlacklistOnMyVideo(Object.assign(Object.assign({}, baseParams), { shortUUID, videoName: name, blacklistType: 'unblacklist' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(500); + yield (0, extra_utils_1.checkNewBlacklistOnMyVideo)(Object.assign(Object.assign({}, baseParams), { shortUUID, videoName: name, blacklistType: 'unblacklist' })); }); }); }); @@ -264,13 +264,13 @@ describe('Test moderation notifications', function () { }; }); it('Should send a notification only to moderators when a user registers on the instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].users.register({ username: 'user_45' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkUserRegistered(Object.assign(Object.assign({}, baseParams), { username: 'user_45', checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkUserRegistered)(Object.assign(Object.assign({}, baseParams), { username: 'user_45', checkType: 'presence' })); const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }; - yield extra_utils_1.checkUserRegistered(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { username: 'user_45', checkType: 'absence' })); + yield (0, extra_utils_1.checkUserRegistered)(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { username: 'user_45', checkType: 'absence' })); }); }); }); @@ -278,7 +278,7 @@ describe('Test moderation notifications', function () { const instanceIndexServer = new extra_utils_1.MockInstancesIndex(); let config; let baseParams; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { baseParams = { server: servers[0], emails, @@ -299,20 +299,20 @@ describe('Test moderation notifications', function () { }; })); it('Should send a notification only to admin when there is a new instance follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[2].follows.follow({ hosts: [servers[0].url] }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewInstanceFollower(Object.assign(Object.assign({}, baseParams), { followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewInstanceFollower)(Object.assign(Object.assign({}, baseParams), { followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })); const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }; - yield extra_utils_1.checkNewInstanceFollower(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewInstanceFollower)(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })); }); }); it('Should send a notification on auto follow back', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); yield servers[2].follows.unfollow({ target: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const config = { followings: { instance: { @@ -322,12 +322,12 @@ describe('Test moderation notifications', function () { }; yield servers[0].config.updateCustomSubConfig({ newConfig: config }); yield servers[2].follows.follow({ hosts: [servers[0].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const followerHost = servers[0].host; const followingHost = servers[2].host; - yield extra_utils_1.checkAutoInstanceFollowing(Object.assign(Object.assign({}, baseParams), { followerHost, followingHost, checkType: 'presence' })); + yield (0, extra_utils_1.checkAutoInstanceFollowing)(Object.assign(Object.assign({}, baseParams), { followerHost, followingHost, checkType: 'presence' })); const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }; - yield extra_utils_1.checkAutoInstanceFollowing(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { followerHost, followingHost, checkType: 'absence' })); + yield (0, extra_utils_1.checkAutoInstanceFollowing)(Object.assign(Object.assign(Object.assign({}, baseParams), userOverride), { followerHost, followingHost, checkType: 'absence' })); config.followings.instance.autoFollowBack.enabled = false; yield servers[0].config.updateCustomSubConfig({ newConfig: config }); yield servers[0].follows.unfollow({ target: servers[2] }); @@ -335,15 +335,15 @@ describe('Test moderation notifications', function () { }); }); it('Should send a notification on auto instances index follow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].follows.unfollow({ target: servers[1] }); yield servers[0].config.updateCustomSubConfig({ newConfig: config }); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); const followerHost = servers[0].host; const followingHost = servers[1].host; - yield extra_utils_1.checkAutoInstanceFollowing(Object.assign(Object.assign({}, baseParams), { followerHost, followingHost, checkType: 'presence' })); + yield (0, extra_utils_1.checkAutoInstanceFollowing)(Object.assign(Object.assign({}, baseParams), { followerHost, followingHost, checkType: 'presence' })); config.followings.instance.autoFollowIndex.enabled = false; yield servers[0].config.updateCustomSubConfig({ newConfig: config }); yield servers[0].follows.unfollow({ target: servers[1] }); @@ -358,7 +358,7 @@ describe('Test moderation notifications', function () { let shortUUID; let videoName; let currentCustomConfig; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { adminBaseParamsServer1 = { server: servers[0], emails, @@ -391,53 +391,53 @@ describe('Test moderation notifications', function () { yield servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }); })); it('Should send notification to moderators on new video with auto-blacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); - videoName = 'video with auto-blacklist ' + uuid_1.buildUUID(); + videoName = 'video with auto-blacklist ' + (0, uuid_1.buildUUID)(); const video = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } }); shortUUID = video.shortUUID; uuid = video.uuid; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoAutoBlacklistForModerators(Object.assign(Object.assign({}, adminBaseParamsServer1), { shortUUID, videoName, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoAutoBlacklistForModerators)(Object.assign(Object.assign({}, adminBaseParamsServer1), { shortUUID, videoName, checkType: 'presence' })); }); }); it('Should not send video publish notification if auto-blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, userBaseParams), { videoName, shortUUID, checkType: 'absence' })); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, userBaseParams), { videoName, shortUUID, checkType: 'absence' })); }); }); it('Should not send a local user subscription notification if auto-blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName, shortUUID, checkType: 'absence' })); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName, shortUUID, checkType: 'absence' })); }); }); it('Should not send a remote user subscription notification if auto-blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName, shortUUID, checkType: 'absence' })); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName, shortUUID, checkType: 'absence' })); }); }); it('Should send video published and unblacklist after video unblacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); yield servers[0].blacklist.remove({ videoId: uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should send a local user subscription notification after removed from blacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName, shortUUID, checkType: 'presence' })); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName, shortUUID, checkType: 'presence' })); }); }); it('Should send a remote user subscription notification after removed from blacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName, shortUUID, checkType: 'presence' })); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName, shortUUID, checkType: 'presence' })); }); }); it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const updateAt = new Date(new Date().getTime() + 1000000); - const name = 'video with auto-blacklist and future schedule ' + uuid_1.buildUUID(); + const name = 'video with auto-blacklist and future schedule ' + (0, uuid_1.buildUUID)(); const attributes = { name, privacy: 3, @@ -448,17 +448,17 @@ describe('Test moderation notifications', function () { }; const { shortUUID, uuid } = yield servers[0].videos.upload({ token: userAccessToken, attributes }); yield servers[0].blacklist.remove({ videoId: uuid }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewBlacklistOnMyVideo(Object.assign(Object.assign({}, userBaseParams), { shortUUID, videoName: name, blacklistType: 'unblacklist' })); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName: name, shortUUID, checkType: 'absence' })); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewBlacklistOnMyVideo)(Object.assign(Object.assign({}, userBaseParams), { shortUUID, videoName: name, blacklistType: 'unblacklist' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const updateAt = new Date(new Date().getTime() + 2000); - const name = 'video with schedule done and still auto-blacklisted ' + uuid_1.buildUUID(); + const name = 'video with schedule done and still auto-blacklisted ' + (0, uuid_1.buildUUID)(); const attributes = { name, privacy: 3, @@ -468,31 +468,31 @@ describe('Test moderation notifications', function () { } }; const { shortUUID } = yield servers[0].videos.upload({ token: userAccessToken, attributes }); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, userBaseParams), { videoName: name, shortUUID, checkType: 'absence' })); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName: name, shortUUID, checkType: 'absence' })); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, userBaseParams), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer1), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, adminBaseParamsServer2), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should not send a notification to moderators on new video without auto-blacklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - const name = 'video without auto-blacklist ' + uuid_1.buildUUID(); + const name = 'video without auto-blacklist ' + (0, uuid_1.buildUUID)(); const { shortUUID } = yield servers[0].videos.upload({ attributes: { name } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoAutoBlacklistForModerators(Object.assign(Object.assign({}, adminBaseParamsServer1), { shortUUID, videoName: name, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoAutoBlacklistForModerators)(Object.assign(Object.assign({}, adminBaseParamsServer1), { shortUUID, videoName: name, checkType: 'absence' })); }); }); - after(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + after(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig }); yield servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }); yield servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }); })); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/notifications/notifications-api.js b/dist/server/tests/api/notifications/notifications-api.js index c4bffd1b..45580c0e 100644 --- a/dist/server/tests/api/notifications/notifications-api.js +++ b/dist/server/tests/api/notifications/notifications-api.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test notifications API', function () { @@ -11,9 +11,9 @@ describe('Test notifications API', function () { let userToken; let emails = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - const res = yield extra_utils_1.prepareNotificationsTest(1); + const res = yield (0, extra_utils_1.prepareNotificationsTest)(1); emails = res.emails; userToken = res.userAccessToken; userNotifications = res.userNotifications; @@ -22,19 +22,19 @@ describe('Test notifications API', function () { for (let i = 0; i < 10; i++) { yield server.videos.randomUpload({ wait: false }); } - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); }); }); describe('Mark as read', function () { it('Should mark as read some notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.notifications.list({ token: userToken, start: 2, count: 3 }); const ids = data.map(n => n.id); yield server.notifications.markAsRead({ token: userToken, ids }); }); }); it('Should have the notifications marked as read', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.notifications.list({ token: userToken, start: 0, count: 10 }); expect(data[0].read).to.be.false; expect(data[1].read).to.be.false; @@ -45,7 +45,7 @@ describe('Test notifications API', function () { }); }); it('Should only list read notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.notifications.list({ token: userToken, start: 0, count: 10, unread: false }); for (const notification of data) { expect(notification.read).to.be.true; @@ -53,7 +53,7 @@ describe('Test notifications API', function () { }); }); it('Should only list unread notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.notifications.list({ token: userToken, start: 0, count: 10, unread: true }); for (const notification of data) { expect(notification.read).to.be.false; @@ -61,7 +61,7 @@ describe('Test notifications API', function () { }); }); it('Should mark as read all notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.notifications.markAsReadAll({ token: userToken }); const body = yield server.notifications.list({ token: userToken, start: 0, count: 10, unread: true }); expect(body.total).to.equal(0); @@ -80,11 +80,11 @@ describe('Test notifications API', function () { }; }); it('Should not have notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.notifications.updateMySettings({ token: userToken, - settings: Object.assign(Object.assign({}, extra_utils_1.getAllNotificationsSettings()), { newVideoFromSubscription: 0 }) + settings: Object.assign(Object.assign({}, (0, extra_utils_1.getAllNotificationsSettings)()), { newVideoFromSubscription: 0 }) }); { const info = yield server.users.getMyInfo({ token: userToken }); @@ -92,15 +92,15 @@ describe('Test notifications API', function () { } const { name, shortUUID } = yield server.videos.randomUpload(); const check = { web: true, mail: true }; - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should only have web notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.notifications.updateMySettings({ token: userToken, - settings: Object.assign(Object.assign({}, extra_utils_1.getAllNotificationsSettings()), { newVideoFromSubscription: 1 }) + settings: Object.assign(Object.assign({}, (0, extra_utils_1.getAllNotificationsSettings)()), { newVideoFromSubscription: 1 }) }); { const info = yield server.users.getMyInfo({ token: userToken }); @@ -109,20 +109,20 @@ describe('Test notifications API', function () { const { name, shortUUID } = yield server.videos.randomUpload(); { const check = { mail: true, web: false }; - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); } { const check = { mail: false, web: true }; - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'presence' })); } }); }); it('Should only have mail notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.notifications.updateMySettings({ token: userToken, - settings: Object.assign(Object.assign({}, extra_utils_1.getAllNotificationsSettings()), { newVideoFromSubscription: 2 }) + settings: Object.assign(Object.assign({}, (0, extra_utils_1.getAllNotificationsSettings)()), { newVideoFromSubscription: 2 }) }); { const info = yield server.users.getMyInfo({ token: userToken }); @@ -131,34 +131,34 @@ describe('Test notifications API', function () { const { name, shortUUID } = yield server.videos.randomUpload(); { const check = { mail: false, web: true }; - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'absence' })); } { const check = { mail: true, web: false }; - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { check, videoName: name, shortUUID, checkType: 'presence' })); } }); }); it('Should have email and web notifications', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.notifications.updateMySettings({ token: userToken, - settings: Object.assign(Object.assign({}, extra_utils_1.getAllNotificationsSettings()), { newVideoFromSubscription: 1 | 2 }) + settings: Object.assign(Object.assign({}, (0, extra_utils_1.getAllNotificationsSettings)()), { newVideoFromSubscription: 1 | 2 }) }); { const info = yield server.users.getMyInfo({ token: userToken }); expect(info.notificationSettings.newVideoFromSubscription).to.equal(1 | 2); } const { name, shortUUID } = yield server.videos.randomUpload(); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/notifications/user-notifications.js b/dist/server/tests/api/notifications/user-notifications.js index 3fbab602..00fc879f 100644 --- a/dist/server/tests/api/notifications/user-notifications.js +++ b/dist/server/tests/api/notifications/user-notifications.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const uuid_1 = require("@server/helpers/uuid"); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; @@ -15,9 +15,9 @@ describe('Test user notifications', function () { let emails = []; let channelId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - const res = yield extra_utils_1.prepareNotificationsTest(3); + const res = yield (0, extra_utils_1.prepareNotificationsTest)(3); emails = res.emails; userAccessToken = res.userAccessToken; servers = res.servers; @@ -38,9 +38,9 @@ describe('Test user notifications', function () { }; }); it('Should not send notifications if the user does not follow the video publisher', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.uploadRandomVideoOnServers(servers, 1); + yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1); const notification = yield servers[0].notifications.getLastest({ token: userAccessToken }); expect(notification).to.be.undefined; expect(emails).to.have.lengthOf(0); @@ -48,25 +48,25 @@ describe('Test user notifications', function () { }); }); it('Should send a new video notification if the user follows the local video publisher', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a new video notification from a remote account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(150000); yield servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a new video notification on a scheduled publication', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const updateAt = new Date(new Date().getTime() + 2000); const data = { @@ -76,13 +76,13 @@ describe('Test user notifications', function () { privacy: 1 } }; - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1, data); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1, data); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a new video notification on a remote scheduled publication', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(100000); const updateAt = new Date(new Date().getTime() + 2000); const data = { @@ -92,14 +92,14 @@ describe('Test user notifications', function () { privacy: 1 } }; - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, data); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, data); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should not send a notification before the video is published', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const updateAt = new Date(new Date().getTime() + 1000000); const data = { @@ -109,56 +109,56 @@ describe('Test user notifications', function () { privacy: 1 } }; - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1, data); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1, data); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should send a new video notification when a video becomes public', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const data = { privacy: 3 }; - const { name, uuid, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1, data); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + const { name, uuid, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1, data); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); yield servers[0].videos.update({ id: uuid, attributes: { privacy: 1 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a new video notification when a remote video becomes public', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const data = { privacy: 3 }; - const { name, uuid, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, data); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + const { name, uuid, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, data); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); yield servers[1].videos.update({ id: uuid, attributes: { privacy: 1 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should not send a new video notification when a video becomes unlisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const data = { privacy: 3 }; - const { name, uuid, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1, data); + const { name, uuid, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1, data); yield servers[0].videos.update({ id: uuid, attributes: { privacy: 2 } }); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should not send a new video notification when a remote video becomes unlisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const data = { privacy: 3 }; - const { name, uuid, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, data); + const { name, uuid, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, data); yield servers[1].videos.update({ id: uuid, attributes: { privacy: 2 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should send a new video notification after a video import', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(100000); - const name = 'video import ' + uuid_1.buildUUID(); + const name = 'video import ' + (0, uuid_1.buildUUID)(); const attributes = { name, channelId, @@ -166,8 +166,8 @@ describe('Test user notifications', function () { targetUrl: extra_utils_1.FIXTURE_URLS.goodVideo }; const { video } = yield servers[0].imports.importVideo({ attributes }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewVideoFromSubscription(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewVideoFromSubscription)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })); }); }); }); @@ -182,18 +182,18 @@ describe('Test user notifications', function () { }; }); it('Should not send a notification if transcoding is not enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 1); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 1); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); }); }); it('Should not send a notification if the wait transcoding is false', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, { waitTranscoding: false }); + yield (0, extra_utils_1.waitJobs)(servers); const notification = yield servers[0].notifications.getLastest({ token: userAccessToken }); if (notification) { expect(notification.type).to.not.equal(6); @@ -201,25 +201,25 @@ describe('Test user notifications', function () { }); }); it('Should send a notification even if the video is not transcoded in other resolutions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' }); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a notification with a transcoded video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, { waitTranscoding: true }); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should send a notification when an imported video is transcoded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - const name = 'video import ' + uuid_1.buildUUID(); + const name = 'video import ' + (0, uuid_1.buildUUID)(); const attributes = { name, channelId, @@ -228,12 +228,12 @@ describe('Test user notifications', function () { waitTranscoding: true }; const { video } = yield servers[1].imports.importVideo({ attributes }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })); }); }); it('Should send a notification when the scheduled update has been proceeded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(70000); const updateAt = new Date(new Date().getTime() + 2000); const data = { @@ -243,13 +243,13 @@ describe('Test user notifications', function () { privacy: 1 } }; - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, data); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, data); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'presence' })); }); }); it('Should not send a notification before the video is published', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const updateAt = new Date(new Date().getTime() + 1000000); const data = { @@ -259,9 +259,9 @@ describe('Test user notifications', function () { privacy: 1 } }; - const { name, shortUUID } = yield extra_utils_1.uploadRandomVideoOnServers(servers, 2, data); - yield extra_utils_1.wait(6000); - yield extra_utils_1.checkVideoIsPublished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); + const { name, shortUUID } = yield (0, extra_utils_1.uploadRandomVideoOnServers)(servers, 2, data); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.checkVideoIsPublished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, checkType: 'absence' })); }); }); }); @@ -276,9 +276,9 @@ describe('Test user notifications', function () { }; }); it('Should send a notification when the video import failed', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(70000); - const name = 'video import ' + uuid_1.buildUUID(); + const name = 'video import ' + (0, uuid_1.buildUUID)(); const attributes = { name, channelId, @@ -286,15 +286,15 @@ describe('Test user notifications', function () { targetUrl: extra_utils_1.FIXTURE_URLS.badVideo }; const { video: { shortUUID } } = yield servers[0].imports.importVideo({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const url = extra_utils_1.FIXTURE_URLS.badVideo; - yield extra_utils_1.checkMyVideoImportIsFinished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, url, success: false, checkType: 'presence' })); + yield (0, extra_utils_1.checkMyVideoImportIsFinished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, url, success: false, checkType: 'presence' })); }); }); it('Should send a notification when the video import succeeded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(70000); - const name = 'video import ' + uuid_1.buildUUID(); + const name = 'video import ' + (0, uuid_1.buildUUID)(); const attributes = { name, channelId, @@ -302,9 +302,9 @@ describe('Test user notifications', function () { targetUrl: extra_utils_1.FIXTURE_URLS.goodVideo }; const { video: { shortUUID } } = yield servers[0].imports.importVideo({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const url = extra_utils_1.FIXTURE_URLS.goodVideo; - yield extra_utils_1.checkMyVideoImportIsFinished(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, url, success: true, checkType: 'presence' })); + yield (0, extra_utils_1.checkMyVideoImportIsFinished)(Object.assign(Object.assign({}, baseParams), { videoName: name, shortUUID, url, success: true, checkType: 'presence' })); }); }); }); @@ -312,7 +312,7 @@ describe('Test user notifications', function () { let baseParams; const myChannelName = 'super channel name'; const myUserName = 'super user name'; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { baseParams = { server: servers[0], emails, @@ -332,28 +332,28 @@ describe('Test user notifications', function () { }); })); it('Should notify when a local channel is following one of our channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); yield servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewActorFollow(Object.assign(Object.assign({}, baseParams), { followType: 'channel', followerName: 'root', followerDisplayName: 'super root name', followingDisplayName: myChannelName, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewActorFollow)(Object.assign(Object.assign({}, baseParams), { followType: 'channel', followerName: 'root', followerDisplayName: 'super root name', followingDisplayName: myChannelName, checkType: 'presence' })); yield servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }); }); }); it('Should notify when a remote channel is following one of our channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); yield servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkNewActorFollow(Object.assign(Object.assign({}, baseParams), { followType: 'channel', followerName: 'root', followerDisplayName: 'super root 2 name', followingDisplayName: myChannelName, checkType: 'presence' })); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkNewActorFollow)(Object.assign(Object.assign({}, baseParams), { followType: 'channel', followerName: 'root', followerDisplayName: 'super root 2 name', followingDisplayName: myChannelName, checkType: 'presence' })); yield servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/object-storage/index.js b/dist/server/tests/api/object-storage/index.js index ed8f92c1..5adcd29b 100644 --- a/dist/server/tests/api/object-storage/index.js +++ b/dist/server/tests/api/object-storage/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./live"), exports); -tslib_1.__exportStar(require("./video-imports"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./live"), exports); +(0, tslib_1.__exportStar)(require("./video-imports"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/server/tests/api/object-storage/live.js b/dist/server/tests/api/object-storage/live.js index 5de680e6..d8b44713 100644 --- a/dist/server/tests/api/object-storage/live.js +++ b/dist/server/tests/api/object-storage/live.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; function createLive(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { channelId: server.store.channel.id, privacy: 1, @@ -19,46 +19,46 @@ function createLive(server) { }); } function checkFiles(files) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const file of files) { - extra_utils_1.expectStartWith(file.fileUrl, extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl()); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(file.fileUrl, extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl()); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } }); } describe('Object storage for lives', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; let ffmpegCommand; let servers; let videoUUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); - servers = yield extra_utils_1.createMultipleServers(2, extra_utils_1.ObjectStorageCommand.getDefaultConfig()); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, extra_utils_1.ObjectStorageCommand.getDefaultConfig()); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].config.enableTranscoding(); }); }); describe('Without live transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.enableLive({ transcoding: false }); videoUUID = yield createLive(servers[0]); }); }); it('Should create a live and save the replay on object storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(220000); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, videoUUID); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); - yield extra_utils_1.waitUntilLiveSavedOnAllServers(servers, videoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, videoUUID); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); + yield (0, extra_utils_1.waitUntilLiveSavedOnAllServers)(servers, videoUUID); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.files).to.have.lengthOf(0); @@ -71,21 +71,21 @@ describe('Object storage for lives', function () { }); }); describe('With live transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.enableLive({ transcoding: true }); videoUUID = yield createLive(servers[0]); }); }); it('Should import a video and have sent it to object storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); ffmpegCommand = yield servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }); - yield extra_utils_1.waitUntilLivePublishedOnAllServers(servers, videoUUID); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); - yield extra_utils_1.waitUntilLiveSavedOnAllServers(servers, videoUUID); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitUntilLivePublishedOnAllServers)(servers, videoUUID); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); + yield (0, extra_utils_1.waitUntilLiveSavedOnAllServers)(servers, videoUUID); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.files).to.have.lengthOf(0); @@ -99,8 +99,8 @@ describe('Object storage for lives', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.killallServers(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.killallServers)(servers); }); }); }); diff --git a/dist/server/tests/api/object-storage/video-imports.js b/dist/server/tests/api/object-storage/video-imports.js index 1e29f0a7..51a155b1 100644 --- a/dist/server/tests/api/object-storage/video-imports.js +++ b/dist/server/tests/api/object-storage/video-imports.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; function importVideo(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'import 2', privacy: 1, @@ -19,72 +19,72 @@ function importVideo(server) { }); } describe('Object storage for video import', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); - server = yield extra_utils_1.createSingleServer(1, extra_utils_1.ObjectStorageCommand.getDefaultConfig()); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, extra_utils_1.ObjectStorageCommand.getDefaultConfig()); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); yield server.config.enableImports(); }); }); describe('Without transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.disableTranscoding(); }); }); it('Should import a video and have sent it to object storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const uuid = yield importVideo(server); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); const video = yield server.videos.get({ id: uuid }); expect(video.files).to.have.lengthOf(1); expect(video.streamingPlaylists).to.have.lengthOf(0); const fileUrl = video.files[0].fileUrl; - extra_utils_1.expectStartWith(fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); - yield extra_utils_1.makeRawRequest(fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); + yield (0, extra_utils_1.makeRawRequest)(fileUrl, models_1.HttpStatusCode.OK_200); }); }); }); }); describe('With transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.enableTranscoding(); }); }); it('Should import a video and have sent it to object storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const uuid = yield importVideo(server); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); const video = yield server.videos.get({ id: uuid }); expect(video.files).to.have.lengthOf(4); expect(video.streamingPlaylists).to.have.lengthOf(1); expect(video.streamingPlaylists[0].files).to.have.lengthOf(4); for (const file of video.files) { - extra_utils_1.expectStartWith(file.fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(file.fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } for (const file of video.streamingPlaylists[0].files) { - extra_utils_1.expectStartWith(file.fileUrl, extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl()); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(file.fileUrl, extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl()); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.killallServers([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.killallServers)([server]); }); }); }); diff --git a/dist/server/tests/api/object-storage/videos.js b/dist/server/tests/api/object-storage/videos.js index b6a55cf5..3811d69b 100644 --- a/dist/server/tests/api/object-storage/videos.js +++ b/dist/server/tests/api/object-storage/videos.js @@ -2,13 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; function checkFiles(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, playlistBucket, webtorrentBucket, baseMockUrl, playlistPrefix, webtorrentPrefix } = options; let allFiles = video.files; for (const file of video.files) { @@ -17,11 +17,11 @@ function checkFiles(options) { : `http://${webtorrentBucket}.${extra_utils_1.ObjectStorageCommand.getEndpointHost()}/`; const prefix = webtorrentPrefix || ''; const start = baseUrl + prefix; - extra_utils_1.expectStartWith(file.fileUrl, start); - const res = yield extra_utils_1.makeRawRequest(file.fileDownloadUrl, models_1.HttpStatusCode.FOUND_302); + (0, extra_utils_1.expectStartWith)(file.fileUrl, start); + const res = yield (0, extra_utils_1.makeRawRequest)(file.fileDownloadUrl, models_1.HttpStatusCode.FOUND_302); const location = res.headers['location']; - extra_utils_1.expectStartWith(location, start); - yield extra_utils_1.makeRawRequest(location, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(location, start); + yield (0, extra_utils_1.makeRawRequest)(location, models_1.HttpStatusCode.OK_200); } const hls = video.streamingPlaylists[0]; if (hls) { @@ -31,25 +31,25 @@ function checkFiles(options) { : `http://${playlistBucket}.${extra_utils_1.ObjectStorageCommand.getEndpointHost()}/`; const prefix = playlistPrefix || ''; const start = baseUrl + prefix; - extra_utils_1.expectStartWith(hls.playlistUrl, start); - extra_utils_1.expectStartWith(hls.segmentsSha256Url, start); - yield extra_utils_1.makeRawRequest(hls.playlistUrl, models_1.HttpStatusCode.OK_200); - const resSha = yield extra_utils_1.makeRawRequest(hls.segmentsSha256Url, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(hls.playlistUrl, start); + (0, extra_utils_1.expectStartWith)(hls.segmentsSha256Url, start); + yield (0, extra_utils_1.makeRawRequest)(hls.playlistUrl, models_1.HttpStatusCode.OK_200); + const resSha = yield (0, extra_utils_1.makeRawRequest)(hls.segmentsSha256Url, models_1.HttpStatusCode.OK_200); expect(JSON.stringify(resSha.body)).to.not.throw; for (const file of hls.files) { - extra_utils_1.expectStartWith(file.fileUrl, start); - const res = yield extra_utils_1.makeRawRequest(file.fileDownloadUrl, models_1.HttpStatusCode.FOUND_302); + (0, extra_utils_1.expectStartWith)(file.fileUrl, start); + const res = yield (0, extra_utils_1.makeRawRequest)(file.fileDownloadUrl, models_1.HttpStatusCode.FOUND_302); const location = res.headers['location']; - extra_utils_1.expectStartWith(location, start); - yield extra_utils_1.makeRawRequest(location, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(location, start); + yield (0, extra_utils_1.makeRawRequest)(location, models_1.HttpStatusCode.OK_200); } } for (const file of allFiles) { - const torrent = yield extra_utils_1.webtorrentAdd(file.magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(file.magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); - const res = yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + const res = yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); expect(res.body).to.have.length.above(100); } return allFiles.map(f => f.fileUrl); @@ -63,7 +63,7 @@ function runTestSuite(options) { const uuidsToDelete = []; let deletedUrls = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const port = yield mockObjectStorage.initialize(); baseMockUrl = options.useMockBaseUrl ? `http://localhost:${port}` : undefined; @@ -92,23 +92,23 @@ function runTestSuite(options) { } } }; - servers = yield extra_utils_1.createMultipleServers(2, config); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); for (const server of servers) { const { uuid } = yield server.videos.quickUpload({ name: 'video to keep' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const files = yield server.videos.listFiles({ id: uuid }); keptUrls = keptUrls.concat(files.map(f => f.fileUrl)); } }); }); it('Should upload a video and move it to the object storage without transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const { uuid } = yield servers[0].videos.quickUpload({ name: 'video 1' }); uuidsToDelete.push(uuid); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: uuid }); const files = yield checkFiles(Object.assign(Object.assign({}, options), { video, baseMockUrl })); @@ -117,11 +117,11 @@ function runTestSuite(options) { }); }); it('Should upload a video and move it to the object storage with transcoding', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const { uuid } = yield servers[1].videos.quickUpload({ name: 'video 2' }); uuidsToDelete.push(uuid); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: uuid }); const files = yield checkFiles(Object.assign(Object.assign({}, options), { video, baseMockUrl })); @@ -130,45 +130,45 @@ function runTestSuite(options) { }); }); it('Should correctly delete the files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.remove({ id: uuidsToDelete[0] }); yield servers[1].videos.remove({ id: uuidsToDelete[1] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const url of deletedUrls) { - yield extra_utils_1.makeRawRequest(url, models_1.HttpStatusCode.NOT_FOUND_404); + yield (0, extra_utils_1.makeRawRequest)(url, models_1.HttpStatusCode.NOT_FOUND_404); } }); }); it('Should have kept other files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const url of keptUrls) { - yield extra_utils_1.makeRawRequest(url, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(url, models_1.HttpStatusCode.OK_200); } }); }); it('Should have an empty tmp directory', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkTmpIsEmpty(server); + yield (0, extra_utils_1.checkTmpIsEmpty)(server); } }); }); it('Should not have downloaded files from object storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.expectLogDoesNotContain(server, 'from object storage'); + yield (0, extra_utils_1.expectLogDoesNotContain)(server, 'from object storage'); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield mockObjectStorage.terminate(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); } describe('Object storage for videos', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; describe('Test config', function () { let server; @@ -191,7 +191,7 @@ describe('Object storage for videos', function () { secret_access_key: 'aJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' }; it('Should fail with same bucket names without prefix', function (done) { - const config = lodash_1.merge({}, baseConfig, { + const config = (0, lodash_1.merge)({}, baseConfig, { object_storage: { streaming_playlists: { bucket_name: 'aaa' @@ -201,33 +201,33 @@ describe('Object storage for videos', function () { } } }); - extra_utils_1.createSingleServer(1, config) + (0, extra_utils_1.createSingleServer)(1, config) .then(() => done(new Error('Did not throw'))) .catch(() => done()); }); it('Should fail with bad credentials', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); - const config = lodash_1.merge({}, baseConfig, { + const config = (0, lodash_1.merge)({}, baseConfig, { object_storage: { credentials: badCredentials } }); - server = yield extra_utils_1.createSingleServer(1, config); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, config); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { uuid } = yield server.videos.quickUpload({ name: 'video' }); - yield extra_utils_1.waitJobs([server], true); + yield (0, extra_utils_1.waitJobs)([server], true); const video = yield server.videos.get({ id: uuid }); - extra_utils_1.expectStartWith(video.files[0].fileUrl, server.url); - yield extra_utils_1.killallServers([server]); + (0, extra_utils_1.expectStartWith)(video.files[0].fileUrl, server.url); + yield (0, extra_utils_1.killallServers)([server]); }); }); it('Should succeed with credentials from env', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); - const config = lodash_1.merge({}, baseConfig, { + const config = (0, lodash_1.merge)({}, baseConfig, { object_storage: { credentials: { access_key_id: '', @@ -236,22 +236,22 @@ describe('Object storage for videos', function () { } }); const goodCredentials = extra_utils_1.ObjectStorageCommand.getCredentialsConfig(); - server = yield extra_utils_1.createSingleServer(1, config, { + server = yield (0, extra_utils_1.createSingleServer)(1, config, { env: { AWS_ACCESS_KEY_ID: goodCredentials.access_key_id, AWS_SECRET_ACCESS_KEY: goodCredentials.secret_access_key } }); - yield extra_utils_1.setAccessTokensToServers([server]); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { uuid } = yield server.videos.quickUpload({ name: 'video' }); - yield extra_utils_1.waitJobs([server], true); + yield (0, extra_utils_1.waitJobs)([server], true); const video = yield server.videos.get({ id: uuid }); - extra_utils_1.expectStartWith(video.files[0].fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); + (0, extra_utils_1.expectStartWith)(video.files[0].fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.killallServers([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.killallServers)([server]); }); }); }); diff --git a/dist/server/tests/api/redundancy/manage-redundancy.js b/dist/server/tests/api/redundancy/manage-redundancy.js index 0962bbbf..8bc2efb8 100644 --- a/dist/server/tests/api/redundancy/manage-redundancy.js +++ b/dist/server/tests/api/redundancy/manage-redundancy.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test manage videos redundancy', function () { @@ -13,7 +13,7 @@ describe('Test manage videos redundancy', function () { let redundanciesToRemove = []; let commands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = { transcoding: { @@ -35,8 +35,8 @@ describe('Test manage videos redundancy', function () { } } }; - servers = yield extra_utils_1.createMultipleServers(3, config); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); commands = servers.map(s => s.redundancy); { const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } }); @@ -46,14 +46,14 @@ describe('Test manage videos redundancy', function () { const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } }); video2Server2UUID = uuid; } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield commands[0].updateRedundancy({ host: servers[1].host, redundancyAllowed: true }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have redundancies on server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const target of targets) { const body = yield commands[2].listVideos({ target }); expect(body.total).to.equal(0); @@ -62,18 +62,18 @@ describe('Test manage videos redundancy', function () { }); }); it('Should not have "remote-videos" redundancies on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 10); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[1].listVideos({ target: 'remote-videos' }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should have "my-videos" redundancies on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const body = yield commands[1].listVideos({ target: 'my-videos' }); expect(body.total).to.equal(2); @@ -96,14 +96,14 @@ describe('Test manage videos redundancy', function () { }); }); it('Should not have "my-videos" redundancies on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].listVideos({ target: 'my-videos' }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should have "remote-videos" redundancies on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const body = yield commands[0].listVideos({ target: 'remote-videos' }); expect(body.total).to.equal(2); @@ -126,7 +126,7 @@ describe('Test manage videos redundancy', function () { }); }); it('Should correctly paginate and sort results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield commands[0].listVideos({ target: 'remote-videos', @@ -161,15 +161,15 @@ describe('Test manage videos redundancy', function () { }); }); it('Should manually add a redundancy and list it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const uuid = (yield servers[1].videos.quickUpload({ name: 'video 3 server 2', privacy: 2 })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const videoId = yield servers[0].videos.getId({ uuid }); yield commands[0].addVideo({ videoId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 15); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield commands[0].listVideos({ target: 'remote-videos', @@ -212,7 +212,7 @@ describe('Test manage videos redundancy', function () { }); }); it('Should manually remove a redundancy and remove it from the list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); for (const redundancyId of redundanciesToRemove) { yield commands[0].removeVideo({ redundancyId }); @@ -236,7 +236,7 @@ describe('Test manage videos redundancy', function () { }); }); it('Should remove another (auto) redundancy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const redundancyId of redundanciesToRemove) { yield commands[0].removeVideo({ redundancyId }); } @@ -252,8 +252,8 @@ describe('Test manage videos redundancy', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/redundancy/redundancy-constraints.js b/dist/server/tests/api/redundancy/redundancy-constraints.js index 99ee9476..45d8c2e1 100644 --- a/dist/server/tests/api/redundancy/redundancy-constraints.js +++ b/dist/server/tests/api/redundancy/redundancy-constraints.js @@ -24,29 +24,29 @@ describe('Test redundancy constraints', function () { } }; function uploadWrapper(videoName) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { id } = yield localServer.videos.upload({ attributes: { name: 'to transcode', privacy: 3 } }); - yield extra_utils_1.waitJobs([localServer]); + yield (0, extra_utils_1.waitJobs)([localServer]); yield localServer.videos.update({ id, attributes: { name: videoName, privacy: 1 } }); }); } function getTotalRedundanciesLocalServer() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield localServer.redundancy.listVideos({ target: 'my-videos' }); return body.total; }); } function getTotalRedundanciesRemoteServer() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield remoteServer.redundancy.listVideos({ target: 'remote-videos' }); return body.total; }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); { - remoteServer = yield extra_utils_1.createSingleServer(1, remoteServerConfig); + remoteServer = yield (0, extra_utils_1.createSingleServer)(1, remoteServerConfig); } { const config = { @@ -56,36 +56,36 @@ describe('Test redundancy constraints', function () { } } }; - localServer = yield extra_utils_1.createSingleServer(2, config); + localServer = yield (0, extra_utils_1.createSingleServer)(2, config); } servers = [remoteServer, localServer]; - yield extra_utils_1.setAccessTokensToServers(servers); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); yield localServer.videos.upload({ attributes: { name: 'video 1 server 2' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield remoteServer.follows.follow({ hosts: [localServer.url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have redundancy on server 1 but not on server 2 with a nobody filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield remoteServer.servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const total = yield getTotalRedundanciesRemoteServer(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); } { const total = yield getTotalRedundanciesLocalServer(); - chai_1.expect(total).to.equal(0); + (0, chai_1.expect)(total).to.equal(0); } }); }); it('Should have redundancy on server 1 and on server 2 with an anybody filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = { remote_redundancy: { @@ -94,23 +94,23 @@ describe('Test redundancy constraints', function () { } } }; - yield extra_utils_1.killallServers([localServer]); + yield (0, extra_utils_1.killallServers)([localServer]); yield localServer.run(config); yield uploadWrapper('video 2 server 2'); yield remoteServer.servers.waitUntilLog('Duplicated ', 10); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const total = yield getTotalRedundanciesRemoteServer(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); } { const total = yield getTotalRedundanciesLocalServer(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); } }); }); it('Should have redundancy on server 1 but not on server 2 with a followings filter', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = { remote_redundancy: { @@ -119,42 +119,42 @@ describe('Test redundancy constraints', function () { } } }; - yield extra_utils_1.killallServers([localServer]); + yield (0, extra_utils_1.killallServers)([localServer]); yield localServer.run(config); yield uploadWrapper('video 3 server 2'); yield remoteServer.servers.waitUntilLog('Duplicated ', 15); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const total = yield getTotalRedundanciesRemoteServer(); - chai_1.expect(total).to.equal(3); + (0, chai_1.expect)(total).to.equal(3); } { const total = yield getTotalRedundanciesLocalServer(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); } }); }); it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield localServer.follows.follow({ hosts: [remoteServer.url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield uploadWrapper('video 4 server 2'); yield remoteServer.servers.waitUntilLog('Duplicated ', 20); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const total = yield getTotalRedundanciesRemoteServer(); - chai_1.expect(total).to.equal(4); + (0, chai_1.expect)(total).to.equal(4); } { const total = yield getTotalRedundanciesLocalServer(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/redundancy/redundancy.js b/dist/server/tests/api/redundancy/redundancy.js index 38713fb1..f0277a80 100644 --- a/dist/server/tests/api/redundancy/redundancy.js +++ b/dist/server/tests/api/redundancy/redundancy.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const fs_extra_1 = require("fs-extra"); -const magnet_uri_1 = tslib_1.__importDefault(require("magnet-uri")); +const magnet_uri_1 = (0, tslib_1.__importDefault)(require("magnet-uri")); const path_1 = require("path"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); @@ -12,20 +12,20 @@ const expect = chai.expect; let servers = []; let video1Server2; function checkMagnetWebseeds(file, baseWebseeds, server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const parsed = magnet_uri_1.default.decode(file.magnetUri); for (const ws of baseWebseeds) { - const found = parsed.urlList.find(url => url === `${ws}${path_1.basename(file.fileUrl)}`); + const found = parsed.urlList.find(url => url === `${ws}${(0, path_1.basename)(file.fileUrl)}`); expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined; } expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length); for (const url of parsed.urlList) { - yield extra_utils_1.makeRawRequest(url, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(url, models_1.HttpStatusCode.OK_200); } }); } function createServers(strategy, additionalParams = {}, withWebtorrent = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const strategies = []; if (strategy !== null) { strategies.push(Object.assign({ min_lifetime: '1 hour', strategy: strategy, size: '400KB' }, additionalParams)); @@ -46,28 +46,28 @@ function createServers(strategy, additionalParams = {}, withWebtorrent = true) { } } }; - servers = yield extra_utils_1.createMultipleServers(3, config); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const { id } = yield servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } }); video1Server2 = yield servers[1].videos.get({ id }); yield servers[1].videos.view({ id }); } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.doubleFollow(servers[0], servers[2]); - yield extra_utils_1.doubleFollow(servers[1], servers[2]); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[1], servers[2]); + yield (0, extra_utils_1.waitJobs)(servers); }); } function ensureSameFilenames(videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let webtorrentFilenames; let hlsFilenames; for (const server of servers) { const video = yield server.videos.getWithToken({ id: videoUUID }); - const localWebtorrentFilenames = video.files.map(f => path_1.basename(f.fileUrl)).sort(); - const localHLSFilenames = video.streamingPlaylists[0].files.map(f => path_1.basename(f.fileUrl)).sort(); + const localWebtorrentFilenames = video.files.map(f => (0, path_1.basename)(f.fileUrl)).sort(); + const localHLSFilenames = video.streamingPlaylists[0].files.map(f => (0, path_1.basename)(f.fileUrl)).sort(); if (webtorrentFilenames) expect(webtorrentFilenames).to.deep.equal(localWebtorrentFilenames); else @@ -81,7 +81,7 @@ function ensureSameFilenames(videoUUID) { }); } function check1WebSeed(videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!videoUUID) videoUUID = video1Server2.uuid; const webseeds = [ @@ -97,7 +97,7 @@ function check1WebSeed(videoUUID) { }); } function check2Webseeds(videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!videoUUID) videoUUID = video1Server2.uuid; const webseeds = [ @@ -116,14 +116,14 @@ function check2Webseeds(videoUUID) { 'test' + servers[1].internalServerNumber + '/videos' ]; for (const directory of directories) { - const files = yield fs_extra_1.readdir(path_1.join(extra_utils_1.root(), directory)); + const files = yield (0, fs_extra_1.readdir)((0, path_1.join)((0, extra_utils_1.root)(), directory)); expect(files).to.have.length.at.least(4); expect(files.find(f => webtorrentFilenames.includes(f))).to.exist; } }); } function check0PlaylistRedundancies(videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!videoUUID) videoUUID = video1Server2.uuid; for (const server of servers) { @@ -136,7 +136,7 @@ function check0PlaylistRedundancies(videoUUID) { }); } function check1PlaylistRedundancies(videoUUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!videoUUID) videoUUID = video1Server2.uuid; for (const server of servers) { @@ -151,7 +151,7 @@ function check1PlaylistRedundancies(videoUUID) { const video = yield servers[0].videos.get({ id: videoUUID }); const hlsPlaylist = video.streamingPlaylists[0]; for (const resolution of [240, 360, 480, 720]) { - yield extra_utils_1.checkSegmentHash({ server: servers[1], baseUrlPlaylist, baseUrlSegment, resolution, hlsPlaylist }); + yield (0, extra_utils_1.checkSegmentHash)({ server: servers[1], baseUrlPlaylist, baseUrlSegment, resolution, hlsPlaylist }); } const { hlsFilenames } = yield ensureSameFilenames(videoUUID); const directories = [ @@ -159,14 +159,14 @@ function check1PlaylistRedundancies(videoUUID) { 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls' ]; for (const directory of directories) { - const files = yield fs_extra_1.readdir(path_1.join(extra_utils_1.root(), directory, videoUUID)); + const files = yield (0, fs_extra_1.readdir)((0, path_1.join)((0, extra_utils_1.root)(), directory, videoUUID)); expect(files).to.have.length.at.least(4); expect(files.find(f => hlsFilenames.includes(f))).to.exist; } }); } function checkStatsGlobal(strategy) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let totalSize = null; let statsLength = 1; if (strategy !== 'manual') { @@ -182,7 +182,7 @@ function checkStatsGlobal(strategy) { }); } function checkStatsWith1Redundancy(strategy, onlyHls = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const stat = yield checkStatsGlobal(strategy); expect(stat.totalUsed).to.be.at.least(1).and.below(409601); expect(stat.totalVideoFiles).to.equal(onlyHls ? 4 : 8); @@ -190,7 +190,7 @@ function checkStatsWith1Redundancy(strategy, onlyHls = false) { }); } function checkStatsWithoutRedundancy(strategy) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const stat = yield checkStatsGlobal(strategy); expect(stat.totalUsed).to.equal(0); expect(stat.totalVideoFiles).to.equal(0); @@ -198,7 +198,7 @@ function checkStatsWithoutRedundancy(strategy) { }); } function findServerFollows() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' }); const follows = body.data; const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`); @@ -207,7 +207,7 @@ function findServerFollows() { }); } function enableRedundancyOnServer1() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true }); const { server2, server3 } = yield findServerFollows(); expect(server3).to.not.be.undefined; @@ -217,7 +217,7 @@ function enableRedundancyOnServer1() { }); } function disableRedundancyOnServer1() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false }); const { server2, server3 } = yield findServerFollows(); expect(server3).to.not.be.undefined; @@ -234,7 +234,7 @@ describe('Test videos redundancy', function () { return createServers(strategy); }); it('Should have 1 webseed on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check1WebSeed(); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy(strategy); @@ -244,30 +244,30 @@ describe('Test videos redundancy', function () { return enableRedundancyOnServer1(); }); it('Should have 2 webseeds on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy); }); }); it('Should undo redundancy on server 1 and remove duplicated videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); yield disableRedundancyOnServer1(); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); yield check1WebSeed(); yield check0PlaylistRedundancies(); - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - return extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + return (0, extra_utils_1.cleanupTests)(servers); }); }); }); @@ -278,7 +278,7 @@ describe('Test videos redundancy', function () { return createServers(strategy); }); it('Should have 1 webseed on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check1WebSeed(); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy(strategy); @@ -288,41 +288,41 @@ describe('Test videos redundancy', function () { return enableRedundancyOnServer1(); }); it('Should have 2 webseeds on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy); }); }); it('Should unfollow server 3 and keep duplicated videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); yield servers[0].follows.unfollow({ target: servers[2] }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy); }); }); it('Should unfollow server 2 and remove duplicated videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); yield servers[0].follows.unfollow({ target: servers[1] }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); yield check1WebSeed(); yield check0PlaylistRedundancies(); - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); @@ -333,7 +333,7 @@ describe('Test videos redundancy', function () { return createServers(strategy, { min_views: 3 }); }); it('Should have 1 webseed on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check1WebSeed(); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy(strategy); @@ -343,63 +343,63 @@ describe('Test videos redundancy', function () { return enableRedundancyOnServer1(); }); it('Should still have 1 webseed on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(15000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(15000); + yield (0, extra_utils_1.waitJobs)(servers); yield check1WebSeed(); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy(strategy); }); }); it('Should view 2 times the first video to have > min_views config', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); yield servers[0].videos.view({ id: video1Server2.uuid }); yield servers[2].videos.view({ id: video1Server2.uuid }); - yield extra_utils_1.wait(10000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(10000); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 2 webseeds on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy); }); }); it('Should remove the video and the redundancy files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.saveVideoInServers(servers, video1Server2.uuid); + yield (0, extra_utils_1.saveVideoInServers)(servers, video1Server2.uuid); yield servers[1].videos.remove({ id: video1Server2.uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { - yield extra_utils_1.checkVideoFilesWereRemoved({ server, video: server.store.videoDetails }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server, video: server.store.videoDetails }); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); describe('With only HLS files', function () { const strategy = 'recently-added'; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield createServers(strategy, { min_views: 3 }, false); }); }); it('Should have 0 playlist redundancy on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check1WebSeed(); yield check0PlaylistRedundancies(); }); @@ -408,43 +408,43 @@ describe('Test videos redundancy', function () { return enableRedundancyOnServer1(); }); it('Should still have 0 redundancy on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(15000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(15000); + yield (0, extra_utils_1.waitJobs)(servers); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy(strategy); }); }); it('Should have 1 redundancy on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); yield servers[0].videos.view({ id: video1Server2.uuid }); yield servers[2].videos.view({ id: video1Server2.uuid }); - yield extra_utils_1.wait(10000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 1); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy, true); }); }); it('Should remove the video and the redundancy files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.saveVideoInServers(servers, video1Server2.uuid); + yield (0, extra_utils_1.saveVideoInServers)(servers, video1Server2.uuid); yield servers[1].videos.remove({ id: video1Server2.uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { - yield extra_utils_1.checkVideoFilesWereRemoved({ server, video: server.store.videoDetails }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server, video: server.store.videoDetails }); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); @@ -454,30 +454,30 @@ describe('Test videos redundancy', function () { return createServers(null); }); it('Should have 1 webseed on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check1WebSeed(); yield check0PlaylistRedundancies(); yield checkStatsWithoutRedundancy('manual'); }); }); it('Should create a redundancy on first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].redundancy.addVideo({ videoId: video1Server2.id }); }); }); it('Should have 2 webseeds on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy('manual'); }); }); it('Should manually remove redundancies on server 1 and remove duplicated videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); const body = yield servers[0].redundancy.listVideos({ target: 'remote-videos' }); const videos = body.data; @@ -486,23 +486,23 @@ describe('Test videos redundancy', function () { for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { yield servers[0].redundancy.removeVideo({ redundancyId: r.id }); } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); yield check1WebSeed(); yield check0PlaylistRedundancies(); - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); describe('Test expiration', function () { const strategy = 'recently-added'; function checkContains(servers, str) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: video1Server2.uuid }); for (const f of video.files) { @@ -512,7 +512,7 @@ describe('Test videos redundancy', function () { }); } function checkNotContains(servers, str) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: video1Server2.uuid }); for (const f of video.files) { @@ -522,36 +522,36 @@ describe('Test videos redundancy', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }); yield enableRedundancyOnServer1(); }); }); it('Should still have 2 webseeds after 10 seconds', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.wait)(10000); try { yield checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port); } catch (_a) { - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port); } }); }); it('Should stop server 1 and expire video redundancy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.killallServers([servers[0]]); - yield extra_utils_1.wait(15000); + yield (0, extra_utils_1.killallServers)([servers[0]]); + yield (0, extra_utils_1.wait)(15000); yield checkNotContains([servers[1], servers[2]], 'http%3A%2F%2Flocalhost%3A' + servers[0].port); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); @@ -559,29 +559,29 @@ describe('Test videos redundancy', function () { let video2Server2UUID; const strategy = 'recently-added'; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }); yield enableRedundancyOnServer1(); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].servers.waitUntilLog('Duplicated ', 5); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield check2Webseeds(); yield check1PlaylistRedundancies(); yield checkStatsWith1Redundancy(strategy); const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: 3 } }); video2Server2UUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: 1 } }); }); }); it('Should cache video 2 webseeds on the first video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); let checked = false; while (checked === false) { - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); try { yield check1WebSeed(); yield check0PlaylistRedundancies(); @@ -596,10 +596,10 @@ describe('Test videos redundancy', function () { }); }); it('Should disable strategy and remove redundancies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(80000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run({ redundancy: { videos: { @@ -608,13 +608,13 @@ describe('Test videos redundancy', function () { } } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video: video1Server2, onlyVideoFiles: true }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/search/search-activitypub-video-channels.js b/dist/server/tests/api/search/search-activitypub-video-channels.js index d700295e..b6ff2713 100644 --- a/dist/server/tests/api/search/search-activitypub-video-channels.js +++ b/dist/server/tests/api/search/search-activitypub-video-channels.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test ActivityPub video channels search', function () { @@ -12,10 +12,10 @@ describe('Test ActivityPub video channels search', function () { let channelIdServer2; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { yield servers[0].users.create({ username: 'user1_server1', password: 'password' }); const channel = { @@ -38,12 +38,12 @@ describe('Test ActivityPub video channels search', function () { const { uuid } = yield servers[1].videos.upload({ token: userServer2Token, attributes }); videoServer2UUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].search; }); }); it('Should not find a remote video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); { const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server3'; @@ -62,7 +62,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should search a local video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const searches = [ 'http://localhost:' + servers[0].port + '/video-channels/channel1_server1', 'channel1_server1@localhost:' + servers[0].port @@ -78,7 +78,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should search a local video channel with an alternative URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = 'http://localhost:' + servers[0].port + '/c/channel1_server1'; for (const token of [undefined, servers[0].accessToken]) { const body = yield command.searchChannels({ search, token }); @@ -91,7 +91,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should search a remote video channel with URL or handle', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const searches = [ 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2', 'http://localhost:' + servers[1].port + '/c/channel1_server2', @@ -109,7 +109,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should not list this remote video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].channels.list(); expect(body.total).to.equal(3); expect(body.data).to.have.lengthOf(3); @@ -119,9 +119,9 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should list video channel videos of server 2 without token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { total, data } = yield servers[0].videos.listByChannel({ token: null, handle: 'channel1_server2@localhost:' + servers[1].port @@ -131,7 +131,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should list video channel videos of server 2 with token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByChannel({ handle: 'channel1_server2@localhost:' + servers[1].port }); @@ -140,7 +140,7 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should update video channel of server 2, and refresh it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].channels.update({ token: userServer2Token, @@ -148,8 +148,8 @@ describe('Test ActivityPub video channels search', function () { attributes: { displayName: 'channel updated' } }); yield servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'; const body = yield command.searchChannels({ search, token: servers[0].accessToken }); expect(body.total).to.equal(1); @@ -159,15 +159,15 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should update and add a video on server 2, and update it on server 1 after a search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }); yield servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'; yield command.searchChannels({ search, token: servers[0].accessToken }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const handle = 'channel1_server2@localhost:' + servers[1].port; const { total, data } = yield servers[0].videos.listByChannel({ handle, sort: '-createdAt' }); expect(total).to.equal(2); @@ -176,11 +176,11 @@ describe('Test ActivityPub video channels search', function () { }); }); it('Should delete video channel of server 2, and delete it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/video-channels/channel1_server2'; const body = yield command.searchChannels({ search, token: servers[0].accessToken }); expect(body.total).to.equal(0); @@ -188,8 +188,8 @@ describe('Test ActivityPub video channels search', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/search/search-activitypub-video-playlists.js b/dist/server/tests/api/search/search-activitypub-video-playlists.js index 1b0878dd..84b8c8bf 100644 --- a/dist/server/tests/api/search/search-activitypub-video-playlists.js +++ b/dist/server/tests/api/search/search-activitypub-video-playlists.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test ActivityPub playlists search', function () { @@ -12,11 +12,11 @@ describe('Test ActivityPub playlists search', function () { let video2Server2; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); { const video1 = (yield servers[0].videos.quickUpload({ name: 'video 1' })).uuid; const video2 = (yield servers[0].videos.quickUpload({ name: 'video 2' })).uuid; @@ -43,12 +43,12 @@ describe('Test ActivityPub playlists search', function () { playlistServer2UUID = created.uuid; yield servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].search; }); }); it('Should not find a remote playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = 'http://localhost:' + servers[1].port + '/video-playlists/43'; const body = yield command.searchPlaylists({ search, token: servers[0].accessToken }); @@ -66,7 +66,7 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should search a local playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = 'http://localhost:' + servers[0].port + '/video-playlists/' + playlistServer1UUID; const body = yield command.searchPlaylists({ search }); expect(body.total).to.equal(1); @@ -77,7 +77,7 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should search a local playlist with an alternative URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const searches = [ 'http://localhost:' + servers[0].port + '/videos/watch/playlist/' + playlistServer1UUID, 'http://localhost:' + servers[0].port + '/w/p/' + playlistServer1UUID @@ -95,7 +95,7 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should search a remote playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const searches = [ 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID, 'http://localhost:' + servers[1].port + '/videos/watch/playlist/' + playlistServer2UUID, @@ -112,7 +112,7 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should not list this remote playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].playlists.list({ start: 0, count: 10 }); expect(body.total).to.equal(1); expect(body.data).to.have.lengthOf(1); @@ -120,14 +120,14 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should update the playlist of server 2, and refresh it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID; yield command.searchPlaylists({ search, token: servers[0].accessToken }); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); const body = yield command.searchPlaylists({ search, token: servers[0].accessToken }); expect(body.total).to.equal(1); expect(body.data).to.have.lengthOf(1); @@ -136,22 +136,22 @@ describe('Test ActivityPub playlists search', function () { }); }); it('Should delete playlist of server 2, and delete it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].playlists.delete({ playlistId: playlistServer2UUID }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID; yield command.searchPlaylists({ search, token: servers[0].accessToken }); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); const body = yield command.searchPlaylists({ search, token: servers[0].accessToken }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/search/search-activitypub-videos.js b/dist/server/tests/api/search/search-activitypub-videos.js index 1302b741..b027139d 100644 --- a/dist/server/tests/api/search/search-activitypub-videos.js +++ b/dist/server/tests/api/search/search-activitypub-videos.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test ActivityPub videos search', function () { @@ -11,10 +11,10 @@ describe('Test ActivityPub videos search', function () { let videoServer2UUID; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video 1 on server 1' } }); videoServer1UUID = uuid; @@ -23,12 +23,12 @@ describe('Test ActivityPub videos search', function () { const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video 1 on server 2' } }); videoServer2UUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].search; }); }); it('Should not find a remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = 'http://localhost:' + servers[1].port + '/videos/watch/43'; const body = yield command.searchVideos({ search, token: servers[0].accessToken }); @@ -46,7 +46,7 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should search a local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID; const body = yield command.searchVideos({ search }); expect(body.total).to.equal(1); @@ -56,7 +56,7 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should search a local video with an alternative URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = 'http://localhost:' + servers[0].port + '/w/' + videoServer1UUID; const body1 = yield command.searchVideos({ search }); const body2 = yield command.searchVideos({ search, token: servers[0].accessToken }); @@ -69,7 +69,7 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should search a remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const searches = [ 'http://localhost:' + servers[1].port + '/w/' + videoServer2UUID, 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID @@ -84,7 +84,7 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should not list this remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -92,7 +92,7 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should update video of server 2, and refresh it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const channelAttributes = { name: 'super_channel', @@ -107,11 +107,11 @@ describe('Test ActivityPub videos search', function () { channelId: videoChannelId }; yield servers[1].videos.update({ id: videoServer2UUID, attributes }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID; yield command.searchVideos({ search, token: servers[0].accessToken }); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); const body = yield command.searchVideos({ search, token: servers[0].accessToken }); expect(body.total).to.equal(1); expect(body.data).to.have.lengthOf(1); @@ -122,22 +122,22 @@ describe('Test ActivityPub videos search', function () { }); }); it('Should delete video of server 2, and delete it on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[1].videos.remove({ id: videoServer2UUID }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(10000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(10000); const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID; yield command.searchVideos({ search, token: servers[0].accessToken }); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); const body = yield command.searchVideos({ search, token: servers[0].accessToken }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/search/search-channels.js b/dist/server/tests/api/search/search-channels.js index 3c2dc761..332308ec 100644 --- a/dist/server/tests/api/search/search-channels.js +++ b/dist/server/tests/api/search/search-channels.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test channels search', function () { @@ -10,15 +10,15 @@ describe('Test channels search', function () { let remoteServer; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const servers = yield Promise.all([ - extra_utils_1.createSingleServer(1), - extra_utils_1.createSingleServer(2, { transcoding: { enabled: false } }) + (0, extra_utils_1.createSingleServer)(1), + (0, extra_utils_1.createSingleServer)(2, { transcoding: { enabled: false } }) ]); server = servers[0]; remoteServer = servers[1]; - yield extra_utils_1.setAccessTokensToServers([server, remoteServer]); + yield (0, extra_utils_1.setAccessTokensToServers)([server, remoteServer]); { yield server.users.create({ username: 'user1' }); const channel = { @@ -36,19 +36,19 @@ describe('Test channels search', function () { const { id } = yield remoteServer.channels.create({ attributes: channel }); yield remoteServer.videos.upload({ attributes: { channelId: id } }); } - yield extra_utils_1.doubleFollow(server, remoteServer); + yield (0, extra_utils_1.doubleFollow)(server, remoteServer); command = server.search; }); }); it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchChannels({ search: 'abc' }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = { search: 'Squall', @@ -75,7 +75,7 @@ describe('Test channels search', function () { }); }); it('Should filter by host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = { search: 'channel', host: remoteServer.host }; const body = yield command.advancedChannelSearch({ search }); @@ -99,7 +99,7 @@ describe('Test channels search', function () { }); }); it('Should filter by names', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.advancedChannelSearch({ search: { handles: ['squall_channel', 'zell_channel'] } }); expect(body.total).to.equal(1); @@ -127,8 +127,8 @@ describe('Test channels search', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server, remoteServer]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server, remoteServer]); }); }); }); diff --git a/dist/server/tests/api/search/search-index.js b/dist/server/tests/api/search/search-index.js index 608d9c04..521c93d4 100644 --- a/dist/server/tests/api/search/search-index.js +++ b/dist/server/tests/api/search/search-index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test videos search', function () { @@ -10,18 +10,18 @@ describe('Test videos search', function () { let server = null; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.videos.upload({ attributes: { name: localVideoName } }); command = server.search; }); }); describe('Default search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { it('Should make a local videos search by default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.config.updateCustomSubConfig({ newConfig: { @@ -40,7 +40,7 @@ describe('Test videos search', function () { }); }); it('Should make a local channels search by default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchChannels({ search: 'root' }); expect(body.total).to.equal(1); expect(body.data[0].name).to.equal('root_channel'); @@ -48,7 +48,7 @@ describe('Test videos search', function () { }); }); it('Should make an index videos search by default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { search: { @@ -65,13 +65,13 @@ describe('Test videos search', function () { }); }); it('Should make an index channels search by default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchChannels({ search: 'root' }); expect(body.total).to.be.greaterThan(2); }); }); it('Should make an index videos search if local search is disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { search: { @@ -88,7 +88,7 @@ describe('Test videos search', function () { }); }); it('Should make an index channels search if local search is disabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchChannels({ search: 'root' }); expect(body.total).to.be.greaterThan(2); }); @@ -96,9 +96,9 @@ describe('Test videos search', function () { }); }); describe('Videos search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function check(search, exists = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.advancedVideoSearch({ search }); if (exists === false) { expect(body.total).to.equal(0); @@ -135,43 +135,43 @@ describe('Test videos search', function () { endDate: '2018-10-01T10:55:46.396Z' }; it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchVideos({ search: 'djidane'.repeat(50) }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a simple search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchVideos({ search: 'What is PeerTube' }); expect(body.total).to.be.greaterThan(1); }); }); it('Should make a simple search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check(baseSearch); }); }); it('Should search by start date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = Object.assign(Object.assign({}, baseSearch), { startDate: '2018-10-01T10:54:46.396Z' }); yield check(search, false); }); }); it('Should search by tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = Object.assign(Object.assign({}, baseSearch), { tagsAllOf: ['toto', 'framasoft'] }); yield check(search, false); }); }); it('Should search by duration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = Object.assign(Object.assign({}, baseSearch), { durationMin: 2000 }); yield check(search, false); }); }); it('Should search by nsfw attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = Object.assign(Object.assign({}, baseSearch), { nsfw: 'true' }); yield check(search, false); @@ -187,7 +187,7 @@ describe('Test videos search', function () { }); }); it('Should search by host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = Object.assign(Object.assign({}, baseSearch), { host: 'example.com' }); yield check(search, false); @@ -199,7 +199,7 @@ describe('Test videos search', function () { }); }); it('Should search by uuids', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const goodUUID = '9c9de5e8-0a1e-484a-b099-e80766180a6d'; const goodShortUUID = 'kkGMgK9ZtnKfYAgnEtQxbv'; const badUUID = 'c29c5b77-4a04-493d-96a9-2e9267e308f0'; @@ -229,7 +229,7 @@ describe('Test videos search', function () { }); }); it('Should have a correct pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = { search: 'video', start: 0, @@ -241,7 +241,7 @@ describe('Test videos search', function () { }); }); it('Should use the nsfw instance policy as default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let nsfwUUID; { yield server.config.updateCustomSubConfig({ @@ -275,9 +275,9 @@ describe('Test videos search', function () { }); }); describe('Channels search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function check(search, exists = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.advancedChannelSearch({ search }); if (exists === false) { expect(body.total).to.equal(0); @@ -298,32 +298,32 @@ describe('Test videos search', function () { }); } it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchChannels({ search: 'a'.repeat(500) }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check({ search: 'Framasoft', sort: 'createdAt' }, true); }); }); it('Should make host search and have appropriate results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check({ search: 'Framasoft', host: 'example.com' }, false); yield check({ search: 'Framasoft', host: 'framatube.org' }, true); }); }); it('Should make handles search and have appropriate results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check({ handles: ['bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org'] }, true); yield check({ handles: ['jeanine', 'bf54d359-cfad-4935-9d45-9d6be93f63e8@framatube.org'] }, true); yield check({ handles: ['jeanine', 'chocobozzz_channel2@peertube2.cpy.re'] }, false); }); }); it('Should have a correct pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } }); expect(body.total).to.be.greaterThan(2); expect(body.data).to.have.lengthOf(2); @@ -332,9 +332,9 @@ describe('Test videos search', function () { }); }); describe('Playlists search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function check(search, exists = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.advancedPlaylistSearch({ search }); if (exists === false) { expect(body.total).to.equal(0); @@ -365,25 +365,25 @@ describe('Test videos search', function () { }); } it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchPlaylists({ search: 'a'.repeat(500) }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check({ search: 'E2E playlist', sort: '-match' }, true); }); }); it('Should make host search and have appropriate results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield check({ search: 'E2E playlist', host: 'example.com' }, false); yield check({ search: 'E2E playlist', host: 'peertube2.cpy.re', sort: '-match' }, true); }); }); it('Should make a search by uuids and have appropriate results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const goodUUID = '73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'; const goodShortUUID = 'fgei1ws1oa6FCaJ2qZPG29'; const badUUID = 'c29c5b77-4a04-493d-96a9-2e9267e308f0'; @@ -413,7 +413,7 @@ describe('Test videos search', function () { }); }); it('Should have a correct pagination', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.advancedChannelSearch({ search: { search: 'root', start: 0, count: 2 } }); expect(body.total).to.be.greaterThan(2); expect(body.data).to.have.lengthOf(2); @@ -422,8 +422,8 @@ describe('Test videos search', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/search/search-playlists.js b/dist/server/tests/api/search/search-playlists.js index 09b8cb20..932124de 100644 --- a/dist/server/tests/api/search/search-playlists.js +++ b/dist/server/tests/api/search/search-playlists.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test playlists search', function () { @@ -12,16 +12,16 @@ describe('Test playlists search', function () { let playlistUUID; let playlistShortUUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const servers = yield Promise.all([ - extra_utils_1.createSingleServer(1), - extra_utils_1.createSingleServer(2, { transcoding: { enabled: false } }) + (0, extra_utils_1.createSingleServer)(1), + (0, extra_utils_1.createSingleServer)(2, { transcoding: { enabled: false } }) ]); server = servers[0]; remoteServer = servers[1]; - yield extra_utils_1.setAccessTokensToServers([remoteServer, server]); - yield extra_utils_1.setDefaultVideoChannel([remoteServer, server]); + yield (0, extra_utils_1.setAccessTokensToServers)([remoteServer, server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([remoteServer, server]); { const videoId = (yield server.videos.upload()).uuid; const attributes = { @@ -52,19 +52,19 @@ describe('Test playlists search', function () { }; yield server.playlists.create({ attributes }); } - yield extra_utils_1.doubleFollow(server, remoteServer); + yield (0, extra_utils_1.doubleFollow)(server, remoteServer); command = server.search; }); }); it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchPlaylists({ search: 'abc' }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = { search: 'tenma', @@ -93,7 +93,7 @@ describe('Test playlists search', function () { }); }); it('Should filter by host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const search = { search: 'tenma', host: server.host }; const body = yield command.advancedPlaylistSearch({ search }); @@ -119,7 +119,7 @@ describe('Test playlists search', function () { }); }); it('Should filter by UUIDs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const uuid of [playlistUUID, playlistShortUUID]) { const body = yield command.advancedPlaylistSearch({ search: { uuids: [uuid] } }); expect(body.total).to.equal(1); @@ -133,7 +133,7 @@ describe('Test playlists search', function () { }); }); it('Should not display playlists without videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = { search: 'Lunge', start: 0, @@ -145,8 +145,8 @@ describe('Test playlists search', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server, remoteServer]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server, remoteServer]); }); }); }); diff --git a/dist/server/tests/api/search/search-videos.js b/dist/server/tests/api/search/search-videos.js index 43e8ed25..0fc59e14 100644 --- a/dist/server/tests/api/search/search-videos.js +++ b/dist/server/tests/api/search/search-videos.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test videos search', function () { @@ -13,16 +13,16 @@ describe('Test videos search', function () { let videoShortUUID; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const servers = yield Promise.all([ - extra_utils_1.createSingleServer(1), - extra_utils_1.createSingleServer(2) + (0, extra_utils_1.createSingleServer)(1), + (0, extra_utils_1.createSingleServer)(2) ]); server = servers[0]; remoteServer = servers[1]; - yield extra_utils_1.setAccessTokensToServers([server, remoteServer]); - yield extra_utils_1.setDefaultVideoChannel([server, remoteServer]); + yield (0, extra_utils_1.setAccessTokensToServers)([server, remoteServer]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server, remoteServer]); { const attributes1 = { name: '1111 2222 3333', @@ -55,7 +55,7 @@ describe('Test videos search', function () { } const attributes4 = Object.assign(Object.assign({}, attributes1), { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }); yield server.videos.upload({ attributes: attributes4 }); - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); startDate = new Date().toISOString(); const attributes5 = Object.assign(Object.assign({}, attributes1), { name: attributes1.name + ' - 5', licence: 2, language: undefined }); yield server.videos.upload({ attributes: attributes5 }); @@ -110,19 +110,19 @@ describe('Test videos search', function () { yield remoteServer.videos.upload({ attributes: { name: 'remote video 1' } }); yield remoteServer.videos.upload({ attributes: { name: 'remote video 2' } }); } - yield extra_utils_1.doubleFollow(server, remoteServer); + yield (0, extra_utils_1.doubleFollow)(server, remoteServer); command = server.search; }); }); it('Should make a simple search and not have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchVideos({ search: 'abc' }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should make a simple search and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.searchVideos({ search: '4444 5555 duplicate' }); expect(body.total).to.equal(2); const videos = body.data; @@ -132,7 +132,7 @@ describe('Test videos search', function () { }); }); it('Should make a search on tags too, and have results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = { search: 'aaaa', categoryOneOf: [1] @@ -146,7 +146,7 @@ describe('Test videos search', function () { }); }); it('Should filter on tags without a search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = { tagsAllOf: ['bbbb'] }; @@ -159,7 +159,7 @@ describe('Test videos search', function () { }); }); it('Should filter on category without a search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = { categoryOneOf: [3] }; @@ -171,7 +171,7 @@ describe('Test videos search', function () { }); }); it('Should search by tags (one of)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '9999', categoryOneOf: [1], @@ -188,7 +188,7 @@ describe('Test videos search', function () { }); }); it('Should search by tags (all of)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '9999', categoryOneOf: [1], @@ -209,7 +209,7 @@ describe('Test videos search', function () { }); }); it('Should search by category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '6666', categoryOneOf: [3] @@ -226,7 +226,7 @@ describe('Test videos search', function () { }); }); it('Should search by licence', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '4444 5555', licenceOneOf: [2] @@ -244,7 +244,7 @@ describe('Test videos search', function () { }); }); it('Should search by languages', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', languageOneOf: ['pl', 'en'] @@ -269,7 +269,7 @@ describe('Test videos search', function () { }); }); it('Should search by start date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', startDate @@ -284,7 +284,7 @@ describe('Test videos search', function () { }); }); it('Should make an advanced search', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', languageOneOf: ['pl', 'fr'], @@ -302,7 +302,7 @@ describe('Test videos search', function () { }); }); it('Should make an advanced search and sort results', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', languageOneOf: ['pl', 'fr'], @@ -321,7 +321,7 @@ describe('Test videos search', function () { }); }); it('Should make an advanced search and only show the first result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', languageOneOf: ['pl', 'fr'], @@ -339,7 +339,7 @@ describe('Test videos search', function () { }); }); it('Should make an advanced search and only show the last result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { search: '1111 2222 3333', languageOneOf: ['pl', 'fr'], @@ -357,7 +357,7 @@ describe('Test videos search', function () { }); }); it('Should search on originally published date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const baseQuery = { search: '1111 2222 3333', languageOneOf: ['pl', 'fr'], @@ -401,7 +401,7 @@ describe('Test videos search', function () { }); }); it('Should search by UUID', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const search = videoUUID; const body = yield command.advancedVideoSearch({ search: { search } }); expect(body.total).to.equal(1); @@ -409,7 +409,7 @@ describe('Test videos search', function () { }); }); it('Should filter by UUIDs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const uuid of [videoUUID, videoShortUUID]) { const body = yield command.advancedVideoSearch({ search: { uuids: [uuid] } }); expect(body.total).to.equal(1); @@ -423,7 +423,7 @@ describe('Test videos search', function () { }); }); it('Should search by host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.advancedVideoSearch({ search: { search: '6666 7777 8888', host: server.host } }); expect(body.total).to.equal(1); @@ -444,7 +444,7 @@ describe('Test videos search', function () { }); }); it('Should search by live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); { const newConfig = { @@ -469,13 +469,13 @@ describe('Test videos search', function () { const body = yield command.advancedVideoSearch({ search: { isLive: true } }); expect(body.total).to.equal(1); expect(body.data[0].name).to.equal('live'); - yield extra_utils_1.stopFfmpeg(ffmpegCommand); + yield (0, extra_utils_1.stopFfmpeg)(ffmpegCommand); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/auto-follows.js b/dist/server/tests/api/server/auto-follows.js index bf4ad32b..be1b068b 100644 --- a/dist/server/tests/api/server/auto-follows.js +++ b/dist/server/tests/api/server/auto-follows.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function checkFollow(follower, following, exists) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield following.follows.getFollowers({ start: 0, count: 5, sort: '-createdAt' }); const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted'); @@ -26,20 +26,20 @@ function checkFollow(follower, following, exists) { }); } function server1Follows2(servers) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].follows.follow({ hosts: [servers[1].host] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); } function resetFollows(servers) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { yield servers[0].follows.unfollow({ target: servers[1] }); yield servers[1].follows.unfollow({ target: servers[0] }); } catch (_a) { } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkFollow(servers[0], servers[1], false); yield checkFollow(servers[1], servers[0], false); }); @@ -47,15 +47,15 @@ function resetFollows(servers) { describe('Test auto follows', function () { let servers = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); }); }); describe('Auto follow back', function () { it('Should not auto follow back if the option is not enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield server1Follows2(servers); yield checkFollow(servers[0], servers[1], true); @@ -64,7 +64,7 @@ describe('Test auto follows', function () { }); }); it('Should auto follow back on auto accept if the option is enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const config = { followings: { @@ -81,7 +81,7 @@ describe('Test auto follows', function () { }); }); it('Should wait the acceptation before auto follow back', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const config = { followings: { @@ -100,7 +100,7 @@ describe('Test auto follows', function () { yield checkFollow(servers[0], servers[1], false); yield checkFollow(servers[1], servers[0], false); yield servers[1].follows.acceptFollower({ follower: 'peertube@' + servers[0].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkFollow(servers[0], servers[1], true); yield checkFollow(servers[1], servers[0], true); yield resetFollows(servers); @@ -113,20 +113,20 @@ describe('Test auto follows', function () { describe('Auto follow index', function () { const instanceIndexServer = new extra_utils_1.MockInstancesIndex(); let port; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { port = yield instanceIndexServer.initialize(); })); it('Should not auto follow index if the option is not enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); yield checkFollow(servers[0], servers[1], false); yield checkFollow(servers[1], servers[0], false); }); }); it('Should auto follow the index', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); instanceIndexServer.addInstance(servers[1].host); const config = { @@ -140,26 +140,26 @@ describe('Test auto follows', function () { } }; yield servers[0].config.updateCustomSubConfig({ newConfig: config }); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); yield checkFollow(servers[0], servers[1], true); yield resetFollows(servers); }); }); it('Should follow new added instances in the index but not old ones', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); instanceIndexServer.addInstance(servers[2].host); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); yield checkFollow(servers[0], servers[1], false); yield checkFollow(servers[0], servers[2], true); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/bulk.js b/dist/server/tests/api/server/bulk.js index 60d58f20..2695943b 100644 --- a/dist/server/tests/api/server/bulk.js +++ b/dist/server/tests/api/server/bulk.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test bulk actions', function () { @@ -13,10 +13,10 @@ describe('Test bulk actions', function () { let user3Token; let bulkCommand; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const user = { username: 'user1', password: 'password' }; yield servers[0].users.create({ username: user.username, password: user.password }); @@ -32,13 +32,13 @@ describe('Test bulk actions', function () { yield servers[1].users.create({ username: user.username, password: user.password }); user3Token = yield servers[1].login.getAccessToken(user); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); bulkCommand = new extra_utils_1.BulkCommand(servers[0]); }); }); describe('Bulk remove comments', function () { function checkInstanceCommentsRemoved() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data } = yield servers[0].videos.list(); for (const video of data) { @@ -63,13 +63,13 @@ describe('Test bulk actions', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } }); yield servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } }); yield servers[0].videos.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } }); yield servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { data } = yield servers[0].videos.list(); for (const video of data) { @@ -86,11 +86,11 @@ describe('Test bulk actions', function () { commentsUser3.push({ videoId: video.id, commentId: comment.id }); } } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should delete comments of an account on my videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield bulkCommand.removeCommentsOf({ token: user1Token, @@ -99,7 +99,7 @@ describe('Test bulk actions', function () { scope: 'my-videos' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); for (const video of data) { @@ -114,7 +114,7 @@ describe('Test bulk actions', function () { }); }); it('Should delete comments of an account on the instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield bulkCommand.removeCommentsOf({ attributes: { @@ -122,12 +122,12 @@ describe('Test bulk actions', function () { scope: 'instance' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkInstanceCommentsRemoved(); }); }); it('Should not re create the comment on video update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); for (const obj of commentsUser3) { yield servers[1].comments.addReply({ @@ -137,14 +137,14 @@ describe('Test bulk actions', function () { text: 'comment by user 3 bis' }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkInstanceCommentsRemoved(); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/config.js b/dist/server/tests/api/server/config.js index c3d6cd0c..ee463f73 100644 --- a/dist/server/tests/api/server/config.js +++ b/dist/server/tests/api/server/config.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -110,7 +110,7 @@ function checkUpdatedConfig(data) { expect(data.signup.limit).to.equal(5); expect(data.signup.requiresEmailVerification).to.be.false; expect(data.signup.minimumAge).to.equal(10); - if (extra_utils_1.parallelTests() === false) { + if ((0, extra_utils_1.parallelTests)() === false) { expect(data.admin.email).to.equal('superadmin1@example.com'); } expect(data.contactForm.enabled).to.be.false; @@ -161,20 +161,20 @@ function checkUpdatedConfig(data) { describe('Test config', function () { let server = null; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); it('Should have a correct config on a server with registration enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield server.config.getConfig(); expect(data.signup.allowed).to.be.true; }); }); it('Should have a correct config on a server with registration enabled and a users limit', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); yield Promise.all([ server.users.register({ username: 'user1' }), @@ -186,7 +186,7 @@ describe('Test config', function () { }); }); it('Should have the correct video allowed extensions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield server.config.getConfig(); expect(data.video.file.extensions).to.have.lengthOf(3); expect(data.video.file.extensions).to.contain('.mp4'); @@ -198,13 +198,13 @@ describe('Test config', function () { }); }); it('Should get the customized configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield server.config.getCustomConfig(); checkInitialConfig(server, data); }); }); it('Should update the customized configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const newCustomConfig = { instance: { name: 'PeerTube updated', @@ -377,7 +377,7 @@ describe('Test config', function () { }); }); it('Should have the correct updated video allowed extensions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const data = yield server.config.getConfig(); expect(data.video.file.extensions).to.have.length.above(4); @@ -395,16 +395,16 @@ describe('Test config', function () { }); }); it('Should have the configuration updated after a restart', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); const data = yield server.config.getCustomConfig(); checkUpdatedConfig(data); }); }); it('Should fetch the about information', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield server.config.getAbout(); expect(data.instance.name).to.equal('PeerTube updated'); expect(data.instance.shortDescription).to.equal('my short description'); @@ -422,7 +422,7 @@ describe('Test config', function () { }); }); it('Should remove the custom configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.config.deleteCustomConfig(); const data = yield server.config.getCustomConfig(); @@ -430,17 +430,17 @@ describe('Test config', function () { }); }); it('Should enable frameguard', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/config', expectedStatus: 200 }); expect(res.headers['x-frame-options']).to.exist; } - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); const config = { security: { frameguard: { enabled: false } @@ -448,7 +448,7 @@ describe('Test config', function () { }; yield server.run(config); { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/api/v1/config', expectedStatus: 200 @@ -458,8 +458,8 @@ describe('Test config', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/contact-form.js b/dist/server/tests/api/server/contact-form.js index 3776a6a5..faf93c48 100644 --- a/dist/server/tests/api/server/contact-form.js +++ b/dist/server/tests/api/server/contact-form.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -11,7 +11,7 @@ describe('Test contact form', function () { const emails = []; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const port = yield extra_utils_1.MockSmtpServer.Instance.collectEmails(emails); const overrideConfig = { @@ -20,13 +20,13 @@ describe('Test contact form', function () { port } }; - server = yield extra_utils_1.createSingleServer(1, overrideConfig); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, overrideConfig); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); command = server.contactForm; }); }); it('Should send a contact form', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.send({ fromEmail: 'toto@example.com', @@ -34,7 +34,7 @@ describe('Test contact form', function () { subject: 'my subject', fromName: 'Super toto' }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(1); const email = emails[0]; expect(email['from'][0]['address']).equal('test-admin@localhost'); @@ -45,9 +45,9 @@ describe('Test contact form', function () { }); }); it('Should not be able to send another contact form because of the anti spam checker', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); yield command.send({ fromEmail: 'toto@example.com', body: 'my super message', @@ -64,8 +64,8 @@ describe('Test contact form', function () { }); }); it('Should be able to send another contact form after a while', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.wait(1000); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.wait)(1000); yield command.send({ fromEmail: 'toto@example.com', fromName: 'Super toto', @@ -75,15 +75,15 @@ describe('Test contact form', function () { }); }); it('Should not have the manage preferences link in the email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const email = emails[0]; expect(email['text']).to.not.contain('Manage your notification preferences'); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/email.js b/dist/server/tests/api/server/email.js index 4f0bc863..e5482370 100644 --- a/dist/server/tests/api/server/email.js +++ b/dist/server/tests/api/server/email.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -23,7 +23,7 @@ describe('Test emails', function () { }; let emailPort; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); emailPort = yield extra_utils_1.MockSmtpServer.Instance.collectEmails(emails); const overrideConfig = { @@ -32,8 +32,8 @@ describe('Test emails', function () { port: emailPort } }; - server = yield extra_utils_1.createSingleServer(1, overrideConfig); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, overrideConfig); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); { const created = yield server.users.create({ username: user.username, password: user.password }); userId = created.id; @@ -56,10 +56,10 @@ describe('Test emails', function () { }); describe('When resetting user password', function () { it('Should ask to reset the password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.users.askResetPassword({ email: 'user_1@example.com' }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(1); const email = emails[0]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -77,7 +77,7 @@ describe('Test emails', function () { }); }); it('Should not reset the password with an invalid verification string', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.resetPassword({ userId, verificationString: verificationString + 'b', @@ -87,12 +87,12 @@ describe('Test emails', function () { }); }); it('Should reset the password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.resetPassword({ userId, verificationString, password: 'super_password2' }); }); }); it('Should not reset the password with the same verification string', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.resetPassword({ userId, verificationString, @@ -102,7 +102,7 @@ describe('Test emails', function () { }); }); it('Should login with this new password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { user.password = 'super_password2'; yield server.login.getAccessToken(user); }); @@ -110,10 +110,10 @@ describe('Test emails', function () { }); describe('When creating a user without password', function () { it('Should send a create password email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.users.create({ username: 'create_password', password: '' }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(2); const email = emails[1]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -131,7 +131,7 @@ describe('Test emails', function () { }); }); it('Should not reset the password with an invalid verification string', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.resetPassword({ userId: userId2, verificationString: verificationString2 + 'c', @@ -141,7 +141,7 @@ describe('Test emails', function () { }); }); it('Should reset the password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.resetPassword({ userId: userId2, verificationString: verificationString2, @@ -150,7 +150,7 @@ describe('Test emails', function () { }); }); it('Should login with this new password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.getAccessToken({ username: 'create_password', password: 'newly_created_password' @@ -160,11 +160,11 @@ describe('Test emails', function () { }); describe('When creating an abuse', function () { it('Should send the notification email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const reason = 'my super bad reason'; yield server.abuses.report({ videoId, reason }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(3); const email = emails[2]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -177,11 +177,11 @@ describe('Test emails', function () { }); describe('When blocking/unblocking user', function () { it('Should send the notification email when blocking a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const reason = 'my super bad reason'; yield server.users.banUser({ userId, reason }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(4); const email = emails[3]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -193,10 +193,10 @@ describe('Test emails', function () { }); }); it('Should send the notification email when unblocking a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.users.unbanUser({ userId }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(5); const email = emails[4]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -209,11 +209,11 @@ describe('Test emails', function () { }); describe('When blacklisting a video', function () { it('Should send the notification email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const reason = 'my super reason'; yield server.blacklist.add({ videoId: videoUserUUID, reason }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(6); const email = emails[5]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -225,10 +225,10 @@ describe('Test emails', function () { }); }); it('Should send the notification email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.blacklist.remove({ videoId: videoUserUUID }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(7); const email = emails[6]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -239,7 +239,7 @@ describe('Test emails', function () { }); }); it('Should have the manage preferences link in the email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const email = emails[6]; expect(email['text']).to.contain('Manage your notification preferences'); }); @@ -247,10 +247,10 @@ describe('Test emails', function () { }); describe('When verifying a user email', function () { it('Should ask to send the verification email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.users.askSendVerifyEmail({ email: 'user_1@example.com' }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(8); const email = emails[7]; expect(email['from'][0]['name']).equal('PeerTube'); @@ -268,7 +268,7 @@ describe('Test emails', function () { }); }); it('Should not verify the email with an invalid verification string', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.verifyEmail({ userId, verificationString: verificationString + 'b', @@ -278,15 +278,15 @@ describe('Test emails', function () { }); }); it('Should verify the email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.verifyEmail({ userId, verificationString }); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/follow-constraints.js b/dist/server/tests/api/server/follow-constraints.js index 887377c0..a806ce12 100644 --- a/dist/server/tests/api/server/follow-constraints.js +++ b/dist/server/tests/api/server/follow-constraints.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -12,10 +12,10 @@ describe('Test follow constraints', function () { let video2UUID; let userToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(90000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video server 1' } }); video1UUID = uuid; @@ -30,37 +30,37 @@ describe('Test follow constraints', function () { }; yield servers[0].users.create({ username: user.username, password: user.password }); userToken = yield servers[0].login.getAccessToken(user); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('With a followed instance', function () { describe('With an unlogged user', function () { it('Should get the local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.get({ id: video1UUID }); }); }); it('Should get the remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.get({ id: video2UUID }); }); }); it('Should list local account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list remote account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list local channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[0].port; const { total, data } = yield servers[0].videos.listByChannel({ handle }); expect(total).to.equal(1); @@ -68,7 +68,7 @@ describe('Test follow constraints', function () { }); }); it('Should list remote channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[1].port; const { total, data } = yield servers[0].videos.listByChannel({ handle }); expect(total).to.equal(1); @@ -78,31 +78,31 @@ describe('Test follow constraints', function () { }); describe('With a logged user', function () { it('Should get the local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: userToken, id: video1UUID }); }); }); it('Should get the remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: userToken, id: video2UUID }); }); }); it('Should list local account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list remote account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list local channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[0].port; const { total, data } = yield servers[0].videos.listByChannel({ token: userToken, handle }); expect(total).to.equal(1); @@ -110,7 +110,7 @@ describe('Test follow constraints', function () { }); }); it('Should list remote channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[1].port; const { total, data } = yield servers[0].videos.listByChannel({ token: userToken, handle }); expect(total).to.equal(1); @@ -121,19 +121,19 @@ describe('Test follow constraints', function () { }); describe('With a non followed instance', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].follows.unfollow({ target: servers[1] }); }); }); describe('With an unlogged user', function () { it('Should get the local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.get({ id: video1UUID }); }); }); it('Should not get the remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].videos.get({ id: video2UUID, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); const error = body; const doc = 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints'; @@ -146,7 +146,7 @@ describe('Test follow constraints', function () { }); }); it('Should list local account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: null, handle: 'root@localhost:' + servers[0].port @@ -156,7 +156,7 @@ describe('Test follow constraints', function () { }); }); it('Should not list remote account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: null, handle: 'root@localhost:' + servers[1].port @@ -166,7 +166,7 @@ describe('Test follow constraints', function () { }); }); it('Should list local channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[0].port; const { total, data } = yield servers[0].videos.listByChannel({ token: null, handle }); expect(total).to.equal(1); @@ -174,7 +174,7 @@ describe('Test follow constraints', function () { }); }); it('Should not list remote channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[1].port; const { total, data } = yield servers[0].videos.listByChannel({ token: null, handle }); expect(total).to.equal(0); @@ -184,31 +184,31 @@ describe('Test follow constraints', function () { }); describe('With a logged user', function () { it('Should get the local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: userToken, id: video1UUID }); }); }); it('Should get the remote video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: userToken, id: video2UUID }); }); }); it('Should list local account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list remote account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); }); }); it('Should list local channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[0].port; const { total, data } = yield servers[0].videos.listByChannel({ token: userToken, handle }); expect(total).to.equal(1); @@ -216,7 +216,7 @@ describe('Test follow constraints', function () { }); }); it('Should list remote channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@localhost:' + servers[1].port; const { total, data } = yield servers[0].videos.listByChannel({ token: userToken, handle }); expect(total).to.equal(1); @@ -226,8 +226,8 @@ describe('Test follow constraints', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/follows-moderation.js b/dist/server/tests/api/server/follows-moderation.js index c8481357..907eb124 100644 --- a/dist/server/tests/api/server/follows-moderation.js +++ b/dist/server/tests/api/server/follows-moderation.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function checkServer1And2HasFollowers(servers, state = 'accepted') { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fns = [ servers[0].follows.getFollowings.bind(servers[0].follows), servers[1].follows.getFollowers.bind(servers[1].follows) @@ -22,7 +22,7 @@ function checkServer1And2HasFollowers(servers, state = 'accepted') { }); } function checkNoFollowers(servers) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fns = [ servers[0].follows.getFollowings.bind(servers[0].follows), servers[1].follows.getFollowers.bind(servers[1].follows) @@ -37,39 +37,39 @@ describe('Test follows moderation', function () { let servers = []; let commands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); commands = servers.map(s => s.follows); }); }); it('Should have server 1 following server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield commands[0].follow({ hosts: [servers[1].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have correct follows', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkServer1And2HasFollowers(servers); }); }); it('Should remove follower on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[1].removeFollower({ follower: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not not have follows anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkNoFollowers(servers); }); }); it('Should disable followers on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const subConfig = { followers: { @@ -81,12 +81,12 @@ describe('Test follows moderation', function () { }; yield servers[1].config.updateCustomSubConfig({ newConfig: subConfig }); yield commands[0].follow({ hosts: [servers[1].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkNoFollowers(servers); }); }); it('Should re enable followers on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const subConfig = { followers: { @@ -98,15 +98,15 @@ describe('Test follows moderation', function () { }; yield servers[1].config.updateCustomSubConfig({ newConfig: subConfig }); yield commands[0].follow({ hosts: [servers[1].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkServer1And2HasFollowers(servers); }); }); it('Should manually approve followers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield commands[1].removeFollower({ follower: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const subConfig = { followers: { instance: { @@ -118,23 +118,23 @@ describe('Test follows moderation', function () { yield servers[1].config.updateCustomSubConfig({ newConfig: subConfig }); yield servers[2].config.updateCustomSubConfig({ newConfig: subConfig }); yield commands[0].follow({ hosts: [servers[1].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkServer1And2HasFollowers(servers, 'pending'); }); }); it('Should accept a follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield commands[1].acceptFollower({ follower: 'peertube@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkServer1And2HasFollowers(servers); }); }); it('Should reject another follower', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield commands[0].follow({ hosts: [servers[2].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield commands[0].getFollowings({ start: 0, count: 5, sort: 'createdAt' }); expect(body.total).to.equal(2); @@ -148,7 +148,7 @@ describe('Test follows moderation', function () { expect(body.total).to.equal(1); } yield commands[2].rejectFollower({ follower: 'peertube@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkServer1And2HasFollowers(servers); { const body = yield commands[2].getFollowers({ start: 0, count: 5, sort: 'createdAt' }); @@ -157,8 +157,8 @@ describe('Test follows moderation', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/follows.js b/dist/server/tests/api/server/follows.js index 235aa617..2d863cd0 100644 --- a/dist/server/tests/api/server/follows.js +++ b/dist/server/tests/api/server/follows.js @@ -2,21 +2,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test follows', function () { let servers = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); }); }); describe('Data propagation after follow', function () { it('Should not have followers/followings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const bodies = yield Promise.all([ server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' }), @@ -32,17 +32,17 @@ describe('Test follows', function () { }); }); it('Should have server 1 following root account of server 2 and server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].follows.follow({ hosts: [servers[2].url], handles: ['root@' + servers[1].host] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have 2 followings on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].follows.getFollowings({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(2); let follows = body.data; @@ -61,7 +61,7 @@ describe('Test follows', function () { }); }); it('Should have 0 followings on server 2 and 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of [servers[1], servers[2]]) { const body = yield server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' }); expect(body.total).to.equal(0); @@ -72,7 +72,7 @@ describe('Test follows', function () { }); }); it('Should have 1 followers on server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[2].follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(1); const follows = body.data; @@ -82,7 +82,7 @@ describe('Test follows', function () { }); }); it('Should have 0 followers on server 1 and 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of [servers[0], servers[1]]) { const body = yield server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' }); expect(body.total).to.equal(0); @@ -93,7 +93,7 @@ describe('Test follows', function () { }); }); it('Should search/filter followings on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const sort = 'createdAt'; const start = 0; const count = 1; @@ -147,7 +147,7 @@ describe('Test follows', function () { }); }); it('Should search/filter followers on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const start = 0; const count = 5; const sort = 'createdAt'; @@ -197,26 +197,26 @@ describe('Test follows', function () { }); }); it('Should have the correct follows counts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); }); }); it('Should unfollow server 3 on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].follows.unfollow({ target: servers[2] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not follow server 3 on server 1 anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].follows.getFollowings({ start: 0, count: 2, sort: 'createdAt' }); expect(body.total).to.equal(1); const follows = body.data; @@ -226,7 +226,7 @@ describe('Test follows', function () { }); }); it('Should not have server 1 as follower on server 3 anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[2].follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' }); expect(body.total).to.equal(0); const follows = body.data; @@ -235,23 +235,23 @@ describe('Test follows', function () { }); }); it('Should have the correct follows counts after the unfollow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 0, following: 0 }); }); }); it('Should upload a video on server 2 and 3 and propagate only the video of server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].videos.upload({ attributes: { name: 'server2' } }); yield servers[2].videos.upload({ attributes: { name: 'server3' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(1); @@ -270,16 +270,16 @@ describe('Test follows', function () { }); }); it('Should remove account follow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].follows.unfollow({ target: 'root@' + servers[1].host }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have removed the account follow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); { const { total, data } = yield servers[0].follows.getFollowings(); expect(total).to.equal(0); @@ -293,14 +293,14 @@ describe('Test follows', function () { }); }); it('Should follow a channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].follows.follow({ handles: ['root_channel@' + servers[1].host] }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.expectChannelsFollows({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectChannelsFollows({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.expectChannelsFollows)({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectChannelsFollows)({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); { const { total, data } = yield servers[0].follows.getFollowings(); expect(total).to.equal(1); @@ -317,7 +317,7 @@ describe('Test follows', function () { describe('Should propagate data on a new server follow', function () { let video4; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); const video4Attributes = { name: 'server3-4', @@ -355,27 +355,27 @@ describe('Test follows', function () { videoId: video4.id, fixture: 'subtitle-good2.vtt' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].follows.follow({ hosts: [servers[2].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the correct follows counts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectChannelsFollows({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); - yield extra_utils_1.expectChannelsFollows({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); - yield extra_utils_1.expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectChannelsFollows)({ server: servers[0], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[1], handle: 'root@' + servers[1].host, followers: 0, following: 0 }); + yield (0, extra_utils_1.expectChannelsFollows)({ server: servers[1], handle: 'root_channel@' + servers[1].host, followers: 1, following: 0 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 }); + yield (0, extra_utils_1.expectAccountFollows)({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 }); }); }); it('Should have propagated videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(7); const video2 = data.find(v => v.name === 'server3-2'); @@ -419,11 +419,11 @@ describe('Test follows', function () { } ] }; - yield extra_utils_1.completeVideoCheck(servers[0], video4, checkAttributes); + yield (0, extra_utils_1.completeVideoCheck)(servers[0], video4, checkAttributes); }); }); it('Should have propagated comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].comments.listThreads({ videoId: video4.id, sort: 'createdAt' }); expect(total).to.equal(2); expect(data).to.be.an('array'); @@ -437,8 +437,8 @@ describe('Test follows', function () { expect(comment.account.name).to.equal('root'); expect(comment.account.host).to.equal(servers[2].host); expect(comment.totalReplies).to.equal(3); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; const threadId = comment.threadId; const tree = yield servers[0].comments.getThread({ videoId: video4.id, threadId }); expect(tree.comment.text).equal('my super first comment'); @@ -462,7 +462,7 @@ describe('Test follows', function () { expect(deletedComment.inReplyToCommentId).to.be.null; expect(deletedComment.account).to.be.null; expect(deletedComment.totalReplies).to.equal(2); - expect(extra_utils_1.dateIsValid(deletedComment.deletedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(deletedComment.deletedAt)).to.be.true; const tree = yield servers[0].comments.getThread({ videoId: video4.id, threadId: deletedComment.threadId }); const [commentRoot, deletedChildRoot] = tree.children; expect(deletedChildRoot).to.not.be.undefined; @@ -485,7 +485,7 @@ describe('Test follows', function () { }); }); it('Should have propagated captions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].captions.list({ videoId: video4.id }); expect(body.total).to.equal(1); expect(body.data).to.have.lengthOf(1); @@ -493,14 +493,14 @@ describe('Test follows', function () { expect(caption1.language.id).to.equal('ar'); expect(caption1.language.label).to.equal('Arabic'); expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/.+-ar.vtt$')); - yield extra_utils_1.testCaptionFile(servers[0].url, caption1.captionPath, 'Subtitle good 2.'); + yield (0, extra_utils_1.testCaptionFile)(servers[0].url, caption1.captionPath, 'Subtitle good 2.'); }); }); it('Should unfollow server 3 on server 1 and does not list server 3 videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); yield servers[0].follows.unfollow({ target: servers[2] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { total } = yield servers[0].videos.list(); expect(total).to.equal(1); }); @@ -508,27 +508,27 @@ describe('Test follows', function () { }); describe('Should propagate data on a new channel follow', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[2].videos.upload({ attributes: { name: 'server3-7' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[0].videos.find({ name: 'server3-7' }); expect(video).to.not.exist; }); }); it('Should have propagated channel video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].follows.follow({ handles: ['root_channel@' + servers[2].host] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[0].videos.find({ name: 'server3-7' }); expect(video).to.exist; }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/handle-down.js b/dist/server/tests/api/server/handle-down.js index 6952bfe2..29a34006 100644 --- a/dist/server/tests/api/server/handle-down.js +++ b/dist/server/tests/api/server/handle-down.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -33,9 +33,9 @@ describe('Test handle downs', function () { let unlistedCheckAttributes; let commentCommands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(3); + servers = yield (0, extra_utils_1.createMultipleServers)(3); commentCommands = servers.map(s => s.comments); checkAttributes = { name: 'my super name for server 1', @@ -70,28 +70,28 @@ describe('Test handle downs', function () { ] }; unlistedCheckAttributes = Object.assign(Object.assign({}, checkAttributes), { privacy: 2 }); - yield extra_utils_1.setAccessTokensToServers(servers); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); }); }); it('Should remove followers that are often down', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield servers[1].follows.follow({ hosts: [servers[0].url] }); yield servers[2].follows.follow({ hosts: [servers[0].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].videos.upload({ attributes: videoAttributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); expect(data).to.be.an('array'); expect(data).to.have.lengthOf(1); } - yield extra_utils_1.killallServers([servers[1]]); + yield (0, extra_utils_1.killallServers)([servers[1]]); for (let i = 0; i < 10; i++) { yield servers[0].videos.upload({ attributes: videoAttributes }); } - yield extra_utils_1.waitJobs([servers[0], servers[2]]); - yield extra_utils_1.killallServers([servers[2]]); + yield (0, extra_utils_1.waitJobs)([servers[0], servers[2]]); + yield (0, extra_utils_1.killallServers)([servers[2]]); missedVideo1 = yield servers[0].videos.upload({ attributes: videoAttributes }); missedVideo2 = yield servers[0].videos.upload({ attributes: videoAttributes }); unlistedVideo = yield servers[0].videos.upload({ attributes: unlistedVideoAttributes }); @@ -103,8 +103,8 @@ describe('Test handle downs', function () { const created = yield commentCommands[0].addReply({ videoId: missedVideo2.uuid, toCommentId: comment.id, text: 'comment 1-2' }); commentIdServer1 = created.id; } - yield extra_utils_1.waitJobs(servers[0]); - yield extra_utils_1.wait(11000); + yield (0, extra_utils_1.waitJobs)(servers[0]); + yield (0, extra_utils_1.wait)(11000); const body = yield servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' }); expect(body.data).to.be.an('array'); expect(body.data).to.have.lengthOf(1); @@ -112,7 +112,7 @@ describe('Test handle downs', function () { }); }); it('Should not have pending/processing jobs anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const states = ['waiting', 'active']; for (const state of states) { const body = yield servers[0].jobs.list({ @@ -126,21 +126,21 @@ describe('Test handle downs', function () { }); }); it('Should re-follow server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(35000); yield servers[1].run(); yield servers[2].run(); yield servers[1].follows.unfollow({ target: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].follows.follow({ hosts: [servers[0].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' }); expect(body.data).to.be.an('array'); expect(body.data).to.have.lengthOf(2); }); }); it('Should send an update to server 3, and automatically fetch the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); { const { data } = yield servers[2].videos.list(); @@ -149,21 +149,21 @@ describe('Test handle downs', function () { } yield servers[0].videos.update({ id: missedVideo1.uuid }); yield servers[0].videos.update({ id: unlistedVideo.uuid }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { data } = yield servers[2].videos.list(); expect(data).to.be.an('array'); expect(data).to.have.lengthOf(12); } const video = yield servers[2].videos.get({ id: unlistedVideo.uuid }); - yield extra_utils_1.completeVideoCheck(servers[2], video, unlistedCheckAttributes); + yield (0, extra_utils_1.completeVideoCheck)(servers[2], video, unlistedCheckAttributes); }); }); it('Should send comments on a video to server 3, and automatically fetch the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); yield commentCommands[0].addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer1, text: 'comment 1-3' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[2].videos.get({ id: missedVideo2.uuid }); { const { data } = yield servers[2].comments.listThreads({ videoId: missedVideo2.uuid }); @@ -187,10 +187,10 @@ describe('Test handle downs', function () { }); }); it('Should correctly reply to the comment', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[2].comments.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const tree = yield commentCommands[0].getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer1 }); expect(tree.comment.text).equal('thread 1'); expect(tree.children).to.have.lengthOf(1); @@ -209,33 +209,33 @@ describe('Test handle downs', function () { }); }); it('Should upload many videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); for (let i = 0; i < 10; i++) { const uuid = (yield servers[0].videos.quickUpload({ name: 'video ' + i })).uuid; videoIdsServer1.push(uuid); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const id of videoIdsServer1) { yield servers[1].videos.get({ id }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[1].sql.setActorFollowScores(20); - yield extra_utils_1.wait(11000); + yield (0, extra_utils_1.wait)(11000); yield servers[1].videos.get({ id: videoIdsServer1[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should remove followings that are down', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.killallServers([servers[0]]); - yield extra_utils_1.wait(11000); + yield (0, extra_utils_1.killallServers)([servers[0]]); + yield (0, extra_utils_1.wait)(11000); for (let i = 0; i < 5; i++) { try { yield servers[1].videos.get({ id: videoIdsServer1[i] }); - yield extra_utils_1.waitJobs([servers[1]]); - yield extra_utils_1.wait(1500); + yield (0, extra_utils_1.waitJobs)([servers[1]]); + yield (0, extra_utils_1.wait)(1500); } catch (_a) { } } @@ -245,8 +245,8 @@ describe('Test handle downs', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/homepage.js b/dist/server/tests/api/server/homepage.js index 308f9bea..4c234efc 100644 --- a/dist/server/tests/api/server/homepage.js +++ b/dist/server/tests/api/server/homepage.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const models_1 = require("@shared/models"); const index_1 = require("../../../../shared/extra-utils/index"); const expect = chai.expect; function getHomepageState(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); return config.homepage.enabled; }); @@ -16,22 +16,22 @@ describe('Test instance homepage actions', function () { let server; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield index_1.createSingleServer(1); - yield index_1.setAccessTokensToServers([server]); + server = yield (0, index_1.createSingleServer)(1); + yield (0, index_1.setAccessTokensToServers)([server]); command = server.customPage; }); }); it('Should not have a homepage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const state = yield getHomepageState(server); expect(state).to.be.false; yield command.getInstanceHomepage({ expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should set a homepage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.updateInstanceHomepage({ content: '' }); const page = yield command.getInstanceHomepage(); expect(page.content).to.equal(''); @@ -40,9 +40,9 @@ describe('Test instance homepage actions', function () { }); }); it('Should have the same homepage after a restart', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield index_1.killallServers([server]); + yield (0, index_1.killallServers)([server]); yield server.run(); const page = yield command.getInstanceHomepage(); expect(page.content).to.equal(''); @@ -51,7 +51,7 @@ describe('Test instance homepage actions', function () { }); }); it('Should empty the homepage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.updateInstanceHomepage({ content: '' }); const page = yield command.getInstanceHomepage(); expect(page.content).to.be.empty; @@ -60,8 +60,8 @@ describe('Test instance homepage actions', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield index_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, index_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/jobs.js b/dist/server/tests/api/server/jobs.js index 637f4f7d..93063af6 100644 --- a/dist/server/tests/api/server/jobs.js +++ b/dist/server/tests/api/server/jobs.js @@ -2,36 +2,36 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test jobs', function () { let servers; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should create some jobs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[1].videos.upload({ attributes: { name: 'video1' } }); yield servers[1].videos.upload({ attributes: { name: 'video2' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list jobs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[1].jobs.list({ state: 'completed' }); expect(body.total).to.be.above(2); expect(body.data).to.have.length.above(2); }); }); it('Should list jobs with sort, pagination and job type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield servers[1].jobs.list({ state: 'completed', @@ -46,9 +46,9 @@ describe('Test jobs', function () { job = body.data[1]; expect(job.state).to.equal('completed'); expect(job.type.startsWith('activitypub-')).to.be.true; - expect(extra_utils_1.dateIsValid(job.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(job.processedOn)).to.be.true; - expect(extra_utils_1.dateIsValid(job.finishedOn)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(job.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(job.processedOn)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(job.finishedOn)).to.be.true; } { const body = yield servers[1].jobs.list({ @@ -66,7 +66,7 @@ describe('Test jobs', function () { }); }); it('Should list all jobs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[1].jobs.list(); expect(body.total).to.be.above(2); const jobs = body.data; @@ -76,8 +76,8 @@ describe('Test jobs', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/logs.js b/dist/server/tests/api/server/logs.js index d37c552a..78c7fb4b 100644 --- a/dist/server/tests/api/server/logs.js +++ b/dist/server/tests/api/server/logs.js @@ -2,29 +2,29 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test logs', function () { let server; let logsCommand; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); logsCommand = server.logs; }); }); describe('With the standard log file', function () { it('Should get logs with a start date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.upload({ attributes: { name: 'video 1' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now = new Date(); yield server.videos.upload({ attributes: { name: 'video 2' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const body = yield logsCommand.getLogs({ startDate: now }); const logsString = JSON.stringify(body); expect(logsString.includes('video 1')).to.be.false; @@ -32,16 +32,16 @@ describe('Test logs', function () { }); }); it('Should get logs with an end date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield server.videos.upload({ attributes: { name: 'video 3' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now1 = new Date(); yield server.videos.upload({ attributes: { name: 'video 4' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now2 = new Date(); yield server.videos.upload({ attributes: { name: 'video 5' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const body = yield logsCommand.getLogs({ startDate: now1, endDate: now2 }); const logsString = JSON.stringify(body); expect(logsString.includes('video 3')).to.be.false; @@ -50,11 +50,11 @@ describe('Test logs', function () { }); }); it('Should get filter by level', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const now = new Date(); yield server.videos.upload({ attributes: { name: 'video 6' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); { const body = yield logsCommand.getLogs({ startDate: now, level: 'info' }); const logsString = JSON.stringify(body); @@ -68,7 +68,7 @@ describe('Test logs', function () { }); }); it('Should log ping requests', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const now = new Date(); yield server.servers.ping(); @@ -78,9 +78,9 @@ describe('Test logs', function () { }); }); it('Should not log ping requests', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run({ log: { log_ping_requests: false } }); const now = new Date(); yield server.servers.ping(); @@ -92,13 +92,13 @@ describe('Test logs', function () { }); describe('With the audit log', function () { it('Should get logs with a start date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.upload({ attributes: { name: 'video 7' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now = new Date(); yield server.videos.upload({ attributes: { name: 'video 8' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const body = yield logsCommand.getAuditLogs({ startDate: now }); const logsString = JSON.stringify(body); expect(logsString.includes('video 7')).to.be.false; @@ -111,16 +111,16 @@ describe('Test logs', function () { }); }); it('Should get logs with an end date', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield server.videos.upload({ attributes: { name: 'video 9' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now1 = new Date(); yield server.videos.upload({ attributes: { name: 'video 10' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const now2 = new Date(); yield server.videos.upload({ attributes: { name: 'video 11' } }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const body = yield logsCommand.getAuditLogs({ startDate: now1, endDate: now2 }); const logsString = JSON.stringify(body); expect(logsString.includes('video 9')).to.be.false; @@ -130,8 +130,8 @@ describe('Test logs', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/no-client.js b/dist/server/tests/api/server/no-client.js index 5b2df8bc..3d638ae9 100644 --- a/dist/server/tests/api/server/no-client.js +++ b/dist/server/tests/api/server/no-client.js @@ -2,25 +2,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const supertest_1 = tslib_1.__importDefault(require("supertest")); +const supertest_1 = (0, tslib_1.__importDefault)(require("supertest")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); describe('Start and stop server without web client routes', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1, {}, { peertubeArgs: ['--no-client'] }); + server = yield (0, extra_utils_1.createSingleServer)(1, {}, { peertubeArgs: ['--no-client'] }); }); }); it('Should fail getting the client', function () { - const req = supertest_1.default(server.url) + const req = (0, supertest_1.default)(server.url) .get('/'); return req.expect(models_1.HttpStatusCode.NOT_FOUND_404); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/plugins.js b/dist/server/tests/api/server/plugins.js index 3eb4543d..035e901d 100644 --- a/dist/server/tests/api/server/plugins.js +++ b/dist/server/tests/api/server/plugins.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -10,20 +10,20 @@ describe('Test plugins', function () { let server = null; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const configOverride = { plugins: { index: { check_latest_versions_interval: '5 seconds' } } }; - server = yield extra_utils_1.createSingleServer(1, configOverride); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, configOverride); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); command = server.plugins; }); }); it('Should list and search available plugins and themes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { const body = yield command.listAvailable({ @@ -68,14 +68,14 @@ describe('Test plugins', function () { }); }); it('Should install a plugin and a theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield command.install({ npmName: 'peertube-plugin-hello-world' }); yield command.install({ npmName: 'peertube-theme-background-red' }); }); }); it('Should have the plugin loaded in the configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const theme = config.theme.registered.find(r => r.name === 'background-red'); expect(theme).to.not.be.undefined; @@ -84,7 +84,7 @@ describe('Test plugins', function () { }); }); it('Should update the default theme in the configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { theme: { default: 'background-red' } @@ -95,14 +95,14 @@ describe('Test plugins', function () { }); }); it('Should update my default theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ theme: 'background-red' }); const user = yield server.users.getMyInfo(); expect(user.theme).to.equal('background-red'); }); }); it('Should list plugins and themes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list({ count: 1, @@ -134,12 +134,12 @@ describe('Test plugins', function () { }); }); it('Should get registered settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.testHelloWorldRegisteredSettings(server); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.testHelloWorldRegisteredSettings)(server); }); }); it('Should get public settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.getPublicSettings({ npmName: 'peertube-plugin-hello-world' }); const publicSettings = body.publicSettings; expect(Object.keys(publicSettings)).to.have.lengthOf(1); @@ -148,7 +148,7 @@ describe('Test plugins', function () { }); }); it('Should update the settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const settings = { 'admin-name': 'Cid' }; @@ -159,13 +159,13 @@ describe('Test plugins', function () { }); }); it('Should have watched settings changes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield server.servers.waitUntilLog('Settings changed!'); }); }); it('Should get a plugin and a theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const plugin = yield command.get({ npmName: 'peertube-plugin-hello-world' }); expect(plugin.type).to.equal(models_1.PluginType.PLUGIN); @@ -198,15 +198,15 @@ describe('Test plugins', function () { }); }); it('Should update the plugin and the theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(90000); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); yield server.sql.setPluginVersion('hello-world', '0.0.1'); const packageJSON = yield command.getPackageJSON('peertube-plugin-hello-world'); const oldVersion = packageJSON.version; packageJSON.version = '0.0.1'; yield command.updatePackageJSON('peertube-plugin-hello-world', packageJSON); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); { const body = yield command.list({ pluginType: models_1.PluginType.PLUGIN }); @@ -226,7 +226,7 @@ describe('Test plugins', function () { }); }); it('Should uninstall the plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.uninstall({ npmName: 'peertube-plugin-hello-world' }); const body = yield command.list({ pluginType: models_1.PluginType.PLUGIN }); expect(body.total).to.equal(0); @@ -234,7 +234,7 @@ describe('Test plugins', function () { }); }); it('Should list uninstalled plugins', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ pluginType: models_1.PluginType.PLUGIN, uninstalled: true }); expect(body.total).to.equal(1); expect(body.data).to.have.lengthOf(1); @@ -245,12 +245,12 @@ describe('Test plugins', function () { }); }); it('Should uninstall the theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.uninstall({ npmName: 'peertube-theme-background-red' }); }); }); it('Should have updated the configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); expect(config.theme.default).to.equal('default'); const theme = config.theme.registered.find(r => r.name === 'background-red'); @@ -260,16 +260,16 @@ describe('Test plugins', function () { }); }); it('Should have updated the user theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield server.users.getMyInfo(); expect(user.theme).to.equal('instance-default'); }); }); it('Should not install a broken plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); function check() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ pluginType: models_1.PluginType.PLUGIN }); const plugins = body.data; expect(plugins.find(p => p.name === 'test-broken')).to.not.exist; @@ -280,14 +280,14 @@ describe('Test plugins', function () { expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); yield check(); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); yield check(); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/proxy.js b/dist/server/tests/api/server/proxy.js index 311907c0..9a8af7ab 100644 --- a/dist/server/tests/api/server/proxy.js +++ b/dist/server/tests/api/server/proxy.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const mock_proxy_1 = require("@shared/extra-utils/mock-servers/mock-proxy"); const expect = chai.expect; @@ -12,22 +12,22 @@ describe('Test proxy', function () { const goodEnv = { HTTP_PROXY: '' }; const badEnv = { HTTP_PROXY: 'http://localhost:9000' }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); proxy = new mock_proxy_1.MockProxy(); const proxyPort = yield proxy.initialize(); - servers = yield extra_utils_1.createMultipleServers(2); + servers = yield (0, extra_utils_1.createMultipleServers)(2); goodEnv.HTTP_PROXY = 'http://localhost:' + proxyPort; - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should succeed federation with the appropriate proxy config', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].kill(); yield servers[0].run({}, { env: goodEnv }); yield servers[0].videos.quickUpload({ name: 'video 1' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(1); @@ -36,11 +36,11 @@ describe('Test proxy', function () { }); }); it('Should fail federation with a wrong proxy config', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].kill(); yield servers[0].run({}, { env: badEnv }); yield servers[0].videos.quickUpload({ name: 'video 2' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(2); @@ -54,9 +54,9 @@ describe('Test proxy', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield proxy.terminate(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/reverse-proxy.js b/dist/server/tests/api/server/reverse-proxy.js index 725a4da6..f175dc6c 100644 --- a/dist/server/tests/api/server/reverse-proxy.js +++ b/dist/server/tests/api/server/reverse-proxy.js @@ -8,7 +8,7 @@ describe('Test application behind a reverse proxy', function () { let server; let videoId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const config = { rates_limit: { @@ -28,54 +28,54 @@ describe('Test application behind a reverse proxy', function () { limit: 20 } }; - server = yield extra_utils_1.createSingleServer(1, config); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, config); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { uuid } = yield server.videos.upload(); videoId = uuid; }); }); it('Should view a video only once with the same IP by default', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.view({ id: videoId }); yield server.videos.view({ id: videoId }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const video = yield server.videos.get({ id: videoId }); - chai_1.expect(video.views).to.equal(1); + (0, chai_1.expect)(video.views).to.equal(1); }); }); it('Should view a video 2 times with the X-Forwarded-For header set', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' }); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const video = yield server.videos.get({ id: videoId }); - chai_1.expect(video.views).to.equal(3); + (0, chai_1.expect)(video.views).to.equal(3); }); }); it('Should view a video only once with the same client IP in the X-Forwarded-For header', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' }); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const video = yield server.videos.get({ id: videoId }); - chai_1.expect(video.views).to.equal(4); + (0, chai_1.expect)(video.views).to.equal(4); }); }); it('Should view a video two times with a different client IP in the X-Forwarded-For header', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' }); yield server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const video = yield server.videos.get({ id: videoId }); - chai_1.expect(video.views).to.equal(6); + (0, chai_1.expect)(video.views).to.equal(6); }); }); it('Should rate limit logins', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'root', password: 'fail' }; for (let i = 0; i < 19; i++) { yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); @@ -84,7 +84,7 @@ describe('Test application behind a reverse proxy', function () { }); }); it('Should rate limit signup', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (let i = 0; i < 10; i++) { try { yield server.users.register({ username: 'test' + i }); @@ -96,9 +96,9 @@ describe('Test application behind a reverse proxy', function () { }); }); it('Should not rate limit failed signup', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(7000); + yield (0, extra_utils_1.wait)(7000); for (let i = 0; i < 3; i++) { yield server.users.register({ username: 'test' + i, expectedStatus: models_1.HttpStatusCode.CONFLICT_409 }); } @@ -106,9 +106,9 @@ describe('Test application behind a reverse proxy', function () { }); }); it('Should rate limit API calls', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(7000); + yield (0, extra_utils_1.wait)(7000); for (let i = 0; i < 100; i++) { try { yield server.videos.get({ id: videoId }); @@ -120,8 +120,8 @@ describe('Test application behind a reverse proxy', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/services.js b/dist/server/tests/api/server/services.js index 9fd113d3..c5206e91 100644 --- a/dist/server/tests/api/server/services.js +++ b/dist/server/tests/api/server/services.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test services', function () { @@ -11,11 +11,11 @@ describe('Test services', function () { let playlistDisplayName; let video; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); { const attributes = { name: 'my super name' }; yield server.videos.upload({ attributes }); @@ -42,7 +42,7 @@ describe('Test services', function () { }); }); it('Should have a valid oEmbed video response', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of ['/videos/watch/', '/w/']) { for (const suffix of ['', '?param=1']) { const oembedUrl = server.url + basePath + video.uuid + suffix; @@ -64,7 +64,7 @@ describe('Test services', function () { }); }); it('Should have a valid playlist oEmbed response', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of ['/videos/watch/playlist/', '/w/p/']) { for (const suffix of ['', '?param=1']) { const oembedUrl = server.url + basePath + playlistUUID + suffix; @@ -85,7 +85,7 @@ describe('Test services', function () { }); }); it('Should have a valid oEmbed response with small max height query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of ['/videos/watch/', '/w/']) { const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid; const format = 'json'; @@ -107,8 +107,8 @@ describe('Test services', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/server/stats.js b/dist/server/tests/api/server/stats.js index 81e81d59..bc0eb427 100644 --- a/dist/server/tests/api/server/stats.js +++ b/dist/server/tests/api/server/stats.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test stats (excluding redundancy)', function () { @@ -13,22 +13,22 @@ describe('Test stats (excluding redundancy)', function () { password: 'super_password' }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].users.create({ username: user.username, password: user.password }); const { uuid } = yield servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } }); yield servers[0].comments.createThread({ videoId: uuid, text: 'comment' }); yield servers[0].videos.view({ id: uuid }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); yield servers[2].follows.follow({ hosts: [servers[0].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the correct stats on instance 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield servers[0].stats.get(); expect(data.totalLocalVideoComments).to.equal(1); expect(data.totalLocalVideos).to.equal(1); @@ -43,7 +43,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct stats on instance 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield servers[1].stats.get(); expect(data.totalLocalVideoComments).to.equal(0); expect(data.totalLocalVideos).to.equal(0); @@ -58,7 +58,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct stats on instance 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const data = yield servers[2].stats.get(); expect(data.totalLocalVideoComments).to.equal(0); expect(data.totalLocalVideos).to.equal(0); @@ -72,16 +72,16 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct total videos stats after an unfollow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[2].follows.unfollow({ target: servers[0] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const data = yield servers[2].stats.get(); expect(data.totalVideos).to.equal(0); }); }); it('Should have the correct active user stats', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = servers[0]; { const data = yield server.stats.get(); @@ -99,7 +99,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct active channel stats', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = servers[0]; { const data = yield server.stats.get(); @@ -129,7 +129,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct playlist stats', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = servers[0]; { const data = yield server.stats.get(); @@ -149,7 +149,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should correctly count video file sizes if transcoding is enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -175,7 +175,7 @@ describe('Test stats (excluding redundancy)', function () { } }); yield servers[0].videos.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const data = yield servers[1].stats.get(); expect(data.totalLocalVideoFilesSize).to.equal(0); @@ -188,7 +188,7 @@ describe('Test stats (excluding redundancy)', function () { }); }); it('Should have the correct AP stats', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -201,8 +201,8 @@ describe('Test stats (excluding redundancy)', function () { for (let i = 0; i < 10; i++) { yield servers[0].videos.upload({ attributes: { name: 'video' } }); } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(6000); const second = yield servers[1].stats.get(); expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed); const apTypes = [ @@ -215,15 +215,15 @@ describe('Test stats (excluding redundancy)', function () { for (const apType of apTypes) { expect(second['totalActivityPub' + apType + 'MessagesErrors']).to.equal(0); } - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); const third = yield servers[1].stats.get(); expect(third.totalActivityPubMessagesWaiting).to.equal(0); expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/server/tracker.js b/dist/server/tests/api/server/tracker.js index 81744ca5..74dfed9d 100644 --- a/dist/server/tests/api/server/tracker.js +++ b/dist/server/tests/api/server/tracker.js @@ -2,18 +2,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const magnet_uri_1 = tslib_1.__importDefault(require("magnet-uri")); -const webtorrent_1 = tslib_1.__importDefault(require("webtorrent")); +const magnet_uri_1 = (0, tslib_1.__importDefault)(require("magnet-uri")); +const webtorrent_1 = (0, tslib_1.__importDefault)(require("webtorrent")); const extra_utils_1 = require("@shared/extra-utils"); describe('Test tracker', function () { let server; let badMagnet; let goodMagnet; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); { const { uuid } = yield server.videos.upload(); const video = yield server.videos.get({ id: uuid }); @@ -39,7 +39,7 @@ describe('Test tracker', function () { it('Should disable the tracker', function (done) { this.timeout(20000); const errCb = () => done(new Error('Tracker is enabled')); - extra_utils_1.killallServers([server]) + (0, extra_utils_1.killallServers)([server]) .then(() => server.run({ tracker: { enabled: false } })) .then(() => { const webtorrent = new webtorrent_1.default(); @@ -57,7 +57,7 @@ describe('Test tracker', function () { }); it('Should return an error when adding an incorrect infohash', function (done) { this.timeout(20000); - extra_utils_1.killallServers([server]) + (0, extra_utils_1.killallServers)([server]) .then(() => server.run()) .then(() => { const webtorrent = new webtorrent_1.default(); @@ -82,8 +82,8 @@ describe('Test tracker', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/users/user-subscriptions.js b/dist/server/tests/api/users/user-subscriptions.js index 0bb569dc..61489ce9 100644 --- a/dist/server/tests/api/users/user-subscriptions.js +++ b/dist/server/tests/api/users/user-subscriptions.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test users subscriptions', function () { @@ -11,11 +11,11 @@ describe('Test users subscriptions', function () { let video3UUID; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); { for (const server of servers) { const user = { username: 'user' + server.serverNumber, password: 'password' }; @@ -28,30 +28,30 @@ describe('Test users subscriptions', function () { yield server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }); } } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); command = servers[0].subscriptions; }); }); it('Should display videos of server 2 on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].videos.list(); expect(total).to.equal(4); }); }); it('User of server 1 should follow user of server 3 and root of server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }); yield command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const attributes = { name: 'video server 3 added after follow' }; const { uuid } = yield servers[2].videos.upload({ token: users[2].accessToken, attributes }); video3UUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not display videos of server 3 on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(4); for (const video of data) { @@ -62,7 +62,7 @@ describe('Test users subscriptions', function () { }); }); it('Should list subscriptions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list(); expect(body.total).to.equal(0); @@ -81,7 +81,7 @@ describe('Test users subscriptions', function () { }); }); it('Should get subscription', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const videoChannel = yield command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }); expect(videoChannel.name).to.equal('user3_channel'); @@ -101,7 +101,7 @@ describe('Test users subscriptions', function () { }); }); it('Should return the existing subscriptions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uris = [ 'user3_channel@localhost:' + servers[2].port, 'root2_channel@localhost:' + servers[0].port, @@ -116,7 +116,7 @@ describe('Test users subscriptions', function () { }); }); it('Should search among subscriptions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }); expect(body.total).to.equal(1); @@ -130,7 +130,7 @@ describe('Test users subscriptions', function () { }); }); it('Should list subscription videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.listVideos(); expect(body.total).to.equal(0); @@ -150,11 +150,11 @@ describe('Test users subscriptions', function () { }); }); it('Should upload a video by root on server 1 and see it in the subscription videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const videoName = 'video server 1 added after follow'; yield servers[0].videos.upload({ attributes: { name: videoName } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield command.listVideos(); expect(body.total).to.equal(0); @@ -184,10 +184,10 @@ describe('Test users subscriptions', function () { }); }); it('Should have server 1 follow server 3 and display server 3 videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].follows.follow({ hosts: [servers[2].url] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data, total } = yield servers[0].videos.list(); expect(total).to.equal(8); const names = ['1-3', '2-3', 'video server 3 added after follow']; @@ -198,10 +198,10 @@ describe('Test users subscriptions', function () { }); }); it('Should remove follow server 1 -> server 3 and hide server 3 videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].follows.unfollow({ target: servers[2] }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(5); for (const video of data) { @@ -212,7 +212,7 @@ describe('Test users subscriptions', function () { }); }); it('Should still list subscription videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.listVideos(); expect(body.total).to.equal(0); @@ -233,23 +233,23 @@ describe('Test users subscriptions', function () { }); }); it('Should update a video of server 3 and see the updated video on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }); expect(body.data[2].name).to.equal('video server 3 added after follow updated'); }); }); it('Should remove user of server 3 subscription', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not display its videos anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }); expect(body.total).to.equal(1); const videos = body.data; @@ -259,10 +259,10 @@ describe('Test users subscriptions', function () { }); }); it('Should remove the root subscription and not display the videos anymore', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield command.list({ token: users[0].accessToken, sort: 'createdAt' }); expect(body.total).to.equal(0); @@ -273,7 +273,7 @@ describe('Test users subscriptions', function () { }); }); it('Should correctly display public videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(5); for (const video of data) { @@ -284,10 +284,10 @@ describe('Test users subscriptions', function () { }); }); it('Should follow user of server 3 again', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }); expect(body.total).to.equal(3); @@ -310,8 +310,8 @@ describe('Test users subscriptions', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/users/users-multiple-servers.js b/dist/server/tests/api/users/users-multiple-servers.js index 4c9a36cd..aa2ebc07 100644 --- a/dist/server/tests/api/users/users-multiple-servers.js +++ b/dist/server/tests/api/users/users-multiple-servers.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test users with multiple servers', function () { @@ -13,13 +13,13 @@ describe('Test users with multiple servers', function () { let userAccessToken; let userAvatarFilename; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.doubleFollow(servers[0], servers[2]); - yield extra_utils_1.doubleFollow(servers[1], servers[2]); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[1], servers[2]); yield servers[0].videos.upload(); { const username = 'user1'; @@ -30,43 +30,43 @@ describe('Test users with multiple servers', function () { { const { uuid } = yield servers[0].videos.upload({ token: userAccessToken }); videoUUID = uuid; - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.saveVideoInServers(servers, videoUUID); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.saveVideoInServers)(servers, videoUUID); } }); }); it('Should be able to update my display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].users.updateMe({ displayName: 'my super display name' }); user = yield servers[0].users.getMyInfo(); expect(user.account.displayName).to.equal('my super display name'); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should be able to update my description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].users.updateMe({ description: 'my super description updated' }); user = yield servers[0].users.getMyInfo(); expect(user.account.displayName).to.equal('my super display name'); expect(user.account.description).to.equal('my super description updated'); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should be able to update my avatar', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const fixture = 'avatar2.png'; yield servers[0].users.updateMyAvatar({ fixture }); user = yield servers[0].users.getMyInfo(); userAvatarFilename = user.account.avatar.path; - yield extra_utils_1.testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png'); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.testImage)(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png'); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have updated my profile on other servers too', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let createdAt; for (const server of servers) { const body = yield server.accounts.list({ sort: '-createdAt' }); @@ -86,12 +86,12 @@ describe('Test users with multiple servers', function () { else { expect(account.userId).to.be.undefined; } - yield extra_utils_1.testImage(server.url, 'avatar2-resized', account.avatar.path, '.png'); + yield (0, extra_utils_1.testImage)(server.url, 'avatar2-resized', account.avatar.path, '.png'); } }); }); it('Should list account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total, data } = yield server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port }); expect(total).to.equal(1); @@ -102,10 +102,10 @@ describe('Test users with multiple servers', function () { }); }); it('Should search through account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const created = yield servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port, search: 'Kami' }); expect(total).to.equal(1); @@ -116,7 +116,7 @@ describe('Test users with multiple servers', function () { }); }); it('Should remove the user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); for (const server of servers) { const body = yield server.accounts.list({ sort: '-createdAt' }); @@ -127,7 +127,7 @@ describe('Test users with multiple servers', function () { expect(videoChannelDeleted).not.to.be.undefined; } yield servers[0].users.remove({ userId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const body = yield server.accounts.list({ sort: '-createdAt' }); const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port); @@ -138,26 +138,26 @@ describe('Test users with multiple servers', function () { } }); }); - it('Should not have actor files', () => tslib_1.__awaiter(this, void 0, void 0, function* () { + it('Should not have actor files', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber); + yield (0, extra_utils_1.checkActorFilesWereRemoved)(userAvatarFilename, server.internalServerNumber); } })); - it('Should not have video files', () => tslib_1.__awaiter(this, void 0, void 0, function* () { + it('Should not have video files', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkVideoFilesWereRemoved({ server, video: server.store.videoDetails }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server, video: server.store.videoDetails }); } })); it('Should have an empty tmp directory', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkTmpIsEmpty(server); + yield (0, extra_utils_1.checkTmpIsEmpty)(server); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/users/users-verification.js b/dist/server/tests/api/users/users-verification.js index ec0de662..4adeec76 100644 --- a/dist/server/tests/api/users/users-verification.js +++ b/dist/server/tests/api/users/users-verification.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -22,7 +22,7 @@ describe('Test users account verification', function () { }; const emails = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const port = yield extra_utils_1.MockSmtpServer.Instance.collectEmails(emails); const overrideConfig = { @@ -31,12 +31,12 @@ describe('Test users account verification', function () { port } }; - server = yield extra_utils_1.createSingleServer(1, overrideConfig); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1, overrideConfig); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); it('Should register user and send verification email if verification required', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield server.config.updateCustomSubConfig({ newConfig: { @@ -48,7 +48,7 @@ describe('Test users account verification', function () { } }); yield server.users.register(user1); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expectedEmailsLength++; expect(emails).to.have.lengthOf(expectedEmailsLength); const email = emails[expectedEmailsLength - 1]; @@ -64,13 +64,13 @@ describe('Test users account verification', function () { }); }); it('Should not allow login for user with unverified email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { detail } = yield server.login.login({ user: user1, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); expect(detail).to.contain('User email is not verified.'); }); }); it('Should verify the user via email and allow login', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.verifyEmail({ userId, verificationString }); const body = yield server.login.login({ user: user1 }); userAccessToken = body.access_token; @@ -79,7 +79,7 @@ describe('Test users account verification', function () { }); }); it('Should be able to change the user email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); let updateVerificationString; { @@ -88,7 +88,7 @@ describe('Test users account verification', function () { email: 'updated@example.com', currentPassword: user1.password }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expectedEmailsLength++; expect(emails).to.have.lengthOf(expectedEmailsLength); const email = emails[expectedEmailsLength - 1]; @@ -109,7 +109,7 @@ describe('Test users account verification', function () { }); }); it('Should register user not requiring email verification if setting not enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); yield server.config.updateCustomSubConfig({ newConfig: { @@ -121,7 +121,7 @@ describe('Test users account verification', function () { } }); yield server.users.register(user2); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); expect(emails).to.have.lengthOf(expectedEmailsLength); const accessToken = yield server.login.getAccessToken(user2); const user = yield server.users.getMyInfo({ token: accessToken }); @@ -129,7 +129,7 @@ describe('Test users account verification', function () { }); }); it('Should allow login for user with unverified email when setting later enabled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.config.updateCustomSubConfig({ newConfig: { signup: { @@ -143,9 +143,9 @@ describe('Test users account verification', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { extra_utils_1.MockSmtpServer.Instance.kill(); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/users/users.js b/dist/server/tests/api/users/users.js index 5030a0ff..797dd79c 100644 --- a/dist/server/tests/api/users/users.js +++ b/dist/server/tests/api/users/users.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -17,16 +17,16 @@ describe('Test users', function () { password: 'super password' }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1, { + server = yield (0, extra_utils_1.createSingleServer)(1, { rates_limit: { login: { max: 30 } } }); - yield extra_utils_1.setAccessTokensToServers([server]); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ npmName: 'peertube-theme-background-red' }); }); }); @@ -35,7 +35,7 @@ describe('Test users', function () { it('Should return the first client'); it('Should remove the last client'); it('Should not login with an invalid client id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const client = { id: 'client', secret: server.store.client.secret }; const body = yield server.login.login({ client, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); expect(body.code).to.equal("invalid_client"); @@ -45,7 +45,7 @@ describe('Test users', function () { }); }); it('Should not login with an invalid client secret', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const client = { id: server.store.client.id, secret: 'coucou' }; const body = yield server.login.login({ client, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); expect(body.code).to.equal("invalid_client"); @@ -57,7 +57,7 @@ describe('Test users', function () { }); describe('Login', function () { it('Should not login with an invalid username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'captain crochet', password: server.store.user.password }; const body = yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); expect(body.code).to.equal("invalid_grant"); @@ -67,7 +67,7 @@ describe('Test users', function () { }); }); it('Should not login with an invalid password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: server.store.user.username, password: 'mew_three' }; const body = yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); expect(body.code).to.equal("invalid_grant"); @@ -77,13 +77,13 @@ describe('Test users', function () { }); }); it('Should not be able to upload a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { token = 'my_super_token'; yield server.videos.upload({ token, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to follow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { token = 'my_super_token'; yield server.follows.follow({ hosts: ['http://example.com'], @@ -94,13 +94,13 @@ describe('Test users', function () { }); it('Should not be able to unfollow'); it('Should be able to login', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.login.login({ expectedStatus: models_1.HttpStatusCode.OK_200 }); token = body.access_token; }); }); it('Should be able to login with an insensitive username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { username: 'RoOt', password: server.store.user.password }; yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.OK_200 }); const user2 = { username: 'rOoT', password: server.store.user.password }; @@ -112,7 +112,7 @@ describe('Test users', function () { }); describe('Upload', function () { it('Should upload the video with the correct token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.upload({ token }); const { data } = yield server.videos.list(); const video = data[0]; @@ -121,14 +121,14 @@ describe('Test users', function () { }); }); it('Should upload the video again with the correct token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.upload({ token }); }); }); }); describe('Ratings', function () { it('Should retrieve a video rating', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.rate({ id: videoId, rating: 'like' }); const rating = yield server.users.getMyRating({ token, videoId }); expect(rating.videoId).to.equal(videoId); @@ -136,7 +136,7 @@ describe('Test users', function () { }); }); it('Should retrieve ratings list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.rate({ id: videoId, rating: 'like' }); const body = yield server.accounts.listRatings({ accountName: server.store.user.username }); expect(body.total).to.equal(1); @@ -145,7 +145,7 @@ describe('Test users', function () { }); }); it('Should retrieve ratings list by rating type', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield server.accounts.listRatings({ accountName: server.store.user.username, rating: 'like' }); expect(body.data.length).to.equal(1); @@ -159,35 +159,35 @@ describe('Test users', function () { }); describe('Remove video', function () { it('Should not be able to remove the video with an incorrect token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ token: 'bad_token', id: videoId, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to remove the video with the token of another account'); it('Should be able to remove the video with the correct token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.remove({ token, id: videoId }); }); }); }); describe('Logout', function () { it('Should logout (revoke token)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.logout({ token: server.accessToken }); }); }); it('Should not be able to get the user information', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyInfo({ expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to upload a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.upload({ attributes: { name: 'video' }, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to rate a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/'; const data = { rating: 'likes' @@ -199,42 +199,42 @@ describe('Test users', function () { fields: data, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }; - yield extra_utils_1.makePutBodyRequest(options); + yield (0, extra_utils_1.makePutBodyRequest)(options); }); }); it('Should be able to login again', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.login.login(); server.accessToken = body.access_token; server.refreshToken = body.refresh_token; }); }); it('Should be able to get my user information again', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyInfo(); }); }); it('Should have an expired access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()); yield server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); yield server.users.getMyInfo({ expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to refresh an access token with an expired refresh token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.refreshToken({ refreshToken: server.refreshToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should refresh the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const futureDate = new Date(new Date().getTime() + 1000 * 60).toISOString(); yield server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); const res = yield server.login.refreshToken({ refreshToken: server.refreshToken }); server.accessToken = res.body.access_token; @@ -242,24 +242,24 @@ describe('Test users', function () { }); }); it('Should be able to get my user information again', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyInfo(); }); }); }); describe('Creating a user', function () { it('Should be able to create a new user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.create(Object.assign(Object.assign({}, user), { videoQuota: 2 * 1024 * 1024, adminFlags: 1 })); }); }); it('Should be able to login with this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { userToken = yield server.login.getAccessToken(user); }); }); it('Should be able to get user information', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const userMe = yield server.users.getMyInfo({ token: userToken }); const userGet = yield server.users.get({ userId: userMe.id, withStats: true }); for (const user of [userMe, userGet]) { @@ -289,7 +289,7 @@ describe('Test users', function () { }); describe('My videos & quotas', function () { it('Should be able to upload a video with this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'super user video', @@ -299,7 +299,7 @@ describe('Test users', function () { }); }); it('Should have video quota updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const quota = yield server.users.getMyQuotaUsed({ token: userToken }); expect(quota.videoQuotaUsed).to.equal(218910); const { data } = yield server.users.list(); @@ -308,7 +308,7 @@ describe('Test users', function () { }); }); it('Should be able to list my videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.listMyVideos({ token: userToken }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -319,7 +319,7 @@ describe('Test users', function () { }); }); it('Should be able to search in my videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { total, data } = yield server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' }); expect(total).to.equal(1); @@ -333,7 +333,7 @@ describe('Test users', function () { }); }); it('Should disable webtorrent, enable HLS, and update my quota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); { const config = yield server.config.getCustomConfig(); @@ -348,7 +348,7 @@ describe('Test users', function () { fixture: 'video_short.webm' }; yield server.videos.upload({ token: userToken, attributes }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); } { const data = yield server.users.getMyQuotaUsed({ token: userToken }); @@ -359,7 +359,7 @@ describe('Test users', function () { }); describe('Users listing', function () { it('Should list all the users', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.users.list(); expect(total).to.equal(2); expect(data).to.be.an('array'); @@ -378,7 +378,7 @@ describe('Test users', function () { }); }); it('Should list only the first user by username asc', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.users.list({ start: 0, count: 1, sort: 'username' }); expect(total).to.equal(2); expect(data.length).to.equal(1); @@ -390,7 +390,7 @@ describe('Test users', function () { }); }); it('Should list only the first user by username desc', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.users.list({ start: 0, count: 1, sort: '-username' }); expect(total).to.equal(2); expect(data.length).to.equal(1); @@ -401,7 +401,7 @@ describe('Test users', function () { }); }); it('Should list only the second user by createdAt desc', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.users.list({ start: 0, count: 1, sort: '-createdAt' }); expect(total).to.equal(2); expect(data.length).to.equal(1); @@ -412,7 +412,7 @@ describe('Test users', function () { }); }); it('Should list all the users by createdAt asc', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.users.list({ start: 0, count: 2, sort: 'createdAt' }); expect(total).to.equal(2); expect(data.length).to.equal(2); @@ -425,7 +425,7 @@ describe('Test users', function () { }); }); it('Should search user by username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' }); expect(total).to.equal(1); expect(data.length).to.equal(1); @@ -433,7 +433,7 @@ describe('Test users', function () { }); }); it('Should search user by email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { total, data } = yield server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' }); expect(total).to.equal(1); @@ -453,7 +453,7 @@ describe('Test users', function () { }); describe('Update my account', function () { it('Should update my password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, currentPassword: 'super password', @@ -464,7 +464,7 @@ describe('Test users', function () { }); }); it('Should be able to change the NSFW display attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, nsfwPolicy: 'do_not_list' @@ -480,7 +480,7 @@ describe('Test users', function () { }); }); it('Should be able to change the autoPlayVideo attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, autoPlayVideo: false @@ -490,7 +490,7 @@ describe('Test users', function () { }); }); it('Should be able to change the autoPlayNextVideo attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, autoPlayNextVideo: true @@ -500,7 +500,7 @@ describe('Test users', function () { }); }); it('Should be able to change the email attribute', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, currentPassword: 'new password', @@ -517,25 +517,25 @@ describe('Test users', function () { }); }); it('Should be able to update my avatar with a gif', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const fixture = 'avatar.gif'; yield server.users.updateMyAvatar({ token: userToken, fixture }); const user = yield server.users.getMyInfo({ token: userToken }); - yield extra_utils_1.testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif'); + yield (0, extra_utils_1.testImage)(server.url, 'avatar-resized', user.account.avatar.path, '.gif'); }); }); it('Should be able to update my avatar with a gif, and then a png', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const extension of ['.png', '.gif']) { const fixture = 'avatar' + extension; yield server.users.updateMyAvatar({ token: userToken, fixture }); const user = yield server.users.getMyInfo({ token: userToken }); - yield extra_utils_1.testImage(server.url, 'avatar-resized', user.account.avatar.path, extension); + yield (0, extra_utils_1.testImage)(server.url, 'avatar-resized', user.account.avatar.path, extension); } }); }); it('Should be able to update my display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, displayName: 'new display name' }); const user = yield server.users.getMyInfo({ token: userToken }); expect(user.username).to.equal('user_1'); @@ -548,7 +548,7 @@ describe('Test users', function () { }); }); it('Should be able to update my description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, description: 'my super description updated' }); const user = yield server.users.getMyInfo({ token: userToken }); expect(user.username).to.equal('user_1'); @@ -564,7 +564,7 @@ describe('Test users', function () { }); }); it('Should be able to update my theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const theme of ['background-red', 'default', 'instance-default']) { yield server.users.updateMe({ token: userToken, theme }); const user = yield server.users.getMyInfo({ token: userToken }); @@ -573,7 +573,7 @@ describe('Test users', function () { }); }); it('Should be able to update my modal preferences', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: userToken, noInstanceConfigWarningModal: true, @@ -589,7 +589,7 @@ describe('Test users', function () { }); describe('Updating another user', function () { it('Should be able to update another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId, token, @@ -613,20 +613,20 @@ describe('Test users', function () { }); }); it('Should reset the auth plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId, token, pluginAuth: null }); const user = yield server.users.get({ token, userId }); expect(user.pluginAuth).to.be.null; }); }); it('Should have removed the user token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.getMyQuotaUsed({ token: userToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); userToken = yield server.login.getAccessToken(user); }); }); it('Should be able to update another user password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.update({ userId, token, password: 'password updated' }); yield server.users.getMyQuotaUsed({ token: userToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); @@ -637,24 +637,24 @@ describe('Test users', function () { }); describe('Video blacklists', function () { it('Should be able to list video blacklist by a moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.blacklist.list({ token: userToken }); }); }); }); describe('Remove a user', function () { it('Should be able to remove this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.remove({ userId, token }); }); }); it('Should not be able to login with this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.login({ user, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should not have videos of this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.videos.list(); expect(total).to.equal(1); const video = data[0]; @@ -665,14 +665,14 @@ describe('Test users', function () { describe('Registering a new user', function () { let user15AccessToken; it('Should register a new user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }; const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }; yield server.users.register(Object.assign(Object.assign({}, user), { channel })); }); }); it('Should be able to login with this registered user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user15 = { username: 'user_15', password: 'my super password' @@ -681,25 +681,25 @@ describe('Test users', function () { }); }); it('Should have the correct display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield server.users.getMyInfo({ token: user15AccessToken }); expect(user.account.displayName).to.equal('super user 15'); }); }); it('Should have the correct video quota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield server.users.getMyInfo({ token: user15AccessToken }); expect(user.videoQuota).to.equal(5 * 1024 * 1024); }); }); it('Should have created the channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { displayName } = yield server.channels.get({ channelName: 'my_user_15_channel' }); expect(displayName).to.equal('my channel rocks'); }); }); it('Should remove me', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data } = yield server.users.list(); expect(data.find(u => u.username === 'user_15')).to.not.be.undefined; @@ -720,7 +720,7 @@ describe('Test users', function () { password: 'my super password' }; it('Should block a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield server.users.create(Object.assign({}, user16)); user16Id = user.id; user16AccessToken = yield server.login.getAccessToken(user16); @@ -731,7 +731,7 @@ describe('Test users', function () { }); }); it('Should search user by banned status', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data, total } = yield server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: true }); expect(total).to.equal(1); @@ -747,7 +747,7 @@ describe('Test users', function () { }); }); it('Should unblock a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.unbanUser({ userId: user16Id }); user16AccessToken = yield server.login.getAccessToken(user16); yield server.users.getMyInfo({ token: user16AccessToken, expectedStatus: models_1.HttpStatusCode.OK_200 }); @@ -758,7 +758,7 @@ describe('Test users', function () { let user17Id; let user17AccessToken; it('Should report correct initial statistics about a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user17 = { username: 'user_17', password: 'my super password' @@ -775,7 +775,7 @@ describe('Test users', function () { }); }); it('Should report correct videos count', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'video to test user stats' }; yield server.videos.upload({ token: user17AccessToken, attributes }); const { data } = yield server.videos.list(); @@ -785,7 +785,7 @@ describe('Test users', function () { }); }); it('Should report correct video comments for user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const text = 'super comment'; yield server.comments.createThread({ token: user17AccessToken, videoId, text }); const user = yield server.users.get({ userId: user17Id, withStats: true }); @@ -793,7 +793,7 @@ describe('Test users', function () { }); }); it('Should report correct abuses counts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const reason = 'my super bad reason'; yield server.abuses.report({ token: user17AccessToken, videoId, reason }); const body1 = yield server.abuses.getAdminList(); @@ -808,8 +808,8 @@ describe('Test users', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/audio-only.js b/dist/server/tests/api/videos/audio-only.js index 9ff8db5c..899fa1ee 100644 --- a/dist/server/tests/api/videos/audio-only.js +++ b/dist/server/tests/api/videos/audio-only.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const ffprobe_utils_1 = require("@server/helpers/ffprobe-utils"); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; @@ -12,7 +12,7 @@ describe('Test audio only video transcoding', function () { let webtorrentAudioFileUrl; let fragmentedAudioFileUrl; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const configOverride = { transcoding: { @@ -35,17 +35,17 @@ describe('Test audio only video transcoding', function () { } } }; - servers = yield extra_utils_1.createMultipleServers(2, configOverride); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, configOverride); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should upload a video and transcode it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'audio only' } }); videoUUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.streamingPlaylists).to.have.lengthOf(1); @@ -63,24 +63,24 @@ describe('Test audio only video transcoding', function () { }); }); it('0p transcoded video should not have video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl), servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl) ]; for (const path of paths) { - const { audioStream } = yield ffprobe_utils_1.getAudioStream(path); + const { audioStream } = yield (0, ffprobe_utils_1.getAudioStream)(path); expect(audioStream['codec_name']).to.be.equal('aac'); expect(audioStream['bit_rate']).to.be.at.most(384 * 8000); - const size = yield ffprobe_utils_1.getVideoStreamSize(path); + const size = yield (0, ffprobe_utils_1.getVideoStreamSize)(path); expect(size.height).to.equal(0); expect(size.width).to.equal(0); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/multiple-servers.js b/dist/server/tests/api/videos/multiple-servers.js index 1b81feee..6e13148a 100644 --- a/dist/server/tests/api/videos/multiple-servers.js +++ b/dist/server/tests/api/videos/multiple-servers.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); -const supertest_1 = tslib_1.__importDefault(require("supertest")); +const chai = (0, tslib_1.__importStar)(require("chai")); +const supertest_1 = (0, tslib_1.__importDefault)(require("supertest")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -13,10 +13,10 @@ describe('Test multiple servers', function () { let videoUUID = ''; let videoChannelId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(3); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(3); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const videoChannel = { name: 'super_channel_name', @@ -27,13 +27,13 @@ describe('Test multiple servers', function () { const { data } = yield servers[0].channels.list({ start: 0, count: 1 }); videoChannelId = data[0].id; } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.doubleFollow(servers[0], servers[2]); - yield extra_utils_1.doubleFollow(servers[1], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[1], servers[2]); }); }); it('Should not have videos for all servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { data } = yield server.videos.list(); expect(data).to.be.an('array'); @@ -43,7 +43,7 @@ describe('Test multiple servers', function () { }); describe('Should upload the video and propagate on each server', function () { it('Should upload the video on server 1 and propagate on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); const attributes = { name: 'my super name for server 1', @@ -59,7 +59,7 @@ describe('Test multiple servers', function () { fixture: 'video_short1.webm' }; yield servers[0].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); let publishedAt = null; for (const server of servers) { const isLocal = server.port === servers[0].port; @@ -101,13 +101,13 @@ describe('Test multiple servers', function () { expect(data).to.be.an('array'); expect(data.length).to.equal(1); const video = data[0]; - yield extra_utils_1.completeVideoCheck(server, video, checkAttributes); + yield (0, extra_utils_1.completeVideoCheck)(server, video, checkAttributes); publishedAt = video.publishedAt; } }); }); it('Should upload the video on server 2 and propagate on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(100000); const user = { username: 'user1', @@ -129,7 +129,7 @@ describe('Test multiple servers', function () { previewfile: 'preview.jpg' }; yield servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const isLocal = server.url === 'http://localhost:' + servers[1].port; const checkAttributes = { @@ -182,12 +182,12 @@ describe('Test multiple servers', function () { expect(data).to.be.an('array'); expect(data.length).to.equal(2); const video = data[1]; - yield extra_utils_1.completeVideoCheck(server, video, checkAttributes); + yield (0, extra_utils_1.completeVideoCheck)(server, video, checkAttributes); } }); }); it('Should upload two videos on server 3 and propagate on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(45000); { const attributes = { @@ -217,7 +217,7 @@ describe('Test multiple servers', function () { }; yield servers[2].videos.upload({ attributes }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const isLocal = server.url === 'http://localhost:' + servers[2].port; const { data } = yield server.videos.list(); @@ -265,7 +265,7 @@ describe('Test multiple servers', function () { } ] }; - yield extra_utils_1.completeVideoCheck(server, video1, checkAttributesVideo1); + yield (0, extra_utils_1.completeVideoCheck)(server, video1, checkAttributesVideo1); const checkAttributesVideo2 = { name: 'my super name for server 3-2', category: 7, @@ -298,14 +298,14 @@ describe('Test multiple servers', function () { } ] }; - yield extra_utils_1.completeVideoCheck(server, video2, checkAttributesVideo2); + yield (0, extra_utils_1.completeVideoCheck)(server, video2, checkAttributesVideo2); } }); }); }); describe('It should list local videos', function () { it('Should list only local videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield servers[0].videos.list({ filter: 'local' }); expect(total).to.equal(1); expect(data).to.be.an('array'); @@ -314,7 +314,7 @@ describe('Test multiple servers', function () { }); }); it('Should list only local videos on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield servers[1].videos.list({ filter: 'local' }); expect(total).to.equal(1); expect(data).to.be.an('array'); @@ -323,7 +323,7 @@ describe('Test multiple servers', function () { }); }); it('Should list only local videos on server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield servers[2].videos.list({ filter: 'local' }); expect(total).to.equal(2); expect(data).to.be.an('array'); @@ -335,64 +335,64 @@ describe('Test multiple servers', function () { }); describe('Should seed the uploaded video', function () { it('Should add the file 1 by asking server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[2].videos.list(); const video = data[0]; toRemove.push(data[2]); toRemove.push(data[3]); const videoDetails = yield servers[2].videos.get({ id: video.id }); - const torrent = yield extra_utils_1.webtorrentAdd(videoDetails.files[0].magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(videoDetails.files[0].magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); }); }); it('Should add the file 2 by asking server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[0].videos.list(); const video = data[1]; const videoDetails = yield servers[0].videos.get({ id: video.id }); - const torrent = yield extra_utils_1.webtorrentAdd(videoDetails.files[0].magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(videoDetails.files[0].magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); }); }); it('Should add the file 3 by asking server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[1].videos.list(); const video = data[2]; const videoDetails = yield servers[1].videos.get({ id: video.id }); - const torrent = yield extra_utils_1.webtorrentAdd(videoDetails.files[0].magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(videoDetails.files[0].magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); }); }); it('Should add the file 3-2 by asking server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[0].videos.list(); const video = data[3]; const videoDetails = yield servers[0].videos.get({ id: video.id }); - const torrent = yield extra_utils_1.webtorrentAdd(videoDetails.files[0].magnetUri); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(videoDetails.files[0].magnetUri); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); }); }); it('Should add the file 2 in 360p by asking server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[0].videos.list(); const video = data.find(v => v.name === 'my super name for server 2'); const videoDetails = yield servers[0].videos.get({ id: video.id }); const file = videoDetails.files.find(f => f.resolution.id === 360); expect(file).not.to.be.undefined; - const torrent = yield extra_utils_1.webtorrentAdd(file.magnetUri); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(file.magnetUri); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); @@ -405,7 +405,7 @@ describe('Test multiple servers', function () { let remoteVideosServer2 = []; let remoteVideosServer3 = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data } = yield servers[0].videos.list(); remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid); @@ -422,18 +422,18 @@ describe('Test multiple servers', function () { }); }); it('Should view multiple videos on owned servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[2].videos.view({ id: localVideosServer3[0] }); - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); yield servers[2].videos.view({ id: localVideosServer3[0] }); yield servers[2].videos.view({ id: localVideosServer3[1] }); - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); yield servers[2].videos.view({ id: localVideosServer3[0] }); yield servers[2].videos.view({ id: localVideosServer3[0] }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(6000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(6000); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video0 = data.find(v => v.uuid === localVideosServer3[0]); @@ -444,7 +444,7 @@ describe('Test multiple servers', function () { }); }); it('Should view multiple videos on each servers', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(45000); const tasks = []; tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] })); @@ -458,9 +458,9 @@ describe('Test multiple servers', function () { tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })); tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })); yield Promise.all(tasks); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(16000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(16000); + yield (0, extra_utils_1.waitJobs)(servers); let baseVideos = null; for (const server of servers) { const { data } = yield server.videos.list(); @@ -476,22 +476,22 @@ describe('Test multiple servers', function () { }); }); it('Should like and dislikes videos on different services', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); yield servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }); - yield extra_utils_1.wait(500); + yield (0, extra_utils_1.wait)(500); yield servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' }); - yield extra_utils_1.wait(500); + yield (0, extra_utils_1.wait)(500); yield servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }); yield servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' }); - yield extra_utils_1.wait(500); + yield (0, extra_utils_1.wait)(500); yield servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' }); yield servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' }); - yield extra_utils_1.wait(500); + yield (0, extra_utils_1.wait)(500); yield servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(5000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(5000); + yield (0, extra_utils_1.waitJobs)(servers); let baseVideos = null; for (const server of servers) { const { data } = yield server.videos.list(); @@ -510,7 +510,7 @@ describe('Test multiple servers', function () { }); describe('Should manipulate these videos', function () { it('Should update the video 3 by asking server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'my super video updated', @@ -526,11 +526,11 @@ describe('Test multiple servers', function () { previewfile: 'preview.jpg' }; yield servers[2].videos.update({ id: toRemove[0].id, attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the video 3 updated on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); for (const server of servers) { const { data } = yield server.videos.list(); @@ -572,25 +572,25 @@ describe('Test multiple servers', function () { thumbnailfile: 'thumbnail', previewfile: 'preview' }; - yield extra_utils_1.completeVideoCheck(server, videoUpdated, checkAttributes); + yield (0, extra_utils_1.completeVideoCheck)(server, videoUpdated, checkAttributes); } }); }); it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); for (const id of [toRemove[0].id, toRemove[1].id]) { - yield extra_utils_1.saveVideoInServers(servers, id); + yield (0, extra_utils_1.saveVideoInServers)(servers, id); yield servers[2].videos.remove({ id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { - yield extra_utils_1.checkVideoFilesWereRemoved({ server, video: server.store.videoDetails }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server, video: server.store.videoDetails }); } } }); }); it('Should have videos 1 and 3 on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { data } = yield server.videos.list(); expect(data).to.be.an('array'); @@ -605,7 +605,7 @@ describe('Test multiple servers', function () { }); }); it('Should get the same video by UUID on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let baseVideo = null; for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); @@ -628,10 +628,10 @@ describe('Test multiple servers', function () { }); }); it('Should get the preview from each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); - yield extra_utils_1.testImage(server.url, 'video_short1-preview.webm', video.previewPath); + yield (0, extra_utils_1.testImage)(server.url, 'video_short1-preview.webm', video.previewPath); } }); }); @@ -639,7 +639,7 @@ describe('Test multiple servers', function () { describe('Should comment these videos', function () { let childOfFirstChild; it('Should add comment (threads and replies)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); { const text = 'my super first comment'; @@ -649,13 +649,13 @@ describe('Test multiple servers', function () { const text = 'my super second comment'; yield servers[2].comments.createThread({ videoId: videoUUID, text }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const threadId = yield servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }); const text = 'my super answer to thread 1'; yield servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const threadId = yield servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }); const body = yield servers[2].comments.getThread({ videoId: videoUUID, threadId }); @@ -665,11 +665,11 @@ describe('Test multiple servers', function () { const text2 = 'my super answer to answer of thread 1'; yield servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have these threads', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.comments.listThreads({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -682,8 +682,8 @@ describe('Test multiple servers', function () { expect(comment.account.name).to.equal('root'); expect(comment.account.host).to.equal('localhost:' + servers[0].port); expect(comment.totalReplies).to.equal(3); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; } { const comment = body.data.find(c => c.text === 'my super second comment'); @@ -692,14 +692,14 @@ describe('Test multiple servers', function () { expect(comment.account.name).to.equal('root'); expect(comment.account.host).to.equal('localhost:' + servers[2].port); expect(comment.totalReplies).to.equal(0); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; } } }); }); it('Should have these comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.comments.listThreads({ videoId: videoUUID }); const threadId = body.data.find(c => c.text === 'my super first comment').id; @@ -727,14 +727,14 @@ describe('Test multiple servers', function () { }); }); it('Should delete a reply', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have this comment marked as deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { data } = yield server.comments.listThreads({ videoId: videoUUID }); const threadId = data.find(c => c.text === 'my super first comment').id; @@ -754,16 +754,16 @@ describe('Test multiple servers', function () { }); }); it('Should delete the thread comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { data } = yield servers[0].comments.listThreads({ videoId: videoUUID }); const commentId = data.find(c => c.text === 'my super first comment').id; yield servers[0].comments.delete({ videoId: videoUUID, commentId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the threads marked as deleted on other servers too', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.comments.listThreads({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -776,8 +776,8 @@ describe('Test multiple servers', function () { expect(comment.account.name).to.equal('root'); expect(comment.account.host).to.equal('localhost:' + servers[2].port); expect(comment.totalReplies).to.equal(0); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; } { const deletedComment = body.data[1]; @@ -788,24 +788,24 @@ describe('Test multiple servers', function () { expect(deletedComment.inReplyToCommentId).to.be.null; expect(deletedComment.account).to.be.null; expect(deletedComment.totalReplies).to.equal(2); - expect(extra_utils_1.dateIsValid(deletedComment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(deletedComment.updatedAt)).to.be.true; - expect(extra_utils_1.dateIsValid(deletedComment.deletedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(deletedComment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(deletedComment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(deletedComment.deletedAt)).to.be.true; } } }); }); it('Should delete a remote thread by the origin server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); const { data } = yield servers[0].comments.listThreads({ videoId: videoUUID }); const commentId = data.find(c => c.text === 'my super second comment').id; yield servers[0].comments.delete({ videoId: videoUUID, commentId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the threads marked as deleted on other servers too', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.comments.listThreads({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -832,14 +832,14 @@ describe('Test multiple servers', function () { }); }); it('Should disable comments and download', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const attributes = { commentsEnabled: false, downloadEnabled: false }; yield servers[0].videos.update({ id: videoUUID, attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.commentsEnabled).to.be.false; @@ -852,19 +852,19 @@ describe('Test multiple servers', function () { }); describe('With minimum parameters', function () { it('Should upload and propagate the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const path = '/api/v1/videos/upload'; - const req = supertest_1.default(servers[1].url) + const req = (0, supertest_1.default)(servers[1].url) .post(path) .set('Accept', 'application/json') .set('Authorization', 'Bearer ' + servers[1].accessToken) .field('name', 'minimum parameters') .field('privacy', '1') .field('channelId', '1'); - yield req.attach('videofile', extra_utils_1.buildAbsoluteFixturePath('video_short.webm')) + yield req.attach('videofile', (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.webm')) .expect(models_1.HttpStatusCode.OK_200); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === 'minimum parameters'); @@ -913,23 +913,23 @@ describe('Test multiple servers', function () { } ] }; - yield extra_utils_1.completeVideoCheck(server, video, checkAttributes); + yield (0, extra_utils_1.completeVideoCheck)(server, video, checkAttributes); } }); }); }); describe('TMP directory', function () { it('Should have an empty tmp directory', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkTmpIsEmpty(server); + yield (0, extra_utils_1.checkTmpIsEmpty)(server); } }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/resumable-upload.js b/dist/server/tests/api/videos/resumable-upload.js index 5736ecef..e8c67194 100644 --- a/dist/server/tests/api/videos/resumable-upload.js +++ b/dist/server/tests/api/videos/resumable-upload.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const extra_utils_1 = require("@shared/extra-utils"); @@ -13,15 +13,15 @@ describe('Test resumable upload', function () { let server; let rootId; function buildSize(fixture, size) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (size !== undefined) return size; - const baseFixture = extra_utils_1.buildAbsoluteFixturePath(fixture); - return (yield fs_extra_1.stat(baseFixture)).size; + const baseFixture = (0, extra_utils_1.buildAbsoluteFixturePath)(fixture); + return (yield (0, fs_extra_1.stat)(baseFixture)).size; }); } function prepareUpload(sizeArg) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const size = yield buildSize(defaultFixture, sizeArg); const attributes = { name: 'video', @@ -35,10 +35,10 @@ describe('Test resumable upload', function () { }); } function sendChunks(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { pathUploadId, expectedStatus, contentLength, contentRangeBuilder } = options; const size = yield buildSize(defaultFixture, options.size); - const absoluteFilePath = extra_utils_1.buildAbsoluteFixturePath(defaultFixture); + const absoluteFilePath = (0, extra_utils_1.buildAbsoluteFixturePath)(defaultFixture); return server.videos.sendResumableChunks({ pathUploadId, videoFilePath: absoluteFilePath, @@ -50,33 +50,33 @@ describe('Test resumable upload', function () { }); } function checkFileSize(uploadIdArg, expectedSize) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = uploadIdArg.replace(/^upload_id=/, ''); - const subPath = path_1.join('tmp', 'resumable-uploads', uploadId); + const subPath = (0, path_1.join)('tmp', 'resumable-uploads', uploadId); const filePath = server.servers.buildDirectory(subPath); - const exists = yield fs_extra_1.pathExists(filePath); + const exists = yield (0, fs_extra_1.pathExists)(filePath); if (expectedSize === null) { expect(exists).to.be.false; return; } expect(exists).to.be.true; - expect((yield fs_extra_1.stat(filePath)).size).to.equal(expectedSize); + expect((yield (0, fs_extra_1.stat)(filePath)).size).to.equal(expectedSize); }); } function countResumableUploads() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const subPath = path_1.join('tmp', 'resumable-uploads'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const subPath = (0, path_1.join)('tmp', 'resumable-uploads'); const filePath = server.servers.buildDirectory(subPath); - const files = yield fs_extra_1.readdir(filePath); + const files = yield (0, fs_extra_1.readdir)(filePath); return files.length; }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); const body = yield server.users.getMyInfo(); rootId = body.id; yield server.users.update({ userId: rootId, videoQuota: 10000000 }); @@ -84,7 +84,7 @@ describe('Test resumable upload', function () { }); describe('Directory cleaning', function () { it('Should correctly delete files after an upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = yield prepareUpload(); yield sendChunks({ pathUploadId: uploadId }); yield server.videos.endResumableUpload({ pathUploadId: uploadId }); @@ -92,19 +92,19 @@ describe('Test resumable upload', function () { }); }); it('Should not delete files after an unfinished upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield prepareUpload(); expect(yield countResumableUploads()).to.equal(2); }); }); it('Should not delete recent uploads', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }); expect(yield countResumableUploads()).to.equal(2); }); }); it('Should delete old uploads', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }); expect(yield countResumableUploads()).to.equal(0); }); @@ -112,21 +112,21 @@ describe('Test resumable upload', function () { }); describe('Resumable upload and chunks', function () { it('Should accept the same amount of chunks', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = yield prepareUpload(); yield sendChunks({ pathUploadId: uploadId }); yield checkFileSize(uploadId, null); }); }); it('Should not accept more chunks than expected', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = yield prepareUpload(100); yield sendChunks({ pathUploadId: uploadId, expectedStatus: models_1.HttpStatusCode.CONFLICT_409 }); yield checkFileSize(uploadId, 0); }); }); it('Should not accept more chunks than expected with an invalid content length/content range', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = yield prepareUpload(1500); if (process.version.startsWith('v16')) { yield sendChunks({ pathUploadId: uploadId, expectedStatus: models_1.HttpStatusCode.CONFLICT_409, contentLength: 1000 }); @@ -139,7 +139,7 @@ describe('Test resumable upload', function () { }); }); it('Should not accept more chunks than expected with an invalid content length', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const uploadId = yield prepareUpload(500); const size = 1000; const expectedStatus = process.version.startsWith('v16') @@ -152,8 +152,8 @@ describe('Test resumable upload', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/single-server.js b/dist/server/tests/api/videos/single-server.js index e534ea1d..e3e5112e 100644 --- a/dist/server/tests/api/videos/single-server.js +++ b/dist/server/tests/api/videos/single-server.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test a single server', function () { @@ -77,42 +77,42 @@ describe('Test a single server', function () { ] }); before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); it('Should list video categories', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const categories = yield server.videos.getCategories(); expect(Object.keys(categories)).to.have.length.above(10); expect(categories[11]).to.equal('News & Politics'); }); }); it('Should list video licences', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const licences = yield server.videos.getLicences(); expect(Object.keys(licences)).to.have.length.above(5); expect(licences[3]).to.equal('Attribution - No Derivatives'); }); }); it('Should list video languages', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const languages = yield server.videos.getLanguages(); expect(Object.keys(languages)).to.have.length.above(5); expect(languages['ru']).to.equal('Russian'); }); }); it('Should list video privacies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const privacies = yield server.videos.getPrivacies(); expect(Object.keys(privacies)).to.have.length.at.least(3); expect(privacies[3]).to.equal('Private'); }); }); it('Should not have videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.videos.list(); expect(total).to.equal(0); expect(data).to.be.an('array'); @@ -120,7 +120,7 @@ describe('Test a single server', function () { }); }); it('Should upload the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'my super name', @@ -138,49 +138,49 @@ describe('Test a single server', function () { }); }); it('Should get and seed the uploaded video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); const { data, total } = yield server.videos.list(); expect(total).to.equal(1); expect(data).to.be.an('array'); expect(data.length).to.equal(1); const video = data[0]; - yield extra_utils_1.completeVideoCheck(server, video, getCheckAttributes()); + yield (0, extra_utils_1.completeVideoCheck)(server, video, getCheckAttributes()); }); }); it('Should get the video by UUID', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(5000); const video = yield server.videos.get({ id: videoUUID }); - yield extra_utils_1.completeVideoCheck(server, video, getCheckAttributes()); + yield (0, extra_utils_1.completeVideoCheck)(server, video, getCheckAttributes()); }); }); it('Should have the views updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield server.videos.view({ id: videoId }); yield server.videos.view({ id: videoId }); yield server.videos.view({ id: videoId }); - yield extra_utils_1.wait(1500); + yield (0, extra_utils_1.wait)(1500); yield server.videos.view({ id: videoId }); yield server.videos.view({ id: videoId }); - yield extra_utils_1.wait(1500); + yield (0, extra_utils_1.wait)(1500); yield server.videos.view({ id: videoId }); yield server.videos.view({ id: videoId }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const video = yield server.videos.get({ id: videoId }); expect(video.views).to.equal(3); }); }); it('Should remove the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield server.videos.get({ id: videoId }); yield server.videos.remove({ id: videoId }); - yield extra_utils_1.checkVideoFilesWereRemoved({ video, server }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ video, server }); }); }); it('Should not have videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list(); expect(total).to.equal(0); expect(data).to.be.an('array'); @@ -188,7 +188,7 @@ describe('Test a single server', function () { }); }); it('Should upload 6 videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(25000); const videos = new Set([ 'video_short.mp4', 'video_short.ogv', 'video_short.webm', @@ -210,7 +210,7 @@ describe('Test a single server', function () { }); }); it('Should have the correct durations', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list(); expect(total).to.equal(6); expect(data).to.be.an('array'); @@ -226,17 +226,17 @@ describe('Test a single server', function () { }); }); it('Should have the correct thumbnails', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.list(); videosListBase = data; for (const video of data) { const videoName = video.name.replace(' name', ''); - yield extra_utils_1.testImage(server.url, videoName, video.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, videoName, video.thumbnailPath); } }); }); it('Should list only the two first videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 0, count: 2, sort: 'name' }); expect(total).to.equal(6); expect(data.length).to.equal(2); @@ -245,7 +245,7 @@ describe('Test a single server', function () { }); }); it('Should list only the next three videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 2, count: 3, sort: 'name' }); expect(total).to.equal(6); expect(data.length).to.equal(3); @@ -255,7 +255,7 @@ describe('Test a single server', function () { }); }); it('Should list the last video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 5, count: 6, sort: 'name' }); expect(total).to.equal(6); expect(data.length).to.equal(1); @@ -263,7 +263,7 @@ describe('Test a single server', function () { }); }); it('Should not have the total field', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true }); expect(total).to.not.exist; expect(data.length).to.equal(1); @@ -271,7 +271,7 @@ describe('Test a single server', function () { }); }); it('Should list and sort by name in descending order', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ sort: '-name' }); expect(total).to.equal(6); expect(data.length).to.equal(6); @@ -286,28 +286,28 @@ describe('Test a single server', function () { }); }); it('Should list and sort by trending in descending order', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 0, count: 2, sort: '-trending' }); expect(total).to.equal(6); expect(data.length).to.equal(2); }); }); it('Should list and sort by hotness in descending order', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 0, count: 2, sort: '-hot' }); expect(total).to.equal(6); expect(data.length).to.equal(2); }); }); it('Should list and sort by best in descending order', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list({ start: 0, count: 2, sort: '-best' }); expect(total).to.equal(6); expect(data.length).to.equal(2); }); }); it('Should update a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'my super video updated', category: 4, @@ -323,7 +323,7 @@ describe('Test a single server', function () { }); }); it('Should filter by tags and category', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { data, total } = yield server.videos.list({ tagsAllOf: ['tagup1', 'tagup2'], categoryOneOf: [4] }); expect(total).to.equal(1); @@ -336,35 +336,35 @@ describe('Test a single server', function () { }); }); it('Should have the video updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const video = yield server.videos.get({ id: videoId }); - yield extra_utils_1.completeVideoCheck(server, video, updateCheckAttributes()); + yield (0, extra_utils_1.completeVideoCheck)(server, video, updateCheckAttributes()); }); }); it('Should update only the tags of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { tags: ['supertag', 'tag1', 'tag2'] }; yield server.videos.update({ id: videoId, attributes }); const video = yield server.videos.get({ id: videoId }); - yield extra_utils_1.completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)); + yield (0, extra_utils_1.completeVideoCheck)(server, video, Object.assign(updateCheckAttributes(), attributes)); }); }); it('Should update only the description of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { description: 'hello everybody' }; yield server.videos.update({ id: videoId, attributes }); const video = yield server.videos.get({ id: videoId }); const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: ['supertag', 'tag1', 'tag2'] }, attributes); - yield extra_utils_1.completeVideoCheck(server, video, expectedAttributes); + yield (0, extra_utils_1.completeVideoCheck)(server, video, expectedAttributes); }); }); it('Should like a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.rate({ id: videoId, rating: 'like' }); const video = yield server.videos.get({ id: videoId }); expect(video.likes).to.equal(1); @@ -372,7 +372,7 @@ describe('Test a single server', function () { }); }); it('Should dislike the same video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.rate({ id: videoId, rating: 'dislike' }); const video = yield server.videos.get({ id: videoId }); expect(video.likes).to.equal(0); @@ -380,7 +380,7 @@ describe('Test a single server', function () { }); }); it('Should sort by originallyPublishedAt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const now = new Date(); const attributes = { originallyPublishedAt: now.toISOString() }; @@ -410,8 +410,8 @@ describe('Test a single server', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); } diff --git a/dist/server/tests/api/videos/video-captions.js b/dist/server/tests/api/videos/video-captions.js index 0ccbdd8e..f7f06a97 100644 --- a/dist/server/tests/api/videos/video-captions.js +++ b/dist/server/tests/api/videos/video-captions.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test video captions', function () { @@ -10,19 +10,19 @@ describe('Test video captions', function () { let servers; let videoUUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.waitJobs(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.waitJobs)(servers); const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'my video name' } }); videoUUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list the captions and return an empty list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.captions.list({ videoId: videoUUID }); expect(body.total).to.equal(0); @@ -31,7 +31,7 @@ describe('Test video captions', function () { }); }); it('Should create two new captions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].captions.add({ language: 'ar', @@ -44,11 +44,11 @@ describe('Test video captions', function () { fixture: 'subtitle-good2.vtt', mimeType: 'application/octet-stream' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list these uploaded captions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.captions.list({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -57,28 +57,28 @@ describe('Test video captions', function () { expect(caption1.language.id).to.equal('ar'); expect(caption1.language.label).to.equal('Arabic'); expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')); - yield extra_utils_1.testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.'); + yield (0, extra_utils_1.testCaptionFile)(server.url, caption1.captionPath, 'Subtitle good 1.'); const caption2 = body.data[1]; expect(caption2.language.id).to.equal('zh'); expect(caption2.language.label).to.equal('Chinese'); expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$')); - yield extra_utils_1.testCaptionFile(server.url, caption2.captionPath, 'Subtitle good 2.'); + yield (0, extra_utils_1.testCaptionFile)(server.url, caption2.captionPath, 'Subtitle good 2.'); } }); }); it('Should replace an existing caption', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].captions.add({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good2.vtt' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have this caption updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.captions.list({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -87,24 +87,24 @@ describe('Test video captions', function () { expect(caption1.language.id).to.equal('ar'); expect(caption1.language.label).to.equal('Arabic'); expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')); - yield extra_utils_1.testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 2.'); + yield (0, extra_utils_1.testCaptionFile)(server.url, caption1.captionPath, 'Subtitle good 2.'); } }); }); it('Should replace an existing caption with a srt file and convert it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].captions.add({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good.srt' }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(3000); }); }); it('Should have this caption updated and converted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.captions.list({ videoId: videoUUID }); expect(body.total).to.equal(2); @@ -126,19 +126,19 @@ describe('Test video captions', function () { '3\r\n' + '00:00:10.000 --> 00:00:14.000\r\n' + 'Adding subtitles is very easy to do\r\n'; - yield extra_utils_1.testCaptionFile(server.url, caption1.captionPath, expected); + yield (0, extra_utils_1.testCaptionFile)(server.url, caption1.captionPath, expected); } }); }); it('Should remove one caption', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].captions.delete({ videoId: videoUUID, language: 'ar' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should only list the caption that was not deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.captions.list({ videoId: videoUUID }); expect(body.total).to.equal(1); @@ -147,21 +147,21 @@ describe('Test video captions', function () { expect(caption.language.id).to.equal('zh'); expect(caption.language.label).to.equal('Chinese'); expect(caption.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$')); - yield extra_utils_1.testCaptionFile(server.url, caption.captionPath, 'Subtitle good 2.'); + yield (0, extra_utils_1.testCaptionFile)(server.url, caption.captionPath, 'Subtitle good 2.'); } }); }); it('Should remove the video, and thus all video captions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield servers[0].videos.get({ id: videoUUID }); const { data: captions } = yield servers[0].captions.list({ videoId: videoUUID }); yield servers[0].videos.remove({ id: videoUUID }); - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video, captions }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video, captions }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-change-ownership.js b/dist/server/tests/api/videos/video-change-ownership.js index 832a4756..edf5f75f 100644 --- a/dist/server/tests/api/videos/video-change-ownership.js +++ b/dist/server/tests/api/videos/video-change-ownership.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -18,11 +18,11 @@ describe('Test video change ownership - nominal', function () { let liveId; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].config.updateCustomSubConfig({ newConfig: { transcoding: { @@ -57,11 +57,11 @@ describe('Test video change ownership - nominal', function () { liveId = video.id; } command = servers[0].changeOwnership; - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should not have video change ownership', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list({ token: firstUserToken }); expect(body.total).to.equal(0); @@ -77,13 +77,13 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should send a request to change ownership of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }); }); }); it('Should only return a request to change ownership for the second user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list({ token: firstUserToken }); expect(body.total).to.equal(0); @@ -100,13 +100,13 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should accept the same change ownership request without crashing', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }); }); }); it('Should not create multiple change ownership requests while one is waiting', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const body = yield command.list({ token: secondUserToken }); expect(body.total).to.equal(1); @@ -115,25 +115,25 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should not be possible to refuse the change of ownership from first user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.refuse({ token: firstUserToken, ownershipId: lastRequestId, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should be possible to refuse the change of ownership from second user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.refuse({ token: secondUserToken, ownershipId: lastRequestId }); }); }); it('Should send a new request to change ownership of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield command.create({ token: firstUserToken, videoId: servers[0].store.videoCreated.id, username: secondUser }); }); }); it('Should return two requests to change ownership for the second user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield command.list({ token: firstUserToken }); expect(body.total).to.equal(0); @@ -150,7 +150,7 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should not be possible to accept the change of ownership from first user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.accept({ token: firstUserToken, @@ -161,14 +161,14 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should be possible to accept the change of ownership from second user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield command.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId: secondUserChannelId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have the channel of the video updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: servers[0].store.videoCreated.uuid }); expect(video.name).to.equal('my super name'); @@ -178,7 +178,7 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should send a request to change ownership of a live', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield command.create({ token: firstUserToken, videoId: liveId, username: secondUser }); const body = yield command.list({ token: secondUserToken }); @@ -188,10 +188,10 @@ describe('Test video change ownership - nominal', function () { }); }); it('Should accept a live ownership change', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield command.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId: secondUserChannelId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: servers[0].store.videoCreated.uuid }); expect(video.name).to.equal('my super name'); @@ -201,8 +201,8 @@ describe('Test video change ownership - nominal', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); @@ -214,10 +214,10 @@ describe('Test video change ownership - quota too small', function () { let secondUserToken = ''; let lastRequestId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.users.create({ username: secondUser, videoQuota: 10 }); firstUserToken = yield server.users.generateUserAndToken(firstUser); secondUserToken = yield server.login.getAccessToken(secondUser); @@ -226,20 +226,20 @@ describe('Test video change ownership - quota too small', function () { description: 'my super description' }; yield server.videos.upload({ token: firstUserToken, attributes }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); const { data } = yield server.videos.list(); expect(data.length).to.equal(1); server.store.videoCreated = data.find(video => video.name === 'my super name'); }); }); it('Should send a request to change ownership of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield server.changeOwnership.create({ token: firstUserToken, videoId: server.store.videoCreated.id, username: secondUser }); }); }); it('Should only return a request to change ownership for the second user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield server.changeOwnership.list({ token: firstUserToken }); expect(body.total).to.equal(0); @@ -256,7 +256,7 @@ describe('Test video change ownership - quota too small', function () { }); }); it('Should not be possible to accept the change of ownership from second user because of exceeded quota', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const { videoChannels } = yield server.users.getMyInfo({ token: secondUserToken }); const channelId = videoChannels[0].id; @@ -269,8 +269,8 @@ describe('Test video change ownership - quota too small', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/video-channels.js b/dist/server/tests/api/videos/video-channels.js index 69e31ef6..d2d5b767 100644 --- a/dist/server/tests/api/videos/video-channels.js +++ b/dist/server/tests/api/videos/video-channels.js @@ -2,13 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const path_1 = require("path"); const constants_1 = require("@server/initializers/constants"); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function findChannel(server, channelId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.channels.list({ sort: '-name' }); return body.data.find(c => c.id === channelId); }); @@ -23,22 +23,22 @@ describe('Test video channels', function () { const avatarPaths = {}; const bannerPaths = {}; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); - it('Should have one video channel (created with root)', () => tslib_1.__awaiter(this, void 0, void 0, function* () { + it('Should have one video channel (created with root)', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].channels.list({ start: 0, count: 2 }); expect(body.total).to.equal(1); expect(body.data).to.be.an('array'); expect(body.data).to.have.lengthOf(1); })); it('Should create another video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); { const videoChannel = { @@ -55,10 +55,10 @@ describe('Test video channels', function () { const { uuid } = yield servers[0].videos.upload({ attributes }); videoUUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); - it('Should have two video channels when getting my information', () => tslib_1.__awaiter(this, void 0, void 0, function* () { + it('Should have two video channels when getting my information', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { userInfo = yield servers[0].users.getMyInfo(); expect(userInfo.videoChannels).to.be.an('array'); expect(userInfo.videoChannels).to.have.lengthOf(2); @@ -72,7 +72,7 @@ describe('Test video channels', function () { accountName = userInfo.account.name + '@' + userInfo.account.host; })); it('Should have two video channels when getting account channels on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].channels.listByAccount({ accountName }); expect(body.total).to.equal(2); const videoChannels = body.data; @@ -87,7 +87,7 @@ describe('Test video channels', function () { }); }); it('Should paginate and sort account channels', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield servers[0].channels.listByAccount({ accountName, @@ -125,7 +125,7 @@ describe('Test video channels', function () { }); }); it('Should have one video channel when getting account channels on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[1].channels.listByAccount({ accountName }); expect(body.total).to.equal(1); expect(body.data).to.be.an('array'); @@ -138,7 +138,7 @@ describe('Test video channels', function () { }); }); it('Should list video channels', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].channels.list({ start: 1, count: 1, sort: '-name' }); expect(body.total).to.equal(2); expect(body.data).to.be.an('array'); @@ -148,7 +148,7 @@ describe('Test video channels', function () { }); }); it('Should update video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const videoChannelAttributes = { displayName: 'video channel updated', @@ -156,11 +156,11 @@ describe('Test video channels', function () { support: 'support updated' }; yield servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have video channel updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.channels.list({ start: 0, count: 1, sort: '-name' }); expect(body.total).to.equal(2); @@ -174,7 +174,7 @@ describe('Test video channels', function () { }); }); it('Should not have updated the video support field', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.support).to.equal('video support field'); @@ -182,14 +182,14 @@ describe('Test video channels', function () { }); }); it('Should update the channel support field and update videos too', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(35000); const videoChannelAttributes = { support: 'video channel support text updated', bulkVideosSupportUpdate: true }; yield servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.support).to.equal(videoChannelAttributes.support); @@ -197,7 +197,7 @@ describe('Test video channels', function () { }); }); it('Should update video channel avatar', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const fixture = 'avatar.png'; yield servers[0].channels.updateImage({ @@ -205,20 +205,20 @@ describe('Test video channels', function () { fixture, type: 'avatar' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoChannel = yield findChannel(server, secondVideoChannelId); avatarPaths[server.port] = videoChannel.avatar.path; - yield extra_utils_1.testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png'); - yield extra_utils_1.testFileExistsOrNot(server, 'avatars', path_1.basename(avatarPaths[server.port]), true); - const row = yield server.sql.getActorImage(path_1.basename(avatarPaths[server.port])); + yield (0, extra_utils_1.testImage)(server.url, 'avatar-resized', avatarPaths[server.port], '.png'); + yield (0, extra_utils_1.testFileExistsOrNot)(server, 'avatars', (0, path_1.basename)(avatarPaths[server.port]), true); + const row = yield server.sql.getActorImage((0, path_1.basename)(avatarPaths[server.port])); expect(row.height).to.equal(constants_1.ACTOR_IMAGES_SIZE.AVATARS.height); expect(row.width).to.equal(constants_1.ACTOR_IMAGES_SIZE.AVATARS.width); } }); }); it('Should update video channel banner', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const fixture = 'banner.jpg'; yield servers[0].channels.updateImage({ @@ -226,44 +226,44 @@ describe('Test video channels', function () { fixture, type: 'banner' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoChannel = yield server.channels.get({ channelName: 'second_video_channel@' + servers[0].host }); bannerPaths[server.port] = videoChannel.banner.path; - yield extra_utils_1.testImage(server.url, 'banner-resized', bannerPaths[server.port]); - yield extra_utils_1.testFileExistsOrNot(server, 'avatars', path_1.basename(bannerPaths[server.port]), true); - const row = yield server.sql.getActorImage(path_1.basename(bannerPaths[server.port])); + yield (0, extra_utils_1.testImage)(server.url, 'banner-resized', bannerPaths[server.port]); + yield (0, extra_utils_1.testFileExistsOrNot)(server, 'avatars', (0, path_1.basename)(bannerPaths[server.port]), true); + const row = yield server.sql.getActorImage((0, path_1.basename)(bannerPaths[server.port])); expect(row.height).to.equal(constants_1.ACTOR_IMAGES_SIZE.BANNERS.height); expect(row.width).to.equal(constants_1.ACTOR_IMAGES_SIZE.BANNERS.width); } }); }); it('Should delete the video channel avatar', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoChannel = yield findChannel(server, secondVideoChannelId); - yield extra_utils_1.testFileExistsOrNot(server, 'avatars', path_1.basename(avatarPaths[server.port]), false); + yield (0, extra_utils_1.testFileExistsOrNot)(server, 'avatars', (0, path_1.basename)(avatarPaths[server.port]), false); expect(videoChannel.avatar).to.be.null; } }); }); it('Should delete the video channel banner', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'banner' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoChannel = yield findChannel(server, secondVideoChannelId); - yield extra_utils_1.testFileExistsOrNot(server, 'avatars', path_1.basename(bannerPaths[server.port]), false); + yield (0, extra_utils_1.testFileExistsOrNot)(server, 'avatars', (0, path_1.basename)(bannerPaths[server.port]), false); expect(videoChannel.banner).to.be.null; } }); }); it('Should list the second video channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); for (const server of servers) { const channelURI = 'second_video_channel@localhost:' + servers[0].port; @@ -276,14 +276,14 @@ describe('Test video channels', function () { }); }); it('Should change the video channel of a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].videos.update({ id: videoUUID, attributes: { channelId: servers[0].store.channel.id } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list the first video channel videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); for (const server of servers) { { @@ -303,12 +303,12 @@ describe('Test video channels', function () { }); }); it('Should delete video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].channels.delete({ channelName: 'second_video_channel' }); }); }); it('Should have video channel deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].channels.list({ start: 0, count: 10 }); expect(body.total).to.equal(1); expect(body.data).to.be.an('array'); @@ -317,7 +317,7 @@ describe('Test video channels', function () { }); }); it('Should create the main channel with an uuid if there is a conflict', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }; const created = yield servers[0].channels.create({ attributes: videoChannel }); @@ -333,7 +333,7 @@ describe('Test video channels', function () { }); }); it('Should report correct channel views per days', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); { const { data } = yield servers[0].channels.listByAccount({ accountName, withStats: true }); @@ -349,7 +349,7 @@ describe('Test video channels', function () { { yield servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' }); yield servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' }); - yield extra_utils_1.wait(8000); + yield (0, extra_utils_1.wait)(8000); const { data } = yield servers[0].channels.listByAccount({ accountName, withStats: true }); const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id); expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2); @@ -357,7 +357,7 @@ describe('Test video channels', function () { }); }); it('Should report correct videos count', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].channels.listByAccount({ accountName, withStats: true }); const totoChannel = data.find(c => c.name === 'toto_channel'); const rootChannel = data.find(c => c.name === 'root_channel'); @@ -366,7 +366,7 @@ describe('Test video channels', function () { }); }); it('Should search among account video channels', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield servers[0].channels.listByAccount({ accountName, search: 'root' }); expect(body.total).to.equal(1); @@ -382,17 +382,17 @@ describe('Test video channels', function () { }); }); it('Should list channels by updatedAt desc if a video has been uploaded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].videos.upload({ attributes: { channelId: totoChannel } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.channels.listByAccount({ accountName, sort: '-updatedAt' }); expect(data[0].name).to.equal('toto_channel'); expect(data[1].name).to.equal('root_channel'); } yield servers[0].videos.upload({ attributes: { channelId: servers[0].store.channel.id } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.channels.listByAccount({ accountName, sort: '-updatedAt' }); expect(data[0].name).to.equal('root_channel'); @@ -401,8 +401,8 @@ describe('Test video channels', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-comments.js b/dist/server/tests/api/videos/video-comments.js index 5ee3de5c..2633bc55 100644 --- a/dist/server/tests/api/videos/video-comments.js +++ b/dist/server/tests/api/videos/video-comments.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test video comments', function () { @@ -14,10 +14,10 @@ describe('Test video comments', function () { let userAccessTokenServer1; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { id, uuid } = yield server.videos.upload(); videoUUID = uuid; videoId = id; @@ -28,7 +28,7 @@ describe('Test video comments', function () { }); describe('User comments', function () { it('Should not have threads on this video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listThreads({ videoId: videoUUID }); expect(body.total).to.equal(0); expect(body.totalNotDeletedComments).to.equal(0); @@ -37,7 +37,7 @@ describe('Test video comments', function () { }); }); it('Should create a thread in this video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const text = 'my super first comment'; const comment = yield command.createThread({ videoId: videoUUID, text }); expect(comment.inReplyToCommentId).to.be.null; @@ -49,12 +49,12 @@ describe('Test video comments', function () { expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root'); expect(comment.totalReplies).to.equal(0); expect(comment.totalRepliesFromVideoAuthor).to.equal(0); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; }); }); it('Should list threads of this video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listThreads({ videoId: videoUUID }); expect(body.total).to.equal(1); expect(body.totalNotDeletedComments).to.equal(1); @@ -67,27 +67,27 @@ describe('Test video comments', function () { expect(comment.id).to.equal(comment.threadId); expect(comment.account.name).to.equal('root'); expect(comment.account.host).to.equal('localhost:' + server.port); - yield extra_utils_1.testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png'); + yield (0, extra_utils_1.testImage)(server.url, 'avatar-resized', comment.account.avatar.path, '.png'); expect(comment.totalReplies).to.equal(0); expect(comment.totalRepliesFromVideoAuthor).to.equal(0); - expect(extra_utils_1.dateIsValid(comment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(comment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(comment.updatedAt)).to.be.true; threadId = comment.threadId; }); }); it('Should get all the thread created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.getThread({ videoId: videoUUID, threadId }); const rootComment = body.comment; expect(rootComment.inReplyToCommentId).to.be.null; expect(rootComment.text).equal('my super first comment'); expect(rootComment.videoId).to.equal(videoId); - expect(extra_utils_1.dateIsValid(rootComment.createdAt)).to.be.true; - expect(extra_utils_1.dateIsValid(rootComment.updatedAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(rootComment.createdAt)).to.be.true; + expect((0, extra_utils_1.dateIsValid)(rootComment.updatedAt)).to.be.true; }); }); it('Should create multiple replies in this thread', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const text1 = 'my super answer to thread 1'; const created = yield command.addReply({ videoId, toCommentId: threadId, text: text1 }); const childCommentId = created.id; @@ -98,7 +98,7 @@ describe('Test video comments', function () { }); }); it('Should get correctly the replies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const tree = yield command.getThread({ videoId: videoUUID, threadId }); expect(tree.comment.text).equal('my super first comment'); expect(tree.children).to.have.lengthOf(2); @@ -115,7 +115,7 @@ describe('Test video comments', function () { }); }); it('Should create other threads', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const text1 = 'super thread 2'; yield command.createThread({ videoId: videoUUID, text: text1 }); const text2 = 'super thread 3'; @@ -123,7 +123,7 @@ describe('Test video comments', function () { }); }); it('Should list the threads', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.listThreads({ videoId: videoUUID, sort: 'createdAt' }); expect(body.total).to.equal(3); expect(body.totalNotDeletedComments).to.equal(6); @@ -138,7 +138,7 @@ describe('Test video comments', function () { }); }); it('Should delete a reply', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ videoId, commentId: replyToDeleteId }); { const body = yield command.listThreads({ videoId: videoUUID, sort: 'createdAt' }); @@ -165,7 +165,7 @@ describe('Test video comments', function () { }); }); it('Should delete a complete thread', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.delete({ videoId, commentId: threadId }); const body = yield command.listThreads({ videoId: videoUUID, sort: 'createdAt' }); expect(body.total).to.equal(3); @@ -183,7 +183,7 @@ describe('Test video comments', function () { }); }); it('Should count replies from the video author correctly', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.createThread({ videoId: videoUUID, text: 'my super first comment' }); const { data } = yield command.listThreads({ videoId: videoUUID }); const threadId2 = data[0].threadId; @@ -198,20 +198,20 @@ describe('Test video comments', function () { }); describe('All instance comments', function () { it('Should list instance comments as admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield command.listForAdmin({ start: 0, count: 1 }); expect(data[0].text).to.equal('my second answer to thread 4'); }); }); it('Should filter instance comments by isLocal', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield command.listForAdmin({ isLocal: false }); expect(data).to.have.lengthOf(0); expect(total).to.equal(0); }); }); it('Should search instance comments by account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield command.listForAdmin({ searchAccount: 'user' }); expect(data).to.have.lengthOf(1); expect(total).to.equal(1); @@ -219,7 +219,7 @@ describe('Test video comments', function () { }); }); it('Should search instance comments by video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { total, data } = yield command.listForAdmin({ searchVideo: 'video' }); expect(data).to.have.lengthOf(7); @@ -233,7 +233,7 @@ describe('Test video comments', function () { }); }); it('Should search instance comments', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield command.listForAdmin({ search: 'super thread 3' }); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -242,8 +242,8 @@ describe('Test video comments', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/video-description.js b/dist/server/tests/api/videos/video-description.js index f33bfde4..985520e4 100644 --- a/dist/server/tests/api/videos/video-description.js +++ b/dist/server/tests/api/videos/video-description.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test video description', function () { @@ -11,28 +11,28 @@ describe('Test video description', function () { let videoId; const longDescription = 'my super description for server 1'.repeat(50); before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should upload video with long description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { description: longDescription }; yield servers[0].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].videos.list(); videoId = data[0].id; videoUUID = data[0].uuid; }); }); it('Should have a truncated description on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); const truncatedDescription = 'my super description for server 1'.repeat(7) + @@ -42,7 +42,7 @@ describe('Test video description', function () { }); }); it('Should fetch long description on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); const { description } = yield server.videos.getDescription({ descriptionPath: video.descriptionPath }); @@ -51,17 +51,17 @@ describe('Test video description', function () { }); }); it('Should update with a short description', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { description: 'short description' }; yield servers[0].videos.update({ id: videoId, attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have a small description on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.description).to.equal('short description'); @@ -71,8 +71,8 @@ describe('Test video description', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-hls.js b/dist/server/tests/api/videos/video-hls.js index ae0161b4..ef133209 100644 --- a/dist/server/tests/api/videos/video-hls.js +++ b/dist/server/tests/api/videos/video-hls.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const path_1 = require("path"); const core_utils_1 = require("@shared/core-utils"); const extra_utils_1 = require("@shared/extra-utils"); @@ -11,7 +11,7 @@ const constants_1 = require("../../../initializers/constants"); const expect = chai.expect; function checkHlsPlaylist(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoUUID, hlsOnly, objectStorageBaseUrl } = options; const resolutions = (_a = options.resolutions) !== null && _a !== void 0 ? _a : [240, 360, 480, 720]; for (const server of options.servers) { @@ -32,41 +32,41 @@ function checkHlsPlaylist(options) { expect(file.magnetUri).to.have.lengthOf.above(2); expect(file.torrentUrl).to.match(new RegExp(`http://${server.host}/lazy-static/torrents/${core_utils_1.uuidRegex}-${file.resolution.id}-hls.torrent`)); if (objectStorageBaseUrl) { - extra_utils_1.expectStartWith(file.fileUrl, objectStorageBaseUrl); + (0, extra_utils_1.expectStartWith)(file.fileUrl, objectStorageBaseUrl); } else { expect(file.fileUrl).to.match(new RegExp(`${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${core_utils_1.uuidRegex}-${file.resolution.id}-fragmented.mp4`)); } expect(file.resolution.label).to.equal(resolution + 'p'); - yield extra_utils_1.makeRawRequest(file.torrentUrl, models_1.HttpStatusCode.OK_200); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); - const torrent = yield extra_utils_1.webtorrentAdd(file.magnetUri, true); + yield (0, extra_utils_1.makeRawRequest)(file.torrentUrl, models_1.HttpStatusCode.OK_200); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(file.magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).to.exist.and.to.not.equal(''); } { - yield extra_utils_1.checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }); + yield (0, extra_utils_1.checkResolutionsInMasterPlaylist)({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }); const masterPlaylist = yield server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl }); let i = 0; for (const resolution of resolutions) { expect(masterPlaylist).to.contain(`${resolution}.m3u8`); expect(masterPlaylist).to.contain(`${resolution}.m3u8`); const url = 'http://' + videoDetails.account.host; - yield extra_utils_1.hlsInfohashExist(url, hlsPlaylist.playlistUrl, i); + yield (0, extra_utils_1.hlsInfohashExist)(url, hlsPlaylist.playlistUrl, i); i++; } } { for (const resolution of resolutions) { const file = hlsFiles.find(f => f.resolution.id === resolution); - const playlistName = core_utils_1.removeFragmentedMP4Ext(path_1.basename(file.fileUrl)) + '.m3u8'; + const playlistName = (0, core_utils_1.removeFragmentedMP4Ext)((0, path_1.basename)(file.fileUrl)) + '.m3u8'; const url = objectStorageBaseUrl ? `${objectStorageBaseUrl}hls/${videoUUID}/${playlistName}` : `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${playlistName}`; const subPlaylist = yield server.streamingPlaylists.get({ url }); expect(subPlaylist).to.match(new RegExp(`${core_utils_1.uuidRegex}-${resolution}-fragmented.mp4`)); - expect(subPlaylist).to.contain(path_1.basename(file.fileUrl)); + expect(subPlaylist).to.contain((0, path_1.basename)(file.fileUrl)); } } { @@ -74,7 +74,7 @@ function checkHlsPlaylist(options) { ? objectStorageBaseUrl + 'hls/' + videoUUID : baseUrl + '/static/streaming-playlists/hls/' + videoUUID; for (const resolution of resolutions) { - yield extra_utils_1.checkSegmentHash({ + yield (0, extra_utils_1.checkSegmentHash)({ server, baseUrlPlaylist: baseUrlAndPath, baseUrlSegment: baseUrlAndPath, @@ -92,20 +92,20 @@ describe('Test HLS videos', function () { let videoAudioUUID = ''; function runTestSuite(hlsOnly, objectStorageBaseUrl) { it('Should upload a video and transcode it to HLS', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }); videoUUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkHlsPlaylist({ servers, videoUUID, hlsOnly, objectStorageBaseUrl }); }); }); it('Should upload an audio file and transcode it to HLS', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }); videoAudioUUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkHlsPlaylist({ servers, videoUUID: videoAudioUUID, @@ -116,19 +116,19 @@ describe('Test HLS videos', function () { }); }); it('Should update the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].videos.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkHlsPlaylist({ servers, videoUUID, hlsOnly, objectStorageBaseUrl }); }); }); it('Should delete videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].videos.remove({ id: videoUUID }); yield servers[0].videos.remove({ id: videoAudioUUID }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { yield server.videos.get({ id: videoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); yield server.videos.get({ id: videoAudioUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); @@ -136,23 +136,23 @@ describe('Test HLS videos', function () { }); }); it('Should have the playlists/segment deleted from the disk', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkDirectoryIsEmpty(server, 'videos'); - yield extra_utils_1.checkDirectoryIsEmpty(server, path_1.join('streaming-playlists', 'hls')); + yield (0, extra_utils_1.checkDirectoryIsEmpty)(server, 'videos'); + yield (0, extra_utils_1.checkDirectoryIsEmpty)(server, (0, path_1.join)('streaming-playlists', 'hls')); } }); }); it('Should have an empty tmp directory', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { - yield extra_utils_1.checkTmpIsEmpty(server); + yield (0, extra_utils_1.checkTmpIsEmpty)(server); } }); }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const configOverride = { transcoding: { @@ -163,9 +163,9 @@ describe('Test HLS videos', function () { } } }; - servers = yield extra_utils_1.createMultipleServers(2, configOverride); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, configOverride); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('With WebTorrent & HLS enabled', function () { @@ -173,7 +173,7 @@ describe('Test HLS videos', function () { }); describe('With only HLS enabled', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.updateCustomSubConfig({ newConfig: { transcoding: { @@ -202,10 +202,10 @@ describe('Test HLS videos', function () { runTestSuite(true); }); describe('With object storage enabled', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const configOverride = extra_utils_1.ObjectStorageCommand.getDefaultConfig(); yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); @@ -216,8 +216,8 @@ describe('Test HLS videos', function () { runTestSuite(true, extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl()); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-imports.js b/dist/server/tests/api/videos/video-imports.js index 228c5d3f..d4bf8ea6 100644 --- a/dist/server/tests/api/videos/video-imports.js +++ b/dist/server/tests/api/videos/video-imports.js @@ -2,17 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test video imports', function () { let servers = []; let channelIdServer1; let channelIdServer2; - if (extra_utils_1.areHttpImportTestsDisabled()) + if ((0, extra_utils_1.areHttpImportTestsDisabled)()) return; function checkVideosServer1(server, idHttp, idMagnet, idTorrent) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoHttp = yield server.videos.get({ id: idHttp }); expect(videoHttp.name).to.equal('small video - youtube'); expect(videoHttp.language.label).to.equal('Unknown'); @@ -42,7 +42,7 @@ describe('Test video imports', function () { }); } function checkVideoServer2(server, id) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield server.videos.get({ id }); expect(video.name).to.equal('my super name'); expect(video.category.label).to.equal('Entertainment'); @@ -57,10 +57,10 @@ describe('Test video imports', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); { const { videoChannels } = yield servers[0].users.getMyInfo(); channelIdServer1 = videoChannels[0].id; @@ -69,11 +69,11 @@ describe('Test video imports', function () { const { videoChannels } = yield servers[1].users.getMyInfo(); channelIdServer2 = videoChannels[0].id; } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should import videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const baseAttributes = { channelId: channelIdServer1, @@ -85,8 +85,8 @@ describe('Test video imports', function () { expect(video.name).to.equal('small video - youtube'); expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`)); expect(video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`)); - yield extra_utils_1.testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath); - yield extra_utils_1.testImage(servers[0].url, 'video_import_preview', video.previewPath); + yield (0, extra_utils_1.testImage)(servers[0].url, 'video_import_thumbnail', video.thumbnailPath); + yield (0, extra_utils_1.testImage)(servers[0].url, 'video_import_preview', video.previewPath); const bodyCaptions = yield servers[0].captions.list({ videoId: video.id }); const videoCaptions = bodyCaptions.data; expect(videoCaptions).to.have.lengthOf(2); @@ -94,7 +94,7 @@ describe('Test video imports', function () { expect(enCaption).to.exist; expect(enCaption.language.label).to.equal('English'); expect(enCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-en.vtt$`)); - yield extra_utils_1.testCaptionFile(servers[0].url, enCaption.captionPath, `WEBVTT + yield (0, extra_utils_1.testCaptionFile)(servers[0].url, enCaption.captionPath, `WEBVTT Kind: captions Language: en @@ -110,7 +110,7 @@ Adding subtitles is very easy to do`); expect(frCaption).to.exist; expect(frCaption.language.label).to.equal('French'); expect(frCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-fr.vtt`)); - yield extra_utils_1.testCaptionFile(servers[0].url, frCaption.captionPath, `WEBVTT + yield (0, extra_utils_1.testCaptionFile)(servers[0].url, frCaption.captionPath, `WEBVTT Kind: captions Language: fr @@ -136,7 +136,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should list the videos to import in my videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listMyVideos({ sort: 'createdAt' }); expect(total).to.equal(3); expect(data).to.have.lengthOf(3); @@ -146,7 +146,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should list the videos to import in my imports on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data: videoImports } = yield servers[0].imports.getMyVideoImports({ sort: '-createdAt' }); expect(total).to.equal(3); expect(videoImports).to.have.lengthOf(3); @@ -165,9 +165,9 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should have the video listed on the two instances', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(3); @@ -178,7 +178,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should import a video on server 2 with some fields', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { targetUrl: extra_utils_1.FIXTURE_URLS.youtube, @@ -196,9 +196,9 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should have the videos listed on the two instances', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(4); @@ -210,7 +210,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should import a video that will be transcoded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const attributes = { name: 'transcoded video', @@ -220,7 +220,7 @@ Ajouter un sous-titre est vraiment facile`); }; const { video } = yield servers[1].imports.importVideo({ attributes }); const videoUUID = video.uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.name).to.equal('transcoded video'); @@ -229,7 +229,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should import no HDR version on a HDR video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = { transcoding: { @@ -266,7 +266,7 @@ Ajouter un sous-titre est vraiment facile`); }; const { video: videoImported } = yield servers[0].imports.importVideo({ attributes }); const videoUUID = videoImported.uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[0].videos.get({ id: videoUUID }); expect(video.name).to.equal('hdr video'); const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id; })); @@ -274,7 +274,7 @@ Ajouter un sous-titre est vraiment facile`); }); }); it('Should import a peertube video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); for (const targetUrl of [extra_utils_1.FIXTURE_URLS.peertube_long]) { yield servers[0].config.disableTranscoding(); @@ -285,7 +285,7 @@ Ajouter un sous-titre est vraiment facile`); }; const { video } = yield servers[0].imports.importVideo({ attributes }); const videoUUID = video.uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const video = yield server.videos.get({ id: videoUUID }); expect(video.name).to.equal('E2E tests'); @@ -294,8 +294,8 @@ Ajouter un sous-titre est vraiment facile`); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-nsfw.js b/dist/server/tests/api/videos/video-nsfw.js index d917da22..3dd7c414 100644 --- a/dist/server/tests/api/videos/video-nsfw.js +++ b/dist/server/tests/api/videos/video-nsfw.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function createOverviewRes(overview) { @@ -14,7 +14,7 @@ describe('Test video NSFW policy', function () { let userAccessToken; let customConfig; function getVideosFunctions(token, query = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield server.users.getMyInfo(); const channelName = user.videoChannels[0].name; const accountName = user.account.name + '@' + user.account.host; @@ -49,10 +49,10 @@ describe('Test video NSFW policy', function () { }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); { const attributes = { name: 'nsfw', nsfw: true, category: 1 }; yield server.videos.upload({ attributes }); @@ -66,7 +66,7 @@ describe('Test video NSFW policy', function () { }); describe('Instance default NSFW policy', function () { it('Should display NSFW videos with display default NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverConfig = yield server.config.getConfig(); expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display'); for (const body of yield getVideosFunctions()) { @@ -79,7 +79,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should not display NSFW videos with do_not_list default NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { customConfig.instance.defaultNSFWPolicy = 'do_not_list'; yield server.config.updateCustomConfig({ newCustomConfig: customConfig }); const serverConfig = yield server.config.getConfig(); @@ -93,7 +93,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should display NSFW videos with blur default NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { customConfig.instance.defaultNSFWPolicy = 'blur'; yield server.config.updateCustomConfig({ newCustomConfig: customConfig }); const serverConfig = yield server.config.getConfig(); @@ -110,7 +110,7 @@ describe('Test video NSFW policy', function () { }); describe('User NSFW policy', function () { it('Should create a user having the default nsfw policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const username = 'user1'; const password = 'my super password'; yield server.users.create({ username: username, password: password }); @@ -120,7 +120,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should display NSFW videos with blur user NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { customConfig.instance.defaultNSFWPolicy = 'do_not_list'; yield server.config.updateCustomConfig({ newCustomConfig: customConfig }); for (const body of yield getVideosFunctions(userAccessToken)) { @@ -133,7 +133,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should display NSFW videos with display user NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ nsfwPolicy: 'display' }); for (const body of yield getVideosFunctions(server.accessToken)) { expect(body.total).to.equal(2); @@ -145,7 +145,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should not display NSFW videos with do_not_list user NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ nsfwPolicy: 'do_not_list' }); for (const body of yield getVideosFunctions(server.accessToken)) { expect(body.total).to.equal(1); @@ -156,7 +156,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.listMyVideos(); expect(total).to.equal(2); expect(data).to.have.lengthOf(2); @@ -165,7 +165,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should display NSFW videos when the nsfw param === true', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const body of yield getVideosFunctions(server.accessToken, { nsfw: 'true' })) { expect(body.total).to.equal(1); const videos = body.data; @@ -175,7 +175,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should hide NSFW videos when the nsfw param === true', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const body of yield getVideosFunctions(server.accessToken, { nsfw: 'false' })) { expect(body.total).to.equal(1); const videos = body.data; @@ -185,7 +185,7 @@ describe('Test video NSFW policy', function () { }); }); it('Should display both videos when the nsfw param === both', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const body of yield getVideosFunctions(server.accessToken, { nsfw: 'both' })) { expect(body.total).to.equal(2); const videos = body.data; @@ -197,8 +197,8 @@ describe('Test video NSFW policy', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/video-playlist-thumbnails.js b/dist/server/tests/api/videos/video-playlist-thumbnails.js index 17a922d8..b055f3e9 100644 --- a/dist/server/tests/api/videos/video-playlist-thumbnails.js +++ b/dist/server/tests/api/videos/video-playlist-thumbnails.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Playlist thumbnail', function () { @@ -16,31 +16,31 @@ describe('Playlist thumbnail', function () { let video1; let video2; function getPlaylistWithoutThumbnail(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.playlists.list({ start: 0, count: 10 }); return body.data.find(p => p.displayName === 'playlist without thumbnail'); }); } function getPlaylistWithThumbnail(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.playlists.list({ start: 0, count: 10 }); return body.data.find(p => p.displayName === 'playlist with thumbnail'); }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2, { transcoding: { enabled: false } }); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, { transcoding: { enabled: false } }); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); video1 = (yield servers[0].videos.quickUpload({ name: 'video 1' })).id; video2 = (yield servers[0].videos.quickUpload({ name: 'video 2' })).id; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should automatically update the thumbnail when adding an element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const created = yield servers[1].playlists.create({ attributes: { @@ -55,15 +55,15 @@ describe('Playlist thumbnail', function () { attributes: { videoId: video1 } }); withoutThumbnailE1 = added.id; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithoutThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail-playlist', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail-playlist', p.thumbnailPath); } }); }); it('Should not update the thumbnail if we explicitly uploaded a thumbnail', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const created = yield servers[1].playlists.create({ attributes: { @@ -79,15 +79,15 @@ describe('Playlist thumbnail', function () { attributes: { videoId: video1 } }); withThumbnailE1 = added.id; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail', p.thumbnailPath); } }); }); it('Should automatically update the thumbnail when moving the first element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const added = yield servers[1].playlists.addElement({ playlistId: playlistWithoutThumbnailId, @@ -101,15 +101,15 @@ describe('Playlist thumbnail', function () { insertAfterPosition: 2 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithoutThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail-playlist', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail-playlist', p.thumbnailPath); } }); }); it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const added = yield servers[1].playlists.addElement({ playlistId: playlistWithThumbnailId, @@ -123,49 +123,49 @@ describe('Playlist thumbnail', function () { insertAfterPosition: 2 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail', p.thumbnailPath); } }); }); it('Should automatically update the thumbnail when deleting the first element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[1].playlists.removeElement({ playlistId: playlistWithoutThumbnailId, elementId: withoutThumbnailE1 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithoutThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail-playlist', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail-playlist', p.thumbnailPath); } }); }); it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[1].playlists.removeElement({ playlistId: playlistWithThumbnailId, elementId: withThumbnailE1 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail', p.thumbnailPath); } }); }); it('Should the thumbnail when we delete the last element', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[1].playlists.removeElement({ playlistId: playlistWithoutThumbnailId, elementId: withoutThumbnailE2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithoutThumbnail(server); expect(p.thumbnailPath).to.be.null; @@ -173,22 +173,22 @@ describe('Playlist thumbnail', function () { }); }); it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[1].playlists.removeElement({ playlistId: playlistWithThumbnailId, elementId: withThumbnailE2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const p = yield getPlaylistWithThumbnail(server); - yield extra_utils_1.testImage(server.url, 'thumbnail', p.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail', p.thumbnailPath); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-playlists.js b/dist/server/tests/api/videos/video-playlists.js index 0c9d35fb..1eccd14f 100644 --- a/dist/server/tests/api/videos/video-playlists.js +++ b/dist/server/tests/api/videos/video-playlists.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; function checkPlaylistElementType(servers, playlistId, type, position, name, total) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const body = yield server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }); expect(body.total).to.equal(total); @@ -38,13 +38,13 @@ describe('Test video playlists', function () { let userTokenServer1; let commands; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(3, { transcoding: { enabled: false } }); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.doubleFollow(servers[0], servers[2]); + servers = yield (0, extra_utils_1.createMultipleServers)(3, { transcoding: { enabled: false } }); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[2]); commands = servers.map(s => s.playlists); { servers[0].store.videos = []; @@ -60,19 +60,19 @@ describe('Test video playlists', function () { } nsfwVideoServer1 = (yield servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id; userTokenServer1 = yield servers[0].users.generateUserAndToken('user1'); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); describe('Get default playlists', function () { it('Should list video playlist privacies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const privacies = yield commands[0].getPrivacies(); expect(Object.keys(privacies)).to.have.length.at.least(3); expect(privacies[3]).to.equal('Private'); }); }); it('Should list watch later playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const token = servers[0].accessToken; { const body = yield commands[0].listByAccount({ token, handle: 'root', playlistType: 2 }); @@ -96,7 +96,7 @@ describe('Test video playlists', function () { }); }); it('Should get private playlist for a classic user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const token = yield servers[0].users.generateUserAndToken('toto'); const body = yield commands[0].listByAccount({ token, handle: 'toto' }); expect(body.total).to.equal(1); @@ -108,7 +108,7 @@ describe('Test video playlists', function () { }); describe('Create and federate playlists', function () { it('Should create a playlist on server 1 and have the playlist on server 2 and 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield commands[0].create({ attributes: { @@ -119,8 +119,8 @@ describe('Test video playlists', function () { videoChannelId: servers[0].store.channel.id } }); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(3000); for (const server of servers) { const body = yield server.playlists.list({ start: 0, count: 5 }); expect(body.total).to.equal(1); @@ -148,7 +148,7 @@ describe('Test video playlists', function () { }); }); it('Should create a playlist on server 2 and have the playlist on server 1 but not on server 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { const playlist = yield servers[1].playlists.create({ @@ -182,16 +182,16 @@ describe('Test video playlists', function () { attributes: { videoId: servers[1].store.videos[1].id } }); } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(3000); for (const server of [servers[0], servers[1]]) { const body = yield server.playlists.list({ start: 0, count: 5 }); const playlist2 = body.data.find(p => p.displayName === 'playlist 2'); expect(playlist2).to.not.be.undefined; - yield extra_utils_1.testImage(server.url, 'thumbnail-playlist', playlist2.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail-playlist', playlist2.thumbnailPath); const playlist3 = body.data.find(p => p.displayName === 'playlist 3'); expect(playlist3).to.not.be.undefined; - yield extra_utils_1.testImage(server.url, 'thumbnail', playlist3.thumbnailPath); + yield (0, extra_utils_1.testImage)(server.url, 'thumbnail', playlist3.thumbnailPath); } const body = yield servers[2].playlists.list({ start: 0, count: 5 }); expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined; @@ -199,20 +199,20 @@ describe('Test video playlists', function () { }); }); it('Should have the playlist on server 3 after a new follow', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.doubleFollow(servers[1], servers[2]); + yield (0, extra_utils_1.doubleFollow)(servers[1], servers[2]); const body = yield servers[2].playlists.list({ start: 0, count: 5 }); const playlist2 = body.data.find(p => p.displayName === 'playlist 2'); expect(playlist2).to.not.be.undefined; - yield extra_utils_1.testImage(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath); + yield (0, extra_utils_1.testImage)(servers[2].url, 'thumbnail-playlist', playlist2.thumbnailPath); expect(body.data.find(p => p.displayName === 'playlist 3')).to.not.be.undefined; }); }); }); describe('List playlists', function () { it('Should correctly list the playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { const body = yield servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' }); @@ -233,7 +233,7 @@ describe('Test video playlists', function () { }); }); it('Should list video channel playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { const body = yield commands[0].listByChannel({ handle: 'root_channel', start: 0, count: 2, sort: '-createdAt' }); @@ -245,7 +245,7 @@ describe('Test video playlists', function () { }); }); it('Should list account playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { const body = yield servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }); @@ -281,7 +281,7 @@ describe('Test video playlists', function () { let unlistedPlaylist; let privatePlaylist; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { unlistedPlaylist = yield servers[1].playlists.create({ @@ -300,12 +300,12 @@ describe('Test video playlists', function () { } }); } - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.wait)(3000); }); }); it('Should not list unlisted or private playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const results = [ yield server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), @@ -323,25 +323,25 @@ describe('Test video playlists', function () { }); }); it('Should not get unlisted playlist using only the id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }); }); }); it('Should get unlisted plyaylist using uuid or shortUUID', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid }); yield servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID }); }); }); it('Should not get private playlist without token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const id of [privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID]) { yield servers[1].playlists.get({ playlistId: id, expectedStatus: 401 }); } }); }); it('Should get private playlist with a token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const id of [privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID]) { yield servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id }); } @@ -350,7 +350,7 @@ describe('Test video playlists', function () { }); describe('Update playlists', function () { it('Should update a playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[1].playlists.update({ attributes: { @@ -362,7 +362,7 @@ describe('Test video playlists', function () { }, playlistId: playlistServer2Id2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const playlist = yield server.playlists.get({ playlistId: playlistServer2UUID2 }); expect(playlist.displayName).to.equal('playlist 3 updated'); @@ -382,7 +382,7 @@ describe('Test video playlists', function () { }); describe('Element timestamps', function () { it('Should create a playlist containing different startTimestamp/endTimestamp videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const addVideo = (attributes) => { return commands[0].addElement({ playlistId: playlistServer1Id, attributes }); @@ -413,11 +413,11 @@ describe('Test video playlists', function () { yield addVideo({ videoId: nsfwVideoServer1, startTimestamp: 4 }); yield addVideo({ videoId: nsfwVideoServer1 }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should correctly list playlist videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); for (const server of servers) { { @@ -475,7 +475,7 @@ describe('Test video playlists', function () { let video2; let video3; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); groupUser1 = [Object.assign({}, servers[0], { accessToken: userTokenServer1 })]; groupWithoutToken1 = [Object.assign({}, servers[0], { accessToken: undefined })]; @@ -497,21 +497,21 @@ describe('Test video playlists', function () { video1 = (yield servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid; video2 = (yield servers[1].videos.quickUpload({ name: 'video 90' })).uuid; video3 = (yield servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield addVideo({ videoId: video1, startTimestamp: 15, stopTimestamp: 28 }); yield addVideo({ videoId: video2, startTimestamp: 35 }); yield addVideo({ videoId: video3 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should update the element type if the video is private', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const name = 'video 89'; const position = 1; { yield servers[0].videos.update({ id: video1, attributes: { privacy: 3 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, 2, position, name, 3); yield checkPlaylistElementType(group1, playlistServer1UUID2, 2, position, name, 3); @@ -519,7 +519,7 @@ describe('Test video playlists', function () { } { yield servers[0].videos.update({ id: video1, attributes: { privacy: 1 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(group1, playlistServer1UUID2, 0, position, name, 3); @@ -528,13 +528,13 @@ describe('Test video playlists', function () { }); }); it('Should update the element type if the video is blacklisted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const name = 'video 89'; const position = 1; { yield servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, 3, position, name, 3); yield checkPlaylistElementType(group1, playlistServer1UUID2, 3, position, name, 3); @@ -542,7 +542,7 @@ describe('Test video playlists', function () { } { yield servers[0].blacklist.remove({ videoId: video1 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(groupWithoutToken1, playlistServer1UUID2, 0, position, name, 3); yield checkPlaylistElementType(group1, playlistServer1UUID2, 0, position, name, 3); @@ -551,51 +551,51 @@ describe('Test video playlists', function () { }); }); it('Should update the element type if the account or server of the video is blocked', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(90000); const command = servers[0].blocklist; const name = 'video 90'; const position = 2; { yield command.addToMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 3, position, name, 3); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); yield command.removeFromMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); } { yield command.addToMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 3, position, name, 3); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); yield command.removeFromMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); } { yield command.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 3, position, name, 3); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); yield command.removeFromServerBlocklist({ account: 'root@localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); } { yield command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(groupUser1, playlistServer1UUID2, 3, position, name, 3); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); yield command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkPlaylistElementType(group2, playlistServer1UUID2, 0, position, name, 3); } }); }); it('Should hide the video if it is NSFW', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield commands[0].listVideos({ token: userTokenServer1, playlistId: playlistServer1UUID2, query: { nsfw: 'false' } }); expect(body.total).to.equal(3); const elements = body.data; @@ -608,7 +608,7 @@ describe('Test video playlists', function () { }); describe('Managing playlist elements', function () { it('Should reorder the playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { yield commands[0].reorderElements({ @@ -618,7 +618,7 @@ describe('Test video playlists', function () { insertAfterPosition: 3 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const body = yield server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }); const names = body.data.map(v => v.video.name); @@ -643,7 +643,7 @@ describe('Test video playlists', function () { insertAfterPosition: 4 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const body = yield server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }); const names = body.data.map(v => v.video.name); @@ -667,7 +667,7 @@ describe('Test video playlists', function () { insertAfterPosition: 3 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data: elements } = yield server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }); const names = elements.map(v => v.video.name); @@ -689,7 +689,7 @@ describe('Test video playlists', function () { }); }); it('Should update startTimestamp/endTimestamp of some elements', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield commands[0].updateElement({ playlistId: playlistServer1Id, @@ -705,7 +705,7 @@ describe('Test video playlists', function () { stopTimestamp: null } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data: elements } = yield server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }); expect(elements[0].video.name).to.equal('video 3 server 1'); @@ -720,7 +720,7 @@ describe('Test video playlists', function () { }); }); it('Should check videos existence in my playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videoIds = [ servers[0].store.videos[0].id, 42000, @@ -757,11 +757,11 @@ describe('Test video playlists', function () { }); }); it('Should automatically update updatedAt field of playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = servers[1]; const videoId = servers[1].store.videos[5].id; function getPlaylistNames() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }); return data.map(p => p.displayName); }); @@ -783,11 +783,11 @@ describe('Test video playlists', function () { }); }); it('Should delete some elements', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield commands[0].removeElement({ playlistId: playlistServer1Id, elementId: playlistElementServer1Video4 }); yield commands[0].removeElement({ playlistId: playlistServer1Id, elementId: playlistElementNSFW }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const body = yield server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }); expect(body.total).to.equal(6); @@ -809,7 +809,7 @@ describe('Test video playlists', function () { }); }); it('Should be able to create a public playlist, and set it to private', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const videoPlaylistIds = yield commands[0].create({ attributes: { @@ -818,13 +818,13 @@ describe('Test video playlists', function () { videoChannelId: servers[0].store.channel.id } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { yield server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: models_1.HttpStatusCode.OK_200 }); } const attributes = { privacy: 3 }; yield commands[0].update({ playlistId: videoPlaylistIds.id, attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of [servers[1], servers[2]]) { yield server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); } @@ -835,25 +835,25 @@ describe('Test video playlists', function () { }); describe('Playlist deletion', function () { it('Should delete the playlist on server 1 and delete on server 2 and 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield commands[0].delete({ playlistId: playlistServer1Id }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { yield server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); } }); }); it('Should have deleted the thumbnail on server 1, 2 and 3', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); for (const server of servers) { - yield extra_utils_1.checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber); + yield (0, extra_utils_1.checkPlaylistFilesWereRemoved)(playlistServer1UUID, server.internalServerNumber); } }); }); it('Should unfollow servers 1 and 2 and hide their playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const finder = (data) => data.find(p => p.displayName === 'my super playlist'); { @@ -870,7 +870,7 @@ describe('Test video playlists', function () { }); }); it('Should delete a channel and put the associated playlist in private mode', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const channel = yield servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }); const playlistCreated = yield commands[0].create({ @@ -880,9 +880,9 @@ describe('Test video playlists', function () { videoChannelId: channel.id } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].channels.delete({ channelName: 'super_channel' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const body = yield commands[0].get({ token: servers[0].accessToken, playlistId: playlistCreated.uuid }); expect(body.displayName).to.equal('channel playlist'); expect(body.privacy.id).to.equal(3); @@ -890,7 +890,7 @@ describe('Test video playlists', function () { }); }); it('Should delete an account and delete its playlists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const { userId, token } = yield servers[0].users.generate('user_1'); const { videoChannels } = yield servers[0].users.getMyInfo({ token }); @@ -902,7 +902,7 @@ describe('Test video playlists', function () { videoChannelId: userChannel.id } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const finder = (data) => data.find(p => p.displayName === 'playlist to be deleted'); { for (const server of [servers[0], servers[1]]) { @@ -911,7 +911,7 @@ describe('Test video playlists', function () { } } yield servers[0].users.remove({ userId }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { for (const server of [servers[0], servers[1]]) { const body = yield server.playlists.list({ start: 0, count: 15 }); @@ -922,8 +922,8 @@ describe('Test video playlists', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-privacy.js b/dist/server/tests/api/videos/video-privacy.js index 140d7942..82c86506 100644 --- a/dist/server/tests/api/videos/video-privacy.js +++ b/dist/server/tests/api/videos/video-privacy.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -24,41 +24,41 @@ describe('Test video privacy', function () { } }; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - servers.push(yield extra_utils_1.createSingleServer(1, dontFederateUnlistedConfig)); - servers.push(yield extra_utils_1.createSingleServer(2)); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers.push(yield (0, extra_utils_1.createSingleServer)(1, dontFederateUnlistedConfig)); + servers.push(yield (0, extra_utils_1.createSingleServer)(2)); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('Private and internal videos', function () { it('Should upload a private and internal videos on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); for (const privacy of [3, 4]) { const attributes = { privacy }; yield servers[0].videos.upload({ attributes }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have these private and internal videos on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[1].videos.list(); expect(total).to.equal(0); expect(data).to.have.lengthOf(0); }); }); it('Should not list the private and internal videos for an unauthenticated user on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.list(); expect(total).to.equal(0); expect(data).to.have.lengthOf(0); }); }); it('Should not list the private video and list the internal video for an authenticated user on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listWithToken(); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -66,7 +66,7 @@ describe('Test video privacy', function () { }); }); it('Should list my (private and internal) videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listMyVideos(); expect(total).to.equal(2); expect(data).to.have.lengthOf(2); @@ -79,13 +79,13 @@ describe('Test video privacy', function () { }); }); it('Should not be able to watch the private/internal video with non authenticated user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.get({ id: privateVideoUUID, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); yield servers[0].videos.get({ id: internalVideoUUID, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should not be able to watch the private video with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const user = { username: 'hello', @@ -101,30 +101,30 @@ describe('Test video privacy', function () { }); }); it('Should be able to watch the internal video with another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ token: anotherUserToken, id: internalVideoUUID }); }); }); it('Should be able to watch the private video with the correct user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.getWithToken({ id: privateVideoUUID }); }); }); }); describe('Unlisted videos', function () { it('Should upload an unlisted video on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'unlisted video', privacy: 2 }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not have this unlisted video listed on server 1 and 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(0); @@ -133,7 +133,7 @@ describe('Test video privacy', function () { }); }); it('Should list my (unlisted) videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[1].videos.listMyVideos(); expect(total).to.equal(1); expect(data).to.have.lengthOf(1); @@ -141,12 +141,12 @@ describe('Test video privacy', function () { }); }); it('Should not be able to get this unlisted video using its id', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[1].videos.get({ id: unlistedVideo.id, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); it('Should be able to get this unlisted video using its uuid/shortUUID', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { for (const id of [unlistedVideo.uuid, unlistedVideo.shortUUID]) { const video = yield server.videos.get({ id }); @@ -156,18 +156,18 @@ describe('Test video privacy', function () { }); }); it('Should upload a non-federating unlisted video to server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const attributes = { name: 'unlisted video', privacy: 2 }; yield servers[0].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list my new unlisted video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listMyVideos(); expect(total).to.equal(3); expect(data).to.have.lengthOf(3); @@ -175,20 +175,20 @@ describe('Test video privacy', function () { }); }); it('Should be able to get non-federated unlisted video from origin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield servers[0].videos.get({ id: nonFederatedUnlistedVideoUUID }); expect(video.name).to.equal('unlisted video'); }); }); it('Should not be able to get non-federated unlisted video from federated server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[1].videos.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); }); }); }); describe('Privacy update', function () { it('Should update the private and internal videos to public on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); now = Date.now(); { @@ -205,11 +205,11 @@ describe('Test video privacy', function () { }; yield servers[0].videos.update({ id: internalVideoId, attributes }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have this new public video listed on server 1 and 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(2); @@ -226,11 +226,11 @@ describe('Test video privacy', function () { }); }); it('Should set these videos as private and internal', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield servers[0].videos.update({ id: internalVideoId, attributes: { privacy: 3 } }); yield servers[0].videos.update({ id: privateVideoId, attributes: { privacy: 4 } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(0); @@ -251,8 +251,8 @@ describe('Test video privacy', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-schedule-update.js b/dist/server/tests/api/videos/video-schedule-update.js index 55c005a5..c868b6a6 100644 --- a/dist/server/tests/api/videos/video-schedule-update.js +++ b/dist/server/tests/api/videos/video-schedule-update.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; function in10Seconds() { @@ -14,15 +14,15 @@ describe('Test video update scheduler', function () { let servers = []; let video2UUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should upload a video and schedule an update in 10 seconds', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'video 1', @@ -33,11 +33,11 @@ describe('Test video update scheduler', function () { } }; yield servers[0].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not list the video (in privacy mode)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total } = yield server.videos.list(); expect(total).to.equal(0); @@ -45,7 +45,7 @@ describe('Test video update scheduler', function () { }); }); it('Should have my scheduled video in my account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listMyVideos(); expect(total).to.equal(1); const videoFromList = data[0]; @@ -59,10 +59,10 @@ describe('Test video update scheduler', function () { }); }); it('Should wait some seconds and have the video in public privacy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.wait(15000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(15000); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(1); @@ -71,7 +71,7 @@ describe('Test video update scheduler', function () { }); }); it('Should upload a video without scheduling an update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'video 2', @@ -79,11 +79,11 @@ describe('Test video update scheduler', function () { }; const { uuid } = yield servers[0].videos.upload({ attributes }); video2UUID = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should update a video by scheduling an update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); const attributes = { name: 'video 2 updated', @@ -93,11 +93,11 @@ describe('Test video update scheduler', function () { } }; yield servers[0].videos.update({ id: video2UUID, attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not display the updated video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const { total } = yield server.videos.list(); expect(total).to.equal(1); @@ -105,7 +105,7 @@ describe('Test video update scheduler', function () { }); }); it('Should have my scheduled updated video in my account videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield servers[0].videos.listMyVideos(); expect(total).to.equal(2); const video = data.find(v => v.uuid === video2UUID); @@ -117,10 +117,10 @@ describe('Test video update scheduler', function () { }); }); it('Should wait some seconds and have the updated video in public privacy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); - yield extra_utils_1.wait(15000); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.wait)(15000); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { total, data } = yield server.videos.list(); expect(total).to.equal(2); @@ -131,8 +131,8 @@ describe('Test video update scheduler', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/video-transcoder.js b/dist/server/tests/api/videos/video-transcoder.js index befc448c..1b68d966 100644 --- a/dist/server/tests/api/videos/video-transcoder.js +++ b/dist/server/tests/api/videos/video-transcoder.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const core_utils_1 = require("@shared/core-utils"); const extra_utils_1 = require("@shared/extra-utils"); @@ -36,17 +36,17 @@ describe('Test video transcoding', function () { let servers = []; let video4k; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield updateConfigForTranscoding(servers[1]); }); }); describe('Basic transcoding (or not)', function () { it('Should not transcode video on server 1', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'my super name for server 1', @@ -54,7 +54,7 @@ describe('Test video transcoding', function () { fixture: 'video_short.webm' }; yield servers[0].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data[0]; @@ -62,7 +62,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(1); const magnetUri = videoDetails.files[0].magnetUri; expect(magnetUri).to.match(/\.webm/); - const torrent = yield extra_utils_1.webtorrentAdd(magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).match(/\.webm$/); @@ -70,7 +70,7 @@ describe('Test video transcoding', function () { }); }); it('Should transcode video on server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const attributes = { name: 'my super name for server 2', @@ -78,7 +78,7 @@ describe('Test video transcoding', function () { fixture: 'video_short.webm' }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); @@ -86,7 +86,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4); const magnetUri = videoDetails.files[0].magnetUri; expect(magnetUri).to.match(/\.mp4/); - const torrent = yield extra_utils_1.webtorrentAdd(magnetUri, true); + const torrent = yield (0, extra_utils_1.webtorrentAdd)(magnetUri, true); expect(torrent.files).to.be.an('array'); expect(torrent.files.length).to.equal(1); expect(torrent.files[0].path).match(/\.mp4$/); @@ -94,7 +94,7 @@ describe('Test video transcoding', function () { }); }); it('Should wait for transcoding before publishing the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); { const attributes = { @@ -124,7 +124,7 @@ describe('Test video transcoding', function () { } yield servers[0].videos.get({ id: videoId, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const videoToFind = data.find(v => v.name === 'waiting video'); @@ -137,7 +137,7 @@ describe('Test video transcoding', function () { }); }); it('Should accept and transcode additional extensions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(300000); for (const fixture of ['video_short.mkv', 'video_short.avi']) { const attributes = { @@ -145,7 +145,7 @@ describe('Test video transcoding', function () { fixture }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); @@ -158,7 +158,7 @@ describe('Test video transcoding', function () { }); }); it('Should transcode a 4k video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(200000); const attributes = { name: '4k video', @@ -166,7 +166,7 @@ describe('Test video transcoding', function () { }; const { uuid } = yield servers[1].videos.upload({ attributes }); video4k = uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const resolutions = [240, 360, 480, 720, 1080, 1440, 2160]; for (const server of servers) { const videoDetails = yield server.videos.get({ id: video4k }); @@ -181,14 +181,14 @@ describe('Test video transcoding', function () { }); describe('Audio transcoding', function () { it('Should transcode high bit rate mp3 to proper bit rate', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'mp3_256k', fixture: 'video_short_mp3_256k.mp4' }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); @@ -196,7 +196,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4); const file = videoDetails.files.find(f => f.resolution.id === 240); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const probe = yield ffprobe_utils_1.getAudioStream(path); + const probe = yield (0, ffprobe_utils_1.getAudioStream)(path); if (probe.audioStream) { expect(probe.audioStream['codec_name']).to.be.equal('aac'); expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000); @@ -208,47 +208,47 @@ describe('Test video transcoding', function () { }); }); it('Should transcode video with no audio and have no audio itself', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'no_audio', fixture: 'video_short_no_audio.mp4' }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); const videoDetails = yield server.videos.get({ id: video.id }); const file = videoDetails.files.find(f => f.resolution.id === 240); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const probe = yield ffprobe_utils_1.getAudioStream(path); + const probe = yield (0, ffprobe_utils_1.getAudioStream)(path); expect(probe).to.not.have.property('audioStream'); } }); }); it('Should leave the audio untouched, but properly transcode the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'untouched_audio', fixture: 'video_short.mp4' }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); const videoDetails = yield server.videos.get({ id: video.id }); expect(videoDetails.files).to.have.lengthOf(4); - const fixturePath = extra_utils_1.buildAbsoluteFixturePath(attributes.fixture); - const fixtureVideoProbe = yield ffprobe_utils_1.getAudioStream(fixturePath); + const fixturePath = (0, extra_utils_1.buildAbsoluteFixturePath)(attributes.fixture); + const fixtureVideoProbe = yield (0, ffprobe_utils_1.getAudioStream)(fixturePath); const file = videoDetails.files.find(f => f.resolution.id === 240); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const videoProbe = yield ffprobe_utils_1.getAudioStream(path); + const videoProbe = yield (0, ffprobe_utils_1.getAudioStream)(path); if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { const toOmit = ['max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts']; - expect(lodash_1.omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(lodash_1.omit(fixtureVideoProbe.audioStream, toOmit)); + expect((0, lodash_1.omit)(videoProbe.audioStream, toOmit)).to.be.deep.equal((0, lodash_1.omit)(fixtureVideoProbe.audioStream, toOmit)); } else { this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath); @@ -260,7 +260,7 @@ describe('Test video transcoding', function () { describe('Audio upload', function () { function runSuite(mode) { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[1].config.updateCustomSubConfig({ newConfig: { transcoding: { @@ -282,43 +282,43 @@ describe('Test video transcoding', function () { }); }); it('Should merge an audio file with the preview file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }; yield servers[1].videos.upload({ attributes, mode }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === 'audio_with_preview'); const videoDetails = yield server.videos.get({ id: video.id }); expect(videoDetails.files).to.have.lengthOf(1); - yield extra_utils_1.makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); - yield extra_utils_1.makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoDetails.previewPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); const magnetUri = videoDetails.files[0].magnetUri; expect(magnetUri).to.contain('.mp4'); } }); }); it('Should upload an audio file and choose a default background image', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }; yield servers[1].videos.upload({ attributes, mode }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === 'audio_without_preview'); const videoDetails = yield server.videos.get({ id: video.id }); expect(videoDetails.files).to.have.lengthOf(1); - yield extra_utils_1.makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); - yield extra_utils_1.makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: videoDetails.previewPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); const magnetUri = videoDetails.files[0].magnetUri; expect(magnetUri).to.contain('.mp4'); } }); }); it('Should upload an audio file and create an audio version only', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[1].config.updateCustomSubConfig({ newConfig: { @@ -335,7 +335,7 @@ describe('Test video transcoding', function () { }); const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }; const { id } = yield servers[1].videos.upload({ attributes, mode }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id }); for (const files of [videoDetails.files, videoDetails.streamingPlaylists[0].files]) { @@ -356,7 +356,7 @@ describe('Test video transcoding', function () { }); describe('Framerate', function () { it('Should transcode a 60 FPS video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const attributes = { name: 'my super 30fps name for server 2', @@ -364,7 +364,7 @@ describe('Test video transcoding', function () { fixture: '60fps_720p_small.mp4' }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const video = data.find(v => v.name === attributes.name); @@ -377,23 +377,23 @@ describe('Test video transcoding', function () { for (const resolution of [240, 360, 480]) { const file = videoDetails.files.find(f => f.resolution.id === resolution); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const fps = yield ffprobe_utils_1.getVideoFileFPS(path); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(path); expect(fps).to.be.below(31); } const file = videoDetails.files.find(f => f.resolution.id === 720); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const fps = yield ffprobe_utils_1.getVideoFileFPS(path); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(path); expect(fps).to.be.above(58).and.below(62); } }); }); it('Should downscale to the closest divisor standard framerate', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(200000); let tempFixturePath; { - tempFixturePath = yield extra_utils_1.generateVideoWithFramerate(59); - const fps = yield ffprobe_utils_1.getVideoFileFPS(tempFixturePath); + tempFixturePath = yield (0, extra_utils_1.generateVideoWithFramerate)(59); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(tempFixturePath); expect(fps).to.be.equal(59); } const attributes = { @@ -402,7 +402,7 @@ describe('Test video transcoding', function () { fixture: tempFixturePath }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const { id } = data.find(v => v.name === attributes.name); @@ -410,13 +410,13 @@ describe('Test video transcoding', function () { { const file = video.files.find(f => f.resolution.id === 240); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const fps = yield ffprobe_utils_1.getVideoFileFPS(path); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(path); expect(fps).to.be.equal(25); } { const file = video.files.find(f => f.resolution.id === 720); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const fps = yield ffprobe_utils_1.getVideoFileFPS(path); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(path); expect(fps).to.be.equal(59); } } @@ -425,16 +425,16 @@ describe('Test video transcoding', function () { }); describe('Bitrate control', function () { it('Should respect maximum bitrate values', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); - const tempFixturePath = yield extra_utils_1.generateHighBitrateVideo(); + const tempFixturePath = yield (0, extra_utils_1.generateHighBitrateVideo)(); const attributes = { name: 'high bitrate video', description: 'high bitrate video', fixture: tempFixturePath }; yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); const { id } = data.find(v => v.name === attributes.name); @@ -442,18 +442,18 @@ describe('Test video transcoding', function () { for (const resolution of [240, 360, 480, 720, 1080]) { const file = video.files.find(f => f.resolution.id === resolution); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const bitrate = yield ffprobe_utils_1.getVideoFileBitrate(path); - const fps = yield ffprobe_utils_1.getVideoFileFPS(path); - const dataResolution = yield ffprobe_utils_1.getVideoFileResolution(path); + const bitrate = yield (0, ffprobe_utils_1.getVideoFileBitrate)(path); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(path); + const dataResolution = yield (0, ffprobe_utils_1.getVideoFileResolution)(path); expect(resolution).to.equal(resolution); - const maxBitrate = core_utils_1.getMaxBitrate(Object.assign(Object.assign({}, dataResolution), { fps })); + const maxBitrate = (0, core_utils_1.getMaxBitrate)(Object.assign(Object.assign({}, dataResolution), { fps })); expect(bitrate).to.be.below(maxBitrate); } } }); }); it('Should not transcode to an higher bitrate than the original file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); const newConfig = { transcoding: { @@ -477,13 +477,13 @@ describe('Test video transcoding', function () { fixture: 'low-bitrate.mp4' }; const { id } = yield servers[1].videos.upload({ attributes }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[1].videos.get({ id }); const resolutions = [240, 360, 480, 720, 1080]; for (const r of resolutions) { const file = video.files.find(f => f.resolution.id === r); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const bitrate = yield ffprobe_utils_1.getVideoFileBitrate(path); + const bitrate = yield (0, ffprobe_utils_1.getVideoFileBitrate)(path); expect(bitrate, `${path} not below ${60000}`).to.be.below(60000); } }); @@ -491,15 +491,15 @@ describe('Test video transcoding', function () { }); describe('FFprobe', function () { it('Should provide valid ffprobe data', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); const videoUUID = (yield servers[1].videos.quickUpload({ name: 'ffprobe data' })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const video = yield servers[1].videos.get({ id: videoUUID }); const file = video.files.find(f => f.resolution.id === 240); const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl); - const metadata = yield ffprobe_utils_1.getMetadataFromFile(path); + const metadata = yield (0, ffprobe_utils_1.getMetadataFromFile)(path); for (const p of [ 'tags.encoder', 'format_long_name', @@ -538,16 +538,16 @@ describe('Test video transcoding', function () { }); }); it('Should correctly detect if quick transcode is possible', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - expect(yield ffprobe_utils_1.canDoQuickTranscode(extra_utils_1.buildAbsoluteFixturePath('video_short.mp4'))).to.be.true; - expect(yield ffprobe_utils_1.canDoQuickTranscode(extra_utils_1.buildAbsoluteFixturePath('video_short.webm'))).to.be.false; + expect(yield (0, ffprobe_utils_1.canDoQuickTranscode)((0, extra_utils_1.buildAbsoluteFixturePath)('video_short.mp4'))).to.be.true; + expect(yield (0, ffprobe_utils_1.canDoQuickTranscode)((0, extra_utils_1.buildAbsoluteFixturePath)('video_short.webm'))).to.be.false; }); }); }); describe('Transcoding job queue', function () { it('Should have the appropriate priorities for transcoding jobs', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[1].jobs.list({ start: 0, count: 100, @@ -571,8 +571,8 @@ describe('Test video transcoding', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/videos-filter.js b/dist/server/tests/api/videos/videos-filter.js index 7ca56c7e..fd568b64 100644 --- a/dist/server/tests/api/videos/videos-filter.js +++ b/dist/server/tests/api/videos/videos-filter.js @@ -6,7 +6,7 @@ const chai_1 = require("chai"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); function getVideosNames(server, token, filter, expectedStatus = models_1.HttpStatusCode.OK_200) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = [ '/api/v1/video-channels/root_channel/videos', '/api/v1/accounts/root/videos', @@ -15,7 +15,7 @@ function getVideosNames(server, token, filter, expectedStatus = models_1.HttpSta ]; const videosResults = []; for (const path of paths) { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path, token, @@ -33,10 +33,10 @@ function getVideosNames(server, token, filter, expectedStatus = models_1.HttpSta describe('Test videos filter', function () { let servers; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(160000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); for (const server of servers) { const moderator = { username: 'moderator', password: 'my super password' }; yield server.users.create({ username: moderator.username, password: moderator.password, role: models_1.UserRole.MODERATOR }); @@ -51,53 +51,53 @@ describe('Test videos filter', function () { yield server.videos.upload({ attributes }); } } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); describe('Check videos filter', function () { it('Should display local videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const namesResults = yield getVideosNames(server, server.accessToken, 'local'); for (const names of namesResults) { - chai_1.expect(names).to.have.lengthOf(1); - chai_1.expect(names[0]).to.equal('public ' + server.serverNumber); + (0, chai_1.expect)(names).to.have.lengthOf(1); + (0, chai_1.expect)(names[0]).to.equal('public ' + server.serverNumber); } } }); }); it('Should display all local videos by the admin or the moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { for (const token of [server.accessToken, server['moderatorAccessToken']]) { const namesResults = yield getVideosNames(server, token, 'all-local'); for (const names of namesResults) { - chai_1.expect(names).to.have.lengthOf(3); - chai_1.expect(names[0]).to.equal('public ' + server.serverNumber); - chai_1.expect(names[1]).to.equal('unlisted ' + server.serverNumber); - chai_1.expect(names[2]).to.equal('private ' + server.serverNumber); + (0, chai_1.expect)(names).to.have.lengthOf(3); + (0, chai_1.expect)(names[0]).to.equal('public ' + server.serverNumber); + (0, chai_1.expect)(names[1]).to.equal('unlisted ' + server.serverNumber); + (0, chai_1.expect)(names[2]).to.equal('private ' + server.serverNumber); } } } }); }); it('Should display all videos by the admin or the moderator', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { for (const token of [server.accessToken, server['moderatorAccessToken']]) { const [channelVideos, accountVideos, videos, searchVideos] = yield getVideosNames(server, token, 'all'); - chai_1.expect(channelVideos).to.have.lengthOf(3); - chai_1.expect(accountVideos).to.have.lengthOf(3); - chai_1.expect(videos).to.have.lengthOf(5); - chai_1.expect(searchVideos).to.have.lengthOf(5); + (0, chai_1.expect)(channelVideos).to.have.lengthOf(3); + (0, chai_1.expect)(accountVideos).to.have.lengthOf(3); + (0, chai_1.expect)(videos).to.have.lengthOf(5); + (0, chai_1.expect)(searchVideos).to.have.lengthOf(5); } } }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/api/videos/videos-history.js b/dist/server/tests/api/videos/videos-history.js index 5ae128b0..39874e88 100644 --- a/dist/server/tests/api/videos/videos-history.js +++ b/dist/server/tests/api/videos/videos-history.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -15,10 +15,10 @@ describe('Test videos history', function () { let userAccessToken; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); command = server.history; { const { uuid } = yield server.videos.upload({ attributes: { name: 'video 1' } }); @@ -41,7 +41,7 @@ describe('Test videos history', function () { }); }); it('Should get videos, without watching history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.listWithToken(); for (const video of data) { const videoDetails = yield server.videos.getWithToken({ id: video.id }); @@ -51,13 +51,13 @@ describe('Test videos history', function () { }); }); it('Should watch the first and second video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.wathVideo({ videoId: video2UUID, currentTime: 8 }); yield command.wathVideo({ videoId: video1UUID, currentTime: 3 }); }); }); it('Should return the correct history when listing, searching and getting videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const videosOfVideos = []; { const { data } = yield server.videos.listWithToken(); @@ -94,7 +94,7 @@ describe('Test videos history', function () { }); }); it('Should have these videos when listing my history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { video3WatchedDate = new Date(); yield command.wathVideo({ videoId: video3UUID, currentTime: 2 }); const body = yield command.list(); @@ -106,14 +106,14 @@ describe('Test videos history', function () { }); }); it('Should not have videos history on another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ token: userAccessToken }); expect(body.total).to.equal(0); expect(body.data).to.have.lengthOf(0); }); }); it('Should be able to search through videos in my history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list({ search: '2' }); expect(body.total).to.equal(1); const videos = body.data; @@ -121,12 +121,12 @@ describe('Test videos history', function () { }); }); it('Should clear my history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.remove({ beforeDate: video3WatchedDate.toISOString() }); }); }); it('Should have my history cleared', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.list(); expect(body.total).to.equal(1); const videos = body.data; @@ -134,7 +134,7 @@ describe('Test videos history', function () { }); }); it('Should disable videos history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ videosHistoryEnabled: false }); @@ -142,7 +142,7 @@ describe('Test videos history', function () { }); }); it('Should re-enable videos history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ videosHistoryEnabled: true }); @@ -155,28 +155,28 @@ describe('Test videos history', function () { }); }); it('Should not clean old history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run({ history: { videos: { max_age: '10 days' } } }); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); const body = yield command.list(); expect(body.total).to.equal(2); }); }); it('Should clean old history', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run({ history: { videos: { max_age: '5 seconds' } } }); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); const body = yield command.list(); expect(body.total).to.equal(0); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/videos-overview.js b/dist/server/tests/api/videos/videos-overview.js index dd5a4068..3d316119 100644 --- a/dist/server/tests/api/videos/videos-overview.js +++ b/dist/server/tests/api/videos/videos-overview.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test a videos overview', function () { @@ -13,22 +13,22 @@ describe('Test a videos overview', function () { expect(overview.channels).to.have.lengthOf(expected); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); it('Should send empty overview', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.overviews.getVideos({ page: 1 }); testOverviewCount(body, 0); }); }); it('Should upload 5 videos in a specific category, tag and channel but not include them in overview', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.wait)(3000); yield server.videos.upload({ attributes: { name: 'video 0', @@ -41,7 +41,7 @@ describe('Test a videos overview', function () { }); }); it('Should upload another video and include all videos in the overview', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); { for (let i = 1; i < 6; i++) { @@ -53,7 +53,7 @@ describe('Test a videos overview', function () { } }); } - yield extra_utils_1.wait(3000); + yield (0, extra_utils_1.wait)(3000); } { const body = yield server.overviews.getVideos({ page: 1 }); @@ -68,7 +68,7 @@ describe('Test a videos overview', function () { }); }); it('Should have the correct overview', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const overview1 = yield server.overviews.getVideos({ page: 1 }); const overview2 = yield server.overviews.getVideos({ page: 2 }); for (const arr of [overview1.tags, overview1.categories, overview1.channels, overview2.tags]) { @@ -90,7 +90,7 @@ describe('Test a videos overview', function () { }); }); it('Should hide muted accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const token = yield server.users.generateUserAndToken('choco'); yield server.blocklist.addToMyBlocklist({ token, account: 'root@' + server.host }); { @@ -104,8 +104,8 @@ describe('Test a videos overview', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/api/videos/videos-views-cleaner.js b/dist/server/tests/api/videos/videos-views-cleaner.js index 686857f2..864af612 100644 --- a/dist/server/tests/api/videos/videos-views-cleaner.js +++ b/dist/server/tests/api/videos/videos-views-cleaner.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../../shared/extra-utils"); const expect = chai.expect; describe('Test video views cleaner', function () { @@ -10,27 +10,27 @@ describe('Test video views cleaner', function () { let videoIdServer1; let videoIdServer2; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); videoIdServer1 = (yield servers[0].videos.quickUpload({ name: 'video server 1' })).uuid; videoIdServer2 = (yield servers[1].videos.quickUpload({ name: 'video server 2' })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].videos.view({ id: videoIdServer1 }); yield servers[1].videos.view({ id: videoIdServer1 }); yield servers[0].videos.view({ id: videoIdServer2 }); yield servers[1].videos.view({ id: videoIdServer2 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should not clean old video views', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run({ views: { videos: { remote: { max_age: '10 days' } } } }); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); { for (const server of servers) { const total = yield server.sql.countVideoViewsOf(videoIdServer1); @@ -46,11 +46,11 @@ describe('Test video views cleaner', function () { }); }); it('Should clean old video views', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(50000); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run({ views: { videos: { remote: { max_age: '5 seconds' } } } }); - yield extra_utils_1.wait(6000); + yield (0, extra_utils_1.wait)(6000); { for (const server of servers) { const total = yield server.sql.countVideoViewsOf(videoIdServer1); @@ -66,8 +66,8 @@ describe('Test video views cleaner', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/cli/create-import-video-file-job.js b/dist/server/tests/cli/create-import-video-file-job.js index f93588c9..465cab75 100644 --- a/dist/server/tests/cli/create-import-video-file-job.js +++ b/dist/server/tests/cli/create-import-video-file-job.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -16,11 +16,11 @@ function assertVideoProperties(video, resolution, extname, size) { expect(video.size).to.equal(size); } function checkFiles(video, objectStorage) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const file of video.files) { if (objectStorage) - extra_utils_1.expectStartWith(file.fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(file.fileUrl, extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl()); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } }); } @@ -29,14 +29,14 @@ function runTests(objectStorage) { let video2UUID; let servers = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(90000); const config = objectStorage ? extra_utils_1.ObjectStorageCommand.getDefaultConfig() : {}; - servers = yield extra_utils_1.createMultipleServers(2, config); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); if (objectStorage) yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); { @@ -47,14 +47,14 @@ function runTests(objectStorage) { const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video2' } }); video2UUID = uuid; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should run a import job on video 1 with a lower resolution', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short-480.webm`; yield servers[0].cli.execWithEnv(command); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data: videos } = yield server.videos.list(); expect(videos).to.have.lengthOf(2); @@ -69,10 +69,10 @@ function runTests(objectStorage) { }); }); it('Should run a import job on video 2 with the same resolution and a different extension', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`; yield servers[1].cli.execWithEnv(command); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data: videos } = yield server.videos.list(); expect(videos).to.have.lengthOf(2); @@ -89,10 +89,10 @@ function runTests(objectStorage) { }); }); it('Should run a import job on video 2 with the same resolution and the same extension', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short2.webm`; yield servers[0].cli.execWithEnv(command); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data: videos } = yield server.videos.list(); expect(videos).to.have.lengthOf(2); @@ -107,8 +107,8 @@ function runTests(objectStorage) { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); } @@ -117,7 +117,7 @@ describe('Test create import video jobs', function () { runTests(false); }); describe('On object storage', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; runTests(true); }); diff --git a/dist/server/tests/cli/create-transcoding-job.js b/dist/server/tests/cli/create-transcoding-job.js index 045cde3e..dcb239b4 100644 --- a/dist/server/tests/cli/create-transcoding-job.js +++ b/dist/server/tests/cli/create-transcoding-job.js @@ -2,18 +2,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const models_1 = require("@shared/models"); const extra_utils_1 = require("../../../shared/extra-utils"); const expect = chai.expect; function checkFilesInObjectStorage(files, type) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const file of files) { const shouldStartWith = type === 'webtorrent' ? extra_utils_1.ObjectStorageCommand.getWebTorrentBaseUrl() : extra_utils_1.ObjectStorageCommand.getPlaylistBaseUrl(); - extra_utils_1.expectStartWith(file.fileUrl, shouldStartWith); - yield extra_utils_1.makeRawRequest(file.fileUrl, models_1.HttpStatusCode.OK_200); + (0, extra_utils_1.expectStartWith)(file.fileUrl, shouldStartWith); + yield (0, extra_utils_1.makeRawRequest)(file.fileUrl, models_1.HttpStatusCode.OK_200); } }); } @@ -22,20 +22,20 @@ function runTests(objectStorage) { const videosUUID = []; const publishedAt = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const config = objectStorage ? extra_utils_1.ObjectStorageCommand.getDefaultConfig() : {}; - servers = yield extra_utils_1.createMultipleServers(2, config); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2, config); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); yield servers[0].config.disableTranscoding(); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); if (objectStorage) yield extra_utils_1.ObjectStorageCommand.prepareDefaultBuckets(); for (let i = 1; i <= 5; i++) { const { uuid, shortUUID } = yield servers[0].videos.upload({ attributes: { name: 'video' + i } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const video = yield servers[0].videos.get({ id: uuid }); publishedAt.push(video.publishedAt); if (i > 2) { @@ -45,11 +45,11 @@ function runTests(objectStorage) { videosUUID.push(shortUUID); } } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should have two video files on each server', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); for (const server of servers) { const { data } = yield server.videos.list(); @@ -63,10 +63,10 @@ function runTests(objectStorage) { }); }); it('Should run a transcoding job on video 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); let infoHashes; @@ -99,10 +99,10 @@ function runTests(objectStorage) { }); }); it('Should run a transcoding job on video 1 with resolution', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); expect(data).to.have.lengthOf(videosUUID.length); @@ -117,10 +117,10 @@ function runTests(objectStorage) { }); }); it('Should generate an HLS resolution', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id: videosUUID[2] }); expect(videoDetails.files).to.have.lengthOf(1); @@ -136,10 +136,10 @@ function runTests(objectStorage) { }); }); it('Should not duplicate an HLS resolution', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id: videosUUID[2] }); const files = videoDetails.streamingPlaylists[0].files; @@ -151,10 +151,10 @@ function runTests(objectStorage) { }); }); it('Should generate all HLS resolutions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id: videosUUID[3] }); expect(videoDetails.files).to.have.lengthOf(1); @@ -167,11 +167,11 @@ function runTests(objectStorage) { }); }); it('Should optimize the video file and generate HLS videos if enabled in config', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].config.enableTranscoding(); yield servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const videoDetails = yield server.videos.get({ id: videosUUID[4] }); expect(videoDetails.files).to.have.lengthOf(4); @@ -185,7 +185,7 @@ function runTests(objectStorage) { }); }); it('Should not have updated published at attributes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const id of videosUUID) { const video = yield servers[0].videos.get({ id }); expect(publishedAt.some(p => video.publishedAt === p)).to.be.true; @@ -193,8 +193,8 @@ function runTests(objectStorage) { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); } @@ -203,7 +203,7 @@ describe('Test create transcoding jobs', function () { runTests(false); }); describe('On object storage', function () { - if (extra_utils_1.areObjectStorageTestsDisabled()) + if ((0, extra_utils_1.areObjectStorageTestsDisabled)()) return; runTests(true); }); diff --git a/dist/server/tests/cli/peertube.js b/dist/server/tests/cli/peertube.js index 1086950c..f27e4180 100644 --- a/dist/server/tests/cli/peertube.js +++ b/dist/server/tests/cli/peertube.js @@ -10,10 +10,10 @@ describe('Test CLI wrapper', function () { let cliCommand; const cmd = 'node ./dist/server/tools/peertube.js'; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.users.create({ username: 'user_1', password: 'super_password' }); userAccessToken = yield server.login.getAccessToken({ username: 'user_1', password: 'super_password' }); { @@ -25,28 +25,28 @@ describe('Test CLI wrapper', function () { }); describe('Authentication and instance selection', function () { it('Should get an access token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const stdout = yield cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`); const token = stdout.trim(); const body = yield server.users.getMyInfo({ token }); - chai_1.expect(body.username).to.equal('user_1'); + (0, chai_1.expect)(body.username).to.equal('user_1'); }); }); it('Should display no selected instance', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const stdout = yield cliCommand.execWithEnv(`${cmd} --help`); - chai_1.expect(stdout).to.contain('no instance selected'); + (0, chai_1.expect)(stdout).to.contain('no instance selected'); }); }); it('Should add a user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U user_1 -p super_password`); }); }); it('Should not fail to add a user if there is a slash at the end of the instance URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); let fullServerURL = server.url + '/'; yield cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`); @@ -55,42 +55,42 @@ describe('Test CLI wrapper', function () { }); }); it('Should default to this user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const stdout = yield cliCommand.execWithEnv(`${cmd} --help`); - chai_1.expect(stdout).to.contain(`instance ${server.url} selected`); + (0, chai_1.expect)(stdout).to.contain(`instance ${server.url} selected`); }); }); it('Should remember the user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const stdout = yield cliCommand.execWithEnv(`${cmd} auth list`); - chai_1.expect(stdout).to.contain(server.url); + (0, chai_1.expect)(stdout).to.contain(server.url); }); }); }); describe('Video upload/import', function () { it('Should upload a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - const fixture = extra_utils_1.buildAbsoluteFixturePath('60fps_720p_small.mp4'); + const fixture = (0, extra_utils_1.buildAbsoluteFixturePath)('60fps_720p_small.mp4'); const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'`; yield cliCommand.execWithEnv(`${cmd} upload ${params}`); }); }); it('Should have the video uploaded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); const video = yield server.videos.get({ id: data[0].uuid }); - chai_1.expect(video.name).to.equal('test upload'); - chai_1.expect(video.support).to.equal('support_text'); - chai_1.expect(video.channel.name).to.equal('user_channel'); + (0, chai_1.expect)(video.name).to.equal('test upload'); + (0, chai_1.expect)(video.support).to.equal('support_text'); + (0, chai_1.expect)(video.channel.name).to.equal('user_channel'); }); }); it('Should import a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (extra_utils_1.areHttpImportTestsDisabled()) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if ((0, extra_utils_1.areHttpImportTestsDisabled)()) return; this.timeout(60000); const params = `--target-url ${extra_utils_1.FIXTURE_URLS.youtube} --channel-name user_channel`; @@ -98,81 +98,81 @@ describe('Test CLI wrapper', function () { }); }); it('Should have imported the video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (extra_utils_1.areHttpImportTestsDisabled()) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if ((0, extra_utils_1.areHttpImportTestsDisabled)()) return; this.timeout(60000); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const { total, data } = yield server.videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); const video = data.find(v => v.name === 'small video - youtube'); - chai_1.expect(video).to.not.be.undefined; + (0, chai_1.expect)(video).to.not.be.undefined; const videoDetails = yield server.videos.get({ id: video.id }); - chai_1.expect(videoDetails.channel.name).to.equal('user_channel'); - chai_1.expect(videoDetails.support).to.equal('super support text'); - chai_1.expect(videoDetails.nsfw).to.be.false; + (0, chai_1.expect)(videoDetails.channel.name).to.equal('user_channel'); + (0, chai_1.expect)(videoDetails.support).to.equal('super support text'); + (0, chai_1.expect)(videoDetails.nsfw).to.be.false; yield server.videos.remove({ token: userAccessToken, id: video.id }); }); }); it('Should import and override some imported attributes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - if (extra_utils_1.areHttpImportTestsDisabled()) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + if ((0, extra_utils_1.areHttpImportTestsDisabled)()) return; this.timeout(60000); const params = `--target-url ${extra_utils_1.FIXTURE_URLS.youtube} ` + `--channel-name user_channel --video-name toto --nsfw --support support`; yield cliCommand.execWithEnv(`${cmd} import ${params}`); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); { const { total, data } = yield server.videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); const video = data.find(v => v.name === 'toto'); - chai_1.expect(video).to.not.be.undefined; + (0, chai_1.expect)(video).to.not.be.undefined; const videoDetails = yield server.videos.get({ id: video.id }); - chai_1.expect(videoDetails.channel.name).to.equal('user_channel'); - chai_1.expect(videoDetails.support).to.equal('support'); - chai_1.expect(videoDetails.nsfw).to.be.true; - chai_1.expect(videoDetails.commentsEnabled).to.be.true; + (0, chai_1.expect)(videoDetails.channel.name).to.equal('user_channel'); + (0, chai_1.expect)(videoDetails.support).to.equal('support'); + (0, chai_1.expect)(videoDetails.nsfw).to.be.true; + (0, chai_1.expect)(videoDetails.commentsEnabled).to.be.true; } }); }); }); describe('Admin auth', function () { it('Should remove the auth user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield cliCommand.execWithEnv(`${cmd} auth del ${server.url}`); const stdout = yield cliCommand.execWithEnv(`${cmd} --help`); - chai_1.expect(stdout).to.contain('no instance selected'); + (0, chai_1.expect)(stdout).to.contain('no instance selected'); }); }); it('Should add the admin user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`); }); }); }); describe('Manage plugins', function () { it('Should install a plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world`); }); }); it('Should have registered settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.testHelloWorldRegisteredSettings(server); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.testHelloWorldRegisteredSettings)(server); }); }); it('Should list installed plugins', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield cliCommand.execWithEnv(`${cmd} plugins list`); - chai_1.expect(res).to.contain('peertube-plugin-hello-world'); + (0, chai_1.expect)(res).to.contain('peertube-plugin-hello-world'); }); }); it('Should uninstall the plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`); - chai_1.expect(res).to.not.contain('peertube-plugin-hello-world'); + (0, chai_1.expect)(res).to.not.contain('peertube-plugin-hello-world'); }); }); }); @@ -181,61 +181,61 @@ describe('Test CLI wrapper', function () { let video1Server2; let servers; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - anotherServer = yield extra_utils_1.createSingleServer(2); - yield extra_utils_1.setAccessTokensToServers([anotherServer]); - yield extra_utils_1.doubleFollow(server, anotherServer); + anotherServer = yield (0, extra_utils_1.createSingleServer)(2); + yield (0, extra_utils_1.setAccessTokensToServers)([anotherServer]); + yield (0, extra_utils_1.doubleFollow)(server, anotherServer); servers = [server, anotherServer]; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { uuid } = yield anotherServer.videos.quickUpload({ name: 'super video' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); video1Server2 = yield server.videos.getId({ uuid }); }); }); it('Should add a redundancy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const params = `add --video ${video1Server2}`; yield cliCommand.execWithEnv(`${cmd} redundancy ${params}`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); it('Should list redundancies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); { const params = 'list-my-redundancies'; const stdout = yield cliCommand.execWithEnv(`${cmd} redundancy ${params}`); - chai_1.expect(stdout).to.contain('super video'); - chai_1.expect(stdout).to.contain(`localhost:${server.port}`); + (0, chai_1.expect)(stdout).to.contain('super video'); + (0, chai_1.expect)(stdout).to.contain(`localhost:${server.port}`); } }); }); it('Should remove a redundancy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const params = `remove --video ${video1Server2}`; yield cliCommand.execWithEnv(`${cmd} redundancy ${params}`); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const params = 'list-my-redundancies'; const stdout = yield cliCommand.execWithEnv(`${cmd} redundancy ${params}`); - chai_1.expect(stdout).to.not.contain('super video'); + (0, chai_1.expect)(stdout).to.not.contain('super video'); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.cleanupTests([anotherServer]); + yield (0, extra_utils_1.cleanupTests)([anotherServer]); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.cleanupTests([server]); + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/cli/plugins.js b/dist/server/tests/cli/plugins.js index 934d51ed..05944849 100644 --- a/dist/server/tests/cli/plugins.js +++ b/dist/server/tests/cli/plugins.js @@ -7,59 +7,59 @@ const extra_utils_1 = require("../../../shared/extra-utils"); describe('Test plugin scripts', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); it('Should install a plugin from stateless CLI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const packagePath = extra_utils_1.PluginsCommand.getPluginTestPath(); yield server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`); }); }); it('Should install a theme from stateless CLI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`); }); }); it('Should have the theme and the plugin registered when we restart peertube', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); const config = yield server.config.getConfig(); const plugin = config.plugin.registered .find(p => p.name === 'test'); - chai_1.expect(plugin).to.not.be.undefined; + (0, chai_1.expect)(plugin).to.not.be.undefined; const theme = config.theme.registered .find(t => t.name === 'background-red'); - chai_1.expect(theme).to.not.be.undefined; + (0, chai_1.expect)(theme).to.not.be.undefined; }); }); it('Should uninstall a plugin from stateless CLI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`); }); }); it('Should have removed the plugin on another peertube restart', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); const config = yield server.config.getConfig(); const plugin = config.plugin.registered .find(p => p.name === 'test'); - chai_1.expect(plugin).to.be.undefined; + (0, chai_1.expect)(plugin).to.be.undefined; }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/cli/print-transcode-command.js b/dist/server/tests/cli/print-transcode-command.js index 84e3d5d2..06de032c 100644 --- a/dist/server/tests/cli/print-transcode-command.js +++ b/dist/server/tests/cli/print-transcode-command.js @@ -2,23 +2,23 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const ffprobe_utils_1 = require("@server/helpers/ffprobe-utils"); const core_utils_1 = require("@shared/core-utils"); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test print transcode jobs', function () { it('Should print the correct command for each resolution', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const fixturePath = extra_utils_1.buildAbsoluteFixturePath('video_short.webm'); - const fps = yield ffprobe_utils_1.getVideoFileFPS(fixturePath); - const bitrate = yield ffprobe_utils_1.getVideoFileBitrate(fixturePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const fixturePath = (0, extra_utils_1.buildAbsoluteFixturePath)('video_short.webm'); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(fixturePath); + const bitrate = yield (0, ffprobe_utils_1.getVideoFileBitrate)(fixturePath); for (const resolution of [ 720, 1080 ]) { const command = yield extra_utils_1.CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`); - const targetBitrate = Math.min(core_utils_1.getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate + (bitrate * 0.3)); + const targetBitrate = Math.min((0, core_utils_1.getMaxBitrate)({ resolution, fps, ratio: 16 / 9 }), bitrate + (bitrate * 0.3)); expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`); expect(command).to.includes(`-y -acodec aac -vcodec libx264`); expect(command).to.includes('-f mp4'); diff --git a/dist/server/tests/cli/prune-storage.js b/dist/server/tests/cli/prune-storage.js index b85515e1..ffe674c7 100644 --- a/dist/server/tests/cli/prune-storage.js +++ b/dist/server/tests/cli/prune-storage.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const uuid_1 = require("@server/helpers/uuid"); @@ -10,21 +10,21 @@ const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; function countFiles(server, directory) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const files = yield fs_extra_1.readdir(server.servers.buildDirectory(directory)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const files = yield (0, fs_extra_1.readdir)(server.servers.buildDirectory(directory)); return files.length; }); } function assertNotExists(server, directory, substring) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const files = yield fs_extra_1.readdir(server.servers.buildDirectory(directory)); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const files = yield (0, fs_extra_1.readdir)(server.servers.buildDirectory(directory)); for (const f of files) { expect(f).to.not.contain(substring); } }); } function assertCountAreOkay(servers, videoServer2UUID) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const videosCount = yield countFiles(server, 'videos'); expect(videosCount).to.equal(8); @@ -44,11 +44,11 @@ describe('Test prune storage scripts', function () { const badNames = {}; let videoServer2UUID; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2, { transcoding: { enabled: true } }); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2, { transcoding: { enabled: true } }); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); for (const server of servers) { yield server.videos.upload({ attributes: { name: 'video 1' } }); const { uuid } = yield server.videos.upload({ attributes: { name: 'video 2' } }); @@ -64,10 +64,10 @@ describe('Test prune storage scripts', function () { } }); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); { const account = yield servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: account.avatar.path, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -75,78 +75,78 @@ describe('Test prune storage scripts', function () { } { const account = yield servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: servers[1].url, path: account.avatar.path, expectedStatus: models_1.HttpStatusCode.OK_200 }); } - yield extra_utils_1.wait(1000); - yield extra_utils_1.waitJobs(servers); - yield extra_utils_1.killallServers(servers); - yield extra_utils_1.wait(1000); + yield (0, extra_utils_1.wait)(1000); + yield (0, extra_utils_1.waitJobs)(servers); + yield (0, extra_utils_1.killallServers)(servers); + yield (0, extra_utils_1.wait)(1000); }); }); it('Should have the files on the disk', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield assertCountAreOkay(servers, videoServer2UUID); }); }); it('Should create some dirty files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (let i = 0; i < 2; i++) { { const base = servers[0].servers.buildDirectory('videos'); - const n1 = uuid_1.buildUUID() + '.mp4'; - const n2 = uuid_1.buildUUID() + '.webm'; - yield fs_extra_1.createFile(path_1.join(base, n1)); - yield fs_extra_1.createFile(path_1.join(base, n2)); + const n1 = (0, uuid_1.buildUUID)() + '.mp4'; + const n2 = (0, uuid_1.buildUUID)() + '.webm'; + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n1)); + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n2)); badNames['videos'] = [n1, n2]; } { const base = servers[0].servers.buildDirectory('torrents'); - const n1 = uuid_1.buildUUID() + '-240.torrent'; - const n2 = uuid_1.buildUUID() + '-480.torrent'; - yield fs_extra_1.createFile(path_1.join(base, n1)); - yield fs_extra_1.createFile(path_1.join(base, n2)); + const n1 = (0, uuid_1.buildUUID)() + '-240.torrent'; + const n2 = (0, uuid_1.buildUUID)() + '-480.torrent'; + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n1)); + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n2)); badNames['torrents'] = [n1, n2]; } { const base = servers[0].servers.buildDirectory('thumbnails'); - const n1 = uuid_1.buildUUID() + '.jpg'; - const n2 = uuid_1.buildUUID() + '.jpg'; - yield fs_extra_1.createFile(path_1.join(base, n1)); - yield fs_extra_1.createFile(path_1.join(base, n2)); + const n1 = (0, uuid_1.buildUUID)() + '.jpg'; + const n2 = (0, uuid_1.buildUUID)() + '.jpg'; + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n1)); + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n2)); badNames['thumbnails'] = [n1, n2]; } { const base = servers[0].servers.buildDirectory('previews'); - const n1 = uuid_1.buildUUID() + '.jpg'; - const n2 = uuid_1.buildUUID() + '.jpg'; - yield fs_extra_1.createFile(path_1.join(base, n1)); - yield fs_extra_1.createFile(path_1.join(base, n2)); + const n1 = (0, uuid_1.buildUUID)() + '.jpg'; + const n2 = (0, uuid_1.buildUUID)() + '.jpg'; + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n1)); + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n2)); badNames['previews'] = [n1, n2]; } { const base = servers[0].servers.buildDirectory('avatars'); - const n1 = uuid_1.buildUUID() + '.png'; - const n2 = uuid_1.buildUUID() + '.jpg'; - yield fs_extra_1.createFile(path_1.join(base, n1)); - yield fs_extra_1.createFile(path_1.join(base, n2)); + const n1 = (0, uuid_1.buildUUID)() + '.png'; + const n2 = (0, uuid_1.buildUUID)() + '.jpg'; + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n1)); + yield (0, fs_extra_1.createFile)((0, path_1.join)(base, n2)); badNames['avatars'] = [n1, n2]; } } }); }); it('Should run prune storage', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const env = servers[0].cli.getEnv(); yield extra_utils_1.CLICommand.exec(`echo y | ${env} npm run prune-storage`); }); }); it('Should have removed files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield assertCountAreOkay(servers, videoServer2UUID); for (const directory of Object.keys(badNames)) { for (const name of badNames[directory]) { @@ -156,8 +156,8 @@ describe('Test prune storage scripts', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/cli/regenerate-thumbnails.js b/dist/server/tests/cli/regenerate-thumbnails.js index 28a526f8..5d5f005b 100644 --- a/dist/server/tests/cli/regenerate-thumbnails.js +++ b/dist/server/tests/cli/regenerate-thumbnails.js @@ -8,15 +8,15 @@ const path_1 = require("path"); const models_1 = require("@shared/models"); const extra_utils_1 = require("../../../shared/extra-utils"); function testThumbnail(server, videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield server.videos.get({ id: videoId }); const requests = [ - extra_utils_1.makeRawRequest(path_1.join(server.url, video.thumbnailPath), models_1.HttpStatusCode.OK_200), - extra_utils_1.makeRawRequest(path_1.join(server.url, video.thumbnailPath), models_1.HttpStatusCode.OK_200) + (0, extra_utils_1.makeRawRequest)((0, path_1.join)(server.url, video.thumbnailPath), models_1.HttpStatusCode.OK_200), + (0, extra_utils_1.makeRawRequest)((0, path_1.join)(server.url, video.thumbnailPath), models_1.HttpStatusCode.OK_200) ]; for (const req of requests) { const res = yield req; - chai_1.expect(res.body).to.not.have.lengthOf(0); + (0, chai_1.expect)(res.body).to.not.have.lengthOf(0); } }); } @@ -28,75 +28,75 @@ describe('Test regenerate thumbnails script', function () { let thumbnail1Path; let thumbnailRemotePath; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); { const videoUUID1 = (yield servers[0].videos.quickUpload({ name: 'video 1' })).uuid; video1 = yield servers[0].videos.get({ id: videoUUID1 }); - thumbnail1Path = path_1.join(servers[0].servers.buildDirectory('thumbnails'), path_1.basename(video1.thumbnailPath)); + thumbnail1Path = (0, path_1.join)(servers[0].servers.buildDirectory('thumbnails'), (0, path_1.basename)(video1.thumbnailPath)); const videoUUID2 = (yield servers[0].videos.quickUpload({ name: 'video 2' })).uuid; video2 = yield servers[0].videos.get({ id: videoUUID2 }); } { const videoUUID = (yield servers[1].videos.quickUpload({ name: 'video 3' })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); remoteVideo = yield servers[0].videos.get({ id: videoUUID }); - thumbnailRemotePath = path_1.join(servers[0].servers.buildDirectory('thumbnails'), path_1.basename(remoteVideo.thumbnailPath)); + thumbnailRemotePath = (0, path_1.join)(servers[0].servers.buildDirectory('thumbnails'), (0, path_1.basename)(remoteVideo.thumbnailPath)); } - yield fs_extra_1.writeFile(thumbnail1Path, ''); - yield fs_extra_1.writeFile(thumbnailRemotePath, ''); + yield (0, fs_extra_1.writeFile)(thumbnail1Path, ''); + yield (0, fs_extra_1.writeFile)(thumbnailRemotePath, ''); }); }); it('Should have empty thumbnails', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { - const res = yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, video1.thumbnailPath), models_1.HttpStatusCode.OK_200); - chai_1.expect(res.body).to.have.lengthOf(0); + const res = yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, video1.thumbnailPath), models_1.HttpStatusCode.OK_200); + (0, chai_1.expect)(res.body).to.have.lengthOf(0); } { - const res = yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, video2.thumbnailPath), models_1.HttpStatusCode.OK_200); - chai_1.expect(res.body).to.not.have.lengthOf(0); + const res = yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, video2.thumbnailPath), models_1.HttpStatusCode.OK_200); + (0, chai_1.expect)(res.body).to.not.have.lengthOf(0); } { - const res = yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); - chai_1.expect(res.body).to.have.lengthOf(0); + const res = yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); + (0, chai_1.expect)(res.body).to.have.lengthOf(0); } }); }); it('Should regenerate local thumbnails from the CLI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); yield servers[0].cli.execWithEnv(`npm run regenerate-thumbnails`); }); }); it('Should have generated new thumbnail files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield testThumbnail(servers[0], video1.uuid); yield testThumbnail(servers[0], video2.uuid); - const res = yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); - chai_1.expect(res.body).to.have.lengthOf(0); + const res = yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); + (0, chai_1.expect)(res.body).to.have.lengthOf(0); }); }); it('Should have deleted old thumbnail files', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { - yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, video1.thumbnailPath), models_1.HttpStatusCode.NOT_FOUND_404); + yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, video1.thumbnailPath), models_1.HttpStatusCode.NOT_FOUND_404); } { - yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, video2.thumbnailPath), models_1.HttpStatusCode.NOT_FOUND_404); + yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, video2.thumbnailPath), models_1.HttpStatusCode.NOT_FOUND_404); } { - const res = yield extra_utils_1.makeRawRequest(path_1.join(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); - chai_1.expect(res.body).to.have.lengthOf(0); + const res = yield (0, extra_utils_1.makeRawRequest)((0, path_1.join)(servers[0].url, remoteVideo.thumbnailPath), models_1.HttpStatusCode.OK_200); + (0, chai_1.expect)(res.body).to.have.lengthOf(0); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/cli/reset-password.js b/dist/server/tests/cli/reset-password.js index 373eb033..5a3c4345 100644 --- a/dist/server/tests/cli/reset-password.js +++ b/dist/server/tests/cli/reset-password.js @@ -6,15 +6,15 @@ const extra_utils_1 = require("../../../shared/extra-utils"); describe('Test reset password scripts', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.users.create({ username: 'user_1', password: 'super password' }); }); }); it('Should change the user password from CLI', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const env = server.cli.getEnv(); yield extra_utils_1.CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`); @@ -22,8 +22,8 @@ describe('Test reset password scripts', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/cli/update-host.js b/dist/server/tests/cli/update-host.js index 25766221..d3c68445 100644 --- a/dist/server/tests/cli/update-host.js +++ b/dist/server/tests/cli/update-host.js @@ -7,15 +7,15 @@ const extra_utils_1 = require("@shared/extra-utils"); describe('Test update host scripts', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); const overrideConfig = { webserver: { port: 9256 } }; - server = yield extra_utils_1.createSingleServer(2, overrideConfig); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(2, overrideConfig); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); const { uuid: video1UUID } = yield server.videos.upload(); yield server.videos.upload(); yield server.users.create({ username: 'toto', password: 'coucou' }); @@ -27,77 +27,77 @@ describe('Test update host scripts', function () { yield server.channels.create({ attributes: videoChannel }); const text = 'my super first comment'; yield server.comments.createThread({ videoId: video1UUID, text }); - yield extra_utils_1.waitJobs(server); + yield (0, extra_utils_1.waitJobs)(server); }); }); it('Should run update host', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - yield extra_utils_1.killallServers([server]); + yield (0, extra_utils_1.killallServers)([server]); yield server.run(); yield server.cli.execWithEnv(`npm run update-host`); }); }); it('Should have updated videos url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield server.videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); for (const video of data) { - const { body } = yield extra_utils_1.makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid); - chai_1.expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid); + const { body } = yield (0, extra_utils_1.makeActivityPubGetRequest)(server.url, '/videos/watch/' + video.uuid); + (0, chai_1.expect)(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid); const videoDetails = yield server.videos.get({ id: video.uuid }); - chai_1.expect(videoDetails.trackerUrls[0]).to.include(server.host); - chai_1.expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host); - chai_1.expect(videoDetails.streamingPlaylists[0].segmentsSha256Url).to.include(server.host); + (0, chai_1.expect)(videoDetails.trackerUrls[0]).to.include(server.host); + (0, chai_1.expect)(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host); + (0, chai_1.expect)(videoDetails.streamingPlaylists[0].segmentsSha256Url).to.include(server.host); } }); }); it('Should have updated video channels url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data, total } = yield server.channels.list({ sort: '-name' }); - chai_1.expect(total).to.equal(3); + (0, chai_1.expect)(total).to.equal(3); for (const channel of data) { - const { body } = yield extra_utils_1.makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name); - chai_1.expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name); + const { body } = yield (0, extra_utils_1.makeActivityPubGetRequest)(server.url, '/video-channels/' + channel.name); + (0, chai_1.expect)(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name); } }); }); it('Should have updated accounts url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.accounts.list(); - chai_1.expect(body.total).to.equal(3); + (0, chai_1.expect)(body.total).to.equal(3); for (const account of body.data) { const usernameWithDomain = account.name; - const { body } = yield extra_utils_1.makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain); - chai_1.expect(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain); + const { body } = yield (0, extra_utils_1.makeActivityPubGetRequest)(server.url, '/accounts/' + usernameWithDomain); + (0, chai_1.expect)(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain); } }); }); it('Should have updated torrent hosts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const { data } = yield server.videos.list(); - chai_1.expect(data).to.have.lengthOf(2); + (0, chai_1.expect)(data).to.have.lengthOf(2); for (const video of data) { const videoDetails = yield server.videos.get({ id: video.id }); const files = videoDetails.files.concat(videoDetails.streamingPlaylists[0].files); - chai_1.expect(files).to.have.lengthOf(8); + (0, chai_1.expect)(files).to.have.lengthOf(8); for (const file of files) { - chai_1.expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket'); - chai_1.expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F'); - const torrent = yield extra_utils_1.parseTorrentVideo(server, file); + (0, chai_1.expect)(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket'); + (0, chai_1.expect)(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F'); + const torrent = yield (0, extra_utils_1.parseTorrentVideo)(server, file); const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket'); - chai_1.expect(announceWS).to.not.be.undefined; + (0, chai_1.expect)(announceWS).to.not.be.undefined; const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce'); - chai_1.expect(announceHttp).to.not.be.undefined; - chai_1.expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/'); + (0, chai_1.expect)(announceHttp).to.not.be.undefined; + (0, chai_1.expect)(torrent.urlList[0]).to.contain('http://localhost:9002/static/'); } } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/client.js b/dist/server/tests/client.js index eee3772a..ad27bd6b 100644 --- a/dist/server/tests/client.js +++ b/dist/server/tests/client.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); const models_1 = require("@shared/models"); const extra_utils_1 = require("../../shared/extra-utils"); @@ -11,7 +11,7 @@ function checkIndexTags(html, title, description, css, config) { expect(html).to.contain('' + title + ''); expect(html).to.contain(''); expect(html).to.contain(''); - const htmlConfig = lodash_1.omit(config, 'signup'); + const htmlConfig = (0, lodash_1.omit)(config, 'signup'); const configObjectString = JSON.stringify(htmlConfig); const configEscapedString = JSON.stringify(configObjectString); expect(html).to.contain(``); @@ -31,12 +31,12 @@ describe('Test a client controllers', function () { let videoIds = []; let playlistIds = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].channels.update({ channelName: servers[0].store.channel.name, attributes: { description: channelDescription } @@ -65,15 +65,15 @@ describe('Test a client controllers', function () { yield servers[0].users.updateMe({ description: 'my account description' }); account = yield servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); describe('oEmbed', function () { it('Should have valid oEmbed discovery tags for videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of watchVideoBasePaths) { for (const id of videoIds) { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: basePath + id, accept: 'text/html', @@ -89,10 +89,10 @@ describe('Test a client controllers', function () { }); }); it('Should have valid oEmbed discovery tags for a playlist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of watchPlaylistBasePaths) { for (const id of playlistIds) { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: basePath + id, accept: 'text/html', @@ -110,8 +110,8 @@ describe('Test a client controllers', function () { }); describe('Open Graph', function () { function accountPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(``); expect(text).to.contain(``); @@ -120,8 +120,8 @@ describe('Test a client controllers', function () { }); } function channelPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(``); expect(text).to.contain(``); @@ -130,8 +130,8 @@ describe('Test a client controllers', function () { }); } function watchVideoPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(``); expect(text).to.contain(``); @@ -140,8 +140,8 @@ describe('Test a client controllers', function () { }); } function watchPlaylistPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(``); expect(text).to.contain(``); @@ -150,21 +150,21 @@ describe('Test a client controllers', function () { }); } it('Should have valid Open Graph tags on the account page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield accountPageTest('/accounts/' + servers[0].store.user.username); yield accountPageTest('/a/' + servers[0].store.user.username); yield accountPageTest('/@' + servers[0].store.user.username); }); }); it('Should have valid Open Graph tags on the channel page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield channelPageTest('/video-channels/' + servers[0].store.channel.name); yield channelPageTest('/c/' + servers[0].store.channel.name); yield channelPageTest('/@' + servers[0].store.channel.name); }); }); it('Should have valid Open Graph tags on the watch page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchVideoBasePaths) { for (const id of videoIds) { yield watchVideoPageTest(path + id); @@ -173,7 +173,7 @@ describe('Test a client controllers', function () { }); }); it('Should have valid Open Graph tags on the watch playlist page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchPlaylistBasePaths) { for (const id of playlistIds) { yield watchPlaylistPageTest(path + id); @@ -183,11 +183,11 @@ describe('Test a client controllers', function () { }); }); describe('Twitter card', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { describe('Not whitelisted', function () { function accountPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); @@ -196,8 +196,8 @@ describe('Test a client controllers', function () { }); } function channelPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); @@ -206,8 +206,8 @@ describe('Test a client controllers', function () { }); } function watchVideoPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); @@ -216,8 +216,8 @@ describe('Test a client controllers', function () { }); } function watchPlaylistPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); @@ -226,7 +226,7 @@ describe('Test a client controllers', function () { }); } it('Should have valid twitter card on the watch video page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchVideoBasePaths) { for (const id of videoIds) { yield watchVideoPageTest(path + id); @@ -235,7 +235,7 @@ describe('Test a client controllers', function () { }); }); it('Should have valid twitter card on the watch playlist page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchPlaylistBasePaths) { for (const id of playlistIds) { yield watchPlaylistPageTest(path + id); @@ -244,14 +244,14 @@ describe('Test a client controllers', function () { }); }); it('Should have valid twitter card on the account page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield accountPageTest('/accounts/' + account.name); yield accountPageTest('/a/' + account.name); yield accountPageTest('/@' + account.name); }); }); it('Should have valid twitter card on the channel page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield channelPageTest('/video-channels/' + servers[0].store.channel.name); yield channelPageTest('/c/' + servers[0].store.channel.name); yield channelPageTest('/@' + servers[0].store.channel.name); @@ -260,7 +260,7 @@ describe('Test a client controllers', function () { }); describe('Whitelisted', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield servers[0].config.getCustomConfig(); config.services.twitter = { username: '@Kuja', @@ -270,39 +270,39 @@ describe('Test a client controllers', function () { }); }); function accountPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); }); } function channelPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); }); } function watchVideoPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); }); } function watchPlaylistPageTest(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path, accept: 'text/html', expectedStatus: models_1.HttpStatusCode.OK_200 }); const text = res.text; expect(text).to.contain(''); expect(text).to.contain(''); }); } it('Should have valid twitter card on the watch video page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchVideoBasePaths) { for (const id of videoIds) { yield watchVideoPageTest(path + id); @@ -311,7 +311,7 @@ describe('Test a client controllers', function () { }); }); it('Should have valid twitter card on the watch playlist page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of watchPlaylistBasePaths) { for (const id of playlistIds) { yield watchPlaylistPageTest(path + id); @@ -320,14 +320,14 @@ describe('Test a client controllers', function () { }); }); it('Should have valid twitter card on the account page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield accountPageTest('/accounts/' + account.name); yield accountPageTest('/a/' + account.name); yield accountPageTest('/@' + account.name); }); }); it('Should have valid twitter card on the channel page', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield channelPageTest('/video-channels/' + servers[0].store.channel.name); yield channelPageTest('/c/' + servers[0].store.channel.name); yield channelPageTest('/@' + servers[0].store.channel.name); @@ -338,15 +338,15 @@ describe('Test a client controllers', function () { }); describe('Index HTML', function () { it('Should have valid index html tags (title, description...)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield servers[0].config.getConfig(); - const res = yield extra_utils_1.makeHTMLRequest(servers[0].url, '/videos/trending'); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, '/videos/trending'); const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'; checkIndexTags(res.text, 'PeerTube', description, '', config); }); }); it('Should update the customized configuration and have the correct index html tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.updateCustomSubConfig({ newConfig: { instance: { @@ -364,94 +364,94 @@ describe('Test a client controllers', function () { } }); const config = yield servers[0].config.getConfig(); - const res = yield extra_utils_1.makeHTMLRequest(servers[0].url, '/videos/trending'); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, '/videos/trending'); checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config); }); }); it('Should have valid index html updated tags (title, description...)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield servers[0].config.getConfig(); - const res = yield extra_utils_1.makeHTMLRequest(servers[0].url, '/videos/trending'); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, '/videos/trending'); checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config); }); }); it('Should use the original video URL for the canonical tag', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of watchVideoBasePaths) { for (const id of videoIds) { - const res = yield extra_utils_1.makeHTMLRequest(servers[1].url, basePath + id); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, basePath + id); expect(res.text).to.contain(``); } } }); }); it('Should use the original account URL for the canonical tag', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accountURLtest = res => { expect(res.text).to.contain(``); }; - accountURLtest(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/accounts/root@' + servers[0].host)); - accountURLtest(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/a/root@' + servers[0].host)); - accountURLtest(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/@root@' + servers[0].host)); + accountURLtest(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/accounts/root@' + servers[0].host)); + accountURLtest(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/a/root@' + servers[0].host)); + accountURLtest(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/@root@' + servers[0].host)); }); }); it('Should use the original channel URL for the canonical tag', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const channelURLtests = res => { expect(res.text).to.contain(``); }; - channelURLtests(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/video-channels/root_channel@' + servers[0].host)); - channelURLtests(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/c/root_channel@' + servers[0].host)); - channelURLtests(yield extra_utils_1.makeHTMLRequest(servers[1].url, '/@root_channel@' + servers[0].host)); + channelURLtests(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/video-channels/root_channel@' + servers[0].host)); + channelURLtests(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/c/root_channel@' + servers[0].host)); + channelURLtests(yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, '/@root_channel@' + servers[0].host)); }); }); it('Should use the original playlist URL for the canonical tag', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const basePath of watchPlaylistBasePaths) { for (const id of playlistIds) { - const res = yield extra_utils_1.makeHTMLRequest(servers[1].url, basePath + id); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, basePath + id); expect(res.text).to.contain(``); } } }); }); it('Should add noindex meta tag for remote accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root@' + servers[0].host; const paths = ['/accounts/', '/a/', '/@']; for (const path of paths) { { - const { text } = yield extra_utils_1.makeHTMLRequest(servers[1].url, path + handle); + const { text } = yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, path + handle); expect(text).to.contain(''); } { - const { text } = yield extra_utils_1.makeHTMLRequest(servers[0].url, path + handle); + const { text } = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, path + handle); expect(text).to.not.contain(''); } } }); }); it('Should add noindex meta tag for remote accounts', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const handle = 'root_channel@' + servers[0].host; const paths = ['/video-channels/', '/c/', '/@']; for (const path of paths) { { - const { text } = yield extra_utils_1.makeHTMLRequest(servers[1].url, path + handle); + const { text } = yield (0, extra_utils_1.makeHTMLRequest)(servers[1].url, path + handle); expect(text).to.contain(''); } { - const { text } = yield extra_utils_1.makeHTMLRequest(servers[0].url, path + handle); + const { text } = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, path + handle); expect(text).to.not.contain(''); } } }); }); it('Should add noindex header for some paths', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const paths = ['/about/peertube']; for (const path of paths) { - const { headers } = yield extra_utils_1.makeHTMLRequest(servers[0].url, path); + const { headers } = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, path); expect(headers['x-robots-tag']).to.equal('noindex'); } }); @@ -459,16 +459,16 @@ describe('Test a client controllers', function () { }); describe('Embed HTML', function () { it('Should have the correct embed html tags', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield servers[0].config.getConfig(); - const res = yield extra_utils_1.makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath); + const res = yield (0, extra_utils_1.makeHTMLRequest)(servers[0].url, servers[0].store.video.embedPath); checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/external-plugins/auth-ldap.js b/dist/server/tests/external-plugins/auth-ldap.js index 77fc071e..7211d90b 100644 --- a/dist/server/tests/external-plugins/auth-ldap.js +++ b/dist/server/tests/external-plugins/auth-ldap.js @@ -10,20 +10,20 @@ describe('Official plugin auth-ldap', function () { let accessToken; let userId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' }); }); }); it('Should not login with without LDAP settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should not login with bad LDAP settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.updateSettings({ npmName: 'peertube-plugin-auth-ldap', settings: { @@ -41,7 +41,7 @@ describe('Official plugin auth-ldap', function () { }); }); it('Should not login with good LDAP settings but wrong username/password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.updateSettings({ npmName: 'peertube-plugin-auth-ldap', settings: { @@ -60,30 +60,30 @@ describe('Official plugin auth-ldap', function () { }); }); it('Should login with the appropriate username/password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { accessToken = yield server.login.getAccessToken({ username: 'fry', password: 'fry' }); }); }); it('Should login with the appropriate email/password', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { accessToken = yield server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' }); }); }); it('Should login get my profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.users.getMyInfo({ token: accessToken }); - chai_1.expect(body.username).to.equal('fry'); - chai_1.expect(body.email).to.equal('fry@planetexpress.com'); + (0, chai_1.expect)(body.username).to.equal('fry'); + (0, chai_1.expect)(body.email).to.equal('fry@planetexpress.com'); userId = body.id; }); }); it('Should upload a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } }); }); }); it('Should not be able to login if the user is banned', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.banUser({ userId }); yield server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' }, @@ -92,13 +92,13 @@ describe('Official plugin auth-ldap', function () { }); }); it('Should be able to login if the user is unbanned', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.unbanUser({ userId }); yield server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }); }); }); it('Should not login if the plugin is uninstalled', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' }); yield server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' }, @@ -107,8 +107,8 @@ describe('Official plugin auth-ldap', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/external-plugins/auto-block-videos.js b/dist/server/tests/external-plugins/auto-block-videos.js index 3ea0898e..3b008920 100644 --- a/dist/server/tests/external-plugins/auto-block-videos.js +++ b/dist/server/tests/external-plugins/auto-block-videos.js @@ -5,13 +5,13 @@ require("mocha"); const chai_1 = require("chai"); const extra_utils_1 = require("@shared/extra-utils"); function check(server, videoUUID, exists = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.videos.list(); const video = data.find(v => v.uuid === videoUUID); if (exists) - chai_1.expect(video).to.not.be.undefined; + (0, chai_1.expect)(video).to.not.be.undefined; else - chai_1.expect(video).to.be.undefined; + (0, chai_1.expect)(video).to.be.undefined; }); } describe('Official plugin auto-block videos', function () { @@ -21,10 +21,10 @@ describe('Official plugin auto-block videos', function () { let server2Videos = []; let port; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); for (const server of servers) { yield server.plugins.install({ npmName: 'peertube-plugin-auto-block-videos' }); } @@ -42,11 +42,11 @@ describe('Official plugin auto-block videos', function () { const { data } = yield servers[1].videos.list(); server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })); } - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should update plugin settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-block-videos', settings: { @@ -57,7 +57,7 @@ describe('Official plugin auto-block videos', function () { }); }); it('Should auto block a video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield check(servers[0], server2Videos[0].uuid, true); blocklistServer.replace({ @@ -67,21 +67,21 @@ describe('Official plugin auto-block videos', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield check(servers[0], server2Videos[0].uuid, false); }); }); it('Should have video in blacklists', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].blacklist.list(); const videoBlacklists = body.data; - chai_1.expect(videoBlacklists).to.have.lengthOf(1); - chai_1.expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin'); - chai_1.expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name); + (0, chai_1.expect)(videoBlacklists).to.have.lengthOf(1); + (0, chai_1.expect)(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin'); + (0, chai_1.expect)(videoBlacklists[0].video.name).to.equal(server2Videos[0].name); }); }); it('Should not block a local video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield check(servers[0], server1Videos[0].uuid, true); blocklistServer.replace({ @@ -91,12 +91,12 @@ describe('Official plugin auto-block videos', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield check(servers[0], server1Videos[0].uuid, true); }); }); it('Should remove a video block', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield check(servers[0], server2Videos[0].uuid, false); blocklistServer.replace({ @@ -107,12 +107,12 @@ describe('Official plugin auto-block videos', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield check(servers[0], server2Videos[0].uuid, true); }); }); it('Should auto block a video, manually unblock it and do not reblock it automatically', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const video = server2Videos[1]; yield check(servers[0], video.uuid, true); @@ -124,20 +124,20 @@ describe('Official plugin auto-block videos', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield check(servers[0], video.uuid, false); yield servers[0].blacklist.remove({ videoId: video.uuid }); yield check(servers[0], video.uuid, true); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run(); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); yield check(servers[0], video.uuid, true); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield blocklistServer.terminate(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/external-plugins/auto-mute.js b/dist/server/tests/external-plugins/auto-mute.js index 5eb712b1..be77ccee 100644 --- a/dist/server/tests/external-plugins/auto-mute.js +++ b/dist/server/tests/external-plugins/auto-mute.js @@ -11,10 +11,10 @@ describe('Official plugin auto-mute', function () { let blocklistServer; let port; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); for (const server of servers) { yield server.plugins.install({ npmName: 'peertube-plugin-auto-mute' }); } @@ -22,11 +22,11 @@ describe('Official plugin auto-mute', function () { port = yield blocklistServer.initialize(); yield servers[0].videos.quickUpload({ name: 'video server 1' }); yield servers[1].videos.quickUpload({ name: 'video server 2' }); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); }); }); it('Should update plugin settings', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { @@ -37,7 +37,7 @@ describe('Official plugin auto-mute', function () { }); }); it('Should add a server blocklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); blocklistServer.replace({ data: [ @@ -46,13 +46,13 @@ describe('Official plugin auto-mute', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); }); }); it('Should remove a server blocklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); blocklistServer.replace({ data: [ @@ -62,13 +62,13 @@ describe('Official plugin auto-mute', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); }); }); it('Should add an account blocklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); blocklistServer.replace({ data: [ @@ -77,13 +77,13 @@ describe('Official plugin auto-mute', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); }); }); it('Should remove an account blocklist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); blocklistServer.replace({ data: [ @@ -93,13 +93,13 @@ describe('Official plugin auto-mute', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); }); }); it('Should auto mute an account, manually unmute it and do not remute it automatically', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); const account = 'root@localhost:' + servers[1].port; blocklistServer.replace({ @@ -110,28 +110,28 @@ describe('Official plugin auto-mute', function () { } ] }); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); { const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); } yield servers[0].blocklist.removeFromServerBlocklist({ account }); { const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); } - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run(); - yield extra_utils_1.wait(2000); + yield (0, extra_utils_1.wait)(2000); { const { total } = yield servers[0].videos.list(); - chai_1.expect(total).to.equal(2); + (0, chai_1.expect)(total).to.equal(2); } }); }); it('Should not expose the auto mute list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 @@ -139,7 +139,7 @@ describe('Official plugin auto-mute', function () { }); }); it('Should enable auto mute list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { @@ -148,7 +148,7 @@ describe('Official plugin auto-mute', function () { 'expose-mute-list': true } }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -156,7 +156,7 @@ describe('Official plugin auto-mute', function () { }); }); it('Should mute an account on server 1, and server 2 auto mutes it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(20000); yield servers[1].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', @@ -168,26 +168,26 @@ describe('Official plugin auto-mute', function () { }); yield servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }); yield servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port }); - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/auto-mute/router/api/v1/mute-list', expectedStatus: models_1.HttpStatusCode.OK_200 }); const data = res.body.data; - chai_1.expect(data).to.have.lengthOf(1); - chai_1.expect(data[0].updatedAt).to.exist; - chai_1.expect(data[0].value).to.equal('root@localhost:' + servers[1].port); - yield extra_utils_1.wait(2000); + (0, chai_1.expect)(data).to.have.lengthOf(1); + (0, chai_1.expect)(data[0].updatedAt).to.exist; + (0, chai_1.expect)(data[0].value).to.equal('root@localhost:' + servers[1].port); + yield (0, extra_utils_1.wait)(2000); for (const server of servers) { const { total } = yield server.videos.list(); - chai_1.expect(total).to.equal(1); + (0, chai_1.expect)(total).to.equal(1); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield blocklistServer.terminate(); - yield extra_utils_1.cleanupTests(servers); + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/feeds/feeds.js b/dist/server/tests/feeds/feeds.js index dcf610a9..aae1a7d0 100644 --- a/dist/server/tests/feeds/feeds.js +++ b/dist/server/tests/feeds/feeds.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const fast_xml_parser_1 = require("fast-xml-parser"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); @@ -20,18 +20,18 @@ describe('Test syndication feeds', () => { let userChannelId; let userFeedToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - servers = yield extra_utils_1.createMultipleServers(2); - serverHLSOnly = yield extra_utils_1.createSingleServer(3, { + servers = yield (0, extra_utils_1.createMultipleServers)(2); + serverHLSOnly = yield (0, extra_utils_1.createSingleServer)(3, { transcoding: { enabled: true, webtorrent: { enabled: false }, hls: { enabled: true } } }); - yield extra_utils_1.setAccessTokensToServers([...servers, serverHLSOnly]); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + yield (0, extra_utils_1.setAccessTokensToServers)([...servers, serverHLSOnly]); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); { const user = yield servers[0].users.getMyInfo(); rootAccountId = user.account.id; @@ -63,12 +63,12 @@ describe('Test syndication feeds', () => { const { id } = yield servers[0].videos.upload({ attributes }); yield servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); }); }); describe('All feed', function () { it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const feed of ['video-comments', 'videos']) { const rss = yield servers[0].feed.getXML({ feed }); expect(rss).xml.to.be.valid(); @@ -78,7 +78,7 @@ describe('Test syndication feeds', () => { }); }); it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const feed of ['video-comments', 'videos']) { const jsonText = yield servers[0].feed.getJSON({ feed }); expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }); @@ -86,8 +86,8 @@ describe('Test syndication feeds', () => { }); }); it('Should serve the endpoint with a classic request', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/feeds/videos.xml', accept: 'application/xml', @@ -96,8 +96,8 @@ describe('Test syndication feeds', () => { }); }); it('Should serve the endpoint as a cached request', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/feeds/videos.xml', accept: 'application/xml', @@ -107,8 +107,8 @@ describe('Test syndication feeds', () => { }); }); it('Should not serve the endpoint as a cached request', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/feeds/videos.xml?v=186', accept: 'application/xml', @@ -118,18 +118,18 @@ describe('Test syndication feeds', () => { }); }); it('Should refuse to serve the endpoint without accept header', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ url: servers[0].url, path: '/feeds/videos.xml', expectedStatus: models_1.HttpStatusCode.NOT_ACCEPTABLE_406 }); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/feeds/videos.xml', expectedStatus: models_1.HttpStatusCode.NOT_ACCEPTABLE_406 }); }); }); }); describe('Videos feed', function () { it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const rss = yield server.feed.getXML({ feed: 'videos' }); - expect(fast_xml_parser_1.validate(rss)).to.be.true; - const xmlDoc = fast_xml_parser_1.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }); + expect((0, fast_xml_parser_1.validate)(rss)).to.be.true; + const xmlDoc = (0, fast_xml_parser_1.parse)(rss, { parseAttributeValue: true, ignoreAttributes: false }); const enclosure = xmlDoc.rss.channel.item[0].enclosure; expect(enclosure).to.exist; expect(enclosure['@_type']).to.equal('application/x-bittorrent'); @@ -139,7 +139,7 @@ describe('Test syndication feeds', () => { }); }); it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const json = yield server.feed.getJSON({ feed: 'videos' }); const jsonObj = JSON.parse(json); @@ -153,7 +153,7 @@ describe('Test syndication feeds', () => { }); }); it('Should filter by account', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const json = yield servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }); const jsonObj = JSON.parse(json); @@ -185,7 +185,7 @@ describe('Test syndication feeds', () => { }); }); it('Should filter by video channel', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const json = yield servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }); const jsonObj = JSON.parse(json); @@ -219,10 +219,10 @@ describe('Test syndication feeds', () => { }); }); it('Should correctly have videos feed with HLS only', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } }); - yield extra_utils_1.waitJobs([serverHLSOnly]); + yield (0, extra_utils_1.waitJobs)([serverHLSOnly]); const json = yield serverHLSOnly.feed.getJSON({ feed: 'videos' }); const jsonObj = JSON.parse(json); expect(jsonObj.items.length).to.be.equal(1); @@ -238,7 +238,7 @@ describe('Test syndication feeds', () => { }); describe('Video comments feed', function () { it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { const json = yield server.feed.getJSON({ feed: 'video-comments' }); const jsonObj = JSON.parse(json); @@ -249,7 +249,7 @@ describe('Test syndication feeds', () => { }); }); it('Should not list comments from muted accounts or instances', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); const remoteHandle = 'root@localhost:' + servers[0].port; yield servers[1].blocklist.addToServerBlocklist({ account: remoteHandle }); @@ -261,9 +261,9 @@ describe('Test syndication feeds', () => { yield servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle }); { const videoUUID = (yield servers[1].videos.quickUpload({ name: 'server 2' })).uuid; - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const json = yield servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } }); const jsonObj = JSON.parse(json); expect(jsonObj.items.length).to.be.equal(3); @@ -281,7 +281,7 @@ describe('Test syndication feeds', () => { let feeduserAccountId; let feeduserFeedToken; it('Should list no videos for a user with no videos and no subscriptions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attr = { username: 'feeduser', password: 'password' }; yield servers[0].users.create({ username: attr.username, password: attr.password }); const feeduserAccessToken = yield servers[0].login.getAccessToken(attr); @@ -304,19 +304,19 @@ describe('Test syndication feeds', () => { }); }); it('Should fail with an invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { accountId: feeduserAccountId, token: 'toto' }; yield servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should fail with a token of another user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const query = { accountId: feeduserAccountId, token: userFeedToken }; yield servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should list no videos for a user with videos but no subscriptions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].subscriptions.listVideos({ token: userAccessToken }); expect(body.total).to.equal(0); const query = { accountId: userAccountId, token: userFeedToken }; @@ -326,10 +326,10 @@ describe('Test syndication feeds', () => { }); }); it('Should list self videos for a user with a subscription to themselves', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield servers[0].subscriptions.listVideos({ token: userAccessToken }); expect(body.total).to.equal(1); @@ -342,10 +342,10 @@ describe('Test syndication feeds', () => { }); }); it('Should list videos of a user\'s subscription', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield servers[0].subscriptions.listVideos({ token: userAccessToken }); expect(body.total).to.equal(2, "there should be 2 videos part of the subscription"); @@ -357,14 +357,14 @@ describe('Test syndication feeds', () => { }); }); it('Should renew the token, and so have an invalid old token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.renewMyScopedTokens({ token: userAccessToken }); const query = { accountId: userAccountId, token: userFeedToken, version: 3 }; yield servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should succeed with the new token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const token = yield servers[0].users.getMyScopedTokens({ token: userAccessToken }); userFeedToken = token.feedToken; const query = { accountId: userAccountId, token: userFeedToken, version: 4 }; @@ -373,8 +373,8 @@ describe('Test syndication feeds', () => { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([...servers, serverHLSOnly]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([...servers, serverHLSOnly]); }); }); }); diff --git a/dist/server/tests/helpers/comment-model.js b/dist/server/tests/helpers/comment-model.js index 22e0c6be..a3a72da0 100644 --- a/dist/server/tests/helpers/comment-model.js +++ b/dist/server/tests/helpers/comment-model.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const video_comment_1 = require("../../models/video/video-comment"); const expect = chai.expect; class CommentMock { @@ -13,7 +13,7 @@ class CommentMock { } describe('Comment model', function () { it('Should correctly extract mentions', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const comment = new CommentMock(); comment.text = '@florian @jean@localhost:9000 @flo @another@localhost:9000 @flo2@jean.com hello ' + 'email@localhost:9000 coucou.com no? @chocobozzz @chocobozzz @end'; diff --git a/dist/server/tests/helpers/core-utils.js b/dist/server/tests/helpers/core-utils.js index 145f1daf..e4d5c845 100644 --- a/dist/server/tests/helpers/core-utils.js +++ b/dist/server/tests/helpers/core-utils.js @@ -2,49 +2,49 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const lodash_1 = require("lodash"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const core_utils_1 = require("@shared/core-utils"); const core_utils_2 = require("../../helpers/core-utils"); const expect = chai.expect; describe('Parse Bytes', function () { it('Should pass when given valid value', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - expect(core_utils_2.parseBytes(1024)).to.be.eq(1024); - expect(core_utils_2.parseBytes(1048576)).to.be.eq(1048576); - expect(core_utils_2.parseBytes('1024')).to.be.eq(1024); - expect(core_utils_2.parseBytes('1048576')).to.be.eq(1048576); - expect(core_utils_2.parseBytes('1B')).to.be.eq(1024); - expect(core_utils_2.parseBytes('1MB')).to.be.eq(1048576); - expect(core_utils_2.parseBytes('1GB')).to.be.eq(1073741824); - expect(core_utils_2.parseBytes('1TB')).to.be.eq(1099511627776); - expect(core_utils_2.parseBytes('5GB')).to.be.eq(5368709120); - expect(core_utils_2.parseBytes('5TB')).to.be.eq(5497558138880); - expect(core_utils_2.parseBytes('1024B')).to.be.eq(1048576); - expect(core_utils_2.parseBytes('1024MB')).to.be.eq(1073741824); - expect(core_utils_2.parseBytes('1024GB')).to.be.eq(1099511627776); - expect(core_utils_2.parseBytes('1024TB')).to.be.eq(1125899906842624); - expect(core_utils_2.parseBytes('1 GB')).to.be.eq(1073741824); - expect(core_utils_2.parseBytes('1\tGB')).to.be.eq(1073741824); - expect(core_utils_2.parseBytes('1TB 1024MB')).to.be.eq(1100585369600); - expect(core_utils_2.parseBytes('4GB 1024MB')).to.be.eq(5368709120); - expect(core_utils_2.parseBytes('4TB 1024GB')).to.be.eq(5497558138880); - expect(core_utils_2.parseBytes('4TB 1024GB 0MB')).to.be.eq(5497558138880); - expect(core_utils_2.parseBytes('1024TB 1024GB 1024MB')).to.be.eq(1127000492212224); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + expect((0, core_utils_2.parseBytes)(1024)).to.be.eq(1024); + expect((0, core_utils_2.parseBytes)(1048576)).to.be.eq(1048576); + expect((0, core_utils_2.parseBytes)('1024')).to.be.eq(1024); + expect((0, core_utils_2.parseBytes)('1048576')).to.be.eq(1048576); + expect((0, core_utils_2.parseBytes)('1B')).to.be.eq(1024); + expect((0, core_utils_2.parseBytes)('1MB')).to.be.eq(1048576); + expect((0, core_utils_2.parseBytes)('1GB')).to.be.eq(1073741824); + expect((0, core_utils_2.parseBytes)('1TB')).to.be.eq(1099511627776); + expect((0, core_utils_2.parseBytes)('5GB')).to.be.eq(5368709120); + expect((0, core_utils_2.parseBytes)('5TB')).to.be.eq(5497558138880); + expect((0, core_utils_2.parseBytes)('1024B')).to.be.eq(1048576); + expect((0, core_utils_2.parseBytes)('1024MB')).to.be.eq(1073741824); + expect((0, core_utils_2.parseBytes)('1024GB')).to.be.eq(1099511627776); + expect((0, core_utils_2.parseBytes)('1024TB')).to.be.eq(1125899906842624); + expect((0, core_utils_2.parseBytes)('1 GB')).to.be.eq(1073741824); + expect((0, core_utils_2.parseBytes)('1\tGB')).to.be.eq(1073741824); + expect((0, core_utils_2.parseBytes)('1TB 1024MB')).to.be.eq(1100585369600); + expect((0, core_utils_2.parseBytes)('4GB 1024MB')).to.be.eq(5368709120); + expect((0, core_utils_2.parseBytes)('4TB 1024GB')).to.be.eq(5497558138880); + expect((0, core_utils_2.parseBytes)('4TB 1024GB 0MB')).to.be.eq(5497558138880); + expect((0, core_utils_2.parseBytes)('1024TB 1024GB 1024MB')).to.be.eq(1127000492212224); }); }); it('Should be invalid when given invalid value', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - expect(core_utils_2.parseBytes('6GB 1GB')).to.be.eq(6); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + expect((0, core_utils_2.parseBytes)('6GB 1GB')).to.be.eq(6); }); }); }); describe('Object', function () { it('Should convert an object', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { function keyConverter(k) { - return lodash_1.snakeCase(k); + return (0, lodash_1.snakeCase)(k); } function valueConverter(v) { if (validator_1.default.isNumeric(v + '')) @@ -69,7 +69,7 @@ describe('Object', function () { superKey4: 15 } }; - const res = core_utils_2.objectConverter(obj, keyConverter, valueConverter); + const res = (0, core_utils_2.objectConverter)(obj, keyConverter, valueConverter); expect(res.my_super_key).to.equal('hello'); expect(res.my_super_2_key).to.equal(45); expect(res.my_super_3_key.my_super_sub_key).to.equal(15); @@ -95,7 +95,7 @@ describe('Bitrate', function () { { resolution: 2160, ratio: 16 / 9, fps: 24, min: 25000, max: 30000 } ]; for (const test of tests) { - expect(core_utils_1.getMaxBitrate(test)).to.be.above(test.min * 1000).and.below(test.max * 1000); + expect((0, core_utils_1.getMaxBitrate)(test)).to.be.above(test.min * 1000).and.below(test.max * 1000); } }); it('Should get appropriate average bitrate', function () { @@ -108,7 +108,7 @@ describe('Bitrate', function () { { resolution: 2160, ratio: 16 / 9, fps: 24, min: 15000, max: 17000 } ]; for (const test of tests) { - expect(core_utils_1.getAverageBitrate(test)).to.be.above(test.min * 1000).and.below(test.max * 1000); + expect((0, core_utils_1.getAverageBitrate)(test)).to.be.above(test.min * 1000).and.below(test.max * 1000); } }); }); diff --git a/dist/server/tests/helpers/image.js b/dist/server/tests/helpers/image.js index 08310927..463f36c4 100644 --- a/dist/server/tests/helpers/image.js +++ b/dist/server/tests/helpers/image.js @@ -8,54 +8,54 @@ const path_1 = require("path"); const image_utils_1 = require("../../../server/helpers/image-utils"); const extra_utils_1 = require("../../../shared/extra-utils"); function checkBuffers(path1, path2, equals) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const [buf1, buf2] = yield Promise.all([ - fs_extra_1.readFile(path1), - fs_extra_1.readFile(path2) + (0, fs_extra_1.readFile)(path1), + (0, fs_extra_1.readFile)(path2) ]); if (equals) { - chai_1.expect(buf1.equals(buf2)).to.be.true; + (0, chai_1.expect)(buf1.equals(buf2)).to.be.true; } else { - chai_1.expect(buf1.equals(buf2)).to.be.false; + (0, chai_1.expect)(buf1.equals(buf2)).to.be.false; } }); } describe('Image helpers', function () { - const imageDestDir = path_1.join(extra_utils_1.root(), 'test-images'); - const imageDest = path_1.join(imageDestDir, 'test.jpg'); + const imageDestDir = (0, path_1.join)((0, extra_utils_1.root)(), 'test-images'); + const imageDest = (0, path_1.join)(imageDestDir, 'test.jpg'); const thumbnailSize = { width: 223, height: 122 }; it('Should skip processing if the source image is okay', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const input = extra_utils_1.buildAbsoluteFixturePath('thumbnail.jpg'); - yield image_utils_1.processImage(input, imageDest, thumbnailSize, true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const input = (0, extra_utils_1.buildAbsoluteFixturePath)('thumbnail.jpg'); + yield (0, image_utils_1.processImage)(input, imageDest, thumbnailSize, true); yield checkBuffers(input, imageDest, true); }); }); it('Should not skip processing if the source image does not have the appropriate extension', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const input = extra_utils_1.buildAbsoluteFixturePath('thumbnail.png'); - yield image_utils_1.processImage(input, imageDest, thumbnailSize, true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const input = (0, extra_utils_1.buildAbsoluteFixturePath)('thumbnail.png'); + yield (0, image_utils_1.processImage)(input, imageDest, thumbnailSize, true); yield checkBuffers(input, imageDest, false); }); }); it('Should not skip processing if the source image does not have the appropriate size', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const input = extra_utils_1.buildAbsoluteFixturePath('preview.jpg'); - yield image_utils_1.processImage(input, imageDest, thumbnailSize, true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const input = (0, extra_utils_1.buildAbsoluteFixturePath)('preview.jpg'); + yield (0, image_utils_1.processImage)(input, imageDest, thumbnailSize, true); yield checkBuffers(input, imageDest, false); }); }); it('Should not skip processing if the source image does not have the appropriate size', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const input = extra_utils_1.buildAbsoluteFixturePath('thumbnail-big.jpg'); - yield image_utils_1.processImage(input, imageDest, thumbnailSize, true); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const input = (0, extra_utils_1.buildAbsoluteFixturePath)('thumbnail-big.jpg'); + yield (0, image_utils_1.processImage)(input, imageDest, thumbnailSize, true); yield checkBuffers(input, imageDest, false); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield fs_extra_1.remove(imageDest); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, fs_extra_1.remove)(imageDest); }); }); }); diff --git a/dist/server/tests/helpers/request.js b/dist/server/tests/helpers/request.js index f45378d1..b911435b 100644 --- a/dist/server/tests/helpers/request.js +++ b/dist/server/tests/helpers/request.js @@ -8,12 +8,12 @@ const path_1 = require("path"); const extra_utils_1 = require("../../../shared/extra-utils"); const requests_1 = require("../../helpers/requests"); describe('Request helpers', function () { - const destPath1 = path_1.join(extra_utils_1.root(), 'test-output-1.txt'); - const destPath2 = path_1.join(extra_utils_1.root(), 'test-output-2.txt'); + const destPath1 = (0, path_1.join)((0, extra_utils_1.root)(), 'test-output-1.txt'); + const destPath2 = (0, path_1.join)((0, extra_utils_1.root)(), 'test-output-2.txt'); it('Should throw an error when the bytes limit is exceeded for request', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - yield requests_1.doRequest(extra_utils_1.FIXTURE_URLS.file4K, { bodyKBLimit: 3 }); + yield (0, requests_1.doRequest)(extra_utils_1.FIXTURE_URLS.file4K, { bodyKBLimit: 3 }); } catch (_a) { return; @@ -22,29 +22,29 @@ describe('Request helpers', function () { }); }); it('Should throw an error when the bytes limit is exceeded for request and save file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { - yield requests_1.doRequestAndSaveToFile(extra_utils_1.FIXTURE_URLS.file4K, destPath1, { bodyKBLimit: 3 }); + yield (0, requests_1.doRequestAndSaveToFile)(extra_utils_1.FIXTURE_URLS.file4K, destPath1, { bodyKBLimit: 3 }); } catch (_a) { - yield extra_utils_1.wait(500); - chai_1.expect(yield fs_extra_1.pathExists(destPath1)).to.be.false; + yield (0, extra_utils_1.wait)(500); + (0, chai_1.expect)(yield (0, fs_extra_1.pathExists)(destPath1)).to.be.false; return; } throw new Error('No error thrown by do request and save to file'); }); }); it('Should succeed if the file is below the limit', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield requests_1.doRequest(extra_utils_1.FIXTURE_URLS.file4K, { bodyKBLimit: 5 }); - yield requests_1.doRequestAndSaveToFile(extra_utils_1.FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }); - chai_1.expect(yield fs_extra_1.pathExists(destPath2)).to.be.true; + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, requests_1.doRequest)(extra_utils_1.FIXTURE_URLS.file4K, { bodyKBLimit: 5 }); + yield (0, requests_1.doRequestAndSaveToFile)(extra_utils_1.FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }); + (0, chai_1.expect)(yield (0, fs_extra_1.pathExists)(destPath2)).to.be.true; }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield fs_extra_1.remove(destPath1); - yield fs_extra_1.remove(destPath2); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, fs_extra_1.remove)(destPath1); + yield (0, fs_extra_1.remove)(destPath2); }); }); }); diff --git a/dist/server/tests/lib/index.js b/dist/server/tests/lib/index.js index 4c54dbfb..7d95a10c 100644 --- a/dist/server/tests/lib/index.js +++ b/dist/server/tests/lib/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-constant-registry-factory"), exports); +(0, tslib_1.__exportStar)(require("./video-constant-registry-factory"), exports); diff --git a/dist/server/tests/lib/video-constant-registry-factory.js b/dist/server/tests/lib/video-constant-registry-factory.js index f45a2e4a..38d120eb 100644 --- a/dist/server/tests/lib/video-constant-registry-factory.js +++ b/dist/server/tests/lib/video-constant-registry-factory.js @@ -13,111 +13,111 @@ describe('VideoConstantManagerFactory', function () { const videoCategoryManager = factory.createVideoConstantManager('category'); it('Should be able to list all video category constants', () => { const constants = videoCategoryManager.getConstants(); - chai_1.expect(constants).to.deep.equal(constants_1.VIDEO_CATEGORIES); + (0, chai_1.expect)(constants).to.deep.equal(constants_1.VIDEO_CATEGORIES); }); it('Should be able to delete a video category constant', () => { const successfullyDeleted = videoCategoryManager.deleteConstant(1); - chai_1.expect(successfullyDeleted).to.be.true; - chai_1.expect(videoCategoryManager.getConstantValue(1)).to.be.undefined; + (0, chai_1.expect)(successfullyDeleted).to.be.true; + (0, chai_1.expect)(videoCategoryManager.getConstantValue(1)).to.be.undefined; }); it('Should be able to add a video category constant', () => { const successfullyAdded = videoCategoryManager.addConstant(42, 'The meaning of life'); - chai_1.expect(successfullyAdded).to.be.true; - chai_1.expect(videoCategoryManager.getConstantValue(42)).to.equal('The meaning of life'); + (0, chai_1.expect)(successfullyAdded).to.be.true; + (0, chai_1.expect)(videoCategoryManager.getConstantValue(42)).to.equal('The meaning of life'); }); it('Should be able to reset video category constants', () => { videoCategoryManager.deleteConstant(1); videoCategoryManager.resetConstants(); - chai_1.expect(videoCategoryManager.getConstantValue(1)).not.be.undefined; + (0, chai_1.expect)(videoCategoryManager.getConstantValue(1)).not.be.undefined; }); }); describe('VideoLicenceManager', () => { const videoLicenceManager = factory.createVideoConstantManager('licence'); it('Should be able to list all video licence constants', () => { const constants = videoLicenceManager.getConstants(); - chai_1.expect(constants).to.deep.equal(constants_1.VIDEO_LICENCES); + (0, chai_1.expect)(constants).to.deep.equal(constants_1.VIDEO_LICENCES); }); it('Should be able to delete a video licence constant', () => { const successfullyDeleted = videoLicenceManager.deleteConstant(1); - chai_1.expect(successfullyDeleted).to.be.true; - chai_1.expect(videoLicenceManager.getConstantValue(1)).to.be.undefined; + (0, chai_1.expect)(successfullyDeleted).to.be.true; + (0, chai_1.expect)(videoLicenceManager.getConstantValue(1)).to.be.undefined; }); it('Should be able to add a video licence constant', () => { const successfullyAdded = videoLicenceManager.addConstant(42, 'European Union Public Licence'); - chai_1.expect(successfullyAdded).to.be.true; - chai_1.expect(videoLicenceManager.getConstantValue(42)).to.equal('European Union Public Licence'); + (0, chai_1.expect)(successfullyAdded).to.be.true; + (0, chai_1.expect)(videoLicenceManager.getConstantValue(42)).to.equal('European Union Public Licence'); }); it('Should be able to reset video licence constants', () => { videoLicenceManager.deleteConstant(1); videoLicenceManager.resetConstants(); - chai_1.expect(videoLicenceManager.getConstantValue(1)).not.be.undefined; + (0, chai_1.expect)(videoLicenceManager.getConstantValue(1)).not.be.undefined; }); }); describe('PlaylistPrivacyManager', () => { const playlistPrivacyManager = factory.createVideoConstantManager('playlistPrivacy'); it('Should be able to list all video playlist privacy constants', () => { const constants = playlistPrivacyManager.getConstants(); - chai_1.expect(constants).to.deep.equal(constants_1.VIDEO_PLAYLIST_PRIVACIES); + (0, chai_1.expect)(constants).to.deep.equal(constants_1.VIDEO_PLAYLIST_PRIVACIES); }); it('Should be able to delete a video playlist privacy constant', () => { const successfullyDeleted = playlistPrivacyManager.deleteConstant(1); - chai_1.expect(successfullyDeleted).to.be.true; - chai_1.expect(playlistPrivacyManager.getConstantValue(1)).to.be.undefined; + (0, chai_1.expect)(successfullyDeleted).to.be.true; + (0, chai_1.expect)(playlistPrivacyManager.getConstantValue(1)).to.be.undefined; }); it('Should be able to add a video playlist privacy constant', () => { const successfullyAdded = playlistPrivacyManager.addConstant(42, 'Friends only'); - chai_1.expect(successfullyAdded).to.be.true; - chai_1.expect(playlistPrivacyManager.getConstantValue(42)).to.equal('Friends only'); + (0, chai_1.expect)(successfullyAdded).to.be.true; + (0, chai_1.expect)(playlistPrivacyManager.getConstantValue(42)).to.equal('Friends only'); }); it('Should be able to reset video playlist privacy constants', () => { playlistPrivacyManager.deleteConstant(1); playlistPrivacyManager.resetConstants(); - chai_1.expect(playlistPrivacyManager.getConstantValue(1)).not.be.undefined; + (0, chai_1.expect)(playlistPrivacyManager.getConstantValue(1)).not.be.undefined; }); }); describe('VideoPrivacyManager', () => { const videoPrivacyManager = factory.createVideoConstantManager('privacy'); it('Should be able to list all video privacy constants', () => { const constants = videoPrivacyManager.getConstants(); - chai_1.expect(constants).to.deep.equal(constants_1.VIDEO_PRIVACIES); + (0, chai_1.expect)(constants).to.deep.equal(constants_1.VIDEO_PRIVACIES); }); it('Should be able to delete a video privacy constant', () => { const successfullyDeleted = videoPrivacyManager.deleteConstant(1); - chai_1.expect(successfullyDeleted).to.be.true; - chai_1.expect(videoPrivacyManager.getConstantValue(1)).to.be.undefined; + (0, chai_1.expect)(successfullyDeleted).to.be.true; + (0, chai_1.expect)(videoPrivacyManager.getConstantValue(1)).to.be.undefined; }); it('Should be able to add a video privacy constant', () => { const successfullyAdded = videoPrivacyManager.addConstant(42, 'Friends only'); - chai_1.expect(successfullyAdded).to.be.true; - chai_1.expect(videoPrivacyManager.getConstantValue(42)).to.equal('Friends only'); + (0, chai_1.expect)(successfullyAdded).to.be.true; + (0, chai_1.expect)(videoPrivacyManager.getConstantValue(42)).to.equal('Friends only'); }); it('Should be able to reset video privacy constants', () => { videoPrivacyManager.deleteConstant(1); videoPrivacyManager.resetConstants(); - chai_1.expect(videoPrivacyManager.getConstantValue(1)).not.be.undefined; + (0, chai_1.expect)(videoPrivacyManager.getConstantValue(1)).not.be.undefined; }); }); describe('VideoLanguageManager', () => { const videoLanguageManager = factory.createVideoConstantManager('language'); it('Should be able to list all video language constants', () => { const constants = videoLanguageManager.getConstants(); - chai_1.expect(constants).to.deep.equal(constants_1.VIDEO_LANGUAGES); + (0, chai_1.expect)(constants).to.deep.equal(constants_1.VIDEO_LANGUAGES); }); it('Should be able to add a video language constant', () => { const successfullyAdded = videoLanguageManager.addConstant('fr', 'Fr occitan'); - chai_1.expect(successfullyAdded).to.be.true; - chai_1.expect(videoLanguageManager.getConstantValue('fr')).to.equal('Fr occitan'); + (0, chai_1.expect)(successfullyAdded).to.be.true; + (0, chai_1.expect)(videoLanguageManager.getConstantValue('fr')).to.equal('Fr occitan'); }); it('Should be able to delete a video language constant', () => { videoLanguageManager.addConstant('fr', 'Fr occitan'); const successfullyDeleted = videoLanguageManager.deleteConstant('fr'); - chai_1.expect(successfullyDeleted).to.be.true; - chai_1.expect(videoLanguageManager.getConstantValue('fr')).to.be.undefined; + (0, chai_1.expect)(successfullyDeleted).to.be.true; + (0, chai_1.expect)(videoLanguageManager.getConstantValue('fr')).to.be.undefined; }); it('Should be able to reset video language constants', () => { videoLanguageManager.addConstant('fr', 'Fr occitan'); videoLanguageManager.resetConstants(); - chai_1.expect(videoLanguageManager.getConstantValue('fr')).to.be.undefined; + (0, chai_1.expect)(videoLanguageManager.getConstantValue('fr')).to.be.undefined; }); }); }); diff --git a/dist/server/tests/misc-endpoints.js b/dist/server/tests/misc-endpoints.js index bd451353..09ce7250 100644 --- a/dist/server/tests/misc-endpoints.js +++ b/dist/server/tests/misc-endpoints.js @@ -2,23 +2,23 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; describe('Test misc endpoints', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); }); }); describe('Test a well known endpoints', function () { it('Should get security.txt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/security.txt', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -27,8 +27,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get nodeinfo', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/nodeinfo', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -39,8 +39,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get dnt policy text', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/dnt-policy.txt', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -49,8 +49,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get dnt policy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/dnt', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -59,8 +59,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get change-password location', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/change-password', expectedStatus: models_1.HttpStatusCode.FOUND_302 @@ -69,10 +69,10 @@ describe('Test misc endpoints', function () { }); }); it('Should test webfinger', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resource = 'acct:peertube@' + server.host; const accountUrl = server.url + '/accounts/peertube'; - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/.well-known/webfinger?resource=' + resource, expectedStatus: models_1.HttpStatusCode.OK_200 @@ -92,8 +92,8 @@ describe('Test misc endpoints', function () { }); describe('Test classic static endpoints', function () { it('Should get robots.txt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/robots.txt', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -102,8 +102,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get security.txt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/security.txt', expectedStatus: models_1.HttpStatusCode.MOVED_PERMANENTLY_301 @@ -111,8 +111,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get nodeinfo', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/nodeinfo/2.0.json', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -125,8 +125,8 @@ describe('Test misc endpoints', function () { }); describe('Test bots endpoints', function () { it('Should get the empty sitemap', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/sitemap.xml', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -136,8 +136,8 @@ describe('Test misc endpoints', function () { }); }); it('Should get the empty cached sitemap', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/sitemap.xml', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -147,7 +147,7 @@ describe('Test misc endpoints', function () { }); }); it('Should add videos, channel and accounts and get sitemap', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(35000); yield server.videos.upload({ attributes: { name: 'video 1', nsfw: false } }); yield server.videos.upload({ attributes: { name: 'video 2', nsfw: false } }); @@ -156,7 +156,7 @@ describe('Test misc endpoints', function () { yield server.channels.create({ attributes: { name: 'channel2', displayName: 'channel 2' } }); yield server.users.create({ username: 'user1', password: 'password' }); yield server.users.create({ username: 'user2', password: 'password' }); - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: '/sitemap.xml?t=1', expectedStatus: models_1.HttpStatusCode.OK_200 @@ -174,8 +174,8 @@ describe('Test misc endpoints', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/action-hooks.js b/dist/server/tests/plugins/action-hooks.js index a13c96cb..ea1c45a9 100644 --- a/dist/server/tests/plugins/action-hooks.js +++ b/dist/server/tests/plugins/action-hooks.js @@ -11,13 +11,13 @@ describe('Test plugin action hooks', function () { return servers[0].servers.waitUntilLog('Run hook ' + hook); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); yield servers[0].plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath() }); - yield extra_utils_1.killallServers([servers[0]]); + yield (0, extra_utils_1.killallServers)([servers[0]]); yield servers[0].run({ live: { enabled: true @@ -27,27 +27,27 @@ describe('Test plugin action hooks', function () { }); describe('Application hooks', function () { it('Should run action:application.listening', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkHook('action:application.listening'); }); }); }); describe('Videos hooks', function () { it('Should run action:api.video.uploaded', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video' } }); videoUUID = uuid; yield checkHook('action:api.video.uploaded'); }); }); it('Should run action:api.video.updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.update({ id: videoUUID, attributes: { name: 'video updated' } }); yield checkHook('action:api.video.updated'); }); }); it('Should run action:api.video.viewed', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.view({ id: videoUUID }); yield checkHook('action:api.video.viewed'); }); @@ -55,7 +55,7 @@ describe('Test plugin action hooks', function () { }); describe('Live hooks', function () { it('Should run action:api.live-video.created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'live', privacy: 1, @@ -68,20 +68,20 @@ describe('Test plugin action hooks', function () { }); describe('Comments hooks', function () { it('Should run action:api.video-thread.created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const created = yield servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' }); threadId = created.id; yield checkHook('action:api.video-thread.created'); }); }); it('Should run action:api.video-comment-reply.created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' }); yield checkHook('action:api.video-comment-reply.created'); }); }); it('Should run action:api.video-comment.deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].comments.delete({ videoId: videoUUID, commentId: threadId }); yield checkHook('action:api.video-comment.deleted'); }); @@ -90,44 +90,44 @@ describe('Test plugin action hooks', function () { describe('Users hooks', function () { let userId; it('Should run action:api.user.registered', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.register({ username: 'registered_user' }); yield checkHook('action:api.user.registered'); }); }); it('Should run action:api.user.created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const user = yield servers[0].users.create({ username: 'created_user' }); userId = user.id; yield checkHook('action:api.user.created'); }); }); it('Should run action:api.user.oauth2-got-token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].login.login({ user: { username: 'created_user' } }); yield checkHook('action:api.user.oauth2-got-token'); }); }); it('Should run action:api.user.blocked', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.banUser({ userId }); yield checkHook('action:api.user.blocked'); }); }); it('Should run action:api.user.unblocked', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.unbanUser({ userId }); yield checkHook('action:api.user.unblocked'); }); }); it('Should run action:api.user.updated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.update({ userId, videoQuota: 50 }); yield checkHook('action:api.user.updated'); }); }); it('Should run action:api.user.deleted', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.remove({ userId }); yield checkHook('action:api.user.deleted'); }); @@ -137,7 +137,7 @@ describe('Test plugin action hooks', function () { let playlistId; let videoId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const { id } = yield servers[0].playlists.create({ attributes: { @@ -154,15 +154,15 @@ describe('Test plugin action hooks', function () { }); }); it('Should run action:api.video-playlist-element.created', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].playlists.addElement({ playlistId, attributes: { videoId } }); yield checkHook('action:api.video-playlist-element.created'); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/plugins/external-auth.js b/dist/server/tests/plugins/external-auth.js index 6a4e4fb1..ce34acac 100644 --- a/dist/server/tests/plugins/external-auth.js +++ b/dist/server/tests/plugins/external-auth.js @@ -6,7 +6,7 @@ const chai_1 = require("chai"); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); function loginExternal(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield options.server.plugins.getExternalAuth({ npmName: options.npmName, npmVersion: '0.0.1', @@ -17,7 +17,7 @@ function loginExternal(options) { if (res.status !== models_1.HttpStatusCode.FOUND_302) return; const location = res.header.location; - const { externalAuthToken } = extra_utils_1.decodeQueryString(location); + const { externalAuthToken } = (0, extra_utils_1.decodeQueryString)(location); const resLogin = yield options.server.login.loginUsingExternalToken({ username: options.username, externalAuthToken: externalAuthToken, @@ -34,28 +34,28 @@ describe('Test external auth plugins', function () { let kefkaRefreshToken; let externalAuthToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); for (const suffix of ['one', 'two', 'three']) { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-external-auth-' + suffix) }); } }); }); it('Should display the correct configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredExternalAuths; - chai_1.expect(auths).to.have.lengthOf(8); + (0, chai_1.expect)(auths).to.have.lengthOf(8); const auth2 = auths.find((a) => a.authName === 'external-auth-2'); - chai_1.expect(auth2).to.exist; - chai_1.expect(auth2.authDisplayName).to.equal('External Auth 2'); - chai_1.expect(auth2.npmName).to.equal('peertube-plugin-test-external-auth-one'); + (0, chai_1.expect)(auth2).to.exist; + (0, chai_1.expect)(auth2.authDisplayName).to.equal('External Auth 2'); + (0, chai_1.expect)(auth2.npmName).to.equal('peertube-plugin-test-external-auth-one'); }); }); it('Should redirect for a Cyan login', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield server.plugins.getExternalAuth({ npmName: 'test-external-auth-one', npmVersion: '0.0.1', @@ -66,31 +66,31 @@ describe('Test external auth plugins', function () { expectedStatus: models_1.HttpStatusCode.FOUND_302 }); const location = res.header.location; - chai_1.expect(location.startsWith('/login?')).to.be.true; - const searchParams = extra_utils_1.decodeQueryString(location); - chai_1.expect(searchParams.externalAuthToken).to.exist; - chai_1.expect(searchParams.username).to.equal('cyan'); + (0, chai_1.expect)(location.startsWith('/login?')).to.be.true; + const searchParams = (0, extra_utils_1.decodeQueryString)(location); + (0, chai_1.expect)(searchParams.externalAuthToken).to.exist; + (0, chai_1.expect)(searchParams.username).to.equal('cyan'); externalAuthToken = searchParams.externalAuthToken; }); }); it('Should reject auto external login with a missing or invalid token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = server.login; yield command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); yield command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should reject auto external login with a missing or invalid username', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = server.login; yield command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); yield command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should reject auto external login with an expired token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); yield server.login.loginUsingExternalToken({ username: 'cyan', externalAuthToken, @@ -100,7 +100,7 @@ describe('Test external auth plugins', function () { }); }); it('Should auto login Cyan, create the user and use the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const res = yield loginExternal({ server, @@ -116,15 +116,15 @@ describe('Test external auth plugins', function () { } { const body = yield server.users.getMyInfo({ token: cyanAccessToken }); - chai_1.expect(body.username).to.equal('cyan'); - chai_1.expect(body.account.displayName).to.equal('cyan'); - chai_1.expect(body.email).to.equal('cyan@example.com'); - chai_1.expect(body.role).to.equal(models_1.UserRole.USER); + (0, chai_1.expect)(body.username).to.equal('cyan'); + (0, chai_1.expect)(body.account.displayName).to.equal('cyan'); + (0, chai_1.expect)(body.email).to.equal('cyan@example.com'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.USER); } }); }); it('Should auto login Kefka, create the user and use the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const res = yield loginExternal({ server, @@ -137,21 +137,21 @@ describe('Test external auth plugins', function () { } { const body = yield server.users.getMyInfo({ token: kefkaAccessToken }); - chai_1.expect(body.username).to.equal('kefka'); - chai_1.expect(body.account.displayName).to.equal('Kefka Palazzo'); - chai_1.expect(body.email).to.equal('kefka@example.com'); - chai_1.expect(body.role).to.equal(models_1.UserRole.ADMINISTRATOR); + (0, chai_1.expect)(body.username).to.equal('kefka'); + (0, chai_1.expect)(body.account.displayName).to.equal('Kefka Palazzo'); + (0, chai_1.expect)(body.email).to.equal('kefka@example.com'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.ADMINISTRATOR); } }); }); it('Should refresh Cyan token, but not Kefka token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const resRefresh = yield server.login.refreshToken({ refreshToken: cyanRefreshToken }); cyanAccessToken = resRefresh.body.access_token; cyanRefreshToken = resRefresh.body.refresh_token; const body = yield server.users.getMyInfo({ token: cyanAccessToken }); - chai_1.expect(body.username).to.equal('cyan'); + (0, chai_1.expect)(body.username).to.equal('cyan'); } { yield server.login.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); @@ -159,30 +159,30 @@ describe('Test external auth plugins', function () { }); }); it('Should update Cyan profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: cyanAccessToken, displayName: 'Cyan Garamonde', description: 'Retainer to the king of Doma' }); const body = yield server.users.getMyInfo({ token: cyanAccessToken }); - chai_1.expect(body.account.displayName).to.equal('Cyan Garamonde'); - chai_1.expect(body.account.description).to.equal('Retainer to the king of Doma'); + (0, chai_1.expect)(body.account.displayName).to.equal('Cyan Garamonde'); + (0, chai_1.expect)(body.account.description).to.equal('Retainer to the king of Doma'); }); }); it('Should logout Cyan', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.logout({ token: cyanAccessToken }); }); }); it('Should have logged out Cyan', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.servers.waitUntilLog('On logout cyan'); yield server.users.getMyInfo({ token: cyanAccessToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should login Cyan and keep the old existing profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const res = yield loginExternal({ server, @@ -196,14 +196,14 @@ describe('Test external auth plugins', function () { cyanAccessToken = res.access_token; } const body = yield server.users.getMyInfo({ token: cyanAccessToken }); - chai_1.expect(body.username).to.equal('cyan'); - chai_1.expect(body.account.displayName).to.equal('Cyan Garamonde'); - chai_1.expect(body.account.description).to.equal('Retainer to the king of Doma'); - chai_1.expect(body.role).to.equal(models_1.UserRole.USER); + (0, chai_1.expect)(body.username).to.equal('cyan'); + (0, chai_1.expect)(body.account.displayName).to.equal('Cyan Garamonde'); + (0, chai_1.expect)(body.account.description).to.equal('Retainer to the king of Doma'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.USER); }); }); it('Should not update an external auth email', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: cyanAccessToken, email: 'toto@example.com', @@ -213,14 +213,14 @@ describe('Test external auth plugins', function () { }); }); it('Should reject token of Kefka by the plugin hook', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); yield server.users.getMyInfo({ token: kefkaAccessToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should unregister external-auth-2 and do not login existing Kefka', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.updateSettings({ npmName: 'peertube-plugin-test-external-auth-one', settings: { disableKefka: true } @@ -239,16 +239,16 @@ describe('Test external auth plugins', function () { }); }); it('Should have disabled this auth', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredExternalAuths; - chai_1.expect(auths).to.have.lengthOf(7); + (0, chai_1.expect)(auths).to.have.lengthOf(7); const auth1 = auths.find(a => a.authName === 'external-auth-2'); - chai_1.expect(auth1).to.not.exist; + (0, chai_1.expect)(auth1).to.not.exist; }); }); it('Should uninstall the plugin one and do not login Cyan', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' }); yield loginExternal({ server, @@ -266,7 +266,7 @@ describe('Test external auth plugins', function () { }); }); it('Should not login kefka with another plugin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield loginExternal({ server, npmName: 'test-external-auth-two', @@ -284,7 +284,7 @@ describe('Test external auth plugins', function () { }); }); it('Should not login an existing user', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.create({ username: 'existing_user', password: 'super_password' }); yield loginExternal({ server, @@ -296,21 +296,21 @@ describe('Test external auth plugins', function () { }); }); it('Should display the correct configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredExternalAuths; - chai_1.expect(auths).to.have.lengthOf(6); + (0, chai_1.expect)(auths).to.have.lengthOf(6); const auth2 = auths.find((a) => a.authName === 'external-auth-2'); - chai_1.expect(auth2).to.not.exist; + (0, chai_1.expect)(auth2).to.not.exist; }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); it('Should forward the redirectUrl if the plugin returns one', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resLogin = yield loginExternal({ server, npmName: 'test-external-auth-three', @@ -318,11 +318,11 @@ describe('Test external auth plugins', function () { username: 'cid' }); const { redirectUrl } = yield server.login.logout({ token: resLogin.access_token }); - chai_1.expect(redirectUrl).to.equal('https://example.com/redirectUrl'); + (0, chai_1.expect)(redirectUrl).to.equal('https://example.com/redirectUrl'); }); }); it('Should call the plugin\'s onLogout method with the request', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const resLogin = yield loginExternal({ server, npmName: 'test-external-auth-three', @@ -330,7 +330,7 @@ describe('Test external auth plugins', function () { username: 'cid' }); const { redirectUrl } = yield server.login.logout({ token: resLogin.access_token }); - chai_1.expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token); + (0, chai_1.expect)(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token); }); }); }); diff --git a/dist/server/tests/plugins/filter-hooks.js b/dist/server/tests/plugins/filter-hooks.js index 216bfbe0..c5301c0d 100644 --- a/dist/server/tests/plugins/filter-hooks.js +++ b/dist/server/tests/plugins/filter-hooks.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; @@ -11,12 +11,12 @@ describe('Test plugin filter hooks', function () { let videoUUID; let threadId; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.setDefaultVideoChannel(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.setDefaultVideoChannel)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath() }); yield servers[0].plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-filter-translations') }); for (let i = 0; i < 10; i++) { @@ -39,66 +39,66 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.videos.list.params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.list({ start: 0, count: 2 }); expect(data).to.have.lengthOf(4); }); }); it('Should run filter:api.videos.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].videos.list({ start: 0, count: 0 }); expect(total).to.equal(11); }); }); it('Should run filter:api.accounts.videos.list.params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }); expect(data).to.have.lengthOf(3); }); }); it('Should run filter:api.accounts.videos.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }); expect(total).to.equal(12); }); }); it('Should run filter:api.video-channels.videos.list.params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }); expect(data).to.have.lengthOf(5); }); }); it('Should run filter:api.video-channels.videos.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }); expect(total).to.equal(13); }); }); it('Should run filter:api.user.me.videos.list.params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].videos.listMyVideos({ start: 0, count: 2 }); expect(data).to.have.lengthOf(6); }); }); it('Should run filter:api.user.me.videos.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].videos.listMyVideos({ start: 0, count: 2 }); expect(total).to.equal(14); }); }); it('Should run filter:api.video.get.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield servers[0].videos.get({ id: videoUUID }); expect(video.name).to.contain('<3'); }); }); it('Should run filter:api.video.upload.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: models_1.HttpStatusCode.FORBIDDEN_403 }); }); }); it('Should run filter:api.live-video.create.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'video with bad word', privacy: 1, @@ -108,7 +108,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video.pre-import-url.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'normal title', privacy: 1, @@ -119,7 +119,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video.pre-import-torrent.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'bad torrent', privacy: 1, @@ -130,7 +130,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video.post-import-url.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); let videoImportId; { @@ -143,7 +143,7 @@ describe('Test plugin filter hooks', function () { const body = yield servers[0].imports.importVideo({ attributes }); videoImportId = body.id; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const body = yield servers[0].imports.getMyVideoImports(); const videoImports = body.data; @@ -154,7 +154,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video.post-import-torrent.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); let videoImportId; { @@ -167,7 +167,7 @@ describe('Test plugin filter hooks', function () { const body = yield servers[0].imports.importVideo({ attributes }); videoImportId = body.id; } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); { const { data: videoImports } = yield servers[0].imports.getMyVideoImports(); const videoImport = videoImports.find(i => i.id === videoImportId); @@ -177,7 +177,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video-thread.create.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].comments.createThread({ videoId: videoUUID, text: 'comment with bad word', @@ -186,7 +186,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video-comment-reply.create.accept.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const created = yield servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' }); threadId = created.id; yield servers[0].comments.addReply({ @@ -204,26 +204,26 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.video-threads.list.params', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 }); expect(data).to.have.lengthOf(1); }); }); it('Should run filter:api.video-threads.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total } = yield servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 }); expect(total).to.equal(2); }); }); it('Should run filter:api.video-thread-comments.list.params'); it('Should run filter:api.video-thread-comments.list.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const thread = yield servers[0].comments.getThread({ videoId: videoUUID, threadId }); expect(thread.comment.text.endsWith(' <3')).to.be.true; }); }); it('Should run filter:api.overviews.videos.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].overviews.getVideos({ page: 1 }); yield servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3); yield servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3); @@ -231,19 +231,19 @@ describe('Test plugin filter hooks', function () { }); describe('Should run filter:video.auto-blacklist.result', function () { function checkIsBlacklisted(id, value) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield servers[0].videos.getWithToken({ id }); expect(video.blacklisted).to.equal(value); }); } it('Should blacklist on upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } }); yield checkIsBlacklisted(uuid, true); }); }); it('Should blacklist on import', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(15000); const attributes = { name: 'video please blacklist me', @@ -255,7 +255,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should blacklist on update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { uuid } = yield servers[0].videos.upload({ attributes: { name: 'video' } }); yield checkIsBlacklisted(uuid, false); yield servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } }); @@ -263,39 +263,39 @@ describe('Test plugin filter hooks', function () { }); }); it('Should blacklist on remote upload', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkIsBlacklisted(uuid, true); }); }); it('Should blacklist on remote update', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); const { uuid } = yield servers[1].videos.upload({ attributes: { name: 'video' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkIsBlacklisted(uuid, false); yield servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); yield checkIsBlacklisted(uuid, true); }); }); }); describe('Should run filter:api.user.signup.allowed.result', function () { it('Should run on config endpoint', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield servers[0].config.getConfig(); expect(body.signup.allowed).to.be.true; }); }); it('Should allow a signup', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].users.register({ username: 'john', password: 'password' }); }); }); it('Should not allow a signup', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield servers[0].users.register({ username: 'jma', password: 'password', @@ -308,7 +308,7 @@ describe('Test plugin filter hooks', function () { describe('Download hooks', function () { const downloadVideos = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(120000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -327,34 +327,34 @@ describe('Test plugin filter hooks', function () { const uuid = (yield servers[0].videos.quickUpload({ name: name })).uuid; uuids.push(uuid); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const uuid of uuids) { downloadVideos.push(yield servers[0].videos.get({ id: uuid })); } }); }); it('Should run filter:api.download.torrent.allowed.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeRawRequest(downloadVideos[0].files[0].torrentDownloadUrl, 403); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeRawRequest)(downloadVideos[0].files[0].torrentDownloadUrl, 403); expect(res.body.error).to.equal('Liu Bei'); - yield extra_utils_1.makeRawRequest(downloadVideos[1].files[0].torrentDownloadUrl, 200); - yield extra_utils_1.makeRawRequest(downloadVideos[2].files[0].torrentDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[1].files[0].torrentDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[2].files[0].torrentDownloadUrl, 200); }); }); it('Should run filter:api.download.video.allowed.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { - const res = yield extra_utils_1.makeRawRequest(downloadVideos[1].files[0].fileDownloadUrl, 403); + const res = yield (0, extra_utils_1.makeRawRequest)(downloadVideos[1].files[0].fileDownloadUrl, 403); expect(res.body.error).to.equal('Cao Cao'); - yield extra_utils_1.makeRawRequest(downloadVideos[0].files[0].fileDownloadUrl, 200); - yield extra_utils_1.makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[0].files[0].fileDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[2].files[0].fileDownloadUrl, 200); } { - const res = yield extra_utils_1.makeRawRequest(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403); + const res = yield (0, extra_utils_1.makeRawRequest)(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403); expect(res.body.error).to.equal('Sun Jian'); - yield extra_utils_1.makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200); - yield extra_utils_1.makeRawRequest(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200); - yield extra_utils_1.makeRawRequest(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[2].files[0].fileDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200); + yield (0, extra_utils_1.makeRawRequest)(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200); } }); }); @@ -363,7 +363,7 @@ describe('Test plugin filter hooks', function () { const embedVideos = []; const embedPlaylists = []; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); yield servers[0].config.updateCustomSubConfig({ newConfig: { @@ -387,21 +387,21 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:html.embed.video.allowed.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeRawRequest(servers[0].url + embedVideos[0].embedPath, 200); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeRawRequest)(servers[0].url + embedVideos[0].embedPath, 200); expect(res.text).to.equal('Lu Bu'); }); }); it('Should run filter:html.embed.video-playlist.allowed.result', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeRawRequest(servers[0].url + embedPlaylists[0].embedPath, 200); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeRawRequest)(servers[0].url + embedPlaylists[0].embedPath, 200); expect(res.text).to.equal('Diao Chan'); }); }); }); describe('Search filters', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].config.updateCustomSubConfig({ newConfig: { search: { @@ -416,7 +416,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.videos.local.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedVideoSearch({ search: { search: 'Sun Quan' @@ -427,7 +427,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.videos.index.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedVideoSearch({ search: { search: 'Sun Quan', @@ -441,7 +441,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.video-channels.local.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedChannelSearch({ search: { search: 'Sun Ce' @@ -452,7 +452,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.video-channels.index.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedChannelSearch({ search: { search: 'Sun Ce', @@ -466,7 +466,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.video-playlists.local.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedPlaylistSearch({ search: { search: 'Sun Jian' @@ -477,7 +477,7 @@ describe('Test plugin filter hooks', function () { }); }); it('Should run filter:api.search.video-playlists.index.list.{params,result}', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].search.advancedPlaylistSearch({ search: { search: 'Sun Jian', @@ -492,8 +492,8 @@ describe('Test plugin filter hooks', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/plugins/html-injection.js b/dist/server/tests/plugins/html-injection.js index 33e89078..b6b14002 100644 --- a/dist/server/tests/plugins/html-injection.js +++ b/dist/server/tests/plugins/html-injection.js @@ -2,66 +2,66 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("../../../shared/extra-utils"); const expect = chai.expect; describe('Test plugins HTML injection', function () { let server = null; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); command = server.plugins; }); }); it('Should not inject global css file in HTML', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const text = yield command.getCSS(); expect(text).to.be.empty; } for (const path of ['/', '/videos/embed/1', '/video-playlists/embed/1']) { - const res = yield extra_utils_1.makeHTMLRequest(server.url, path); + const res = yield (0, extra_utils_1.makeHTMLRequest)(server.url, path); expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css'); } }); }); it('Should install a plugin and a theme', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); yield command.install({ npmName: 'peertube-plugin-hello-world' }); }); }); it('Should have the correct global css', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const text = yield command.getCSS(); expect(text).to.contain('background-color: red'); } for (const path of ['/', '/videos/embed/1', '/video-playlists/embed/1']) { - const res = yield extra_utils_1.makeHTMLRequest(server.url, path); + const res = yield (0, extra_utils_1.makeHTMLRequest)(server.url, path); expect(res.text).to.include('link rel="stylesheet" href="/plugins/global.css'); } }); }); it('Should have an empty global css on uninstall', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.uninstall({ npmName: 'peertube-plugin-hello-world' }); { const text = yield command.getCSS(); expect(text).to.be.empty; } for (const path of ['/', '/videos/embed/1', '/video-playlists/embed/1']) { - const res = yield extra_utils_1.makeHTMLRequest(server.url, path); + const res = yield (0, extra_utils_1.makeHTMLRequest)(server.url, path); expect(res.text).to.not.include('link rel="stylesheet" href="/plugins/global.css'); } }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/id-and-pass-auth.js b/dist/server/tests/plugins/id-and-pass-auth.js index 21d8e998..c891a8f6 100644 --- a/dist/server/tests/plugins/id-and-pass-auth.js +++ b/dist/server/tests/plugins/id-and-pass-auth.js @@ -12,42 +12,42 @@ describe('Test id and pass auth plugins', function () { let lagunaAccessToken; let lagunaRefreshToken; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); for (const suffix of ['one', 'two', 'three']) { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) }); } }); }); it('Should display the correct configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredIdAndPassAuths; - chai_1.expect(auths).to.have.lengthOf(8); + (0, chai_1.expect)(auths).to.have.lengthOf(8); const crashAuth = auths.find(a => a.authName === 'crash-auth'); - chai_1.expect(crashAuth).to.exist; - chai_1.expect(crashAuth.npmName).to.equal('peertube-plugin-test-id-pass-auth-one'); - chai_1.expect(crashAuth.weight).to.equal(50); + (0, chai_1.expect)(crashAuth).to.exist; + (0, chai_1.expect)(crashAuth.npmName).to.equal('peertube-plugin-test-id-pass-auth-one'); + (0, chai_1.expect)(crashAuth.weight).to.equal(50); }); }); it('Should not login', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.login({ user: { username: 'toto', password: 'password' }, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should login Spyro, create the user and use the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const accessToken = yield server.login.getAccessToken({ username: 'spyro', password: 'spyro password' }); const body = yield server.users.getMyInfo({ token: accessToken }); - chai_1.expect(body.username).to.equal('spyro'); - chai_1.expect(body.account.displayName).to.equal('Spyro the Dragon'); - chai_1.expect(body.role).to.equal(models_1.UserRole.USER); + (0, chai_1.expect)(body.username).to.equal('spyro'); + (0, chai_1.expect)(body.account.displayName).to.equal('Spyro the Dragon'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.USER); }); }); it('Should login Crash, create the user and use the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield server.login.login({ user: { username: 'crash', password: 'crash password' } }); crashAccessToken = body.access_token; @@ -55,14 +55,14 @@ describe('Test id and pass auth plugins', function () { } { const body = yield server.users.getMyInfo({ token: crashAccessToken }); - chai_1.expect(body.username).to.equal('crash'); - chai_1.expect(body.account.displayName).to.equal('Crash Bandicoot'); - chai_1.expect(body.role).to.equal(models_1.UserRole.MODERATOR); + (0, chai_1.expect)(body.username).to.equal('crash'); + (0, chai_1.expect)(body.account.displayName).to.equal('Crash Bandicoot'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.MODERATOR); } }); }); it('Should login the first Laguna, create the user and use the token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const body = yield server.login.login({ user: { username: 'laguna', password: 'laguna password' } }); lagunaAccessToken = body.access_token; @@ -70,20 +70,20 @@ describe('Test id and pass auth plugins', function () { } { const body = yield server.users.getMyInfo({ token: lagunaAccessToken }); - chai_1.expect(body.username).to.equal('laguna'); - chai_1.expect(body.account.displayName).to.equal('laguna'); - chai_1.expect(body.role).to.equal(models_1.UserRole.USER); + (0, chai_1.expect)(body.username).to.equal('laguna'); + (0, chai_1.expect)(body.account.displayName).to.equal('laguna'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.USER); } }); }); it('Should refresh crash token, but not laguna token', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { { const resRefresh = yield server.login.refreshToken({ refreshToken: crashRefreshToken }); crashAccessToken = resRefresh.body.access_token; crashRefreshToken = resRefresh.body.refresh_token; const body = yield server.users.getMyInfo({ token: crashAccessToken }); - chai_1.expect(body.username).to.equal('crash'); + (0, chai_1.expect)(body.username).to.equal('crash'); } { yield server.login.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); @@ -91,47 +91,47 @@ describe('Test id and pass auth plugins', function () { }); }); it('Should update Crash profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.users.updateMe({ token: crashAccessToken, displayName: 'Beautiful Crash', description: 'Mutant eastern barred bandicoot' }); const body = yield server.users.getMyInfo({ token: crashAccessToken }); - chai_1.expect(body.account.displayName).to.equal('Beautiful Crash'); - chai_1.expect(body.account.description).to.equal('Mutant eastern barred bandicoot'); + (0, chai_1.expect)(body.account.displayName).to.equal('Beautiful Crash'); + (0, chai_1.expect)(body.account.description).to.equal('Mutant eastern barred bandicoot'); }); }); it('Should logout Crash', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.login.logout({ token: crashAccessToken }); }); }); it('Should have logged out Crash', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.servers.waitUntilLog('On logout for auth 1 - 2'); yield server.users.getMyInfo({ token: crashAccessToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should login Crash and keep the old existing profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { crashAccessToken = yield server.login.getAccessToken({ username: 'crash', password: 'crash password' }); const body = yield server.users.getMyInfo({ token: crashAccessToken }); - chai_1.expect(body.username).to.equal('crash'); - chai_1.expect(body.account.displayName).to.equal('Beautiful Crash'); - chai_1.expect(body.account.description).to.equal('Mutant eastern barred bandicoot'); - chai_1.expect(body.role).to.equal(models_1.UserRole.MODERATOR); + (0, chai_1.expect)(body.username).to.equal('crash'); + (0, chai_1.expect)(body.account.displayName).to.equal('Beautiful Crash'); + (0, chai_1.expect)(body.account.description).to.equal('Mutant eastern barred bandicoot'); + (0, chai_1.expect)(body.role).to.equal(models_1.UserRole.MODERATOR); }); }); it('Should reject token of laguna by the plugin hook', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); - yield extra_utils_1.wait(5000); + yield (0, extra_utils_1.wait)(5000); yield server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: models_1.HttpStatusCode.UNAUTHORIZED_401 }); }); }); it('Should reject an invalid username, email, role or display name', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = server.login; yield command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); yield server.servers.waitUntilLog('valid username'); @@ -144,7 +144,7 @@ describe('Test id and pass auth plugins', function () { }); }); it('Should unregister spyro-auth and do not login existing Spyro', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.updateSettings({ npmName: 'peertube-plugin-test-id-pass-auth-one', settings: { disableSpyro: true } @@ -155,16 +155,16 @@ describe('Test id and pass auth plugins', function () { }); }); it('Should have disabled this auth', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredIdAndPassAuths; - chai_1.expect(auths).to.have.lengthOf(7); + (0, chai_1.expect)(auths).to.have.lengthOf(7); const spyroAuth = auths.find(a => a.authName === 'spyro-auth'); - chai_1.expect(spyroAuth).to.not.exist; + (0, chai_1.expect)(spyroAuth).to.not.exist; }); }); it('Should uninstall the plugin one and do not login existing Crash', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' }); yield server.login.login({ user: { username: 'crash', password: 'crash password' }, @@ -173,28 +173,28 @@ describe('Test id and pass auth plugins', function () { }); }); it('Should display the correct configuration', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); const auths = config.plugin.registeredIdAndPassAuths; - chai_1.expect(auths).to.have.lengthOf(6); + (0, chai_1.expect)(auths).to.have.lengthOf(6); const crashAuth = auths.find(a => a.authName === 'crash-auth'); - chai_1.expect(crashAuth).to.not.exist; + (0, chai_1.expect)(crashAuth).to.not.exist; }); }); it('Should display plugin auth information in users list', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield server.users.list(); const root = data.find(u => u.username === 'root'); const crash = data.find(u => u.username === 'crash'); const laguna = data.find(u => u.username === 'laguna'); - chai_1.expect(root.pluginAuth).to.be.null; - chai_1.expect(crash.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-one'); - chai_1.expect(laguna.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-two'); + (0, chai_1.expect)(root.pluginAuth).to.be.null; + (0, chai_1.expect)(crash.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-one'); + (0, chai_1.expect)(laguna.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-two'); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/plugin-helpers.js b/dist/server/tests/plugins/plugin-helpers.js index c1943e67..4220568f 100644 --- a/dist/server/tests/plugins/plugin-helpers.js +++ b/dist/server/tests/plugins/plugin-helpers.js @@ -9,7 +9,7 @@ function postCommand(server, command, bodyArg) { const body = { command }; if (bodyArg) Object.assign(body, bodyArg); - return extra_utils_1.makePostBodyRequest({ + return (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: '/plugins/test-four/router/commander', fields: body, @@ -19,17 +19,17 @@ function postCommand(server, command, bodyArg) { describe('Test plugin helpers', function () { let servers; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - servers = yield extra_utils_1.createMultipleServers(2); - yield extra_utils_1.setAccessTokensToServers(servers); - yield extra_utils_1.doubleFollow(servers[0], servers[1]); + servers = yield (0, extra_utils_1.createMultipleServers)(2); + yield (0, extra_utils_1.setAccessTokensToServers)(servers); + yield (0, extra_utils_1.doubleFollow)(servers[0], servers[1]); yield servers[0].plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-four') }); }); }); describe('Logger', function () { it('Should have logged things', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].servers.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false); yield servers[0].servers.waitUntilLog('Hello world from plugin four', 1); }); @@ -37,63 +37,63 @@ describe('Test plugin helpers', function () { }); describe('Database', function () { it('Should have made a query', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].servers.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`); }); }); }); describe('Config', function () { it('Should have the correct webserver url', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].servers.waitUntilLog(`server url is http://localhost:${servers[0].port}`); }); }); it('Should have the correct config', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/test-four/router/server-config', expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.serverConfig).to.exist; - chai_1.expect(res.body.serverConfig.instance.name).to.equal('PeerTube'); + (0, chai_1.expect)(res.body.serverConfig).to.exist; + (0, chai_1.expect)(res.body.serverConfig.instance.name).to.equal('PeerTube'); }); }); }); describe('Server', function () { it('Should get the server actor', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].servers.waitUntilLog('server actor name is peertube'); }); }); }); describe('Plugin', function () { it('Should get the base static route', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/test-four/router/static-route', expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/'); + (0, chai_1.expect)(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/'); }); }); it('Should get the base static route', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const baseRouter = '/plugins/test-four/0.0.1/router/'; - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: baseRouter + 'router-route', expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.routerRoute).to.equal(baseRouter); + (0, chai_1.expect)(res.body.routerRoute).to.equal(baseRouter); }); }); }); describe('User', function () { it('Should not get a user if not authenticated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, path: '/plugins/test-four/router/user', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -101,25 +101,25 @@ describe('Test plugin helpers', function () { }); }); it('Should get a user if authenticated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: servers[0].url, token: servers[0].accessToken, path: '/plugins/test-four/router/user', expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.username).to.equal('root'); - chai_1.expect(res.body.displayName).to.equal('root'); - chai_1.expect(res.body.isAdmin).to.be.true; - chai_1.expect(res.body.isModerator).to.be.false; - chai_1.expect(res.body.isUser).to.be.false; + (0, chai_1.expect)(res.body.username).to.equal('root'); + (0, chai_1.expect)(res.body.displayName).to.equal('root'); + (0, chai_1.expect)(res.body.isAdmin).to.be.true; + (0, chai_1.expect)(res.body.isModerator).to.be.false; + (0, chai_1.expect)(res.body.isUser).to.be.false; }); }); }); describe('Moderation', function () { let videoUUIDServer1; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); { const res = yield servers[0].videos.quickUpload({ name: 'video server 1' }); @@ -128,74 +128,74 @@ describe('Test plugin helpers', function () { { yield servers[1].videos.quickUpload({ name: 'video server 2' }); } - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); const { data } = yield servers[0].videos.list(); - chai_1.expect(data).to.have.lengthOf(2); + (0, chai_1.expect)(data).to.have.lengthOf(2); }); }); it('Should mute server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` }); const { data } = yield servers[0].videos.list(); - chai_1.expect(data).to.have.lengthOf(1); - chai_1.expect(data[0].name).to.equal('video server 1'); + (0, chai_1.expect)(data).to.have.lengthOf(1); + (0, chai_1.expect)(data[0].name).to.equal('video server 1'); }); }); it('Should unmute server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` }); const { data } = yield servers[0].videos.list(); - chai_1.expect(data).to.have.lengthOf(2); + (0, chai_1.expect)(data).to.have.lengthOf(2); }); }); it('Should mute account of server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` }); const { data } = yield servers[0].videos.list(); - chai_1.expect(data).to.have.lengthOf(1); - chai_1.expect(data[0].name).to.equal('video server 1'); + (0, chai_1.expect)(data).to.have.lengthOf(1); + (0, chai_1.expect)(data[0].name).to.equal('video server 1'); }); }); it('Should unmute account of server 2', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` }); const { data } = yield servers[0].videos.list(); - chai_1.expect(data).to.have.lengthOf(2); + (0, chai_1.expect)(data).to.have.lengthOf(2); }); }); it('Should blacklist video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield postCommand(servers[0], 'blacklist', { videoUUID: videoUUIDServer1, unfederate: true }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); - chai_1.expect(data).to.have.lengthOf(1); - chai_1.expect(data[0].name).to.equal('video server 2'); + (0, chai_1.expect)(data).to.have.lengthOf(1); + (0, chai_1.expect)(data[0].name).to.equal('video server 2'); } }); }); it('Should unblacklist video', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(10000); yield postCommand(servers[0], 'unblacklist', { videoUUID: videoUUIDServer1 }); - yield extra_utils_1.waitJobs(servers); + yield (0, extra_utils_1.waitJobs)(servers); for (const server of servers) { const { data } = yield server.videos.list(); - chai_1.expect(data).to.have.lengthOf(2); + (0, chai_1.expect)(data).to.have.lengthOf(2); } }); }); }); describe('Videos', function () { let videoUUID; - before(() => tslib_1.__awaiter(this, void 0, void 0, function* () { + before(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const res = yield servers[0].videos.quickUpload({ name: 'video1' }); videoUUID = res.uuid; })); it('Should remove a video after a view', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(40000); const video = yield servers[0].videos.get({ id: videoUUID }); yield servers[0].videos.view({ id: videoUUID }); @@ -208,18 +208,18 @@ describe('Test plugin helpers', function () { if (err.message.includes('exists')) throw err; } - yield extra_utils_1.checkVideoFilesWereRemoved({ server: servers[0], video }); + yield (0, extra_utils_1.checkVideoFilesWereRemoved)({ server: servers[0], video }); }); }); it('Should have fetched the video by URL', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers[0].servers.waitUntilLog(`video from DB uuid is ${videoUUID}`); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests(servers); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)(servers); }); }); }); diff --git a/dist/server/tests/plugins/plugin-router.js b/dist/server/tests/plugins/plugin-router.js index 89f9824e..eee50237 100644 --- a/dist/server/tests/plugins/plugin-router.js +++ b/dist/server/tests/plugins/plugin-router.js @@ -12,72 +12,72 @@ describe('Test plugin helpers', function () { '/plugins/test-five/0.0.1/router/' ]; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-five') }); }); }); it('Should answer "pong"', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of basePaths) { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + 'ping', expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.message).to.equal('pong'); + (0, chai_1.expect)(res.body.message).to.equal('pong'); } }); }); it('Should check if authenticated', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const path of basePaths) { - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + 'is-authenticated', token: server.accessToken, expectedStatus: 200 }); - chai_1.expect(res.body.isAuthenticated).to.equal(true); - const secRes = yield extra_utils_1.makeGetRequest({ + (0, chai_1.expect)(res.body.isAuthenticated).to.equal(true); + const secRes = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + 'is-authenticated', expectedStatus: 200 }); - chai_1.expect(secRes.body.isAuthenticated).to.equal(false); + (0, chai_1.expect)(secRes.body.isAuthenticated).to.equal(false); } }); }); it('Should mirror post body', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = { hello: 'world', riri: 'fifi', loulou: 'picsou' }; for (const path of basePaths) { - const res = yield extra_utils_1.makePostBodyRequest({ + const res = yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + 'form/post/mirror', fields: body, expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body).to.deep.equal(body); + (0, chai_1.expect)(res.body).to.deep.equal(body); } }); }); it('Should remove the plugin and remove the routes', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' }); for (const path of basePaths) { - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: path + 'ping', expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 }); - yield extra_utils_1.makePostBodyRequest({ + yield (0, extra_utils_1.makePostBodyRequest)({ url: server.url, path: path + 'ping', fields: {}, @@ -87,8 +87,8 @@ describe('Test plugin helpers', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/plugin-storage.js b/dist/server/tests/plugins/plugin-storage.js index cfd7176e..a7c4e9fa 100644 --- a/dist/server/tests/plugins/plugin-storage.js +++ b/dist/server/tests/plugins/plugin-storage.js @@ -10,16 +10,16 @@ const models_1 = require("@shared/models"); describe('Test plugin storage', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-six') }); }); }); describe('DB storage', function () { it('Should correctly store a subkey', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.servers.waitUntilLog('superkey stored value is toto'); }); }); @@ -28,55 +28,55 @@ describe('Test plugin storage', function () { let dataPath; let pluginDataPath; function getFileContent() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const files = yield fs_extra_1.readdir(pluginDataPath); - chai_1.expect(files).to.have.lengthOf(1); - return fs_extra_1.readFile(path_1.join(pluginDataPath, files[0]), 'utf8'); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const files = yield (0, fs_extra_1.readdir)(pluginDataPath); + (0, chai_1.expect)(files).to.have.lengthOf(1); + return (0, fs_extra_1.readFile)((0, path_1.join)(pluginDataPath, files[0]), 'utf8'); }); } before(function () { dataPath = server.servers.buildDirectory('plugins/data'); - pluginDataPath = path_1.join(dataPath, 'peertube-plugin-test-six'); + pluginDataPath = (0, path_1.join)(dataPath, 'peertube-plugin-test-six'); }); it('Should have created the directory on install', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const dataPath = server.servers.buildDirectory('plugins/data'); - const pluginDataPath = path_1.join(dataPath, 'peertube-plugin-test-six'); - chai_1.expect(yield fs_extra_1.pathExists(dataPath)).to.be.true; - chai_1.expect(yield fs_extra_1.pathExists(pluginDataPath)).to.be.true; - chai_1.expect(yield fs_extra_1.readdir(pluginDataPath)).to.have.lengthOf(0); + const pluginDataPath = (0, path_1.join)(dataPath, 'peertube-plugin-test-six'); + (0, chai_1.expect)(yield (0, fs_extra_1.pathExists)(dataPath)).to.be.true; + (0, chai_1.expect)(yield (0, fs_extra_1.pathExists)(pluginDataPath)).to.be.true; + (0, chai_1.expect)(yield (0, fs_extra_1.readdir)(pluginDataPath)).to.have.lengthOf(0); }); }); it('Should have created a file', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path: '/plugins/test-six/router/create-file', expectedStatus: models_1.HttpStatusCode.OK_200 }); const content = yield getFileContent(); - chai_1.expect(content).to.equal('Prince Ali'); + (0, chai_1.expect)(content).to.equal('Prince Ali'); }); }); it('Should still have the file after an uninstallation', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-six' }); const content = yield getFileContent(); - chai_1.expect(content).to.equal('Prince Ali'); + (0, chai_1.expect)(content).to.equal('Prince Ali'); }); }); it('Should still have the file after the reinstallation', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-six') }); const content = yield getFileContent(); - chai_1.expect(content).to.equal('Prince Ali'); + (0, chai_1.expect)(content).to.equal('Prince Ali'); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/plugin-transcoding.js b/dist/server/tests/plugins/plugin-transcoding.js index 36a53982..a2bf2a6a 100644 --- a/dist/server/tests/plugins/plugin-transcoding.js +++ b/dist/server/tests/plugins/plugin-transcoding.js @@ -6,7 +6,7 @@ const chai_1 = require("chai"); const ffprobe_utils_1 = require("@server/helpers/ffprobe-utils"); const extra_utils_1 = require("@shared/extra-utils"); function createLiveWrapper(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const liveAttributes = { name: 'live video', channelId: server.store.channel.id, @@ -53,143 +53,143 @@ function updateConf(server, vodProfile, liveProfile) { describe('Test transcoding plugins', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(60000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); - yield extra_utils_1.setDefaultVideoChannel([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); + yield (0, extra_utils_1.setDefaultVideoChannel)([server]); yield updateConf(server, 'default', 'default'); }); }); describe('When using a plugin adding profiles to existing encoders', function () { function checkVideoFPS(uuid, type, fps) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield server.videos.get({ id: uuid }); const files = video.files.concat(...video.streamingPlaylists.map(p => p.files)); for (const file of files) { if (type === 'above') { - chai_1.expect(file.fps).to.be.above(fps); + (0, chai_1.expect)(file.fps).to.be.above(fps); } else { - chai_1.expect(file.fps).to.be.below(fps); + (0, chai_1.expect)(file.fps).to.be.below(fps); } } }); } function checkLiveFPS(uuid, type, fps) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlistUrl = `${server.url}/static/streaming-playlists/hls/${uuid}/0.m3u8`; - const videoFPS = yield ffprobe_utils_1.getVideoFileFPS(playlistUrl); + const videoFPS = yield (0, ffprobe_utils_1.getVideoFileFPS)(playlistUrl); if (type === 'above') { - chai_1.expect(videoFPS).to.be.above(fps); + (0, chai_1.expect)(videoFPS).to.be.above(fps); } else { - chai_1.expect(videoFPS).to.be.below(fps); + (0, chai_1.expect)(videoFPS).to.be.below(fps); } }); } before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-transcoding-one') }); }); }); it('Should have the appropriate available profiles', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const config = yield server.config.getConfig(); - chai_1.expect(config.transcoding.availableProfiles).to.have.members(['default', 'low-vod', 'input-options-vod', 'bad-scale-vod']); - chai_1.expect(config.live.transcoding.availableProfiles).to.have.members(['default', 'high-live', 'input-options-live', 'bad-scale-live']); + (0, chai_1.expect)(config.transcoding.availableProfiles).to.have.members(['default', 'low-vod', 'input-options-vod', 'bad-scale-vod']); + (0, chai_1.expect)(config.live.transcoding.availableProfiles).to.have.members(['default', 'high-live', 'input-options-live', 'bad-scale-live']); }); }); describe('VOD', function () { it('Should not use the plugin profile if not chosen by the admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); const videoUUID = (yield server.videos.quickUpload({ name: 'video' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkVideoFPS(videoUUID, 'above', 20); }); }); it('Should use the vod profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'low-vod', 'default'); const videoUUID = (yield server.videos.quickUpload({ name: 'video' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkVideoFPS(videoUUID, 'below', 12); }); }); it('Should apply input options in vod profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'input-options-vod', 'default'); const videoUUID = (yield server.videos.quickUpload({ name: 'video' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkVideoFPS(videoUUID, 'below', 6); }); }); it('Should apply the scale filter in vod profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'bad-scale-vod', 'default'); const videoUUID = (yield server.videos.quickUpload({ name: 'video' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const video = yield server.videos.get({ id: videoUUID }); - chai_1.expect(video.files).to.have.lengthOf(1); - chai_1.expect(video.streamingPlaylists).to.have.lengthOf(0); + (0, chai_1.expect)(video.files).to.have.lengthOf(1); + (0, chai_1.expect)(video.streamingPlaylists).to.have.lengthOf(0); }); }); }); describe('Live', function () { it('Should not use the plugin profile if not chosen by the admin', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); const liveVideoId = yield createLiveWrapper(server); yield server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }); yield server.live.waitUntilPublished({ videoId: liveVideoId }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkLiveFPS(liveVideoId, 'above', 20); }); }); it('Should use the live profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'low-vod', 'high-live'); const liveVideoId = yield createLiveWrapper(server); yield server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }); yield server.live.waitUntilPublished({ videoId: liveVideoId }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkLiveFPS(liveVideoId, 'above', 45); }); }); it('Should apply the input options on live profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'low-vod', 'input-options-live'); const liveVideoId = yield createLiveWrapper(server); yield server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }); yield server.live.waitUntilPublished({ videoId: liveVideoId }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkLiveFPS(liveVideoId, 'above', 45); }); }); it('Should apply the scale filter name on live profile', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield updateConf(server, 'low-vod', 'bad-scale-live'); const liveVideoId = yield createLiveWrapper(server); const command = yield server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }); - yield extra_utils_1.testFfmpegStreamError(command, true); + yield (0, extra_utils_1.testFfmpegStreamError)(command, true); }); }); it('Should default to the default profile if the specified profile does not exist', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }); const config = yield server.config.getConfig(); - chai_1.expect(config.transcoding.availableProfiles).to.deep.equal(['default']); - chai_1.expect(config.live.transcoding.availableProfiles).to.deep.equal(['default']); + (0, chai_1.expect)(config.transcoding.availableProfiles).to.deep.equal(['default']); + (0, chai_1.expect)(config.live.transcoding.availableProfiles).to.deep.equal(['default']); const videoUUID = (yield server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); yield checkVideoFPS(videoUUID, 'above', 20); }); }); @@ -197,42 +197,42 @@ describe('Test transcoding plugins', function () { }); describe('When using a plugin adding new encoders', function () { before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-transcoding-two') }); yield updateConf(server, 'test-vod-profile', 'test-live-profile'); }); }); it('Should use the new vod encoders', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); const videoUUID = (yield server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid; - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const video = yield server.videos.get({ id: videoUUID }); const path = server.servers.buildWebTorrentFilePath(video.files[0].fileUrl); - const audioProbe = yield ffprobe_utils_1.getAudioStream(path); - chai_1.expect(audioProbe.audioStream.codec_name).to.equal('opus'); - const videoProbe = yield ffprobe_utils_1.getVideoStreamFromFile(path); - chai_1.expect(videoProbe.codec_name).to.equal('vp9'); + const audioProbe = yield (0, ffprobe_utils_1.getAudioStream)(path); + (0, chai_1.expect)(audioProbe.audioStream.codec_name).to.equal('opus'); + const videoProbe = yield (0, ffprobe_utils_1.getVideoStreamFromFile)(path); + (0, chai_1.expect)(videoProbe.codec_name).to.equal('vp9'); }); }); it('Should use the new live encoders', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(240000); const liveVideoId = yield createLiveWrapper(server); yield server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }); yield server.live.waitUntilPublished({ videoId: liveVideoId }); - yield extra_utils_1.waitJobs([server]); + yield (0, extra_utils_1.waitJobs)([server]); const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8`; - const audioProbe = yield ffprobe_utils_1.getAudioStream(playlistUrl); - chai_1.expect(audioProbe.audioStream.codec_name).to.equal('opus'); - const videoProbe = yield ffprobe_utils_1.getVideoStreamFromFile(playlistUrl); - chai_1.expect(videoProbe.codec_name).to.equal('h264'); + const audioProbe = yield (0, ffprobe_utils_1.getAudioStream)(playlistUrl); + (0, chai_1.expect)(audioProbe.audioStream.codec_name).to.equal('opus'); + const videoProbe = yield (0, ffprobe_utils_1.getVideoStreamFromFile)(playlistUrl); + (0, chai_1.expect)(videoProbe.codec_name).to.equal('h264'); }); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/plugin-unloading.js b/dist/server/tests/plugins/plugin-unloading.js index e3fe7d5a..2f4e1519 100644 --- a/dist/server/tests/plugins/plugin-unloading.js +++ b/dist/server/tests/plugins/plugin-unloading.js @@ -10,38 +10,38 @@ describe('Test plugins module unloading', function () { const requestPath = '/plugins/test-unloading/router/get'; let value = null; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-unloading') }); }); }); it('Should return a numeric value', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: requestPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.message).to.match(/^\d+$/); + (0, chai_1.expect)(res.body.message).to.match(/^\d+$/); value = res.body.message; }); }); it('Should return the same value the second time', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield extra_utils_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: requestPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.message).to.be.equal(value); + (0, chai_1.expect)(res.body.message).to.be.equal(value); }); }); it('Should uninstall the plugin and free the route', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' }); - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: requestPath, expectedStatus: models_1.HttpStatusCode.NOT_FOUND_404 @@ -49,20 +49,20 @@ describe('Test plugins module unloading', function () { }); }); it('Should return a different numeric value', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-unloading') }); - const res = yield extra_utils_1.makeGetRequest({ + const res = yield (0, extra_utils_1.makeGetRequest)({ url: server.url, path: requestPath, expectedStatus: models_1.HttpStatusCode.OK_200 }); - chai_1.expect(res.body.message).to.match(/^\d+$/); - chai_1.expect(res.body.message).to.be.not.equal(value); + (0, chai_1.expect)(res.body.message).to.match(/^\d+$/); + (0, chai_1.expect)(res.body.message).to.be.not.equal(value); }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/translations.js b/dist/server/tests/plugins/translations.js index f1e506ba..79efc76f 100644 --- a/dist/server/tests/plugins/translations.js +++ b/dist/server/tests/plugins/translations.js @@ -2,30 +2,30 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const expect = chai.expect; describe('Test plugin translations', function () { let server; let command; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); command = server.plugins; yield command.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath() }); yield command.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-filter-translations') }); }); }); it('Should not have translations for locale pt', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.getTranslations({ locale: 'pt' }); expect(body).to.deep.equal({}); }); }); it('Should have translations for locale fr', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.getTranslations({ locale: 'fr-FR' }); expect(body).to.deep.equal({ 'peertube-plugin-test': { @@ -38,7 +38,7 @@ describe('Test plugin translations', function () { }); }); it('Should have translations of locale it', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield command.getTranslations({ locale: 'it-IT' }); expect(body).to.deep.equal({ 'peertube-plugin-test-filter-translations': { @@ -48,7 +48,7 @@ describe('Test plugin translations', function () { }); }); it('Should remove the plugin and remove the locales', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' }); { const body = yield command.getTranslations({ locale: 'fr-FR' }); @@ -65,8 +65,8 @@ describe('Test plugin translations', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/plugins/video-constants.js b/dist/server/tests/plugins/video-constants.js index e6e7a41e..221ee270 100644 --- a/dist/server/tests/plugins/video-constants.js +++ b/dist/server/tests/plugins/video-constants.js @@ -2,22 +2,22 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); require("mocha"); -const chai = tslib_1.__importStar(require("chai")); +const chai = (0, tslib_1.__importStar)(require("chai")); const extra_utils_1 = require("@shared/extra-utils"); const models_1 = require("@shared/models"); const expect = chai.expect; describe('Test plugin altering video constants', function () { let server; before(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { this.timeout(30000); - server = yield extra_utils_1.createSingleServer(1); - yield extra_utils_1.setAccessTokensToServers([server]); + server = yield (0, extra_utils_1.createSingleServer)(1); + yield (0, extra_utils_1.setAccessTokensToServers)([server]); yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-video-constants') }); }); }); it('Should have updated languages', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const languages = yield server.videos.getLanguages(); expect(languages['en']).to.not.exist; expect(languages['fr']).to.not.exist; @@ -27,7 +27,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should have updated categories', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const categories = yield server.videos.getCategories(); expect(categories[1]).to.not.exist; expect(categories[2]).to.not.exist; @@ -36,7 +36,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should have updated licences', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const licences = yield server.videos.getLicences(); expect(licences[1]).to.not.exist; expect(licences[7]).to.not.exist; @@ -45,7 +45,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should have updated video privacies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const privacies = yield server.videos.getPrivacies(); expect(privacies[1]).to.exist; expect(privacies[2]).to.not.exist; @@ -54,7 +54,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should have updated playlist privacies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const playlistPrivacies = yield server.playlists.getPrivacies(); expect(playlistPrivacies[1]).to.exist; expect(playlistPrivacies[2]).to.exist; @@ -62,19 +62,19 @@ describe('Test plugin altering video constants', function () { }); }); it('Should not be able to create a video with this privacy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'video', privacy: 2 }; yield server.videos.upload({ attributes, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should not be able to create a video with this privacy', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { displayName: 'video playlist', privacy: 3 }; yield server.playlists.create({ attributes, expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); }); }); it('Should be able to upload a video with these values', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }; const { uuid } = yield server.videos.upload({ attributes }); const video = yield server.videos.get({ id: uuid }); @@ -84,7 +84,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should uninstall the plugin and reset languages, categories, licences and privacies', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.uninstall({ npmName: 'peertube-plugin-test-video-constants' }); { const languages = yield server.videos.getLanguages(); @@ -124,7 +124,7 @@ describe('Test plugin altering video constants', function () { }); }); it('Should be able to reset categories', function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield server.plugins.install({ path: extra_utils_1.PluginsCommand.getPluginTestPath('-video-constants') }); { const categories = yield server.videos.getCategories(); @@ -133,7 +133,7 @@ describe('Test plugin altering video constants', function () { expect(categories[42]).to.exist; expect(categories[43]).to.exist; } - yield extra_utils_1.makeGetRequest({ + yield (0, extra_utils_1.makeGetRequest)({ url: server.url, token: server.accessToken, path: '/plugins/test-video-constants/router/reset-categories', @@ -149,8 +149,8 @@ describe('Test plugin altering video constants', function () { }); }); after(function () { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield extra_utils_1.cleanupTests([server]); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, extra_utils_1.cleanupTests)([server]); }); }); }); diff --git a/dist/server/tests/register.js b/dist/server/tests/register.js index b961acc6..aa10de04 100644 --- a/dist/server/tests/register.js +++ b/dist/server/tests/register.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const register_ts_paths_1 = require("../helpers/register-ts-paths"); -register_ts_paths_1.registerTSPaths(); +(0, register_ts_paths_1.registerTSPaths)(); diff --git a/dist/server/types/index.js b/dist/server/types/index.js index 7b51258e..104fc5e4 100644 --- a/dist/server/types/index.js +++ b/dist/server/types/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./plugins"), exports); -tslib_1.__exportStar(require("./activitypub-processor.model"), exports); -tslib_1.__exportStar(require("./sequelize"), exports); +(0, tslib_1.__exportStar)(require("./plugins"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-processor.model"), exports); +(0, tslib_1.__exportStar)(require("./sequelize"), exports); diff --git a/dist/server/types/models/abuse/index.js b/dist/server/types/models/abuse/index.js index 8aa08d43..740ee6b8 100644 --- a/dist/server/types/models/abuse/index.js +++ b/dist/server/types/models/abuse/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./abuse-message"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./abuse-message"), exports); diff --git a/dist/server/types/models/account/index.js b/dist/server/types/models/account/index.js index 7315d682..7f599ad2 100644 --- a/dist/server/types/models/account/index.js +++ b/dist/server/types/models/account/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./account"), exports); -tslib_1.__exportStar(require("./actor-custom-page"), exports); -tslib_1.__exportStar(require("./account-blocklist"), exports); +(0, tslib_1.__exportStar)(require("./account"), exports); +(0, tslib_1.__exportStar)(require("./actor-custom-page"), exports); +(0, tslib_1.__exportStar)(require("./account-blocklist"), exports); diff --git a/dist/server/types/models/actor/index.js b/dist/server/types/models/actor/index.js index 0fdfbd66..4e01e030 100644 --- a/dist/server/types/models/actor/index.js +++ b/dist/server/types/models/actor/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./actor-follow"), exports); -tslib_1.__exportStar(require("./actor-image"), exports); -tslib_1.__exportStar(require("./actor"), exports); +(0, tslib_1.__exportStar)(require("./actor-follow"), exports); +(0, tslib_1.__exportStar)(require("./actor-image"), exports); +(0, tslib_1.__exportStar)(require("./actor"), exports); diff --git a/dist/server/types/models/application/index.js b/dist/server/types/models/application/index.js index 7cee7e7d..7ca13e86 100644 --- a/dist/server/types/models/application/index.js +++ b/dist/server/types/models/application/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./application"), exports); +(0, tslib_1.__exportStar)(require("./application"), exports); diff --git a/dist/server/types/models/index.js b/dist/server/types/models/index.js index 6b60a150..b5696c68 100644 --- a/dist/server/types/models/index.js +++ b/dist/server/types/models/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./account"), exports); -tslib_1.__exportStar(require("./actor"), exports); -tslib_1.__exportStar(require("./application"), exports); -tslib_1.__exportStar(require("./oauth"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./user"), exports); -tslib_1.__exportStar(require("./video"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./account"), exports); +(0, tslib_1.__exportStar)(require("./actor"), exports); +(0, tslib_1.__exportStar)(require("./application"), exports); +(0, tslib_1.__exportStar)(require("./oauth"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./user"), exports); +(0, tslib_1.__exportStar)(require("./video"), exports); diff --git a/dist/server/types/models/oauth/index.js b/dist/server/types/models/oauth/index.js index a4ed9788..3d231608 100644 --- a/dist/server/types/models/oauth/index.js +++ b/dist/server/types/models/oauth/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./oauth-client"), exports); -tslib_1.__exportStar(require("./oauth-token"), exports); +(0, tslib_1.__exportStar)(require("./oauth-client"), exports); +(0, tslib_1.__exportStar)(require("./oauth-token"), exports); diff --git a/dist/server/types/models/server/index.js b/dist/server/types/models/server/index.js index b05b3a2c..fc4ff8ee 100644 --- a/dist/server/types/models/server/index.js +++ b/dist/server/types/models/server/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./plugin"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./server-blocklist"), exports); +(0, tslib_1.__exportStar)(require("./plugin"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./server-blocklist"), exports); diff --git a/dist/server/types/models/user/index.js b/dist/server/types/models/user/index.js index b8bd62de..5e1047c5 100644 --- a/dist/server/types/models/user/index.js +++ b/dist/server/types/models/user/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./user"), exports); -tslib_1.__exportStar(require("./user-notification"), exports); -tslib_1.__exportStar(require("./user-notification-setting"), exports); -tslib_1.__exportStar(require("./user-video-history"), exports); +(0, tslib_1.__exportStar)(require("./user"), exports); +(0, tslib_1.__exportStar)(require("./user-notification"), exports); +(0, tslib_1.__exportStar)(require("./user-notification-setting"), exports); +(0, tslib_1.__exportStar)(require("./user-video-history"), exports); diff --git a/dist/server/types/models/video/index.js b/dist/server/types/models/video/index.js index 7fea903f..7970f7f9 100644 --- a/dist/server/types/models/video/index.js +++ b/dist/server/types/models/video/index.js @@ -1,21 +1,21 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./schedule-video-update"), exports); -tslib_1.__exportStar(require("./tag"), exports); -tslib_1.__exportStar(require("./thumbnail"), exports); -tslib_1.__exportStar(require("./video"), exports); -tslib_1.__exportStar(require("./video-blacklist"), exports); -tslib_1.__exportStar(require("./video-caption"), exports); -tslib_1.__exportStar(require("./video-change-ownership"), exports); -tslib_1.__exportStar(require("./video-channels"), exports); -tslib_1.__exportStar(require("./video-comment"), exports); -tslib_1.__exportStar(require("./video-file"), exports); -tslib_1.__exportStar(require("./video-import"), exports); -tslib_1.__exportStar(require("./video-live"), exports); -tslib_1.__exportStar(require("./video-playlist"), exports); -tslib_1.__exportStar(require("./video-playlist-element"), exports); -tslib_1.__exportStar(require("./video-rate"), exports); -tslib_1.__exportStar(require("./video-redundancy"), exports); -tslib_1.__exportStar(require("./video-share"), exports); -tslib_1.__exportStar(require("./video-streaming-playlist"), exports); +(0, tslib_1.__exportStar)(require("./schedule-video-update"), exports); +(0, tslib_1.__exportStar)(require("./tag"), exports); +(0, tslib_1.__exportStar)(require("./thumbnail"), exports); +(0, tslib_1.__exportStar)(require("./video"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist"), exports); +(0, tslib_1.__exportStar)(require("./video-caption"), exports); +(0, tslib_1.__exportStar)(require("./video-change-ownership"), exports); +(0, tslib_1.__exportStar)(require("./video-channels"), exports); +(0, tslib_1.__exportStar)(require("./video-comment"), exports); +(0, tslib_1.__exportStar)(require("./video-file"), exports); +(0, tslib_1.__exportStar)(require("./video-import"), exports); +(0, tslib_1.__exportStar)(require("./video-live"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-element"), exports); +(0, tslib_1.__exportStar)(require("./video-rate"), exports); +(0, tslib_1.__exportStar)(require("./video-redundancy"), exports); +(0, tslib_1.__exportStar)(require("./video-share"), exports); +(0, tslib_1.__exportStar)(require("./video-streaming-playlist"), exports); diff --git a/dist/server/types/plugins/index.js b/dist/server/types/plugins/index.js index 6ba75e4f..c5d24706 100644 --- a/dist/server/types/plugins/index.js +++ b/dist/server/types/plugins/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./plugin-library.model"), exports); -tslib_1.__exportStar(require("./register-server-auth.model"), exports); -tslib_1.__exportStar(require("./register-server-option.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-library.model"), exports); +(0, tslib_1.__exportStar)(require("./register-server-auth.model"), exports); +(0, tslib_1.__exportStar)(require("./register-server-option.model"), exports); diff --git a/dist/shared/core-utils/abuse/index.js b/dist/shared/core-utils/abuse/index.js index d2933472..6a9eed3f 100644 --- a/dist/shared/core-utils/abuse/index.js +++ b/dist/shared/core-utils/abuse/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse-predefined-reasons"), exports); +(0, tslib_1.__exportStar)(require("./abuse-predefined-reasons"), exports); diff --git a/dist/shared/core-utils/common/index.js b/dist/shared/core-utils/common/index.js index 507be283..44fbbbc1 100644 --- a/dist/shared/core-utils/common/index.js +++ b/dist/shared/core-utils/common/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./date"), exports); -tslib_1.__exportStar(require("./miscs"), exports); -tslib_1.__exportStar(require("./regexp"), exports); -tslib_1.__exportStar(require("./promises"), exports); -tslib_1.__exportStar(require("./types"), exports); -tslib_1.__exportStar(require("./url"), exports); +(0, tslib_1.__exportStar)(require("./date"), exports); +(0, tslib_1.__exportStar)(require("./miscs"), exports); +(0, tslib_1.__exportStar)(require("./regexp"), exports); +(0, tslib_1.__exportStar)(require("./promises"), exports); +(0, tslib_1.__exportStar)(require("./types"), exports); +(0, tslib_1.__exportStar)(require("./url"), exports); diff --git a/dist/shared/core-utils/common/url.js b/dist/shared/core-utils/common/url.js index 55c77bc1..8061b31d 100644 --- a/dist/shared/core-utils/common/url.js +++ b/dist/shared/core-utils/common/url.js @@ -39,11 +39,11 @@ function decorateVideoLink(options) { const params = generateParams(window.location.search); if (options.startTime !== undefined && options.startTime !== null) { const startTimeInt = Math.floor(options.startTime); - params.set('start', date_1.secondsToTime(startTimeInt)); + params.set('start', (0, date_1.secondsToTime)(startTimeInt)); } if (options.stopTime) { const stopTimeInt = Math.floor(options.stopTime); - params.set('stop', date_1.secondsToTime(stopTimeInt)); + params.set('stop', (0, date_1.secondsToTime)(stopTimeInt)); } if (options.subtitle) params.set('subtitle', options.subtitle); diff --git a/dist/shared/core-utils/i18n/index.js b/dist/shared/core-utils/i18n/index.js index 21586a38..33c96da6 100644 --- a/dist/shared/core-utils/i18n/index.js +++ b/dist/shared/core-utils/i18n/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./i18n"), exports); +(0, tslib_1.__exportStar)(require("./i18n"), exports); diff --git a/dist/shared/core-utils/index.js b/dist/shared/core-utils/index.js index d55e6b41..cc52860b 100644 --- a/dist/shared/core-utils/index.js +++ b/dist/shared/core-utils/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./common"), exports); -tslib_1.__exportStar(require("./i18n"), exports); -tslib_1.__exportStar(require("./plugins"), exports); -tslib_1.__exportStar(require("./renderer"), exports); -tslib_1.__exportStar(require("./users"), exports); -tslib_1.__exportStar(require("./utils"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./common"), exports); +(0, tslib_1.__exportStar)(require("./i18n"), exports); +(0, tslib_1.__exportStar)(require("./plugins"), exports); +(0, tslib_1.__exportStar)(require("./renderer"), exports); +(0, tslib_1.__exportStar)(require("./users"), exports); +(0, tslib_1.__exportStar)(require("./utils"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/shared/core-utils/plugins/hooks.js b/dist/shared/core-utils/plugins/hooks.js index e6f1aaf1..cbbabee8 100644 --- a/dist/shared/core-utils/plugins/hooks.js +++ b/dist/shared/core-utils/plugins/hooks.js @@ -12,11 +12,11 @@ function getHookType(hookName) { } exports.getHookType = getHookType; function internalRunHook(handler, hookType, result, params, onError) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { try { if (hookType === 3) { const p = handler(result, params); - if (promises_1.isPromise(p)) + if ((0, promises_1.isPromise)(p)) result = yield p; else result = p; @@ -24,12 +24,12 @@ function internalRunHook(handler, hookType, result, params, onError) { } const p = handler(params); if (hookType === 1) { - if (promises_1.isPromise(p)) + if ((0, promises_1.isPromise)(p)) yield p; return undefined; } if (hookType === 2) { - if (promises_1.isCatchable(p)) + if ((0, promises_1.isCatchable)(p)) p.catch((err) => onError(err)); return undefined; } diff --git a/dist/shared/core-utils/plugins/index.js b/dist/shared/core-utils/plugins/index.js index 25c572ca..46c3367c 100644 --- a/dist/shared/core-utils/plugins/index.js +++ b/dist/shared/core-utils/plugins/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./hooks"), exports); +(0, tslib_1.__exportStar)(require("./hooks"), exports); diff --git a/dist/shared/core-utils/renderer/index.js b/dist/shared/core-utils/renderer/index.js index 97650212..a8a7c654 100644 --- a/dist/shared/core-utils/renderer/index.js +++ b/dist/shared/core-utils/renderer/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./markdown"), exports); -tslib_1.__exportStar(require("./html"), exports); +(0, tslib_1.__exportStar)(require("./markdown"), exports); +(0, tslib_1.__exportStar)(require("./html"), exports); diff --git a/dist/shared/core-utils/users/index.js b/dist/shared/core-utils/users/index.js index f6a53e94..f8b6d01a 100644 --- a/dist/shared/core-utils/users/index.js +++ b/dist/shared/core-utils/users/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./user-role"), exports); +(0, tslib_1.__exportStar)(require("./user-role"), exports); diff --git a/dist/shared/core-utils/utils/index.js b/dist/shared/core-utils/utils/index.js index dd147e7b..035532b2 100644 --- a/dist/shared/core-utils/utils/index.js +++ b/dist/shared/core-utils/utils/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./object"), exports); +(0, tslib_1.__exportStar)(require("./object"), exports); diff --git a/dist/shared/core-utils/videos/index.js b/dist/shared/core-utils/videos/index.js index 22b423d2..95cb63b3 100644 --- a/dist/shared/core-utils/videos/index.js +++ b/dist/shared/core-utils/videos/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./bitrate"), exports); +(0, tslib_1.__exportStar)(require("./bitrate"), exports); diff --git a/dist/shared/extra-utils/bulk/index.js b/dist/shared/extra-utils/bulk/index.js index 4a08dae1..5c334442 100644 --- a/dist/shared/extra-utils/bulk/index.js +++ b/dist/shared/extra-utils/bulk/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./bulk-command"), exports); +(0, tslib_1.__exportStar)(require("./bulk-command"), exports); diff --git a/dist/shared/extra-utils/cli/cli-command.js b/dist/shared/extra-utils/cli/cli-command.js index d2947337..e4337364 100644 --- a/dist/shared/extra-utils/cli/cli-command.js +++ b/dist/shared/extra-utils/cli/cli-command.js @@ -7,7 +7,7 @@ const shared_1 = require("../shared"); class CLICommand extends shared_1.AbstractCommand { static exec(command) { return new Promise((res, rej) => { - child_process_1.exec(command, (err, stdout, _stderr) => { + (0, child_process_1.exec)(command, (err, stdout, _stderr) => { if (err) return rej(err); return res(stdout); @@ -18,7 +18,7 @@ class CLICommand extends shared_1.AbstractCommand { return `NODE_ENV=test NODE_APP_INSTANCE=${this.server.internalServerNumber}`; } execWithEnv(command) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return CLICommand.exec(`${this.getEnv()} ${command}`); }); } diff --git a/dist/shared/extra-utils/cli/index.js b/dist/shared/extra-utils/cli/index.js index 9f1a7a7a..901ac684 100644 --- a/dist/shared/extra-utils/cli/index.js +++ b/dist/shared/extra-utils/cli/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./cli-command"), exports); +(0, tslib_1.__exportStar)(require("./cli-command"), exports); diff --git a/dist/shared/extra-utils/custom-pages/index.js b/dist/shared/extra-utils/custom-pages/index.js index 077aa908..21037cae 100644 --- a/dist/shared/extra-utils/custom-pages/index.js +++ b/dist/shared/extra-utils/custom-pages/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./custom-pages-command"), exports); +(0, tslib_1.__exportStar)(require("./custom-pages-command"), exports); diff --git a/dist/shared/extra-utils/feeds/index.js b/dist/shared/extra-utils/feeds/index.js index 9e1800f8..ff491ca3 100644 --- a/dist/shared/extra-utils/feeds/index.js +++ b/dist/shared/extra-utils/feeds/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./feeds-command"), exports); +(0, tslib_1.__exportStar)(require("./feeds-command"), exports); diff --git a/dist/shared/extra-utils/index.js b/dist/shared/extra-utils/index.js index 77047f9c..ccb17335 100644 --- a/dist/shared/extra-utils/index.js +++ b/dist/shared/extra-utils/index.js @@ -1,18 +1,18 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./bulk"), exports); -tslib_1.__exportStar(require("./cli"), exports); -tslib_1.__exportStar(require("./custom-pages"), exports); -tslib_1.__exportStar(require("./feeds"), exports); -tslib_1.__exportStar(require("./logs"), exports); -tslib_1.__exportStar(require("./miscs"), exports); -tslib_1.__exportStar(require("./mock-servers"), exports); -tslib_1.__exportStar(require("./moderation"), exports); -tslib_1.__exportStar(require("./overviews"), exports); -tslib_1.__exportStar(require("./requests"), exports); -tslib_1.__exportStar(require("./search"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./socket"), exports); -tslib_1.__exportStar(require("./users"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./bulk"), exports); +(0, tslib_1.__exportStar)(require("./cli"), exports); +(0, tslib_1.__exportStar)(require("./custom-pages"), exports); +(0, tslib_1.__exportStar)(require("./feeds"), exports); +(0, tslib_1.__exportStar)(require("./logs"), exports); +(0, tslib_1.__exportStar)(require("./miscs"), exports); +(0, tslib_1.__exportStar)(require("./mock-servers"), exports); +(0, tslib_1.__exportStar)(require("./moderation"), exports); +(0, tslib_1.__exportStar)(require("./overviews"), exports); +(0, tslib_1.__exportStar)(require("./requests"), exports); +(0, tslib_1.__exportStar)(require("./search"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./socket"), exports); +(0, tslib_1.__exportStar)(require("./users"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/shared/extra-utils/logs/index.js b/dist/shared/extra-utils/logs/index.js index 20dd47e9..ec3bda5e 100644 --- a/dist/shared/extra-utils/logs/index.js +++ b/dist/shared/extra-utils/logs/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./logs-command"), exports); +(0, tslib_1.__exportStar)(require("./logs-command"), exports); diff --git a/dist/shared/extra-utils/miscs/checks.js b/dist/shared/extra-utils/miscs/checks.js index 8c4225bf..30816672 100644 --- a/dist/shared/extra-utils/miscs/checks.js +++ b/dist/shared/extra-utils/miscs/checks.js @@ -15,36 +15,36 @@ function dateIsValid(dateString, interval = 300000) { } exports.dateIsValid = dateIsValid; function expectStartWith(str, start) { - chai_1.expect(str.startsWith(start), `${str} does not start with ${start}`).to.be.true; + (0, chai_1.expect)(str.startsWith(start), `${str} does not start with ${start}`).to.be.true; } exports.expectStartWith = expectStartWith; function expectLogDoesNotContain(server, str) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const content = yield server.servers.getLogContent(); - chai_1.expect(content.toString()).to.not.contain(str); + (0, chai_1.expect)(content.toString()).to.not.contain(str); }); } exports.expectLogDoesNotContain = expectLogDoesNotContain; function testImage(url, imageName, imagePath, extension = '.jpg') { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield requests_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, requests_1.makeGetRequest)({ url, path: imagePath, expectedStatus: models_1.HttpStatusCode.OK_200 }); const body = res.body; - const data = yield fs_extra_1.readFile(path_1.join(core_utils_1.root(), 'server', 'tests', 'fixtures', imageName + extension)); + const data = yield (0, fs_extra_1.readFile)((0, path_1.join)((0, core_utils_1.root)(), 'server', 'tests', 'fixtures', imageName + extension)); const minLength = body.length - ((30 * body.length) / 100); const maxLength = body.length + ((30 * body.length) / 100); - chai_1.expect(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture'); - chai_1.expect(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture'); + (0, chai_1.expect)(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture'); + (0, chai_1.expect)(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture'); }); } exports.testImage = testImage; function testFileExistsOrNot(server, directory, filePath, exist) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const base = server.servers.buildDirectory(directory); - chai_1.expect(yield fs_extra_1.pathExists(path_1.join(base, filePath))).to.equal(exist); + (0, chai_1.expect)(yield (0, fs_extra_1.pathExists)((0, path_1.join)(base, filePath))).to.equal(exist); }); } exports.testFileExistsOrNot = testFileExistsOrNot; diff --git a/dist/shared/extra-utils/miscs/generate.js b/dist/shared/extra-utils/miscs/generate.js index 01037b39..e8d235fa 100644 --- a/dist/shared/extra-utils/miscs/generate.js +++ b/dist/shared/extra-utils/miscs/generate.js @@ -3,30 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.generateVideoWithFramerate = exports.generateHighBitrateVideo = void 0; const tslib_1 = require("tslib"); const chai_1 = require("chai"); -const fluent_ffmpeg_1 = tslib_1.__importDefault(require("fluent-ffmpeg")); +const fluent_ffmpeg_1 = (0, tslib_1.__importDefault)(require("fluent-ffmpeg")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const ffprobe_utils_1 = require("@server/helpers/ffprobe-utils"); const core_utils_1 = require("@shared/core-utils"); const tests_1 = require("./tests"); function ensureHasTooBigBitrate(fixturePath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const bitrate = yield ffprobe_utils_1.getVideoFileBitrate(fixturePath); - const dataResolution = yield ffprobe_utils_1.getVideoFileResolution(fixturePath); - const fps = yield ffprobe_utils_1.getVideoFileFPS(fixturePath); - const maxBitrate = core_utils_1.getMaxBitrate(Object.assign(Object.assign({}, dataResolution), { fps })); - chai_1.expect(bitrate).to.be.above(maxBitrate); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const bitrate = yield (0, ffprobe_utils_1.getVideoFileBitrate)(fixturePath); + const dataResolution = yield (0, ffprobe_utils_1.getVideoFileResolution)(fixturePath); + const fps = yield (0, ffprobe_utils_1.getVideoFileFPS)(fixturePath); + const maxBitrate = (0, core_utils_1.getMaxBitrate)(Object.assign(Object.assign({}, dataResolution), { fps })); + (0, chai_1.expect)(bitrate).to.be.above(maxBitrate); }); } function generateHighBitrateVideo() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const tempFixturePath = tests_1.buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true); - yield fs_extra_1.ensureDir(path_1.dirname(tempFixturePath)); - const exists = yield fs_extra_1.pathExists(tempFixturePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const tempFixturePath = (0, tests_1.buildAbsoluteFixturePath)('video_high_bitrate_1080p.mp4', true); + yield (0, fs_extra_1.ensureDir)((0, path_1.dirname)(tempFixturePath)); + const exists = yield (0, fs_extra_1.pathExists)(tempFixturePath); if (!exists) { console.log('Generating high bitrate video.'); return new Promise((res, rej) => { - fluent_ffmpeg_1.default() + (0, fluent_ffmpeg_1.default)() .outputOptions(['-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom']) .outputOptions(['-ac 2', '-f s16le', '-i /dev/urandom', '-t 10']) .outputOptions(['-maxrate 10M', '-bufsize 10M']) @@ -42,14 +42,14 @@ function generateHighBitrateVideo() { } exports.generateHighBitrateVideo = generateHighBitrateVideo; function generateVideoWithFramerate(fps = 60) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const tempFixturePath = tests_1.buildAbsoluteFixturePath(`video_${fps}fps.mp4`, true); - yield fs_extra_1.ensureDir(path_1.dirname(tempFixturePath)); - const exists = yield fs_extra_1.pathExists(tempFixturePath); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const tempFixturePath = (0, tests_1.buildAbsoluteFixturePath)(`video_${fps}fps.mp4`, true); + yield (0, fs_extra_1.ensureDir)((0, path_1.dirname)(tempFixturePath)); + const exists = yield (0, fs_extra_1.pathExists)(tempFixturePath); if (!exists) { console.log('Generating video with framerate %d.', fps); return new Promise((res, rej) => { - fluent_ffmpeg_1.default() + (0, fluent_ffmpeg_1.default)() .outputOptions(['-f rawvideo', '-video_size 1280x720', '-i /dev/urandom']) .outputOptions(['-ac 2', '-f s16le', '-i /dev/urandom', '-t 10']) .outputOptions([`-r ${fps}`]) diff --git a/dist/shared/extra-utils/miscs/index.js b/dist/shared/extra-utils/miscs/index.js index 0814837b..9b78d66a 100644 --- a/dist/shared/extra-utils/miscs/index.js +++ b/dist/shared/extra-utils/miscs/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./checks"), exports); -tslib_1.__exportStar(require("./generate"), exports); -tslib_1.__exportStar(require("./sql-command"), exports); -tslib_1.__exportStar(require("./tests"), exports); -tslib_1.__exportStar(require("./webtorrent"), exports); +(0, tslib_1.__exportStar)(require("./checks"), exports); +(0, tslib_1.__exportStar)(require("./generate"), exports); +(0, tslib_1.__exportStar)(require("./sql-command"), exports); +(0, tslib_1.__exportStar)(require("./tests"), exports); +(0, tslib_1.__exportStar)(require("./webtorrent"), exports); diff --git a/dist/shared/extra-utils/miscs/sql-command.js b/dist/shared/extra-utils/miscs/sql-command.js index 9c242d15..976a7fe6 100644 --- a/dist/shared/extra-utils/miscs/sql-command.js +++ b/dist/shared/extra-utils/miscs/sql-command.js @@ -11,7 +11,7 @@ class SQLCommand extends abstract_command_1.AbstractCommand { return seq.query(`DELETE FROM "${table}"`, options); } getCount(table) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const seq = this.getSequelize(); const options = { type: sequelize_1.QueryTypes.SELECT }; const [{ total }] = yield seq.query(`SELECT COUNT(*) as total FROM "${table}"`, options); @@ -36,7 +36,7 @@ class SQLCommand extends abstract_command_1.AbstractCommand { return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options); } countVideoViewsOf(uuid) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const seq = this.getSequelize(); const query = 'SELECT SUM("videoView"."views") AS "total" FROM "videoView" ' + `INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`; @@ -83,7 +83,7 @@ class SQLCommand extends abstract_command_1.AbstractCommand { return seq.query(`UPDATE "oAuthToken" SET "${field}" = '${value}' WHERE "accessToken" = '${accessToken}'`, options); } cleanup() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.sequelize) return; yield this.sequelize.close(); diff --git a/dist/shared/extra-utils/miscs/tests.js b/dist/shared/extra-utils/miscs/tests.js index bd6653d7..945f2e2b 100644 --- a/dist/shared/extra-utils/miscs/tests.js +++ b/dist/shared/extra-utils/miscs/tests.js @@ -39,18 +39,18 @@ function areObjectStorageTestsDisabled() { } exports.areObjectStorageTestsDisabled = areObjectStorageTestsDisabled; function buildAbsoluteFixturePath(path, customCIPath = false) { - if (path_1.isAbsolute(path)) + if ((0, path_1.isAbsolute)(path)) return path; if (customCIPath && process.env.GITHUB_WORKSPACE) { - return path_1.join(process.env.GITHUB_WORKSPACE, 'fixtures', path); + return (0, path_1.join)(process.env.GITHUB_WORKSPACE, 'fixtures', path); } - return path_1.join(root(), 'server', 'tests', 'fixtures', path); + return (0, path_1.join)(root(), 'server', 'tests', 'fixtures', path); } exports.buildAbsoluteFixturePath = buildAbsoluteFixturePath; function root() { - let root = path_1.join(__dirname, '..', '..', '..'); - if (path_1.basename(root) === 'dist') - root = path_1.resolve(root, '..'); + let root = (0, path_1.join)(__dirname, '..', '..', '..'); + if ((0, path_1.basename)(root) === 'dist') + root = (0, path_1.resolve)(root, '..'); return root; } exports.root = root; @@ -59,8 +59,8 @@ function wait(milliseconds) { } exports.wait = wait; function getFileSize(path) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const stats = yield fs_extra_1.stat(path); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const stats = yield (0, fs_extra_1.stat)(path); return stats.size; }); } diff --git a/dist/shared/extra-utils/miscs/webtorrent.js b/dist/shared/extra-utils/miscs/webtorrent.js index 99356e9a..6e034bf9 100644 --- a/dist/shared/extra-utils/miscs/webtorrent.js +++ b/dist/shared/extra-utils/miscs/webtorrent.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.parseTorrentVideo = exports.webtorrentAdd = void 0; const tslib_1 = require("tslib"); const fs_extra_1 = require("fs-extra"); -const parse_torrent_1 = tslib_1.__importDefault(require("parse-torrent")); +const parse_torrent_1 = (0, tslib_1.__importDefault)(require("parse-torrent")); const path_1 = require("path"); let webtorrent; function webtorrentAdd(torrentId, refreshWebTorrent = false) { @@ -28,11 +28,11 @@ function webtorrentAdd(torrentId, refreshWebTorrent = false) { } exports.webtorrentAdd = webtorrentAdd; function parseTorrentVideo(server, file) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const torrentName = path_1.basename(file.torrentUrl); - const torrentPath = server.servers.buildDirectory(path_1.join('torrents', torrentName)); - const data = yield fs_extra_1.readFile(torrentPath); - return parse_torrent_1.default(data); + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const torrentName = (0, path_1.basename)(file.torrentUrl); + const torrentPath = server.servers.buildDirectory((0, path_1.join)('torrents', torrentName)); + const data = yield (0, fs_extra_1.readFile)(torrentPath); + return (0, parse_torrent_1.default)(data); }); } exports.parseTorrentVideo = parseTorrentVideo; diff --git a/dist/shared/extra-utils/mock-servers/index.js b/dist/shared/extra-utils/mock-servers/index.js index 968b85ec..1a1a94f4 100644 --- a/dist/shared/extra-utils/mock-servers/index.js +++ b/dist/shared/extra-utils/mock-servers/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./mock-email"), exports); -tslib_1.__exportStar(require("./mock-instances-index"), exports); -tslib_1.__exportStar(require("./mock-joinpeertube-versions"), exports); -tslib_1.__exportStar(require("./mock-plugin-blocklist"), exports); -tslib_1.__exportStar(require("./mock-object-storage"), exports); +(0, tslib_1.__exportStar)(require("./mock-email"), exports); +(0, tslib_1.__exportStar)(require("./mock-instances-index"), exports); +(0, tslib_1.__exportStar)(require("./mock-joinpeertube-versions"), exports); +(0, tslib_1.__exportStar)(require("./mock-plugin-blocklist"), exports); +(0, tslib_1.__exportStar)(require("./mock-object-storage"), exports); diff --git a/dist/shared/extra-utils/mock-servers/mock-email.js b/dist/shared/extra-utils/mock-servers/mock-email.js index 8a523d3b..37446dc4 100644 --- a/dist/shared/extra-utils/mock-servers/mock-email.js +++ b/dist/shared/extra-utils/mock-servers/mock-email.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockSmtpServer = void 0; const tslib_1 = require("tslib"); -const maildev_1 = tslib_1.__importDefault(require("maildev")); +const maildev_1 = (0, tslib_1.__importDefault)(require("maildev")); const core_utils_1 = require("@shared/core-utils"); const miscs_1 = require("../miscs"); class MockSmtpServer { @@ -11,7 +11,7 @@ class MockSmtpServer { } collectEmails(emailsCollection) { return new Promise((res, rej) => { - const port = miscs_1.parallelTests() ? core_utils_1.randomInt(1000, 2000) : 1025; + const port = (0, miscs_1.parallelTests)() ? (0, core_utils_1.randomInt)(1000, 2000) : 1025; this.emails = emailsCollection; if (this.started) { return res(undefined); diff --git a/dist/shared/extra-utils/mock-servers/mock-instances-index.js b/dist/shared/extra-utils/mock-servers/mock-instances-index.js index e3e21022..c6515b2c 100644 --- a/dist/shared/extra-utils/mock-servers/mock-instances-index.js +++ b/dist/shared/extra-utils/mock-servers/mock-instances-index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockInstancesIndex = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@shared/core-utils"); class MockInstancesIndex { constructor() { @@ -10,7 +10,7 @@ class MockInstancesIndex { } initialize() { return new Promise(res => { - const app = express_1.default(); + const app = (0, express_1.default)(); app.use('/', (req, res, next) => { if (process.env.DEBUG) console.log('Receiving request on mocked server %s.', req.url); @@ -28,7 +28,7 @@ class MockInstancesIndex { data: filtered }); }); - const port = 42000 + core_utils_1.randomInt(1, 1000); + const port = 42000 + (0, core_utils_1.randomInt)(1, 1000); app.listen(port, () => res(port)); }); } diff --git a/dist/shared/extra-utils/mock-servers/mock-joinpeertube-versions.js b/dist/shared/extra-utils/mock-servers/mock-joinpeertube-versions.js index 22ec69d3..d8b2a72e 100644 --- a/dist/shared/extra-utils/mock-servers/mock-joinpeertube-versions.js +++ b/dist/shared/extra-utils/mock-servers/mock-joinpeertube-versions.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockJoinPeerTubeVersions = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@shared/core-utils"); class MockJoinPeerTubeVersions { initialize() { return new Promise(res => { - const app = express_1.default(); + const app = (0, express_1.default)(); app.use('/', (req, res, next) => { if (process.env.DEBUG) console.log('Receiving request on mocked server %s.', req.url); @@ -20,7 +20,7 @@ class MockJoinPeerTubeVersions { } }); }); - const port = 43000 + core_utils_1.randomInt(1, 1000); + const port = 43000 + (0, core_utils_1.randomInt)(1, 1000); app.listen(port, () => res(port)); }); } diff --git a/dist/shared/extra-utils/mock-servers/mock-object-storage.js b/dist/shared/extra-utils/mock-servers/mock-object-storage.js index 4d16d802..e0e52f00 100644 --- a/dist/shared/extra-utils/mock-servers/mock-object-storage.js +++ b/dist/shared/extra-utils/mock-servers/mock-object-storage.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockObjectStorage = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); -const got_1 = tslib_1.__importDefault(require("got")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); +const got_1 = (0, tslib_1.__importDefault)(require("got")); const stream_1 = require("stream"); const core_utils_1 = require("@shared/core-utils"); const server_1 = require("../server"); @@ -11,25 +11,25 @@ const utils_1 = require("./utils"); class MockObjectStorage { initialize() { return new Promise(res => { - const app = express_1.default(); + const app = (0, express_1.default)(); app.get('/:bucketName/:path(*)', (req, res, next) => { const url = `http://${req.params.bucketName}.${server_1.ObjectStorageCommand.getEndpointHost()}/${req.params.path}`; if (process.env.DEBUG) { console.log('Receiving request on mocked server %s.', req.url); console.log('Proxifying request to %s', url); } - return stream_1.pipeline(got_1.default.stream(url, { throwHttpErrors: false }), res, (err) => { + return (0, stream_1.pipeline)(got_1.default.stream(url, { throwHttpErrors: false }), res, (err) => { if (!err) return; console.error('Pipeline failed.', err); }); }); - const port = 44000 + core_utils_1.randomInt(1, 1000); + const port = 44000 + (0, core_utils_1.randomInt)(1, 1000); this.server = app.listen(port, () => res(port)); }); } terminate() { - return utils_1.terminateServer(this.server); + return (0, utils_1.terminateServer)(this.server); } } exports.MockObjectStorage = MockObjectStorage; diff --git a/dist/shared/extra-utils/mock-servers/mock-plugin-blocklist.js b/dist/shared/extra-utils/mock-servers/mock-plugin-blocklist.js index b741cb7e..bc3698fc 100644 --- a/dist/shared/extra-utils/mock-servers/mock-plugin-blocklist.js +++ b/dist/shared/extra-utils/mock-servers/mock-plugin-blocklist.js @@ -2,17 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockBlocklist = void 0; const tslib_1 = require("tslib"); -const express_1 = tslib_1.__importDefault(require("express")); +const express_1 = (0, tslib_1.__importDefault)(require("express")); const core_utils_1 = require("@shared/core-utils"); const utils_1 = require("./utils"); class MockBlocklist { initialize() { return new Promise(res => { - const app = express_1.default(); + const app = (0, express_1.default)(); app.get('/blocklist', (req, res) => { return res.json(this.body); }); - const port = 45000 + core_utils_1.randomInt(1, 1000); + const port = 45000 + (0, core_utils_1.randomInt)(1, 1000); this.server = app.listen(port, () => res(port)); }); } @@ -20,7 +20,7 @@ class MockBlocklist { this.body = body; } terminate() { - return utils_1.terminateServer(this.server); + return (0, utils_1.terminateServer)(this.server); } } exports.MockBlocklist = MockBlocklist; diff --git a/dist/shared/extra-utils/mock-servers/mock-proxy.js b/dist/shared/extra-utils/mock-servers/mock-proxy.js index af49de64..74e8bb59 100644 --- a/dist/shared/extra-utils/mock-servers/mock-proxy.js +++ b/dist/shared/extra-utils/mock-servers/mock-proxy.js @@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MockProxy = void 0; const tslib_1 = require("tslib"); const http_1 = require("http"); -const proxy_1 = tslib_1.__importDefault(require("proxy")); +const proxy_1 = (0, tslib_1.__importDefault)(require("proxy")); const core_utils_1 = require("@shared/core-utils"); const utils_1 = require("./utils"); class MockProxy { initialize() { return new Promise(res => { - const port = 46000 + core_utils_1.randomInt(1, 1000); - this.server = proxy_1.default(http_1.createServer()); + const port = 46000 + (0, core_utils_1.randomInt)(1, 1000); + this.server = (0, proxy_1.default)((0, http_1.createServer)()); this.server.listen(port, () => res(port)); }); } terminate() { - return utils_1.terminateServer(this.server); + return (0, utils_1.terminateServer)(this.server); } } exports.MockProxy = MockProxy; diff --git a/dist/shared/extra-utils/moderation/abuses-command.js b/dist/shared/extra-utils/moderation/abuses-command.js index 19ad03a8..5a7cc23d 100644 --- a/dist/shared/extra-utils/moderation/abuses-command.js +++ b/dist/shared/extra-utils/moderation/abuses-command.js @@ -28,7 +28,7 @@ class AbusesCommand extends shared_1.AbstractCommand { reason: options.reason, predefinedReasons: options.predefinedReasons }; - return requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: body, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: body, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } getAdminList(options = {}) { const toPick = [ @@ -48,7 +48,7 @@ class AbusesCommand extends shared_1.AbstractCommand { ]; const path = '/api/v1/abuses'; const defaultQuery = { sort: 'createdAt' }; - const query = Object.assign(Object.assign({}, defaultQuery), core_utils_1.pick(options, toPick)); + const query = Object.assign(Object.assign({}, defaultQuery), (0, core_utils_1.pick)(options, toPick)); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } @@ -63,7 +63,7 @@ class AbusesCommand extends shared_1.AbstractCommand { ]; const path = '/api/v1/users/me/abuses'; const defaultQuery = { sort: 'createdAt' }; - const query = Object.assign(Object.assign({}, defaultQuery), core_utils_1.pick(options, toPick)); + const query = Object.assign(Object.assign({}, defaultQuery), (0, core_utils_1.pick)(options, toPick)); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } diff --git a/dist/shared/extra-utils/moderation/index.js b/dist/shared/extra-utils/moderation/index.js index 822811c7..11660e34 100644 --- a/dist/shared/extra-utils/moderation/index.js +++ b/dist/shared/extra-utils/moderation/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuses-command"), exports); +(0, tslib_1.__exportStar)(require("./abuses-command"), exports); diff --git a/dist/shared/extra-utils/overviews/index.js b/dist/shared/extra-utils/overviews/index.js index 040b1621..38336960 100644 --- a/dist/shared/extra-utils/overviews/index.js +++ b/dist/shared/extra-utils/overviews/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./overviews-command"), exports); +(0, tslib_1.__exportStar)(require("./overviews-command"), exports); diff --git a/dist/shared/extra-utils/requests/activitypub.js b/dist/shared/extra-utils/requests/activitypub.js index 3372d946..5ac511ce 100644 --- a/dist/shared/extra-utils/requests/activitypub.js +++ b/dist/shared/extra-utils/requests/activitypub.js @@ -13,18 +13,18 @@ function makePOSTAPRequest(url, body, httpSignature, headers) { httpSignature, headers }; - return requests_1.doRequest(url, options); + return (0, requests_1.doRequest)(url, options); } exports.makePOSTAPRequest = makePOSTAPRequest; function makeFollowRequest(to, by) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const follow = { type: 'Follow', id: by.url + '/' + new Date().getTime(), actor: by.url, object: to.url }; - const body = activitypub_1.activityPubContextify(follow); + const body = (0, activitypub_1.activityPubContextify)(follow); const httpSignature = { algorithm: constants_1.HTTP_SIGNATURE.ALGORITHM, authorizationHeaderName: constants_1.HTTP_SIGNATURE.HEADER_NAME, @@ -32,7 +32,7 @@ function makeFollowRequest(to, by) { key: by.privateKey, headers: constants_1.HTTP_SIGNATURE.HEADERS_TO_SIGN }; - const headers = activitypub_http_utils_1.buildGlobalHeaders(body); + const headers = (0, activitypub_http_utils_1.buildGlobalHeaders)(body); return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers); }); } diff --git a/dist/shared/extra-utils/requests/check-api-params.js b/dist/shared/extra-utils/requests/check-api-params.js index 40a0931a..6ca922b6 100644 --- a/dist/shared/extra-utils/requests/check-api-params.js +++ b/dist/shared/extra-utils/requests/check-api-params.js @@ -5,7 +5,7 @@ const tslib_1 = require("tslib"); const models_1 = require("@shared/models"); const requests_1 = require("./requests"); function checkBadStartPagination(url, path, token, query = {}) { - return requests_1.makeGetRequest({ + return (0, requests_1.makeGetRequest)({ url, path, token, @@ -15,15 +15,15 @@ function checkBadStartPagination(url, path, token, query = {}) { } exports.checkBadStartPagination = checkBadStartPagination; function checkBadCountPagination(url, path, token, query = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield requests_1.makeGetRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, requests_1.makeGetRequest)({ url, path, token, query: Object.assign(Object.assign({}, query), { count: 'hello' }), expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }); - yield requests_1.makeGetRequest({ + yield (0, requests_1.makeGetRequest)({ url, path, token, @@ -34,7 +34,7 @@ function checkBadCountPagination(url, path, token, query = {}) { } exports.checkBadCountPagination = checkBadCountPagination; function checkBadSortPagination(url, path, token, query = {}) { - return requests_1.makeGetRequest({ + return (0, requests_1.makeGetRequest)({ url, path, token, diff --git a/dist/shared/extra-utils/requests/index.js b/dist/shared/extra-utils/requests/index.js index 3b5fb1c4..d0a079eb 100644 --- a/dist/shared/extra-utils/requests/index.js +++ b/dist/shared/extra-utils/requests/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./check-api-params"), exports); -tslib_1.__exportStar(require("./requests"), exports); +(0, tslib_1.__exportStar)(require("./check-api-params"), exports); +(0, tslib_1.__exportStar)(require("./requests"), exports); diff --git a/dist/shared/extra-utils/requests/requests.js b/dist/shared/extra-utils/requests/requests.js index e7a53c79..a7679af7 100644 --- a/dist/shared/extra-utils/requests/requests.js +++ b/dist/shared/extra-utils/requests/requests.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.unwrapText = exports.unwrapBodyOrDecodeToJSON = exports.unwrapTextOrDecode = exports.unwrapBody = exports.makeActivityPubGetRequest = exports.makeRawRequest = exports.makeDeleteRequest = exports.makePutBodyRequest = exports.makePostBodyRequest = exports.makeUploadRequest = exports.decodeQueryString = exports.makeGetRequest = exports.makeHTMLRequest = void 0; const tslib_1 = require("tslib"); const querystring_1 = require("querystring"); -const supertest_1 = tslib_1.__importDefault(require("supertest")); +const supertest_1 = (0, tslib_1.__importDefault)(require("supertest")); const url_1 = require("url"); const models_1 = require("@shared/models"); const tests_1 = require("../miscs/tests"); @@ -13,7 +13,7 @@ function makeRawRequest(url, expectedStatus, range) { } exports.makeRawRequest = makeRawRequest; function makeGetRequest(options) { - const req = supertest_1.default(options.url).get(options.path); + const req = (0, supertest_1.default)(options.url).get(options.path); if (options.query) req.query(options.query); if (options.rawQuery) @@ -40,7 +40,7 @@ function makeActivityPubGetRequest(url, path, expectedStatus = models_1.HttpStat } exports.makeActivityPubGetRequest = makeActivityPubGetRequest; function makeDeleteRequest(options) { - const req = supertest_1.default(options.url).delete(options.path); + const req = (0, supertest_1.default)(options.url).delete(options.path); if (options.query) req.query(options.query); if (options.rawQuery) @@ -50,36 +50,36 @@ function makeDeleteRequest(options) { exports.makeDeleteRequest = makeDeleteRequest; function makeUploadRequest(options) { let req = options.method === 'PUT' - ? supertest_1.default(options.url).put(options.path) - : supertest_1.default(options.url).post(options.path); + ? (0, supertest_1.default)(options.url).put(options.path) + : (0, supertest_1.default)(options.url).post(options.path); req = buildRequest(req, Object.assign({ accept: 'application/json', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, options)); buildFields(req, options.fields); Object.keys(options.attaches || {}).forEach(attach => { const value = options.attaches[attach]; if (Array.isArray(value)) { - req.attach(attach, tests_1.buildAbsoluteFixturePath(value[0]), value[1]); + req.attach(attach, (0, tests_1.buildAbsoluteFixturePath)(value[0]), value[1]); } else { - req.attach(attach, tests_1.buildAbsoluteFixturePath(value)); + req.attach(attach, (0, tests_1.buildAbsoluteFixturePath)(value)); } }); return req; } exports.makeUploadRequest = makeUploadRequest; function makePostBodyRequest(options) { - const req = supertest_1.default(options.url).post(options.path) + const req = (0, supertest_1.default)(options.url).post(options.path) .send(options.fields); return buildRequest(req, Object.assign({ accept: 'application/json', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, options)); } exports.makePostBodyRequest = makePostBodyRequest; function makePutBodyRequest(options) { - const req = supertest_1.default(options.url).put(options.path) + const req = (0, supertest_1.default)(options.url).put(options.path) .send(options.fields); return buildRequest(req, Object.assign({ accept: 'application/json', expectedStatus: models_1.HttpStatusCode.BAD_REQUEST_400 }, options)); } exports.makePutBodyRequest = makePutBodyRequest; function decodeQueryString(path) { - return querystring_1.decode(path.split('?')[1]); + return (0, querystring_1.decode)(path.split('?')[1]); } exports.decodeQueryString = decodeQueryString; function unwrapBody(test) { diff --git a/dist/shared/extra-utils/search/index.js b/dist/shared/extra-utils/search/index.js index c9db6c7d..63dc844b 100644 --- a/dist/shared/extra-utils/search/index.js +++ b/dist/shared/extra-utils/search/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./search-command"), exports); +(0, tslib_1.__exportStar)(require("./search-command"), exports); diff --git a/dist/shared/extra-utils/server/config-command.js b/dist/shared/extra-utils/server/config-command.js index c70850b5..aaee93da 100644 --- a/dist/shared/extra-utils/server/config-command.js +++ b/dist/shared/extra-utils/server/config-command.js @@ -94,9 +94,9 @@ class ConfigCommand extends shared_1.AbstractCommand { return this.deleteRequest(Object.assign(Object.assign({}, options), { path, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } updateExistingSubConfig(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const existing = yield this.getCustomConfig(options); - return this.updateCustomConfig(Object.assign(Object.assign({}, options), { newCustomConfig: lodash_1.merge({}, existing, options.newConfig) })); + return this.updateCustomConfig(Object.assign(Object.assign({}, options), { newCustomConfig: (0, lodash_1.merge)({}, existing, options.newConfig) })); }); } updateCustomSubConfig(options) { @@ -266,7 +266,7 @@ class ConfigCommand extends shared_1.AbstractCommand { } } }; - lodash_1.merge(newCustomConfig, options.newConfig); + (0, lodash_1.merge)(newCustomConfig, options.newConfig); return this.updateCustomConfig(Object.assign(Object.assign({}, options), { newCustomConfig })); } } diff --git a/dist/shared/extra-utils/server/directories.js b/dist/shared/extra-utils/server/directories.js index 1eb86dd0..8aaceeff 100644 --- a/dist/shared/extra-utils/server/directories.js +++ b/dist/shared/extra-utils/server/directories.js @@ -7,23 +7,23 @@ const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const core_utils_1 = require("@server/helpers/core-utils"); function checkTmpIsEmpty(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield checkDirectoryIsEmpty(server, 'tmp', ['plugins-global.css', 'hls', 'resumable-uploads']); - if (yield fs_extra_1.pathExists(path_1.join('test' + server.internalServerNumber, 'tmp', 'hls'))) { + if (yield (0, fs_extra_1.pathExists)((0, path_1.join)('test' + server.internalServerNumber, 'tmp', 'hls'))) { yield checkDirectoryIsEmpty(server, 'tmp/hls'); } }); } exports.checkTmpIsEmpty = checkTmpIsEmpty; function checkDirectoryIsEmpty(server, directory, exceptions = []) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const testDirectory = 'test' + server.internalServerNumber; - const directoryPath = path_1.join(core_utils_1.root(), testDirectory, directory); - const directoryExists = yield fs_extra_1.pathExists(directoryPath); - chai_1.expect(directoryExists).to.be.true; - const files = yield fs_extra_1.readdir(directoryPath); + const directoryPath = (0, path_1.join)((0, core_utils_1.root)(), testDirectory, directory); + const directoryExists = yield (0, fs_extra_1.pathExists)(directoryPath); + (0, chai_1.expect)(directoryExists).to.be.true; + const files = yield (0, fs_extra_1.readdir)(directoryPath); const filtered = files.filter(f => exceptions.includes(f) === false); - chai_1.expect(filtered).to.have.lengthOf(0); + (0, chai_1.expect)(filtered).to.have.lengthOf(0); }); } exports.checkDirectoryIsEmpty = checkDirectoryIsEmpty; diff --git a/dist/shared/extra-utils/server/follows-command.js b/dist/shared/extra-utils/server/follows-command.js index c50891f4..50f235aa 100644 --- a/dist/shared/extra-utils/server/follows-command.js +++ b/dist/shared/extra-utils/server/follows-command.js @@ -8,13 +8,13 @@ const shared_1 = require("../shared"); class FollowsCommand extends shared_1.AbstractCommand { getFollowers(options) { const path = '/api/v1/server/followers'; - const query = core_utils_1.pick(options, ['start', 'count', 'sort', 'search', 'state', 'actorType']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'search', 'state', 'actorType']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } getFollowings(options = {}) { const path = '/api/v1/server/following'; - const query = core_utils_1.pick(options, ['start', 'count', 'sort', 'search', 'state', 'actorType']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'search', 'state', 'actorType']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } @@ -31,7 +31,7 @@ class FollowsCommand extends shared_1.AbstractCommand { fields, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } unfollow(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { target } = options; const handle = typeof target === 'string' ? target diff --git a/dist/shared/extra-utils/server/follows.js b/dist/shared/extra-utils/server/follows.js index 09fedc9d..9ee17456 100644 --- a/dist/shared/extra-utils/server/follows.js +++ b/dist/shared/extra-utils/server/follows.js @@ -4,12 +4,12 @@ exports.doubleFollow = void 0; const tslib_1 = require("tslib"); const jobs_1 = require("./jobs"); function doubleFollow(server1, server2) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield Promise.all([ server1.follows.follow({ hosts: [server2.url] }), server2.follows.follow({ hosts: [server1.url] }) ]); - yield jobs_1.waitJobs([server1, server2]); + yield (0, jobs_1.waitJobs)([server1, server2]); return true; }); } diff --git a/dist/shared/extra-utils/server/index.js b/dist/shared/extra-utils/server/index.js index ec2ac86b..58225437 100644 --- a/dist/shared/extra-utils/server/index.js +++ b/dist/shared/extra-utils/server/index.js @@ -1,20 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./config-command"), exports); -tslib_1.__exportStar(require("./contact-form-command"), exports); -tslib_1.__exportStar(require("./debug-command"), exports); -tslib_1.__exportStar(require("./directories"), exports); -tslib_1.__exportStar(require("./follows-command"), exports); -tslib_1.__exportStar(require("./follows"), exports); -tslib_1.__exportStar(require("./jobs"), exports); -tslib_1.__exportStar(require("./jobs-command"), exports); -tslib_1.__exportStar(require("./object-storage-command"), exports); -tslib_1.__exportStar(require("./plugins-command"), exports); -tslib_1.__exportStar(require("./plugins"), exports); -tslib_1.__exportStar(require("./redundancy-command"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./servers-command"), exports); -tslib_1.__exportStar(require("./servers"), exports); -tslib_1.__exportStar(require("./stats-command"), exports); -tslib_1.__exportStar(require("./tracker"), exports); +(0, tslib_1.__exportStar)(require("./config-command"), exports); +(0, tslib_1.__exportStar)(require("./contact-form-command"), exports); +(0, tslib_1.__exportStar)(require("./debug-command"), exports); +(0, tslib_1.__exportStar)(require("./directories"), exports); +(0, tslib_1.__exportStar)(require("./follows-command"), exports); +(0, tslib_1.__exportStar)(require("./follows"), exports); +(0, tslib_1.__exportStar)(require("./jobs"), exports); +(0, tslib_1.__exportStar)(require("./jobs-command"), exports); +(0, tslib_1.__exportStar)(require("./object-storage-command"), exports); +(0, tslib_1.__exportStar)(require("./plugins-command"), exports); +(0, tslib_1.__exportStar)(require("./plugins"), exports); +(0, tslib_1.__exportStar)(require("./redundancy-command"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./servers-command"), exports); +(0, tslib_1.__exportStar)(require("./servers"), exports); +(0, tslib_1.__exportStar)(require("./stats-command"), exports); +(0, tslib_1.__exportStar)(require("./tracker"), exports); diff --git a/dist/shared/extra-utils/server/jobs-command.js b/dist/shared/extra-utils/server/jobs-command.js index 4d193525..468a542e 100644 --- a/dist/shared/extra-utils/server/jobs-command.js +++ b/dist/shared/extra-utils/server/jobs-command.js @@ -7,7 +7,7 @@ const models_1 = require("@shared/models"); const shared_1 = require("../shared"); class JobsCommand extends shared_1.AbstractCommand { getLatest(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield this.list(Object.assign(Object.assign({}, options), { start: 0, count: 1, sort: '-createdAt' })); if (data.length === 0) return undefined; @@ -16,7 +16,7 @@ class JobsCommand extends shared_1.AbstractCommand { } list(options = {}) { const path = this.buildJobsUrl(options.state); - const query = core_utils_1.pick(options, ['start', 'count', 'sort', 'jobType']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'jobType']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } diff --git a/dist/shared/extra-utils/server/jobs.js b/dist/shared/extra-utils/server/jobs.js index c55f03ca..1e8ffb42 100644 --- a/dist/shared/extra-utils/server/jobs.js +++ b/dist/shared/extra-utils/server/jobs.js @@ -4,7 +4,7 @@ exports.waitJobs = void 0; const tslib_1 = require("tslib"); const miscs_1 = require("../miscs"); function waitJobs(serversArg, skipDelayed = false) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) : 250; @@ -50,11 +50,11 @@ function waitJobs(serversArg, skipDelayed = false) { pendingRequests = false; yield Promise.all(tasksBuilder()); if (pendingRequests === false) { - yield miscs_1.wait(pendingJobWait); + yield (0, miscs_1.wait)(pendingJobWait); yield Promise.all(tasksBuilder()); } if (pendingRequests) { - yield miscs_1.wait(pendingJobWait); + yield (0, miscs_1.wait)(pendingJobWait); } } while (pendingRequests); }); diff --git a/dist/shared/extra-utils/server/object-storage-command.js b/dist/shared/extra-utils/server/object-storage-command.js index d60d1910..7b28f950 100644 --- a/dist/shared/extra-utils/server/object-storage-command.js +++ b/dist/shared/extra-utils/server/object-storage-command.js @@ -41,24 +41,24 @@ class ObjectStorageCommand extends shared_1.AbstractCommand { return `http://${this.DEFAULT_PLAYLIST_BUCKET}.${this.getEndpointHost()}/`; } static prepareDefaultBuckets() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield this.createBucket(this.DEFAULT_PLAYLIST_BUCKET); yield this.createBucket(this.DEFAULT_WEBTORRENT_BUCKET); }); } static createBucket(name) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield requests_1.makePostBodyRequest({ + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + yield (0, requests_1.makePostBodyRequest)({ url: this.getEndpointHost(), path: '/ui/' + name + '?delete', expectedStatus: models_1.HttpStatusCode.TEMPORARY_REDIRECT_307 }); - yield requests_1.makePostBodyRequest({ + yield (0, requests_1.makePostBodyRequest)({ url: this.getEndpointHost(), path: '/ui/' + name + '?create', expectedStatus: models_1.HttpStatusCode.TEMPORARY_REDIRECT_307 }); - yield requests_1.makePostBodyRequest({ + yield (0, requests_1.makePostBodyRequest)({ url: this.getEndpointHost(), path: '/ui/' + name + '?make-public', expectedStatus: models_1.HttpStatusCode.TEMPORARY_REDIRECT_307 diff --git a/dist/shared/extra-utils/server/plugins-command.js b/dist/shared/extra-utils/server/plugins-command.js index 7edc8e0e..006976d4 100644 --- a/dist/shared/extra-utils/server/plugins-command.js +++ b/dist/shared/extra-utils/server/plugins-command.js @@ -8,7 +8,7 @@ const models_1 = require("@shared/models"); const shared_1 = require("../shared"); class PluginsCommand extends shared_1.AbstractCommand { static getPluginTestPath(suffix = '') { - return path_1.join(core_utils_1.root(), 'server', 'tests', 'fixtures', 'peertube-plugin-test' + suffix); + return (0, path_1.join)((0, core_utils_1.root)(), 'server', 'tests', 'fixtures', 'peertube-plugin-test' + suffix); } list(options) { const { start, count, sort, pluginType, uninstalled } = options; @@ -85,14 +85,14 @@ class PluginsCommand extends shared_1.AbstractCommand { } updatePackageJSON(npmName, json) { const path = this.getPackageJSONPath(npmName); - return fs_extra_1.writeJSON(path, json); + return (0, fs_extra_1.writeJSON)(path, json); } getPackageJSON(npmName) { const path = this.getPackageJSONPath(npmName); - return fs_extra_1.readJSON(path); + return (0, fs_extra_1.readJSON)(path); } getPackageJSONPath(npmName) { - return this.server.servers.buildDirectory(path_1.join('plugins', 'node_modules', npmName, 'package.json')); + return this.server.servers.buildDirectory((0, path_1.join)('plugins', 'node_modules', npmName, 'package.json')); } } exports.PluginsCommand = PluginsCommand; diff --git a/dist/shared/extra-utils/server/plugins.js b/dist/shared/extra-utils/server/plugins.js index 65a75f8c..0694590d 100644 --- a/dist/shared/extra-utils/server/plugins.js +++ b/dist/shared/extra-utils/server/plugins.js @@ -4,12 +4,12 @@ exports.testHelloWorldRegisteredSettings = void 0; const tslib_1 = require("tslib"); const chai_1 = require("chai"); function testHelloWorldRegisteredSettings(server) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const body = yield server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }); const registeredSettings = body.registeredSettings; - chai_1.expect(registeredSettings).to.have.length.at.least(1); + (0, chai_1.expect)(registeredSettings).to.have.length.at.least(1); const adminNameSettings = registeredSettings.find(s => s.name === 'admin-name'); - chai_1.expect(adminNameSettings).to.not.be.undefined; + (0, chai_1.expect)(adminNameSettings).to.not.be.undefined; }); } exports.testHelloWorldRegisteredSettings = testHelloWorldRegisteredSettings; diff --git a/dist/shared/extra-utils/server/server.js b/dist/shared/extra-utils/server/server.js index 0efa5012..c8b1d4c1 100644 --- a/dist/shared/extra-utils/server/server.js +++ b/dist/shared/extra-utils/server/server.js @@ -52,7 +52,7 @@ class PeerTubeServer { } setServerNumber(serverNumber) { this.serverNumber = serverNumber; - this.parallel = miscs_1.parallelTests(); + this.parallel = (0, miscs_1.parallelTests)(); this.internalServerNumber = this.parallel ? this.randomServer() : this.serverNumber; this.rtmpPort = this.parallel ? this.randomRTMP() : 1936; this.port = 9000 + this.internalServerNumber; @@ -68,13 +68,13 @@ class PeerTubeServer { this.port = parseInt(parsed.port); } flushAndRun(configOverride, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield servers_command_1.ServersCommand.flushTests(this.internalServerNumber); return this.run(configOverride, options); }); } run(configOverrideArg, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const serverRunString = { 'HTTP server listening': false }; @@ -106,7 +106,7 @@ class PeerTubeServer { }; return new Promise((res, rej) => { const self = this; - this.app = child_process_1.fork(path_1.join(core_utils_1.root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions); + this.app = (0, child_process_1.fork)((0, path_1.join)((0, core_utils_1.root)(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions); const onPeerTubeExit = () => rej(new Error('Process exited')); const onParentExit = () => { if (!this.app || !this.app.pid) @@ -156,7 +156,7 @@ class PeerTubeServer { }); } kill() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!this.app) return; yield this.sql.cleanup(); @@ -167,20 +167,20 @@ class PeerTubeServer { randomServer() { const low = 10; const high = 10000; - return core_utils_2.randomInt(low, high); + return (0, core_utils_2.randomInt)(low, high); } randomRTMP() { const low = 1900; const high = 2100; - return core_utils_2.randomInt(low, high); + return (0, core_utils_2.randomInt)(low, high); } assignCustomConfigFile() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (this.internalServerNumber === this.serverNumber) return; - const basePath = path_1.join(core_utils_1.root(), 'config'); - const tmpConfigFile = path_1.join(basePath, `test-${this.internalServerNumber}.yaml`); - yield fs_extra_1.copy(path_1.join(basePath, `test-${this.serverNumber}.yaml`), tmpConfigFile); + const basePath = (0, path_1.join)((0, core_utils_1.root)(), 'config'); + const tmpConfigFile = (0, path_1.join)(basePath, `test-${this.internalServerNumber}.yaml`); + yield (0, fs_extra_1.copy)((0, path_1.join)(basePath, `test-${this.serverNumber}.yaml`), tmpConfigFile); this.customConfigFile = tmpConfigFile; }); } diff --git a/dist/shared/extra-utils/server/servers-command.js b/dist/shared/extra-utils/server/servers-command.js index 8fc01578..bc04552b 100644 --- a/dist/shared/extra-utils/server/servers-command.js +++ b/dist/shared/extra-utils/server/servers-command.js @@ -13,7 +13,7 @@ class ServersCommand extends shared_1.AbstractCommand { static flushTests(internalServerNumber) { return new Promise((res, rej) => { const suffix = ` -- ${internalServerNumber}`; - return child_process_1.exec('npm run clean:server:test' + suffix, (err, _stdout, stderr) => { + return (0, child_process_1.exec)('npm run clean:server:test' + suffix, (err, _stdout, stderr) => { if (err || stderr) return rej(err || new Error(stderr)); return res(); @@ -24,54 +24,54 @@ class ServersCommand extends shared_1.AbstractCommand { return this.getRequestBody(Object.assign(Object.assign({}, options), { path: '/api/v1/ping', implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } cleanupTests() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const p = []; - if (miscs_1.isGithubCI()) { - yield fs_extra_1.ensureDir('artifacts'); + if ((0, miscs_1.isGithubCI)()) { + yield (0, fs_extra_1.ensureDir)('artifacts'); const origin = this.buildDirectory('logs/peertube.log'); const destname = `peertube-${this.server.internalServerNumber}.log`; console.log('Saving logs %s.', destname); - yield fs_extra_1.copy(origin, path_1.join('artifacts', destname)); + yield (0, fs_extra_1.copy)(origin, (0, path_1.join)('artifacts', destname)); } if (this.server.parallel) { p.push(ServersCommand.flushTests(this.server.internalServerNumber)); } if (this.server.customConfigFile) { - p.push(fs_extra_1.remove(this.server.customConfigFile)); + p.push((0, fs_extra_1.remove)(this.server.customConfigFile)); } return p; }); } waitUntilLog(str, count = 1, strictCount = true) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const logfile = this.buildDirectory('logs/peertube.log'); while (true) { - const buf = yield fs_extra_1.readFile(logfile); + const buf = yield (0, fs_extra_1.readFile)(logfile); const matches = buf.toString().match(new RegExp(str, 'g')); if (matches && matches.length === count) return; if (matches && strictCount === false && matches.length >= count) return; - yield miscs_1.wait(1000); + yield (0, miscs_1.wait)(1000); } }); } buildDirectory(directory) { - return path_1.join(core_utils_1.root(), 'test' + this.server.internalServerNumber, directory); + return (0, path_1.join)((0, core_utils_1.root)(), 'test' + this.server.internalServerNumber, directory); } buildWebTorrentFilePath(fileUrl) { - return this.buildDirectory(path_1.join('videos', path_1.basename(fileUrl))); + return this.buildDirectory((0, path_1.join)('videos', (0, path_1.basename)(fileUrl))); } buildFragmentedFilePath(videoUUID, fileUrl) { - return this.buildDirectory(path_1.join('streaming-playlists', 'hls', videoUUID, path_1.basename(fileUrl))); + return this.buildDirectory((0, path_1.join)('streaming-playlists', 'hls', videoUUID, (0, path_1.basename)(fileUrl))); } getLogContent() { - return fs_extra_1.readFile(this.buildDirectory('logs/peertube.log')); + return (0, fs_extra_1.readFile)(this.buildDirectory('logs/peertube.log')); } getServerFileSize(subPath) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = this.server.servers.buildDirectory(subPath); - return miscs_1.getFileSize(path); + return (0, miscs_1.getFileSize)(path); }); } } diff --git a/dist/shared/extra-utils/server/servers.js b/dist/shared/extra-utils/server/servers.js index 4f13bf22..222abfd7 100644 --- a/dist/shared/extra-utils/server/servers.js +++ b/dist/shared/extra-utils/server/servers.js @@ -6,7 +6,7 @@ const fs_extra_1 = require("fs-extra"); const miscs_1 = require("../miscs"); const server_1 = require("./server"); function createSingleServer(serverNumber, configOverride, options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = new server_1.PeerTubeServer({ serverNumber }); yield server.flushAndRun(configOverride, options); return server; @@ -22,16 +22,16 @@ function createMultipleServers(totalServers, configOverride, options = {}) { } exports.createMultipleServers = createMultipleServers; function killallServers(servers) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return Promise.all(servers.map(s => s.kill())); }); } exports.killallServers = killallServers; function cleanupTests(servers) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { yield killallServers(servers); - if (miscs_1.isGithubCI()) { - yield fs_extra_1.ensureDir('artifacts'); + if ((0, miscs_1.isGithubCI)()) { + yield (0, fs_extra_1.ensureDir)('artifacts'); } let p = []; for (const server of servers) { diff --git a/dist/shared/extra-utils/server/tracker.js b/dist/shared/extra-utils/server/tracker.js index d0ad81e2..263e9f09 100644 --- a/dist/shared/extra-utils/server/tracker.js +++ b/dist/shared/extra-utils/server/tracker.js @@ -6,19 +6,19 @@ const chai_1 = require("chai"); const core_utils_1 = require("@server/helpers/core-utils"); const requests_1 = require("../requests"); function hlsInfohashExist(serverUrl, masterPlaylistUrl, fileNumber) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/tracker/announce'; - const infohash = core_utils_1.sha1(`2${masterPlaylistUrl}+V${fileNumber}`); + const infohash = (0, core_utils_1.sha1)(`2${masterPlaylistUrl}+V${fileNumber}`); const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) { return '%' + char.charCodeAt(0).toString(16).toUpperCase(); }); - const res = yield requests_1.makeGetRequest({ + const res = yield (0, requests_1.makeGetRequest)({ url: serverUrl, path, rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`, expectedStatus: 200 }); - chai_1.expect(res.text).to.not.contain('failure'); + (0, chai_1.expect)(res.text).to.not.contain('failure'); }); } exports.hlsInfohashExist = hlsInfohashExist; diff --git a/dist/shared/extra-utils/shared/abstract-command.js b/dist/shared/extra-utils/shared/abstract-command.js index 3fc25c3c..701bf21b 100644 --- a/dist/shared/extra-utils/shared/abstract-command.js +++ b/dist/shared/extra-utils/shared/abstract-command.js @@ -9,10 +9,10 @@ class AbstractCommand { this.server = server; } getRequestBody(options) { - return requests_1.unwrapBody(this.getRequest(options)); + return (0, requests_1.unwrapBody)(this.getRequest(options)); } getRequestText(options) { - return requests_1.unwrapText(this.getRequest(options)); + return (0, requests_1.unwrapText)(this.getRequest(options)); } getRawRequest(options) { const { url, range } = options; @@ -21,35 +21,35 @@ class AbstractCommand { } getRequest(options) { const { query } = options; - return requests_1.makeGetRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { query })); + return (0, requests_1.makeGetRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { query })); } deleteRequest(options) { const { query, rawQuery } = options; - return requests_1.makeDeleteRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { query, + return (0, requests_1.makeDeleteRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { query, rawQuery })); } putBodyRequest(options) { const { fields } = options; - return requests_1.makePutBodyRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { fields })); + return (0, requests_1.makePutBodyRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { fields })); } postBodyRequest(options) { const { fields } = options; - return requests_1.makePostBodyRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { fields })); + return (0, requests_1.makePostBodyRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { fields })); } postUploadRequest(options) { const { fields, attaches } = options; - return requests_1.makeUploadRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { method: 'POST', fields, + return (0, requests_1.makeUploadRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { method: 'POST', fields, attaches })); } putUploadRequest(options) { const { fields, attaches } = options; - return requests_1.makeUploadRequest(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { method: 'PUT', fields, + return (0, requests_1.makeUploadRequest)(Object.assign(Object.assign({}, this.buildCommonRequestOptions(options)), { method: 'PUT', fields, attaches })); } updateImageRequest(options) { - const filePath = path_1.isAbsolute(options.fixture) + const filePath = (0, path_1.isAbsolute)(options.fixture) ? options.fixture - : path_1.join(tests_1.root(), 'server', 'tests', 'fixtures', options.fixture); + : (0, path_1.join)((0, tests_1.root)(), 'server', 'tests', 'fixtures', options.fixture); return this.postUploadRequest(Object.assign(Object.assign({}, options), { fields: {}, attaches: { [options.fieldname]: filePath } })); } buildCommonRequestOptions(options) { diff --git a/dist/shared/extra-utils/shared/index.js b/dist/shared/extra-utils/shared/index.js index 32146a83..77e71c12 100644 --- a/dist/shared/extra-utils/shared/index.js +++ b/dist/shared/extra-utils/shared/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abstract-command"), exports); +(0, tslib_1.__exportStar)(require("./abstract-command"), exports); diff --git a/dist/shared/extra-utils/socket/index.js b/dist/shared/extra-utils/socket/index.js index fd7fe920..4470244d 100644 --- a/dist/shared/extra-utils/socket/index.js +++ b/dist/shared/extra-utils/socket/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./socket-io-command"), exports); +(0, tslib_1.__exportStar)(require("./socket-io-command"), exports); diff --git a/dist/shared/extra-utils/socket/socket-io-command.js b/dist/shared/extra-utils/socket/socket-io-command.js index ddcebc84..660db7ef 100644 --- a/dist/shared/extra-utils/socket/socket-io-command.js +++ b/dist/shared/extra-utils/socket/socket-io-command.js @@ -6,12 +6,12 @@ const shared_1 = require("../shared"); class SocketIOCommand extends shared_1.AbstractCommand { getUserNotificationSocket(options = {}) { var _a; - return socket_io_client_1.io(this.server.url + '/user-notifications', { + return (0, socket_io_client_1.io)(this.server.url + '/user-notifications', { query: { accessToken: (_a = options.token) !== null && _a !== void 0 ? _a : this.server.accessToken } }); } getLiveNotificationSocket() { - return socket_io_client_1.io(this.server.url + '/live-videos'); + return (0, socket_io_client_1.io)(this.server.url + '/live-videos'); } } exports.SocketIOCommand = SocketIOCommand; diff --git a/dist/shared/extra-utils/users/actors.js b/dist/shared/extra-utils/users/actors.js index 90c1789d..5d5ee693 100644 --- a/dist/shared/extra-utils/users/actors.js +++ b/dist/shared/extra-utils/users/actors.js @@ -7,7 +7,7 @@ const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const core_utils_1 = require("@server/helpers/core-utils"); function expectChannelsFollows(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server } = options; const { data } = yield server.channels.list(); return expectActorFollow(Object.assign(Object.assign({}, options), { data })); @@ -15,7 +15,7 @@ function expectChannelsFollows(options) { } exports.expectChannelsFollows = expectChannelsFollows; function expectAccountFollows(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server } = options; const { data } = yield server.accounts.list(); return expectActorFollow(Object.assign(Object.assign({}, options), { data })); @@ -23,15 +23,15 @@ function expectAccountFollows(options) { } exports.expectAccountFollows = expectAccountFollows; function checkActorFilesWereRemoved(filename, serverNumber) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const testDirectory = 'test' + serverNumber; for (const directory of ['avatars']) { - const directoryPath = path_1.join(core_utils_1.root(), testDirectory, directory); - const directoryExists = yield fs_extra_1.pathExists(directoryPath); - chai_1.expect(directoryExists).to.be.true; - const files = yield fs_extra_1.readdir(directoryPath); + const directoryPath = (0, path_1.join)((0, core_utils_1.root)(), testDirectory, directory); + const directoryExists = yield (0, fs_extra_1.pathExists)(directoryPath); + (0, chai_1.expect)(directoryExists).to.be.true; + const files = yield (0, fs_extra_1.readdir)(directoryPath); for (const file of files) { - chai_1.expect(file).to.not.contain(filename); + (0, chai_1.expect)(file).to.not.contain(filename); } } }); @@ -41,7 +41,7 @@ function expectActorFollow(options) { const { server, data, handle, followers, following } = options; const actor = data.find(a => a.name + '@' + a.host === handle); const message = `${handle} on ${server.url}`; - chai_1.expect(actor, message).to.exist; - chai_1.expect(actor.followersCount).to.equal(followers, message); - chai_1.expect(actor.followingCount).to.equal(following, message); + (0, chai_1.expect)(actor, message).to.exist; + (0, chai_1.expect)(actor.followersCount).to.equal(followers, message); + (0, chai_1.expect)(actor.followingCount).to.equal(following, message); } diff --git a/dist/shared/extra-utils/users/index.js b/dist/shared/extra-utils/users/index.js index 1bcc0e7b..4b32e58c 100644 --- a/dist/shared/extra-utils/users/index.js +++ b/dist/shared/extra-utils/users/index.js @@ -1,12 +1,12 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./accounts-command"), exports); -tslib_1.__exportStar(require("./actors"), exports); -tslib_1.__exportStar(require("./blocklist-command"), exports); -tslib_1.__exportStar(require("./login"), exports); -tslib_1.__exportStar(require("./login-command"), exports); -tslib_1.__exportStar(require("./notifications"), exports); -tslib_1.__exportStar(require("./notifications-command"), exports); -tslib_1.__exportStar(require("./subscriptions-command"), exports); -tslib_1.__exportStar(require("./users-command"), exports); +(0, tslib_1.__exportStar)(require("./accounts-command"), exports); +(0, tslib_1.__exportStar)(require("./actors"), exports); +(0, tslib_1.__exportStar)(require("./blocklist-command"), exports); +(0, tslib_1.__exportStar)(require("./login"), exports); +(0, tslib_1.__exportStar)(require("./login-command"), exports); +(0, tslib_1.__exportStar)(require("./notifications"), exports); +(0, tslib_1.__exportStar)(require("./notifications-command"), exports); +(0, tslib_1.__exportStar)(require("./subscriptions-command"), exports); +(0, tslib_1.__exportStar)(require("./users-command"), exports); diff --git a/dist/shared/extra-utils/users/login-command.js b/dist/shared/extra-utils/users/login-command.js index 081e22e1..affd6c11 100644 --- a/dist/shared/extra-utils/users/login-command.js +++ b/dist/shared/extra-utils/users/login-command.js @@ -19,10 +19,10 @@ class LoginCommand extends shared_1.AbstractCommand { grant_type: 'password', scope: 'upload' }; - return requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, requestType: 'form', fields: body, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, requestType: 'form', fields: body, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } getAccessToken(arg1, password) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let user; if (!arg1) user = this.server.store.user; @@ -55,7 +55,7 @@ class LoginCommand extends shared_1.AbstractCommand { } logout(options) { const path = '/api/v1/users/revoke-token'; - return requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, requestType: 'form', implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, requestType: 'form', implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } refreshToken(options) { const path = '/api/v1/users/token'; diff --git a/dist/shared/extra-utils/users/notifications-command.js b/dist/shared/extra-utils/users/notifications-command.js index 2b448326..5371a470 100644 --- a/dist/shared/extra-utils/users/notifications-command.js +++ b/dist/shared/extra-utils/users/notifications-command.js @@ -29,7 +29,7 @@ class NotificationsCommand extends shared_1.AbstractCommand { return this.postBodyRequest(Object.assign(Object.assign({}, options), { path, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } getLastest(options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { total, data } = yield this.list(Object.assign(Object.assign({}, options), { start: 0, count: 1, sort: '-createdAt' })); if (total === 0) return undefined; diff --git a/dist/shared/extra-utils/users/notifications.js b/dist/shared/extra-utils/users/notifications.js index 9ca8d8de..45259992 100644 --- a/dist/shared/extra-utils/users/notifications.js +++ b/dist/shared/extra-utils/users/notifications.js @@ -30,18 +30,18 @@ function getAllNotificationsSettings() { } exports.getAllNotificationsSettings = getAllNotificationsSettings; function checkNewVideoFromSubscription(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoName, shortUUID } = options; const notificationType = 1; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkVideo(notification.video, videoName, shortUUID); checkActor(notification.video.channel); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.type !== 1 || n.video.name !== videoName; }); } @@ -55,18 +55,18 @@ function checkNewVideoFromSubscription(options) { } exports.checkNewVideoFromSubscription = checkNewVideoFromSubscription; function checkVideoIsPublished(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoName, shortUUID } = options; const notificationType = 6; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkVideo(notification.video, videoName, shortUUID); checkActor(notification.video.channel); } else { - chai_1.expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName); + (0, chai_1.expect)(notification.video).to.satisfy(v => v === undefined || v.name !== videoName); } } function emailNotificationFinder(email) { @@ -78,19 +78,19 @@ function checkVideoIsPublished(options) { } exports.checkVideoIsPublished = checkVideoIsPublished; function checkMyVideoImportIsFinished(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoName, shortUUID, url, success } = options; const notificationType = success ? 7 : 8; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.videoImport.targetUrl).to.equal(url); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.videoImport.targetUrl).to.equal(url); if (success) checkVideo(notification.videoImport.video, videoName, shortUUID); } else { - chai_1.expect(notification.videoImport).to.satisfy(i => i === undefined || i.targetUrl !== url); + (0, chai_1.expect)(notification.videoImport).to.satisfy(i => i === undefined || i.targetUrl !== url); } } function emailNotificationFinder(email) { @@ -103,18 +103,18 @@ function checkMyVideoImportIsFinished(options) { } exports.checkMyVideoImportIsFinished = checkMyVideoImportIsFinished; function checkUserRegistered(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { username } = options; const notificationType = 9; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkActor(notification.account); - chai_1.expect(notification.account.name).to.equal(username); + (0, chai_1.expect)(notification.account.name).to.equal(username); } else { - chai_1.expect(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username); + (0, chai_1.expect)(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username); } } function emailNotificationFinder(email) { @@ -126,23 +126,23 @@ function checkUserRegistered(options) { } exports.checkUserRegistered = checkUserRegistered; function checkNewActorFollow(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { followType, followerName, followerDisplayName, followingDisplayName } = options; const notificationType = 10; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkActor(notification.actorFollow.follower); - chai_1.expect(notification.actorFollow.follower.displayName).to.equal(followerDisplayName); - chai_1.expect(notification.actorFollow.follower.name).to.equal(followerName); - chai_1.expect(notification.actorFollow.follower.host).to.not.be.undefined; + (0, chai_1.expect)(notification.actorFollow.follower.displayName).to.equal(followerDisplayName); + (0, chai_1.expect)(notification.actorFollow.follower.name).to.equal(followerName); + (0, chai_1.expect)(notification.actorFollow.follower.host).to.not.be.undefined; const following = notification.actorFollow.following; - chai_1.expect(following.displayName).to.equal(followingDisplayName); - chai_1.expect(following.type).to.equal(followType); + (0, chai_1.expect)(following.displayName).to.equal(followingDisplayName); + (0, chai_1.expect)(following.type).to.equal(followType); } else { - chai_1.expect(notification).to.satisfy(n => { + (0, chai_1.expect)(notification).to.satisfy(n => { return n.type !== notificationType || (n.actorFollow.follower.name !== followerName && n.actorFollow.following !== followingDisplayName); }); @@ -157,20 +157,20 @@ function checkNewActorFollow(options) { } exports.checkNewActorFollow = checkNewActorFollow; function checkNewInstanceFollower(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { followerHost } = options; const notificationType = 13; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkActor(notification.actorFollow.follower); - chai_1.expect(notification.actorFollow.follower.name).to.equal('peertube'); - chai_1.expect(notification.actorFollow.follower.host).to.equal(followerHost); - chai_1.expect(notification.actorFollow.following.name).to.equal('peertube'); + (0, chai_1.expect)(notification.actorFollow.follower.name).to.equal('peertube'); + (0, chai_1.expect)(notification.actorFollow.follower.host).to.equal(followerHost); + (0, chai_1.expect)(notification.actorFollow.following.name).to.equal('peertube'); } else { - chai_1.expect(notification).to.satisfy(n => { + (0, chai_1.expect)(notification).to.satisfy(n => { return n.type !== notificationType || n.actorFollow.follower.host !== followerHost; }); } @@ -184,22 +184,22 @@ function checkNewInstanceFollower(options) { } exports.checkNewInstanceFollower = checkNewInstanceFollower; function checkAutoInstanceFollowing(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { followerHost, followingHost } = options; const notificationType = 14; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); const following = notification.actorFollow.following; checkActor(following); - chai_1.expect(following.name).to.equal('peertube'); - chai_1.expect(following.host).to.equal(followingHost); - chai_1.expect(notification.actorFollow.follower.name).to.equal('peertube'); - chai_1.expect(notification.actorFollow.follower.host).to.equal(followerHost); + (0, chai_1.expect)(following.name).to.equal('peertube'); + (0, chai_1.expect)(following.host).to.equal(followingHost); + (0, chai_1.expect)(notification.actorFollow.follower.name).to.equal('peertube'); + (0, chai_1.expect)(notification.actorFollow.follower.host).to.equal(followerHost); } else { - chai_1.expect(notification).to.satisfy(n => { + (0, chai_1.expect)(notification).to.satisfy(n => { return n.type !== notificationType || n.actorFollow.following.host !== followingHost; }); } @@ -213,20 +213,20 @@ function checkAutoInstanceFollowing(options) { } exports.checkAutoInstanceFollowing = checkAutoInstanceFollowing; function checkCommentMention(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { shortUUID, commentId, threadId, byAccountDisplayName } = options; const notificationType = 11; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkComment(notification.comment, commentId, threadId); checkActor(notification.comment.account); - chai_1.expect(notification.comment.account.displayName).to.equal(byAccountDisplayName); + (0, chai_1.expect)(notification.comment.account.displayName).to.equal(byAccountDisplayName); checkVideo(notification.comment.video, undefined, shortUUID); } else { - chai_1.expect(notification).to.satisfy(n => n.type !== notificationType || n.comment.id !== commentId); + (0, chai_1.expect)(notification).to.satisfy(n => n.type !== notificationType || n.comment.id !== commentId); } } function emailNotificationFinder(email) { @@ -239,19 +239,19 @@ function checkCommentMention(options) { exports.checkCommentMention = checkCommentMention; let lastEmailCount = 0; function checkNewCommentOnMyVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server, shortUUID, commentId, threadId, checkType, emails } = options; const notificationType = 2; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); checkComment(notification.comment, commentId, threadId); checkActor(notification.comment.account); checkVideo(notification.comment.video, undefined, shortUUID); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.comment === undefined || n.comment.id !== commentId; }); } @@ -262,25 +262,25 @@ function checkNewCommentOnMyVideo(options) { } yield checkNotification(Object.assign(Object.assign({}, options), { notificationChecker, emailNotificationFinder })); if (checkType === 'presence') { - chai_1.expect(emails).to.have.length.above(lastEmailCount); + (0, chai_1.expect)(emails).to.have.length.above(lastEmailCount); lastEmailCount = emails.length; } }); } exports.checkNewCommentOnMyVideo = checkNewCommentOnMyVideo; function checkNewVideoAbuseForModerators(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { shortUUID, videoName } = options; const notificationType = 3; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.abuse.id).to.be.a('number'); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.abuse.id).to.be.a('number'); checkVideo(notification.abuse.video, videoName, shortUUID); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.abuse === undefined || n.abuse.video.shortUUID !== shortUUID; }); } @@ -294,17 +294,17 @@ function checkNewVideoAbuseForModerators(options) { } exports.checkNewVideoAbuseForModerators = checkNewVideoAbuseForModerators; function checkNewAbuseMessage(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { abuseId, message, toEmail } = options; const notificationType = 16; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.abuse.id).to.equal(abuseId); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.abuse.id).to.equal(abuseId); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.type !== notificationType || n.abuse === undefined || n.abuse.id !== abuseId; }); } @@ -319,18 +319,18 @@ function checkNewAbuseMessage(options) { } exports.checkNewAbuseMessage = checkNewAbuseMessage; function checkAbuseStateChange(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { abuseId, state } = options; const notificationType = 15; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.abuse.id).to.equal(abuseId); - chai_1.expect(notification.abuse.state).to.equal(state); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.abuse.id).to.equal(abuseId); + (0, chai_1.expect)(notification.abuse.state).to.equal(state); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.abuse === undefined || n.abuse.id !== abuseId; }); } @@ -347,18 +347,18 @@ function checkAbuseStateChange(options) { } exports.checkAbuseStateChange = checkAbuseStateChange; function checkNewCommentAbuseForModerators(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { shortUUID, videoName } = options; const notificationType = 3; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.abuse.id).to.be.a('number'); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.abuse.id).to.be.a('number'); checkVideo(notification.abuse.comment.video, videoName, shortUUID); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.abuse === undefined || n.abuse.comment.video.shortUUID !== shortUUID; }); } @@ -372,18 +372,18 @@ function checkNewCommentAbuseForModerators(options) { } exports.checkNewCommentAbuseForModerators = checkNewCommentAbuseForModerators; function checkNewAccountAbuseForModerators(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { displayName } = options; const notificationType = 3; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.abuse.id).to.be.a('number'); - chai_1.expect(notification.abuse.account.displayName).to.equal(displayName); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.abuse.id).to.be.a('number'); + (0, chai_1.expect)(notification.abuse.account.displayName).to.equal(displayName); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.abuse === undefined || n.abuse.account.displayName !== displayName; }); } @@ -397,18 +397,18 @@ function checkNewAccountAbuseForModerators(options) { } exports.checkNewAccountAbuseForModerators = checkNewAccountAbuseForModerators; function checkVideoAutoBlacklistForModerators(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { shortUUID, videoName } = options; const notificationType = 12; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.videoBlacklist.video.id).to.be.a('number'); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.videoBlacklist.video.id).to.be.a('number'); checkVideo(notification.videoBlacklist.video, videoName, shortUUID); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.video === undefined || n.video.shortUUID !== shortUUID; }); } @@ -422,14 +422,14 @@ function checkVideoAutoBlacklistForModerators(options) { } exports.checkVideoAutoBlacklistForModerators = checkVideoAutoBlacklistForModerators; function checkNewBlacklistOnMyVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoName, shortUUID, blacklistType } = options; const notificationType = blacklistType === 'blacklist' ? 4 : 5; function notificationChecker(notification) { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); const video = blacklistType === 'blacklist' ? notification.videoBlacklist.video : notification.video; checkVideo(video, videoName, shortUUID); } @@ -445,18 +445,18 @@ function checkNewBlacklistOnMyVideo(options) { } exports.checkNewBlacklistOnMyVideo = checkNewBlacklistOnMyVideo; function checkNewPeerTubeVersion(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { latestVersion } = options; const notificationType = 18; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.peertube).to.exist; - chai_1.expect(notification.peertube.latestVersion).to.equal(latestVersion); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.peertube).to.exist; + (0, chai_1.expect)(notification.peertube.latestVersion).to.equal(latestVersion); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.peertube === undefined || n.peertube.latestVersion !== latestVersion; }); } @@ -470,18 +470,18 @@ function checkNewPeerTubeVersion(options) { } exports.checkNewPeerTubeVersion = checkNewPeerTubeVersion; function checkNewPluginVersion(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { pluginName, pluginType } = options; const notificationType = 17; function notificationChecker(notification, checkType) { if (checkType === 'presence') { - chai_1.expect(notification).to.not.be.undefined; - chai_1.expect(notification.type).to.equal(notificationType); - chai_1.expect(notification.plugin.name).to.equal(pluginName); - chai_1.expect(notification.plugin.type).to.equal(pluginType); + (0, chai_1.expect)(notification).to.not.be.undefined; + (0, chai_1.expect)(notification.type).to.equal(notificationType); + (0, chai_1.expect)(notification.plugin.name).to.equal(pluginName); + (0, chai_1.expect)(notification.plugin.type).to.equal(pluginType); } else { - chai_1.expect(notification).to.satisfy((n) => { + (0, chai_1.expect)(notification).to.satisfy((n) => { return n === undefined || n.plugin === undefined || n.plugin.name !== pluginName; }); } @@ -495,7 +495,7 @@ function checkNewPluginVersion(options) { } exports.checkNewPluginVersion = checkNewPluginVersion; function prepareNotificationsTest(serversCount = 3, overrideConfigArg = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const userNotifications = []; const adminNotifications = []; const adminNotificationsServer2 = []; @@ -510,10 +510,10 @@ function prepareNotificationsTest(serversCount = 3, overrideConfigArg = {}) { limit: 20 } }; - const servers = yield servers_1.createMultipleServers(serversCount, Object.assign(overrideConfig, overrideConfigArg)); - yield login_1.setAccessTokensToServers(servers); + const servers = yield (0, servers_1.createMultipleServers)(serversCount, Object.assign(overrideConfig, overrideConfigArg)); + yield (0, login_1.setAccessTokensToServers)(servers); if (serversCount > 1) { - yield follows_1.doubleFollow(servers[0], servers[1]); + yield (0, follows_1.doubleFollow)(servers[0], servers[1]); } const user = { username: 'user_1', password: 'super password' }; yield servers[0].users.create(Object.assign(Object.assign({}, user), { videoQuota: 10 * 1000 * 1000 })); @@ -550,7 +550,7 @@ function prepareNotificationsTest(serversCount = 3, overrideConfigArg = {}) { } exports.prepareNotificationsTest = prepareNotificationsTest; function checkNotification(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server, token, checkType, notificationChecker, emailNotificationFinder, socketNotifications, emails } = options; const check = options.check || { web: true, mail: true }; if (check.web) { @@ -568,12 +568,12 @@ function checkNotification(options) { } }); if (checkType === 'presence') { - const obj = util_1.inspect(socketNotifications, { depth: 5 }); - chai_1.expect(socketNotification, 'The socket notification is absent when it should be present. ' + obj).to.not.be.undefined; + const obj = (0, util_1.inspect)(socketNotifications, { depth: 5 }); + (0, chai_1.expect)(socketNotification, 'The socket notification is absent when it should be present. ' + obj).to.not.be.undefined; } else { - const obj = util_1.inspect(socketNotification, { depth: 5 }); - chai_1.expect(socketNotification, 'The socket notification is present when it should not be present. ' + obj).to.be.undefined; + const obj = (0, util_1.inspect)(socketNotification, { depth: 5 }); + (0, chai_1.expect)(socketNotification, 'The socket notification is present when it should not be present. ' + obj).to.be.undefined; } } if (check.mail) { @@ -583,33 +583,33 @@ function checkNotification(options) { .find(e => emailNotificationFinder(e)); if (checkType === 'presence') { const texts = emails.map(e => e.text); - chai_1.expect(email, 'The email is absent when is should be present. ' + util_1.inspect(texts)).to.not.be.undefined; + (0, chai_1.expect)(email, 'The email is absent when is should be present. ' + (0, util_1.inspect)(texts)).to.not.be.undefined; } else { - chai_1.expect(email, 'The email is present when is should not be present. ' + util_1.inspect(email)).to.be.undefined; + (0, chai_1.expect)(email, 'The email is present when is should not be present. ' + (0, util_1.inspect)(email)).to.be.undefined; } } }); } function checkVideo(video, videoName, shortUUID) { if (videoName) { - chai_1.expect(video.name).to.be.a('string'); - chai_1.expect(video.name).to.not.be.empty; - chai_1.expect(video.name).to.equal(videoName); + (0, chai_1.expect)(video.name).to.be.a('string'); + (0, chai_1.expect)(video.name).to.not.be.empty; + (0, chai_1.expect)(video.name).to.equal(videoName); } if (shortUUID) { - chai_1.expect(video.shortUUID).to.be.a('string'); - chai_1.expect(video.shortUUID).to.not.be.empty; - chai_1.expect(video.shortUUID).to.equal(shortUUID); + (0, chai_1.expect)(video.shortUUID).to.be.a('string'); + (0, chai_1.expect)(video.shortUUID).to.not.be.empty; + (0, chai_1.expect)(video.shortUUID).to.equal(shortUUID); } - chai_1.expect(video.id).to.be.a('number'); + (0, chai_1.expect)(video.id).to.be.a('number'); } function checkActor(actor) { - chai_1.expect(actor.displayName).to.be.a('string'); - chai_1.expect(actor.displayName).to.not.be.empty; - chai_1.expect(actor.host).to.not.be.undefined; + (0, chai_1.expect)(actor.displayName).to.be.a('string'); + (0, chai_1.expect)(actor.displayName).to.not.be.empty; + (0, chai_1.expect)(actor.host).to.not.be.undefined; } function checkComment(comment, commentId, threadId) { - chai_1.expect(comment.id).to.equal(commentId); - chai_1.expect(comment.threadId).to.equal(threadId); + (0, chai_1.expect)(comment.id).to.equal(commentId); + (0, chai_1.expect)(comment.threadId).to.equal(threadId); } diff --git a/dist/shared/extra-utils/users/users-command.js b/dist/shared/extra-utils/users/users-command.js index 26487a20..b94f23c6 100644 --- a/dist/shared/extra-utils/users/users-command.js +++ b/dist/shared/extra-utils/users/users-command.js @@ -52,7 +52,7 @@ class UsersCommand extends shared_1.AbstractCommand { create(options) { const { username, adminFlags, password = 'password', videoQuota = 42000000, videoQuotaDaily = -1, role = models_1.UserRole.USER } = options; const path = '/api/v1/users'; - return requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { + return (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { username, password, role, @@ -63,7 +63,7 @@ class UsersCommand extends shared_1.AbstractCommand { }, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))).then(res => res.user); } generate(username) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const password = 'password'; const user = yield this.create({ username, password }); const token = yield this.server.login.getAccessToken({ username, password }); @@ -76,7 +76,7 @@ class UsersCommand extends shared_1.AbstractCommand { }); } generateUserAndToken(username) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const password = 'password'; yield this.create({ username, password }); return this.server.login.getAccessToken({ username, password }); @@ -112,7 +112,7 @@ class UsersCommand extends shared_1.AbstractCommand { } updateMe(options) { const path = '/api/v1/users/me'; - const toSend = lodash_1.omit(options, 'url', 'accessToken'); + const toSend = (0, lodash_1.omit)(options, 'url', 'accessToken'); return this.putBodyRequest(Object.assign(Object.assign({}, options), { path, fields: toSend, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } updateMyAvatar(options) { @@ -128,7 +128,7 @@ class UsersCommand extends shared_1.AbstractCommand { } list(options = {}) { const path = '/api/v1/users'; - return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: core_utils_1.pick(options, ['start', 'count', 'sort', 'search', 'blocked']), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); + return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'search', 'blocked']), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } remove(options) { const { userId } = options; diff --git a/dist/shared/extra-utils/videos/captions-command.js b/dist/shared/extra-utils/videos/captions-command.js index 0aebfb9b..be463c66 100644 --- a/dist/shared/extra-utils/videos/captions-command.js +++ b/dist/shared/extra-utils/videos/captions-command.js @@ -8,7 +8,7 @@ class CaptionsCommand extends shared_1.AbstractCommand { add(options) { const { videoId, language, fixture, mimeType } = options; const path = '/api/v1/videos/' + videoId + '/captions/' + language; - const captionfile = miscs_1.buildAbsoluteFixturePath(fixture); + const captionfile = (0, miscs_1.buildAbsoluteFixturePath)(fixture); const captionfileAttach = mimeType ? [captionfile, { contentType: mimeType }] : captionfile; diff --git a/dist/shared/extra-utils/videos/captions.js b/dist/shared/extra-utils/videos/captions.js index ee843b28..0fd68130 100644 --- a/dist/shared/extra-utils/videos/captions.js +++ b/dist/shared/extra-utils/videos/captions.js @@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.testCaptionFile = void 0; const tslib_1 = require("tslib"); const chai_1 = require("chai"); -const supertest_1 = tslib_1.__importDefault(require("supertest")); +const supertest_1 = (0, tslib_1.__importDefault)(require("supertest")); const models_1 = require("@shared/models"); function testCaptionFile(url, captionPath, containsString) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const res = yield supertest_1.default(url) + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { + const res = yield (0, supertest_1.default)(url) .get(captionPath) .expect(models_1.HttpStatusCode.OK_200); - chai_1.expect(res.text).to.contain(containsString); + (0, chai_1.expect)(res.text).to.contain(containsString); }); } exports.testCaptionFile = testCaptionFile; diff --git a/dist/shared/extra-utils/videos/channels-command.js b/dist/shared/extra-utils/videos/channels-command.js index 9f9ca7b8..926e5ee7 100644 --- a/dist/shared/extra-utils/videos/channels-command.js +++ b/dist/shared/extra-utils/videos/channels-command.js @@ -9,15 +9,15 @@ const shared_1 = require("../shared"); class ChannelsCommand extends shared_1.AbstractCommand { list(options = {}) { const path = '/api/v1/video-channels'; - return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: core_utils_1.pick(options, ['start', 'count', 'sort', 'withStats']), implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); + return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'withStats']), implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } listByAccount(options) { const { accountName, sort = 'createdAt' } = options; const path = '/api/v1/accounts/' + accountName + '/video-channels'; - return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: Object.assign({ sort }, core_utils_1.pick(options, ['start', 'count', 'withStats', 'search'])), implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); + return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: Object.assign({ sort }, (0, core_utils_1.pick)(options, ['start', 'count', 'withStats', 'search'])), implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } create(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/video-channels/'; const defaultAttributes = { displayName: 'my super video channel', @@ -25,7 +25,7 @@ class ChannelsCommand extends shared_1.AbstractCommand { support: 'my super channel support' }; const attributes = Object.assign(Object.assign({}, defaultAttributes), options.attributes); - const body = yield requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: attributes, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + const body = yield (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: attributes, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); return body.videoChannel; }); } diff --git a/dist/shared/extra-utils/videos/comments-command.js b/dist/shared/extra-utils/videos/comments-command.js index 5c82a484..65490e86 100644 --- a/dist/shared/extra-utils/videos/comments-command.js +++ b/dist/shared/extra-utils/videos/comments-command.js @@ -10,7 +10,7 @@ class CommentsCommand extends shared_1.AbstractCommand { listForAdmin(options = {}) { const { sort = '-createdAt' } = options; const path = '/api/v1/videos/comments'; - const query = Object.assign({ sort }, lodash_1.pick(options, ['start', 'count', 'isLocal', 'search', 'searchAccount', 'searchVideo'])); + const query = Object.assign({ sort }, (0, lodash_1.pick)(options, ['start', 'count', 'isLocal', 'search', 'searchAccount', 'searchVideo'])); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } @@ -26,10 +26,10 @@ class CommentsCommand extends shared_1.AbstractCommand { } createThread(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, text } = options; const path = '/api/v1/videos/' + videoId + '/comment-threads'; - const body = yield requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { text }, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + const body = yield (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { text }, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); this.lastThreadId = (_a = body.comment) === null || _a === void 0 ? void 0 : _a.id; this.lastVideoId = videoId; return body.comment; @@ -37,26 +37,26 @@ class CommentsCommand extends shared_1.AbstractCommand { } addReply(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, toCommentId, text } = options; const path = '/api/v1/videos/' + videoId + '/comments/' + toCommentId; - const body = yield requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { text }, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + const body = yield (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: { text }, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); this.lastReplyId = (_a = body.comment) === null || _a === void 0 ? void 0 : _a.id; return body.comment; }); } addReplyToLastReply(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.addReply(Object.assign(Object.assign({}, options), { videoId: this.lastVideoId, toCommentId: this.lastReplyId })); }); } addReplyToLastThread(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return this.addReply(Object.assign(Object.assign({}, options), { videoId: this.lastVideoId, toCommentId: this.lastThreadId })); }); } findCommentId(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, text } = options; const { data } = yield this.listThreads({ videoId, count: 25, sort: '-createdAt' }); return data.find(c => c.text === text).id; diff --git a/dist/shared/extra-utils/videos/imports-command.js b/dist/shared/extra-utils/videos/imports-command.js index 25ba9fa6..b6e80fa7 100644 --- a/dist/shared/extra-utils/videos/imports-command.js +++ b/dist/shared/extra-utils/videos/imports-command.js @@ -11,7 +11,7 @@ class ImportsCommand extends shared_1.AbstractCommand { let attaches = {}; if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }; - return requests_1.unwrapBody(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, + return (0, requests_1.unwrapBody)(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, attaches, fields: options.attributes, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } getMyVideoImports(options = {}) { diff --git a/dist/shared/extra-utils/videos/index.js b/dist/shared/extra-utils/videos/index.js index 078508e4..2059b939 100644 --- a/dist/shared/extra-utils/videos/index.js +++ b/dist/shared/extra-utils/videos/index.js @@ -1,22 +1,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./blacklist-command"), exports); -tslib_1.__exportStar(require("./captions-command"), exports); -tslib_1.__exportStar(require("./captions"), exports); -tslib_1.__exportStar(require("./change-ownership-command"), exports); -tslib_1.__exportStar(require("./channels"), exports); -tslib_1.__exportStar(require("./channels-command"), exports); -tslib_1.__exportStar(require("./comments-command"), exports); -tslib_1.__exportStar(require("./history-command"), exports); -tslib_1.__exportStar(require("./imports-command"), exports); -tslib_1.__exportStar(require("./live-command"), exports); -tslib_1.__exportStar(require("./live"), exports); -tslib_1.__exportStar(require("./playlists-command"), exports); -tslib_1.__exportStar(require("./playlists"), exports); -tslib_1.__exportStar(require("./services-command"), exports); -tslib_1.__exportStar(require("./streaming-playlists-command"), exports); -tslib_1.__exportStar(require("./streaming-playlists"), exports); -tslib_1.__exportStar(require("./comments-command"), exports); -tslib_1.__exportStar(require("./videos-command"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./blacklist-command"), exports); +(0, tslib_1.__exportStar)(require("./captions-command"), exports); +(0, tslib_1.__exportStar)(require("./captions"), exports); +(0, tslib_1.__exportStar)(require("./change-ownership-command"), exports); +(0, tslib_1.__exportStar)(require("./channels"), exports); +(0, tslib_1.__exportStar)(require("./channels-command"), exports); +(0, tslib_1.__exportStar)(require("./comments-command"), exports); +(0, tslib_1.__exportStar)(require("./history-command"), exports); +(0, tslib_1.__exportStar)(require("./imports-command"), exports); +(0, tslib_1.__exportStar)(require("./live-command"), exports); +(0, tslib_1.__exportStar)(require("./live"), exports); +(0, tslib_1.__exportStar)(require("./playlists-command"), exports); +(0, tslib_1.__exportStar)(require("./playlists"), exports); +(0, tslib_1.__exportStar)(require("./services-command"), exports); +(0, tslib_1.__exportStar)(require("./streaming-playlists-command"), exports); +(0, tslib_1.__exportStar)(require("./streaming-playlists"), exports); +(0, tslib_1.__exportStar)(require("./comments-command"), exports); +(0, tslib_1.__exportStar)(require("./videos-command"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/shared/extra-utils/videos/live-command.js b/dist/shared/extra-utils/videos/live-command.js index 73cff778..555f013a 100644 --- a/dist/shared/extra-utils/videos/live-command.js +++ b/dist/shared/extra-utils/videos/live-command.js @@ -21,7 +21,7 @@ class LiveCommand extends shared_1.AbstractCommand { return this.putBodyRequest(Object.assign(Object.assign({}, options), { path: path + '/' + videoId, fields, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } create(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { fields } = options; const path = '/api/v1/videos/live'; const attaches = {}; @@ -29,22 +29,22 @@ class LiveCommand extends shared_1.AbstractCommand { attaches.thumbnailfile = fields.thumbnailfile; if (fields.previewfile) attaches.previewfile = fields.previewfile; - const body = yield requests_1.unwrapBody(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, - attaches, fields: lodash_1.omit(fields, 'thumbnailfile', 'previewfile'), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + const body = yield (0, requests_1.unwrapBody)(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, + attaches, fields: (0, lodash_1.omit)(fields, 'thumbnailfile', 'previewfile'), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); return body.video; }); } sendRTMPStreamInVideo(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { videoId, fixtureName, copyCodecs } = options; const videoLive = yield this.get({ videoId }); - return live_1.sendRTMPStream({ rtmpBaseUrl: videoLive.rtmpUrl, streamKey: videoLive.streamKey, fixtureName, copyCodecs }); + return (0, live_1.sendRTMPStream)({ rtmpBaseUrl: videoLive.rtmpUrl, streamKey: videoLive.streamKey, fixtureName, copyCodecs }); }); } runAndTestStreamError(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const command = yield this.sendRTMPStreamInVideo(options); - return live_1.testFfmpegStreamError(command, options.shouldHaveError); + return (0, live_1.testFfmpegStreamError)(command, options.shouldHaveError); }); } waitUntilPublished(options) { @@ -65,28 +65,28 @@ class LiveCommand extends shared_1.AbstractCommand { return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false); } waitUntilSaved(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let video; do { video = yield this.server.videos.getWithToken({ token: options.token, id: options.videoId }); - yield miscs_1.wait(500); + yield (0, miscs_1.wait)(500); } while (video.isLive === true || video.state.id !== 1); }); } countPlaylists(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const basePath = this.server.servers.buildDirectory('streaming-playlists'); - const hlsPath = path_1.join(basePath, 'hls', options.videoUUID); - const files = yield fs_extra_1.readdir(hlsPath); + const hlsPath = (0, path_1.join)(basePath, 'hls', options.videoUUID); + const files = yield (0, fs_extra_1.readdir)(hlsPath); return files.filter(f => f.endsWith('.m3u8')).length; }); } waitUntilState(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let video; do { video = yield this.server.videos.getWithToken({ token: options.token, id: options.videoId }); - yield miscs_1.wait(500); + yield (0, miscs_1.wait)(500); } while (video.state.id !== options.state); }); } diff --git a/dist/shared/extra-utils/videos/live.js b/dist/shared/extra-utils/videos/live.js index 59858ff9..6109938f 100644 --- a/dist/shared/extra-utils/videos/live.js +++ b/dist/shared/extra-utils/videos/live.js @@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.checkLiveCleanupAfterSave = exports.waitUntilLiveSavedOnAllServers = exports.waitUntilLivePublishedOnAllServers = exports.stopFfmpeg = exports.testFfmpegStreamError = exports.waitFfmpegUntilError = exports.sendRTMPStream = void 0; const tslib_1 = require("tslib"); const chai_1 = require("chai"); -const fluent_ffmpeg_1 = tslib_1.__importDefault(require("fluent-ffmpeg")); +const fluent_ffmpeg_1 = (0, tslib_1.__importDefault)(require("fluent-ffmpeg")); const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const miscs_1 = require("../miscs"); function sendRTMPStream(options) { const { rtmpBaseUrl, streamKey, fixtureName = 'video_short.mp4', copyCodecs = false } = options; - const fixture = miscs_1.buildAbsoluteFixturePath(fixtureName); - const command = fluent_ffmpeg_1.default(fixture); + const fixture = (0, miscs_1.buildAbsoluteFixturePath)(fixtureName); + const command = (0, fluent_ffmpeg_1.default)(fixture); command.inputOption('-stream_loop -1'); command.inputOption('-re'); if (copyCodecs) { @@ -51,7 +51,7 @@ function waitFfmpegUntilError(command, successAfterMS = 10000) { } exports.waitFfmpegUntilError = waitFfmpegUntilError; function testFfmpegStreamError(command, shouldHaveError) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { let error; try { yield waitFfmpegUntilError(command, 35000); @@ -68,14 +68,14 @@ function testFfmpegStreamError(command, shouldHaveError) { } exports.testFfmpegStreamError = testFfmpegStreamError; function stopFfmpeg(command) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { command.kill('SIGINT'); - yield miscs_1.wait(500); + yield (0, miscs_1.wait)(500); }); } exports.stopFfmpeg = stopFfmpeg; function waitUntilLivePublishedOnAllServers(servers, videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { yield server.live.waitUntilPublished({ videoId }); } @@ -83,7 +83,7 @@ function waitUntilLivePublishedOnAllServers(servers, videoId) { } exports.waitUntilLivePublishedOnAllServers = waitUntilLivePublishedOnAllServers; function waitUntilLiveSavedOnAllServers(servers, videoId) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { yield server.live.waitUntilSaved({ videoId }); } @@ -91,26 +91,26 @@ function waitUntilLiveSavedOnAllServers(servers, videoId) { } exports.waitUntilLiveSavedOnAllServers = waitUntilLiveSavedOnAllServers; function checkLiveCleanupAfterSave(server, videoUUID, resolutions = []) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const basePath = server.servers.buildDirectory('streaming-playlists'); - const hlsPath = path_1.join(basePath, 'hls', videoUUID); + const hlsPath = (0, path_1.join)(basePath, 'hls', videoUUID); if (resolutions.length === 0) { - const result = yield fs_extra_1.pathExists(hlsPath); - chai_1.expect(result).to.be.false; + const result = yield (0, fs_extra_1.pathExists)(hlsPath); + (0, chai_1.expect)(result).to.be.false; return; } - const files = yield fs_extra_1.readdir(hlsPath); - chai_1.expect(files).to.have.lengthOf(resolutions.length * 2 + 2); + const files = yield (0, fs_extra_1.readdir)(hlsPath); + (0, chai_1.expect)(files).to.have.lengthOf(resolutions.length * 2 + 2); for (const resolution of resolutions) { const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`)); - chai_1.expect(fragmentedFile).to.exist; + (0, chai_1.expect)(fragmentedFile).to.exist; const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`)); - chai_1.expect(playlistFile).to.exist; + (0, chai_1.expect)(playlistFile).to.exist; } const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8')); - chai_1.expect(masterPlaylistFile).to.exist; + (0, chai_1.expect)(masterPlaylistFile).to.exist; const shaFile = files.find(f => f.endsWith('-segments-sha256.json')); - chai_1.expect(shaFile).to.exist; + (0, chai_1.expect)(shaFile).to.exist; }); } exports.checkLiveCleanupAfterSave = checkLiveCleanupAfterSave; diff --git a/dist/shared/extra-utils/videos/playlists-command.js b/dist/shared/extra-utils/videos/playlists-command.js index 0b07c8a1..7e81041b 100644 --- a/dist/shared/extra-utils/videos/playlists-command.js +++ b/dist/shared/extra-utils/videos/playlists-command.js @@ -10,19 +10,19 @@ const shared_1 = require("../shared"); class PlaylistsCommand extends shared_1.AbstractCommand { list(options) { const path = '/api/v1/video-playlists'; - const query = core_utils_1.pick(options, ['start', 'count', 'sort']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } listByChannel(options) { const path = '/api/v1/video-channels/' + options.handle + '/video-playlists'; - const query = core_utils_1.pick(options, ['start', 'count', 'sort']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } listByAccount(options) { const path = '/api/v1/accounts/' + options.handle + '/video-playlists'; - const query = core_utils_1.pick(options, ['start', 'count', 'sort', 'search', 'playlistType']); + const query = (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'search', 'playlistType']); return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } @@ -42,13 +42,13 @@ class PlaylistsCommand extends shared_1.AbstractCommand { return this.deleteRequest(Object.assign(Object.assign({}, options), { path, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } create(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/video-playlists'; - const fields = lodash_1.omit(options.attributes, 'thumbnailfile'); + const fields = (0, lodash_1.omit)(options.attributes, 'thumbnailfile'); const attaches = options.attributes.thumbnailfile ? { thumbnailfile: options.attributes.thumbnailfile } : {}; - const body = yield requests_1.unwrapBody(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, + const body = yield (0, requests_1.unwrapBody)(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, fields, attaches, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); return body.videoPlaylist; @@ -56,7 +56,7 @@ class PlaylistsCommand extends shared_1.AbstractCommand { } update(options) { const path = '/api/v1/video-playlists/' + options.playlistId; - const fields = lodash_1.omit(options.attributes, 'thumbnailfile'); + const fields = (0, lodash_1.omit)(options.attributes, 'thumbnailfile'); const attaches = options.attributes.thumbnailfile ? { thumbnailfile: options.attributes.thumbnailfile } : {}; @@ -65,10 +65,10 @@ class PlaylistsCommand extends shared_1.AbstractCommand { attaches, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 })); } addElement(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const attributes = Object.assign(Object.assign({}, options.attributes), { videoId: yield this.server.videos.getId(Object.assign(Object.assign({}, options), { uuid: options.attributes.videoId })) }); const path = '/api/v1/video-playlists/' + options.playlistId + '/videos'; - const body = yield requests_1.unwrapBody(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: attributes, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + const body = yield (0, requests_1.unwrapBody)(this.postBodyRequest(Object.assign(Object.assign({}, options), { path, fields: attributes, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); return body.videoPlaylistElement; }); } diff --git a/dist/shared/extra-utils/videos/playlists.js b/dist/shared/extra-utils/videos/playlists.js index a3d6199c..8900b213 100644 --- a/dist/shared/extra-utils/videos/playlists.js +++ b/dist/shared/extra-utils/videos/playlists.js @@ -7,13 +7,13 @@ const fs_extra_1 = require("fs-extra"); const path_1 = require("path"); const miscs_1 = require("../miscs"); function checkPlaylistFilesWereRemoved(playlistUUID, internalServerNumber, directories = ['thumbnails']) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const testDirectory = 'test' + internalServerNumber; for (const directory of directories) { - const directoryPath = path_1.join(miscs_1.root(), testDirectory, directory); - const files = yield fs_extra_1.readdir(directoryPath); + const directoryPath = (0, path_1.join)((0, miscs_1.root)(), testDirectory, directory); + const files = yield (0, fs_extra_1.readdir)(directoryPath); for (const file of files) { - chai_1.expect(file).to.not.contain(playlistUUID); + (0, chai_1.expect)(file).to.not.contain(playlistUUID); } } }); diff --git a/dist/shared/extra-utils/videos/streaming-playlists-command.js b/dist/shared/extra-utils/videos/streaming-playlists-command.js index a04659ce..2c4e9f0e 100644 --- a/dist/shared/extra-utils/videos/streaming-playlists-command.js +++ b/dist/shared/extra-utils/videos/streaming-playlists-command.js @@ -6,13 +6,13 @@ const requests_1 = require("../requests"); const shared_1 = require("../shared"); class StreamingPlaylistsCommand extends shared_1.AbstractCommand { get(options) { - return requests_1.unwrapTextOrDecode(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapTextOrDecode)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } getSegment(options) { - return requests_1.unwrapBody(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, range: options.range, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBody)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, range: options.range, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } getSegmentSha256(options) { - return requests_1.unwrapBodyOrDecodeToJSON(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBodyOrDecodeToJSON)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } } exports.StreamingPlaylistsCommand = StreamingPlaylistsCommand; diff --git a/dist/shared/extra-utils/videos/streaming-playlists.js b/dist/shared/extra-utils/videos/streaming-playlists.js index 39385f1a..c5e137a2 100644 --- a/dist/shared/extra-utils/videos/streaming-playlists.js +++ b/dist/shared/extra-utils/videos/streaming-playlists.js @@ -8,12 +8,12 @@ const core_utils_1 = require("@server/helpers/core-utils"); const core_utils_2 = require("@shared/core-utils"); const models_1 = require("@shared/models"); function checkSegmentHash(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server, baseUrlPlaylist, baseUrlSegment, resolution, hlsPlaylist } = options; const command = server.streamingPlaylists; const file = hlsPlaylist.files.find(f => f.resolution.id === resolution); - const videoName = path_1.basename(file.fileUrl); - const playlist = yield command.get({ url: `${baseUrlPlaylist}/${core_utils_2.removeFragmentedMP4Ext(videoName)}.m3u8` }); + const videoName = (0, path_1.basename)(file.fileUrl); + const playlist = yield command.get({ url: `${baseUrlPlaylist}/${(0, core_utils_2.removeFragmentedMP4Ext)(videoName)}.m3u8` }); const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist); const length = parseInt(matches[1], 10); const offset = parseInt(matches[2], 10); @@ -24,27 +24,27 @@ function checkSegmentHash(options) { range: `bytes=${range}` }); const shaBody = yield command.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url }); - chai_1.expect(core_utils_1.sha256(segmentBody)).to.equal(shaBody[videoName][range]); + (0, chai_1.expect)((0, core_utils_1.sha256)(segmentBody)).to.equal(shaBody[videoName][range]); }); } exports.checkSegmentHash = checkSegmentHash; function checkLiveSegmentHash(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server, baseUrlSegment, videoUUID, segmentName, hlsPlaylist } = options; const command = server.streamingPlaylists; const segmentBody = yield command.getSegment({ url: `${baseUrlSegment}/${videoUUID}/${segmentName}` }); const shaBody = yield command.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url }); - chai_1.expect(core_utils_1.sha256(segmentBody)).to.equal(shaBody[segmentName]); + (0, chai_1.expect)((0, core_utils_1.sha256)(segmentBody)).to.equal(shaBody[segmentName]); }); } exports.checkLiveSegmentHash = checkLiveSegmentHash; function checkResolutionsInMasterPlaylist(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { server, playlistUrl, resolutions } = options; const masterPlaylist = yield server.streamingPlaylists.get({ url: playlistUrl }); for (const resolution of resolutions) { const reg = new RegExp('#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',(FRAME-RATE=\\d+,)?CODECS="avc1.64001f,mp4a.40.2"'); - chai_1.expect(masterPlaylist).to.match(reg); + (0, chai_1.expect)(masterPlaylist).to.match(reg); } }); } diff --git a/dist/shared/extra-utils/videos/videos-command.js b/dist/shared/extra-utils/videos/videos-command.js index dda0c940..83052a03 100644 --- a/dist/shared/extra-utils/videos/videos-command.js +++ b/dist/shared/extra-utils/videos/videos-command.js @@ -4,9 +4,9 @@ exports.VideosCommand = void 0; const tslib_1 = require("tslib"); const chai_1 = require("chai"); const fs_extra_1 = require("fs-extra"); -const got_1 = tslib_1.__importDefault(require("got")); +const got_1 = (0, tslib_1.__importDefault)(require("got")); const lodash_1 = require("lodash"); -const validator_1 = tslib_1.__importDefault(require("validator")); +const validator_1 = (0, tslib_1.__importDefault)(require("validator")); const uuid_1 = require("@server/helpers/uuid"); const constants_1 = require("@server/initializers/constants"); const core_utils_1 = require("@shared/core-utils"); @@ -18,7 +18,7 @@ const shared_1 = require("../shared"); class VideosCommand extends shared_1.AbstractCommand { constructor(server) { super(server); - constants_1.loadLanguages(); + (0, constants_1.loadLanguages)(); } getCategories(options = {}) { const path = '/api/v1/videos/categories'; @@ -40,7 +40,7 @@ class VideosCommand extends shared_1.AbstractCommand { return this.getRequestBody(Object.assign(Object.assign({}, options), { path: options.descriptionPath, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } getFileMetadata(options) { - return requests_1.unwrapBody(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); + return (0, requests_1.unwrapBody)(this.getRawRequest(Object.assign(Object.assign({}, options), { url: options.url, implicitToken: false, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))); } view(options) { const { id, xForwardedFor } = options; @@ -61,7 +61,7 @@ class VideosCommand extends shared_1.AbstractCommand { return this.get(Object.assign(Object.assign({}, options), { token: this.buildCommonRequestToken(Object.assign(Object.assign({}, options), { implicitToken: true })) })); } getId(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { uuid } = options; if (validator_1.default.isUUID('' + uuid) === false) return uuid; @@ -71,7 +71,7 @@ class VideosCommand extends shared_1.AbstractCommand { } listFiles(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const video = yield this.get(options); const files = video.files || []; const hlsFiles = ((_a = video.streamingPlaylists[0]) === null || _a === void 0 ? void 0 : _a.files) || []; @@ -80,7 +80,7 @@ class VideosCommand extends shared_1.AbstractCommand { } listMyVideos(options = {}) { const path = '/api/v1/users/me/videos'; - return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: core_utils_1.pick(options, ['start', 'count', 'sort', 'search', 'isLive']), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); + return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: (0, core_utils_1.pick)(options, ['start', 'count', 'sort', 'search', 'isLive']), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } list(options = {}) { const path = '/api/v1/videos'; @@ -101,7 +101,7 @@ class VideosCommand extends shared_1.AbstractCommand { return this.getRequestBody(Object.assign(Object.assign({}, options), { path, query: this.buildListQuery(options), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 })); } find(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield this.list(options); return data.find(v => v.name === options.name); }); @@ -124,10 +124,10 @@ class VideosCommand extends shared_1.AbstractCommand { } remove(options) { const path = '/api/v1/videos/' + options.id; - return requests_1.unwrapBody(this.deleteRequest(Object.assign(Object.assign({}, options), { path, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }))); + return (0, requests_1.unwrapBody)(this.deleteRequest(Object.assign(Object.assign({}, options), { path, implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.NO_CONTENT_204 }))); } removeAll() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { data } = yield this.list(); for (const v of data) { yield this.remove({ id: v.id }); @@ -135,7 +135,7 @@ class VideosCommand extends shared_1.AbstractCommand { }); } upload(options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { mode = 'legacy' } = options; let defaultChannelId = 1; try { @@ -152,28 +152,28 @@ class VideosCommand extends shared_1.AbstractCommand { let video; do { video = yield this.getWithToken(Object.assign(Object.assign({}, options), { id: created.uuid })); - yield miscs_1.wait(50); + yield (0, miscs_1.wait)(50); } while (!video.files[0].torrentUrl); } return created; }); } buildLegacyUpload(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const path = '/api/v1/videos/upload'; - return requests_1.unwrapBody(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, fields: this.buildUploadFields(options.attributes), attaches: this.buildUploadAttaches(options.attributes), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))).then(body => body.video || body); + return (0, requests_1.unwrapBody)(this.postUploadRequest(Object.assign(Object.assign({}, options), { path, fields: this.buildUploadFields(options.attributes), attaches: this.buildUploadAttaches(options.attributes), implicitToken: true, defaultExpectedStatus: models_1.HttpStatusCode.OK_200 }))).then(body => body.video || body); }); } buildResumeUpload(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { attributes, expectedStatus } = options; let size = 0; let videoFilePath; let mimetype = 'video/mp4'; if (attributes.fixture) { - videoFilePath = miscs_1.buildAbsoluteFixturePath(attributes.fixture); - size = (yield fs_extra_1.stat(videoFilePath)).size; + videoFilePath = (0, miscs_1.buildAbsoluteFixturePath)(attributes.fixture); + size = (yield (0, fs_extra_1.stat)(videoFilePath)).size; if (videoFilePath.endsWith('.mkv')) { mimetype = 'video/x-matroska'; } @@ -185,7 +185,7 @@ class VideosCommand extends shared_1.AbstractCommand { const initStatus = initializeSessionRes.status; if (videoFilePath && initStatus === models_1.HttpStatusCode.CREATED_201) { const locationHeader = initializeSessionRes.header['location']; - chai_1.expect(locationHeader).to.not.be.undefined; + (0, chai_1.expect)(locationHeader).to.not.be.undefined; const pathUploadId = locationHeader.split('?')[1]; const result = yield this.sendResumableChunks(Object.assign(Object.assign({}, options), { pathUploadId, videoFilePath, size })); if (result.statusCode === models_1.HttpStatusCode.OK_200) { @@ -196,18 +196,18 @@ class VideosCommand extends shared_1.AbstractCommand { const expectedInitStatus = expectedStatus === models_1.HttpStatusCode.OK_200 ? models_1.HttpStatusCode.CREATED_201 : expectedStatus; - chai_1.expect(initStatus).to.equal(expectedInitStatus); + (0, chai_1.expect)(initStatus).to.equal(expectedInitStatus); return initializeSessionRes.body.video || initializeSessionRes.body; }); } prepareResumableUpload(options) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { attributes, size, mimetype } = options; const path = '/api/v1/videos/upload-resumable'; return this.postUploadRequest(Object.assign(Object.assign({}, options), { path, headers: { 'X-Upload-Content-Type': mimetype, 'X-Upload-Content-Length': size.toString() - }, fields: Object.assign({ filename: attributes.fixture }, this.buildUploadFields(options.attributes)), attaches: this.buildUploadAttaches(lodash_1.omit(options.attributes, 'fixture')), implicitToken: true, defaultExpectedStatus: null })); + }, fields: Object.assign({ filename: attributes.fixture }, this.buildUploadFields(options.attributes)), attaches: this.buildUploadAttaches((0, lodash_1.omit)(options.attributes, 'fixture')), implicitToken: true, defaultExpectedStatus: null })); }); } sendResumableChunks(options) { @@ -216,10 +216,10 @@ class VideosCommand extends shared_1.AbstractCommand { let start = 0; const token = this.buildCommonRequestToken(Object.assign(Object.assign({}, options), { implicitToken: true })); const url = this.server.url; - const readable = fs_extra_1.createReadStream(videoFilePath, { highWaterMark: 8 * 1024 }); + const readable = (0, fs_extra_1.createReadStream)(videoFilePath, { highWaterMark: 8 * 1024 }); return new Promise((resolve, reject) => { readable.on('data', function onData(chunk) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { readable.pause(); const headers = { 'Authorization': 'Bearer ' + token, @@ -229,7 +229,7 @@ class VideosCommand extends shared_1.AbstractCommand { : `bytes ${start}-${start + chunk.length - 1}/${size}`, 'Content-Length': contentLength ? contentLength + '' : chunk.length + '' }; - const res = yield got_1.default({ + const res = yield (0, got_1.default)({ url, method: 'put', headers, @@ -265,19 +265,19 @@ class VideosCommand extends shared_1.AbstractCommand { return this.upload(Object.assign(Object.assign({}, options), { attributes })); } randomUpload(options = {}) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { wait = true, additionalParams } = options; const prefixName = (additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.prefixName) || ''; - const name = prefixName + uuid_1.buildUUID(); + const name = prefixName + (0, uuid_1.buildUUID)(); const attributes = Object.assign({ name }, additionalParams); const result = yield this.upload(Object.assign(Object.assign({}, options), { attributes })); if (wait) - yield server_1.waitJobs([this.server]); + yield (0, server_1.waitJobs)([this.server]); return Object.assign(Object.assign({}, result), { name }); }); } buildListQuery(options) { - return core_utils_1.pick(options, [ + return (0, core_utils_1.pick)(options, [ 'start', 'count', 'sort', @@ -293,16 +293,16 @@ class VideosCommand extends shared_1.AbstractCommand { ]); } buildUploadFields(attributes) { - return lodash_1.omit(attributes, ['fixture', 'thumbnailfile', 'previewfile']); + return (0, lodash_1.omit)(attributes, ['fixture', 'thumbnailfile', 'previewfile']); } buildUploadAttaches(attributes) { const attaches = {}; for (const key of ['thumbnailfile', 'previewfile']) { if (attributes[key]) - attaches[key] = miscs_1.buildAbsoluteFixturePath(attributes[key]); + attaches[key] = (0, miscs_1.buildAbsoluteFixturePath)(attributes[key]); } if (attributes.fixture) - attaches.videofile = miscs_1.buildAbsoluteFixturePath(attributes.fixture); + attaches.videofile = (0, miscs_1.buildAbsoluteFixturePath)(attributes.fixture); return attaches; } } diff --git a/dist/shared/extra-utils/videos/videos.js b/dist/shared/extra-utils/videos/videos.js index 23ea4852..4e28470f 100644 --- a/dist/shared/extra-utils/videos/videos.js +++ b/dist/shared/extra-utils/videos/videos.js @@ -14,34 +14,34 @@ const requests_1 = require("../requests/requests"); const server_1 = require("../server"); function checkVideoFilesWereRemoved(options) { var _a; - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const { video, server, captions = [], onlyVideoFiles = false } = options; const webtorrentFiles = video.files || []; const hlsFiles = ((_a = video.streamingPlaylists[0]) === null || _a === void 0 ? void 0 : _a.files) || []; - const thumbnailName = path_1.basename(video.thumbnailPath); - const previewName = path_1.basename(video.previewPath); - const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => path_1.basename(f.torrentUrl)); - const captionNames = captions.map(c => path_1.basename(c.captionPath)); - const webtorrentFilenames = webtorrentFiles.map(f => path_1.basename(f.fileUrl)); - const hlsFilenames = hlsFiles.map(f => path_1.basename(f.fileUrl)); + const thumbnailName = (0, path_1.basename)(video.thumbnailPath); + const previewName = (0, path_1.basename)(video.previewPath); + const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => (0, path_1.basename)(f.torrentUrl)); + const captionNames = captions.map(c => (0, path_1.basename)(c.captionPath)); + const webtorrentFilenames = webtorrentFiles.map(f => (0, path_1.basename)(f.fileUrl)); + const hlsFilenames = hlsFiles.map(f => (0, path_1.basename)(f.fileUrl)); let directories = { videos: webtorrentFilenames, redundancy: webtorrentFilenames, - [path_1.join('playlists', 'hls')]: hlsFilenames, - [path_1.join('redundancy', 'hls')]: hlsFilenames + [(0, path_1.join)('playlists', 'hls')]: hlsFilenames, + [(0, path_1.join)('redundancy', 'hls')]: hlsFilenames }; if (onlyVideoFiles !== true) { directories = Object.assign(Object.assign({}, directories), { thumbnails: [thumbnailName], previews: [previewName], torrents: torrentNames, captions: captionNames }); } for (const directory of Object.keys(directories)) { const directoryPath = server.servers.buildDirectory(directory); - const directoryExists = yield fs_extra_1.pathExists(directoryPath); + const directoryExists = yield (0, fs_extra_1.pathExists)(directoryPath); if (directoryExists === false) continue; - const existingFiles = yield fs_extra_1.readdir(directoryPath); + const existingFiles = yield (0, fs_extra_1.readdir)(directoryPath); for (const existingFile of existingFiles) { for (const shouldNotExist of directories[directory]) { - chai_1.expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist); + (0, chai_1.expect)(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist); } } } @@ -49,7 +49,7 @@ function checkVideoFilesWereRemoved(options) { } exports.checkVideoFilesWereRemoved = checkVideoFilesWereRemoved; function saveVideoInServers(servers, uuid) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { for (const server of servers) { server.store.videoDetails = yield server.videos.get({ id: uuid }); } @@ -63,98 +63,98 @@ function checkUploadVideoParam(server, token, attributes, expectedStatus = model } exports.checkUploadVideoParam = checkUploadVideoParam; function completeVideoCheck(server, video, attributes) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { if (!attributes.likes) attributes.likes = 0; if (!attributes.dislikes) attributes.dislikes = 0; const host = new URL(server.url).host; const originHost = attributes.account.host; - chai_1.expect(video.name).to.equal(attributes.name); - chai_1.expect(video.category.id).to.equal(attributes.category); - chai_1.expect(video.category.label).to.equal(attributes.category !== null ? constants_1.VIDEO_CATEGORIES[attributes.category] : 'Misc'); - chai_1.expect(video.licence.id).to.equal(attributes.licence); - chai_1.expect(video.licence.label).to.equal(attributes.licence !== null ? constants_1.VIDEO_LICENCES[attributes.licence] : 'Unknown'); - chai_1.expect(video.language.id).to.equal(attributes.language); - chai_1.expect(video.language.label).to.equal(attributes.language !== null ? constants_1.VIDEO_LANGUAGES[attributes.language] : 'Unknown'); - chai_1.expect(video.privacy.id).to.deep.equal(attributes.privacy); - chai_1.expect(video.privacy.label).to.deep.equal(constants_1.VIDEO_PRIVACIES[attributes.privacy]); - chai_1.expect(video.nsfw).to.equal(attributes.nsfw); - chai_1.expect(video.description).to.equal(attributes.description); - chai_1.expect(video.account.id).to.be.a('number'); - chai_1.expect(video.account.host).to.equal(attributes.account.host); - chai_1.expect(video.account.name).to.equal(attributes.account.name); - chai_1.expect(video.channel.displayName).to.equal(attributes.channel.displayName); - chai_1.expect(video.channel.name).to.equal(attributes.channel.name); - chai_1.expect(video.likes).to.equal(attributes.likes); - chai_1.expect(video.dislikes).to.equal(attributes.dislikes); - chai_1.expect(video.isLocal).to.equal(attributes.isLocal); - chai_1.expect(video.duration).to.equal(attributes.duration); - chai_1.expect(miscs_1.dateIsValid(video.createdAt)).to.be.true; - chai_1.expect(miscs_1.dateIsValid(video.publishedAt)).to.be.true; - chai_1.expect(miscs_1.dateIsValid(video.updatedAt)).to.be.true; + (0, chai_1.expect)(video.name).to.equal(attributes.name); + (0, chai_1.expect)(video.category.id).to.equal(attributes.category); + (0, chai_1.expect)(video.category.label).to.equal(attributes.category !== null ? constants_1.VIDEO_CATEGORIES[attributes.category] : 'Misc'); + (0, chai_1.expect)(video.licence.id).to.equal(attributes.licence); + (0, chai_1.expect)(video.licence.label).to.equal(attributes.licence !== null ? constants_1.VIDEO_LICENCES[attributes.licence] : 'Unknown'); + (0, chai_1.expect)(video.language.id).to.equal(attributes.language); + (0, chai_1.expect)(video.language.label).to.equal(attributes.language !== null ? constants_1.VIDEO_LANGUAGES[attributes.language] : 'Unknown'); + (0, chai_1.expect)(video.privacy.id).to.deep.equal(attributes.privacy); + (0, chai_1.expect)(video.privacy.label).to.deep.equal(constants_1.VIDEO_PRIVACIES[attributes.privacy]); + (0, chai_1.expect)(video.nsfw).to.equal(attributes.nsfw); + (0, chai_1.expect)(video.description).to.equal(attributes.description); + (0, chai_1.expect)(video.account.id).to.be.a('number'); + (0, chai_1.expect)(video.account.host).to.equal(attributes.account.host); + (0, chai_1.expect)(video.account.name).to.equal(attributes.account.name); + (0, chai_1.expect)(video.channel.displayName).to.equal(attributes.channel.displayName); + (0, chai_1.expect)(video.channel.name).to.equal(attributes.channel.name); + (0, chai_1.expect)(video.likes).to.equal(attributes.likes); + (0, chai_1.expect)(video.dislikes).to.equal(attributes.dislikes); + (0, chai_1.expect)(video.isLocal).to.equal(attributes.isLocal); + (0, chai_1.expect)(video.duration).to.equal(attributes.duration); + (0, chai_1.expect)((0, miscs_1.dateIsValid)(video.createdAt)).to.be.true; + (0, chai_1.expect)((0, miscs_1.dateIsValid)(video.publishedAt)).to.be.true; + (0, chai_1.expect)((0, miscs_1.dateIsValid)(video.updatedAt)).to.be.true; if (attributes.publishedAt) { - chai_1.expect(video.publishedAt).to.equal(attributes.publishedAt); + (0, chai_1.expect)(video.publishedAt).to.equal(attributes.publishedAt); } if (attributes.originallyPublishedAt) { - chai_1.expect(video.originallyPublishedAt).to.equal(attributes.originallyPublishedAt); + (0, chai_1.expect)(video.originallyPublishedAt).to.equal(attributes.originallyPublishedAt); } else { - chai_1.expect(video.originallyPublishedAt).to.be.null; + (0, chai_1.expect)(video.originallyPublishedAt).to.be.null; } const videoDetails = yield server.videos.get({ id: video.uuid }); - chai_1.expect(videoDetails.files).to.have.lengthOf(attributes.files.length); - chai_1.expect(videoDetails.tags).to.deep.equal(attributes.tags); - chai_1.expect(videoDetails.account.name).to.equal(attributes.account.name); - chai_1.expect(videoDetails.account.host).to.equal(attributes.account.host); - chai_1.expect(video.channel.displayName).to.equal(attributes.channel.displayName); - chai_1.expect(video.channel.name).to.equal(attributes.channel.name); - chai_1.expect(videoDetails.channel.host).to.equal(attributes.account.host); - chai_1.expect(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal); - chai_1.expect(miscs_1.dateIsValid(videoDetails.channel.createdAt.toString())).to.be.true; - chai_1.expect(miscs_1.dateIsValid(videoDetails.channel.updatedAt.toString())).to.be.true; - chai_1.expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled); - chai_1.expect(videoDetails.downloadEnabled).to.equal(attributes.downloadEnabled); + (0, chai_1.expect)(videoDetails.files).to.have.lengthOf(attributes.files.length); + (0, chai_1.expect)(videoDetails.tags).to.deep.equal(attributes.tags); + (0, chai_1.expect)(videoDetails.account.name).to.equal(attributes.account.name); + (0, chai_1.expect)(videoDetails.account.host).to.equal(attributes.account.host); + (0, chai_1.expect)(video.channel.displayName).to.equal(attributes.channel.displayName); + (0, chai_1.expect)(video.channel.name).to.equal(attributes.channel.name); + (0, chai_1.expect)(videoDetails.channel.host).to.equal(attributes.account.host); + (0, chai_1.expect)(videoDetails.channel.isLocal).to.equal(attributes.channel.isLocal); + (0, chai_1.expect)((0, miscs_1.dateIsValid)(videoDetails.channel.createdAt.toString())).to.be.true; + (0, chai_1.expect)((0, miscs_1.dateIsValid)(videoDetails.channel.updatedAt.toString())).to.be.true; + (0, chai_1.expect)(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled); + (0, chai_1.expect)(videoDetails.downloadEnabled).to.equal(attributes.downloadEnabled); for (const attributeFile of attributes.files) { const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution); - chai_1.expect(file).not.to.be.undefined; - let extension = core_utils_1.getLowercaseExtension(attributes.fixture); + (0, chai_1.expect)(file).not.to.be.undefined; + let extension = (0, core_utils_1.getLowercaseExtension)(attributes.fixture); if (attributes.files.length > 1) extension = '.mp4'; - chai_1.expect(file.magnetUri).to.have.lengthOf.above(2); - chai_1.expect(file.torrentDownloadUrl).to.match(new RegExp(`http://${host}/download/torrents/${core_utils_2.uuidRegex}-${file.resolution.id}.torrent`)); - chai_1.expect(file.torrentUrl).to.match(new RegExp(`http://${host}/lazy-static/torrents/${core_utils_2.uuidRegex}-${file.resolution.id}.torrent`)); - chai_1.expect(file.fileUrl).to.match(new RegExp(`http://${originHost}/static/webseed/${core_utils_2.uuidRegex}-${file.resolution.id}${extension}`)); - chai_1.expect(file.fileDownloadUrl).to.match(new RegExp(`http://${originHost}/download/videos/${core_utils_2.uuidRegex}-${file.resolution.id}${extension}`)); + (0, chai_1.expect)(file.magnetUri).to.have.lengthOf.above(2); + (0, chai_1.expect)(file.torrentDownloadUrl).to.match(new RegExp(`http://${host}/download/torrents/${core_utils_2.uuidRegex}-${file.resolution.id}.torrent`)); + (0, chai_1.expect)(file.torrentUrl).to.match(new RegExp(`http://${host}/lazy-static/torrents/${core_utils_2.uuidRegex}-${file.resolution.id}.torrent`)); + (0, chai_1.expect)(file.fileUrl).to.match(new RegExp(`http://${originHost}/static/webseed/${core_utils_2.uuidRegex}-${file.resolution.id}${extension}`)); + (0, chai_1.expect)(file.fileDownloadUrl).to.match(new RegExp(`http://${originHost}/download/videos/${core_utils_2.uuidRegex}-${file.resolution.id}${extension}`)); yield Promise.all([ - requests_1.makeRawRequest(file.torrentUrl, 200), - requests_1.makeRawRequest(file.torrentDownloadUrl, 200), - requests_1.makeRawRequest(file.metadataUrl, 200) + (0, requests_1.makeRawRequest)(file.torrentUrl, 200), + (0, requests_1.makeRawRequest)(file.torrentDownloadUrl, 200), + (0, requests_1.makeRawRequest)(file.metadataUrl, 200) ]); - chai_1.expect(file.resolution.id).to.equal(attributeFile.resolution); - chai_1.expect(file.resolution.label).to.equal(attributeFile.resolution + 'p'); + (0, chai_1.expect)(file.resolution.id).to.equal(attributeFile.resolution); + (0, chai_1.expect)(file.resolution.label).to.equal(attributeFile.resolution + 'p'); const minSize = attributeFile.size - ((10 * attributeFile.size) / 100); const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100); - chai_1.expect(file.size, 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')').to.be.above(minSize).and.below(maxSize); - const torrent = yield miscs_1.webtorrentAdd(file.magnetUri, true); - chai_1.expect(torrent.files).to.be.an('array'); - chai_1.expect(torrent.files.length).to.equal(1); - chai_1.expect(torrent.files[0].path).to.exist.and.to.not.equal(''); + (0, chai_1.expect)(file.size, 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')').to.be.above(minSize).and.below(maxSize); + const torrent = yield (0, miscs_1.webtorrentAdd)(file.magnetUri, true); + (0, chai_1.expect)(torrent.files).to.be.an('array'); + (0, chai_1.expect)(torrent.files.length).to.equal(1); + (0, chai_1.expect)(torrent.files[0].path).to.exist.and.to.not.equal(''); } - chai_1.expect(videoDetails.thumbnailPath).to.exist; - yield miscs_1.testImage(server.url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath); + (0, chai_1.expect)(videoDetails.thumbnailPath).to.exist; + yield (0, miscs_1.testImage)(server.url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath); if (attributes.previewfile) { - chai_1.expect(videoDetails.previewPath).to.exist; - yield miscs_1.testImage(server.url, attributes.previewfile, videoDetails.previewPath); + (0, chai_1.expect)(videoDetails.previewPath).to.exist; + yield (0, miscs_1.testImage)(server.url, attributes.previewfile, videoDetails.previewPath); } }); } exports.completeVideoCheck = completeVideoCheck; function uploadRandomVideoOnServers(servers, serverNumber, additionalParams) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { + return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const server = servers.find(s => s.serverNumber === serverNumber); const res = yield server.videos.randomUpload({ wait: false, additionalParams }); - yield server_1.waitJobs(servers); + yield (0, server_1.waitJobs)(servers); return res; }); } diff --git a/dist/shared/index.js b/dist/shared/index.js index 829a2f9f..38af583d 100644 --- a/dist/shared/index.js +++ b/dist/shared/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./models"), exports); +(0, tslib_1.__exportStar)(require("./models"), exports); diff --git a/dist/shared/models/activitypub/index.js b/dist/shared/models/activitypub/index.js index 04f0edb7..b1fd0322 100644 --- a/dist/shared/models/activitypub/index.js +++ b/dist/shared/models/activitypub/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./activity"), exports); -tslib_1.__exportStar(require("./activitypub-actor"), exports); -tslib_1.__exportStar(require("./activitypub-collection"), exports); -tslib_1.__exportStar(require("./activitypub-ordered-collection"), exports); -tslib_1.__exportStar(require("./activitypub-root"), exports); -tslib_1.__exportStar(require("./activitypub-signature"), exports); -tslib_1.__exportStar(require("./objects"), exports); -tslib_1.__exportStar(require("./webfinger"), exports); +(0, tslib_1.__exportStar)(require("./activity"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-actor"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-collection"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-ordered-collection"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-root"), exports); +(0, tslib_1.__exportStar)(require("./activitypub-signature"), exports); +(0, tslib_1.__exportStar)(require("./objects"), exports); +(0, tslib_1.__exportStar)(require("./webfinger"), exports); diff --git a/dist/shared/models/activitypub/objects/index.js b/dist/shared/models/activitypub/objects/index.js index 0c1abd39..6196b5e8 100644 --- a/dist/shared/models/activitypub/objects/index.js +++ b/dist/shared/models/activitypub/objects/index.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse-object"), exports); -tslib_1.__exportStar(require("./cache-file-object"), exports); -tslib_1.__exportStar(require("./common-objects"), exports); -tslib_1.__exportStar(require("./dislike-object"), exports); -tslib_1.__exportStar(require("./object.model"), exports); -tslib_1.__exportStar(require("./playlist-element-object"), exports); -tslib_1.__exportStar(require("./playlist-object"), exports); -tslib_1.__exportStar(require("./video-comment-object"), exports); -tslib_1.__exportStar(require("./video-torrent-object"), exports); -tslib_1.__exportStar(require("./view-object"), exports); +(0, tslib_1.__exportStar)(require("./abuse-object"), exports); +(0, tslib_1.__exportStar)(require("./cache-file-object"), exports); +(0, tslib_1.__exportStar)(require("./common-objects"), exports); +(0, tslib_1.__exportStar)(require("./dislike-object"), exports); +(0, tslib_1.__exportStar)(require("./object.model"), exports); +(0, tslib_1.__exportStar)(require("./playlist-element-object"), exports); +(0, tslib_1.__exportStar)(require("./playlist-object"), exports); +(0, tslib_1.__exportStar)(require("./video-comment-object"), exports); +(0, tslib_1.__exportStar)(require("./video-torrent-object"), exports); +(0, tslib_1.__exportStar)(require("./view-object"), exports); diff --git a/dist/shared/models/actors/index.js b/dist/shared/models/actors/index.js index 5029a0ef..c874a805 100644 --- a/dist/shared/models/actors/index.js +++ b/dist/shared/models/actors/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./account.model"), exports); -tslib_1.__exportStar(require("./actor-image.model"), exports); -tslib_1.__exportStar(require("./actor-image.type"), exports); -tslib_1.__exportStar(require("./actor.model"), exports); -tslib_1.__exportStar(require("./custom-page.model"), exports); -tslib_1.__exportStar(require("./follow.model"), exports); +(0, tslib_1.__exportStar)(require("./account.model"), exports); +(0, tslib_1.__exportStar)(require("./actor-image.model"), exports); +(0, tslib_1.__exportStar)(require("./actor-image.type"), exports); +(0, tslib_1.__exportStar)(require("./actor.model"), exports); +(0, tslib_1.__exportStar)(require("./custom-page.model"), exports); +(0, tslib_1.__exportStar)(require("./follow.model"), exports); diff --git a/dist/shared/models/bulk/index.js b/dist/shared/models/bulk/index.js index 700cc6c0..bb9174d1 100644 --- a/dist/shared/models/bulk/index.js +++ b/dist/shared/models/bulk/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./bulk-remove-comments-of-body.model"), exports); +(0, tslib_1.__exportStar)(require("./bulk-remove-comments-of-body.model"), exports); diff --git a/dist/shared/models/common/index.js b/dist/shared/models/common/index.js index 1a44f52f..d770c8f0 100644 --- a/dist/shared/models/common/index.js +++ b/dist/shared/models/common/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./result-list.model"), exports); +(0, tslib_1.__exportStar)(require("./result-list.model"), exports); diff --git a/dist/shared/models/custom-markup/index.js b/dist/shared/models/custom-markup/index.js index d458f6f1..03b4b7da 100644 --- a/dist/shared/models/custom-markup/index.js +++ b/dist/shared/models/custom-markup/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./custom-markup-data.model"), exports); +(0, tslib_1.__exportStar)(require("./custom-markup-data.model"), exports); diff --git a/dist/shared/models/feeds/index.js b/dist/shared/models/feeds/index.js index 2ed7eb54..f2a036cb 100644 --- a/dist/shared/models/feeds/index.js +++ b/dist/shared/models/feeds/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./feed-format.enum"), exports); +(0, tslib_1.__exportStar)(require("./feed-format.enum"), exports); diff --git a/dist/shared/models/http/index.js b/dist/shared/models/http/index.js index 4bf03782..86395fde 100644 --- a/dist/shared/models/http/index.js +++ b/dist/shared/models/http/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./http-error-codes"), exports); -tslib_1.__exportStar(require("./http-methods"), exports); +(0, tslib_1.__exportStar)(require("./http-error-codes"), exports); +(0, tslib_1.__exportStar)(require("./http-methods"), exports); diff --git a/dist/shared/models/index.js b/dist/shared/models/index.js index 0a44ba8f..f4cb1e2b 100644 --- a/dist/shared/models/index.js +++ b/dist/shared/models/index.js @@ -1,20 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./activitypub"), exports); -tslib_1.__exportStar(require("./actors"), exports); -tslib_1.__exportStar(require("./bulk"), exports); -tslib_1.__exportStar(require("./common"), exports); -tslib_1.__exportStar(require("./custom-markup"), exports); -tslib_1.__exportStar(require("./feeds"), exports); -tslib_1.__exportStar(require("./http"), exports); -tslib_1.__exportStar(require("./joinpeertube"), exports); -tslib_1.__exportStar(require("./moderation"), exports); -tslib_1.__exportStar(require("./overviews"), exports); -tslib_1.__exportStar(require("./plugins"), exports); -tslib_1.__exportStar(require("./redundancy"), exports); -tslib_1.__exportStar(require("./search"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./tokens"), exports); -tslib_1.__exportStar(require("./users"), exports); -tslib_1.__exportStar(require("./videos"), exports); +(0, tslib_1.__exportStar)(require("./activitypub"), exports); +(0, tslib_1.__exportStar)(require("./actors"), exports); +(0, tslib_1.__exportStar)(require("./bulk"), exports); +(0, tslib_1.__exportStar)(require("./common"), exports); +(0, tslib_1.__exportStar)(require("./custom-markup"), exports); +(0, tslib_1.__exportStar)(require("./feeds"), exports); +(0, tslib_1.__exportStar)(require("./http"), exports); +(0, tslib_1.__exportStar)(require("./joinpeertube"), exports); +(0, tslib_1.__exportStar)(require("./moderation"), exports); +(0, tslib_1.__exportStar)(require("./overviews"), exports); +(0, tslib_1.__exportStar)(require("./plugins"), exports); +(0, tslib_1.__exportStar)(require("./redundancy"), exports); +(0, tslib_1.__exportStar)(require("./search"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./tokens"), exports); +(0, tslib_1.__exportStar)(require("./users"), exports); +(0, tslib_1.__exportStar)(require("./videos"), exports); diff --git a/dist/shared/models/joinpeertube/index.js b/dist/shared/models/joinpeertube/index.js index 4c093976..fb3eaa59 100644 --- a/dist/shared/models/joinpeertube/index.js +++ b/dist/shared/models/joinpeertube/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./versions.model"), exports); +(0, tslib_1.__exportStar)(require("./versions.model"), exports); diff --git a/dist/shared/models/moderation/abuse/index.js b/dist/shared/models/moderation/abuse/index.js index 60ad53cc..64bcaca0 100644 --- a/dist/shared/models/moderation/abuse/index.js +++ b/dist/shared/models/moderation/abuse/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse-create.model"), exports); -tslib_1.__exportStar(require("./abuse-filter.type"), exports); -tslib_1.__exportStar(require("./abuse-message.model"), exports); -tslib_1.__exportStar(require("./abuse-reason.model"), exports); -tslib_1.__exportStar(require("./abuse-state.model"), exports); -tslib_1.__exportStar(require("./abuse-update.model"), exports); -tslib_1.__exportStar(require("./abuse-video-is.type"), exports); -tslib_1.__exportStar(require("./abuse.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-create.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-filter.type"), exports); +(0, tslib_1.__exportStar)(require("./abuse-message.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-reason.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-state.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-update.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse-video-is.type"), exports); +(0, tslib_1.__exportStar)(require("./abuse.model"), exports); diff --git a/dist/shared/models/moderation/index.js b/dist/shared/models/moderation/index.js index 0db1173c..17d7e65e 100644 --- a/dist/shared/models/moderation/index.js +++ b/dist/shared/models/moderation/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./abuse"), exports); -tslib_1.__exportStar(require("./account-block.model"), exports); -tslib_1.__exportStar(require("./server-block.model"), exports); +(0, tslib_1.__exportStar)(require("./abuse"), exports); +(0, tslib_1.__exportStar)(require("./account-block.model"), exports); +(0, tslib_1.__exportStar)(require("./server-block.model"), exports); diff --git a/dist/shared/models/nodeinfo/index.js b/dist/shared/models/nodeinfo/index.js index 2dd30fdc..03b730ad 100644 --- a/dist/shared/models/nodeinfo/index.js +++ b/dist/shared/models/nodeinfo/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./nodeinfo.model"), exports); +(0, tslib_1.__exportStar)(require("./nodeinfo.model"), exports); diff --git a/dist/shared/models/overviews/index.js b/dist/shared/models/overviews/index.js index 6b9c95d3..2fb31f3b 100644 --- a/dist/shared/models/overviews/index.js +++ b/dist/shared/models/overviews/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./videos-overview.model"), exports); +(0, tslib_1.__exportStar)(require("./videos-overview.model"), exports); diff --git a/dist/shared/models/plugins/client/index.js b/dist/shared/models/plugins/client/index.js index 1c7e4856..e675e2f4 100644 --- a/dist/shared/models/plugins/client/index.js +++ b/dist/shared/models/plugins/client/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./client-hook.model"), exports); -tslib_1.__exportStar(require("./plugin-client-scope.type"), exports); -tslib_1.__exportStar(require("./plugin-element-placeholder.type"), exports); -tslib_1.__exportStar(require("./register-client-form-field.model"), exports); -tslib_1.__exportStar(require("./register-client-hook.model"), exports); -tslib_1.__exportStar(require("./register-client-settings-script.model"), exports); +(0, tslib_1.__exportStar)(require("./client-hook.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-client-scope.type"), exports); +(0, tslib_1.__exportStar)(require("./plugin-element-placeholder.type"), exports); +(0, tslib_1.__exportStar)(require("./register-client-form-field.model"), exports); +(0, tslib_1.__exportStar)(require("./register-client-hook.model"), exports); +(0, tslib_1.__exportStar)(require("./register-client-settings-script.model"), exports); diff --git a/dist/shared/models/plugins/index.js b/dist/shared/models/plugins/index.js index 6ab99aed..0aafbcfb 100644 --- a/dist/shared/models/plugins/index.js +++ b/dist/shared/models/plugins/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./client"), exports); -tslib_1.__exportStar(require("./plugin-index"), exports); -tslib_1.__exportStar(require("./server"), exports); -tslib_1.__exportStar(require("./hook-type.enum"), exports); -tslib_1.__exportStar(require("./plugin-package-json.model"), exports); -tslib_1.__exportStar(require("./plugin.type"), exports); +(0, tslib_1.__exportStar)(require("./client"), exports); +(0, tslib_1.__exportStar)(require("./plugin-index"), exports); +(0, tslib_1.__exportStar)(require("./server"), exports); +(0, tslib_1.__exportStar)(require("./hook-type.enum"), exports); +(0, tslib_1.__exportStar)(require("./plugin-package-json.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin.type"), exports); diff --git a/dist/shared/models/plugins/plugin-index/index.js b/dist/shared/models/plugins/plugin-index/index.js index a58448a6..650cde4b 100644 --- a/dist/shared/models/plugins/plugin-index/index.js +++ b/dist/shared/models/plugins/plugin-index/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./peertube-plugin-index-list.model"), exports); -tslib_1.__exportStar(require("./peertube-plugin-index.model"), exports); -tslib_1.__exportStar(require("./peertube-plugin-latest-version.model"), exports); +(0, tslib_1.__exportStar)(require("./peertube-plugin-index-list.model"), exports); +(0, tslib_1.__exportStar)(require("./peertube-plugin-index.model"), exports); +(0, tslib_1.__exportStar)(require("./peertube-plugin-latest-version.model"), exports); diff --git a/dist/shared/models/plugins/server/api/index.js b/dist/shared/models/plugins/server/api/index.js index 42783529..4f4ae192 100644 --- a/dist/shared/models/plugins/server/api/index.js +++ b/dist/shared/models/plugins/server/api/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./install-plugin.model"), exports); -tslib_1.__exportStar(require("./manage-plugin.model"), exports); -tslib_1.__exportStar(require("./peertube-plugin.model"), exports); +(0, tslib_1.__exportStar)(require("./install-plugin.model"), exports); +(0, tslib_1.__exportStar)(require("./manage-plugin.model"), exports); +(0, tslib_1.__exportStar)(require("./peertube-plugin.model"), exports); diff --git a/dist/shared/models/plugins/server/index.js b/dist/shared/models/plugins/server/index.js index b1dafe1c..ee387a38 100644 --- a/dist/shared/models/plugins/server/index.js +++ b/dist/shared/models/plugins/server/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./api"), exports); -tslib_1.__exportStar(require("./managers"), exports); -tslib_1.__exportStar(require("./settings"), exports); -tslib_1.__exportStar(require("./plugin-translation.model"), exports); -tslib_1.__exportStar(require("./register-server-hook.model"), exports); -tslib_1.__exportStar(require("./server-hook.model"), exports); +(0, tslib_1.__exportStar)(require("./api"), exports); +(0, tslib_1.__exportStar)(require("./managers"), exports); +(0, tslib_1.__exportStar)(require("./settings"), exports); +(0, tslib_1.__exportStar)(require("./plugin-translation.model"), exports); +(0, tslib_1.__exportStar)(require("./register-server-hook.model"), exports); +(0, tslib_1.__exportStar)(require("./server-hook.model"), exports); diff --git a/dist/shared/models/plugins/server/managers/index.js b/dist/shared/models/plugins/server/managers/index.js index 2718ea8c..eb20cd2e 100644 --- a/dist/shared/models/plugins/server/managers/index.js +++ b/dist/shared/models/plugins/server/managers/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./plugin-playlist-privacy-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-settings-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-storage-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-transcoding-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-video-category-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-video-language-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-video-licence-manager.model"), exports); -tslib_1.__exportStar(require("./plugin-video-privacy-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-playlist-privacy-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-settings-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-storage-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-transcoding-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-video-category-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-video-language-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-video-licence-manager.model"), exports); +(0, tslib_1.__exportStar)(require("./plugin-video-privacy-manager.model"), exports); diff --git a/dist/shared/models/plugins/server/settings/index.js b/dist/shared/models/plugins/server/settings/index.js index 1af197df..ca9d5952 100644 --- a/dist/shared/models/plugins/server/settings/index.js +++ b/dist/shared/models/plugins/server/settings/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./public-server.setting"), exports); -tslib_1.__exportStar(require("./register-server-setting.model"), exports); +(0, tslib_1.__exportStar)(require("./public-server.setting"), exports); +(0, tslib_1.__exportStar)(require("./register-server-setting.model"), exports); diff --git a/dist/shared/models/redundancy/index.js b/dist/shared/models/redundancy/index.js index 27f55030..4edbfd8e 100644 --- a/dist/shared/models/redundancy/index.js +++ b/dist/shared/models/redundancy/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-redundancies-filters.model"), exports); -tslib_1.__exportStar(require("./video-redundancy-config-filter.type"), exports); -tslib_1.__exportStar(require("./video-redundancy.model"), exports); -tslib_1.__exportStar(require("./videos-redundancy-strategy.model"), exports); +(0, tslib_1.__exportStar)(require("./video-redundancies-filters.model"), exports); +(0, tslib_1.__exportStar)(require("./video-redundancy-config-filter.type"), exports); +(0, tslib_1.__exportStar)(require("./video-redundancy.model"), exports); +(0, tslib_1.__exportStar)(require("./videos-redundancy-strategy.model"), exports); diff --git a/dist/shared/models/search/index.js b/dist/shared/models/search/index.js index a338b501..790cf101 100644 --- a/dist/shared/models/search/index.js +++ b/dist/shared/models/search/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./boolean-both-query.model"), exports); -tslib_1.__exportStar(require("./search-target-query.model"), exports); -tslib_1.__exportStar(require("./videos-common-query.model"), exports); -tslib_1.__exportStar(require("./video-channels-search-query.model"), exports); -tslib_1.__exportStar(require("./video-playlists-search-query.model"), exports); -tslib_1.__exportStar(require("./videos-search-query.model"), exports); +(0, tslib_1.__exportStar)(require("./boolean-both-query.model"), exports); +(0, tslib_1.__exportStar)(require("./search-target-query.model"), exports); +(0, tslib_1.__exportStar)(require("./videos-common-query.model"), exports); +(0, tslib_1.__exportStar)(require("./video-channels-search-query.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlists-search-query.model"), exports); +(0, tslib_1.__exportStar)(require("./videos-search-query.model"), exports); diff --git a/dist/shared/models/server/index.js b/dist/shared/models/server/index.js index a46fcc11..6811cc81 100644 --- a/dist/shared/models/server/index.js +++ b/dist/shared/models/server/index.js @@ -1,17 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./about.model"), exports); -tslib_1.__exportStar(require("./broadcast-message-level.type"), exports); -tslib_1.__exportStar(require("./contact-form.model"), exports); -tslib_1.__exportStar(require("./custom-config.model"), exports); -tslib_1.__exportStar(require("./debug.model"), exports); -tslib_1.__exportStar(require("./emailer.model"), exports); -tslib_1.__exportStar(require("./job.model"), exports); -tslib_1.__exportStar(require("./log-level.type"), exports); -tslib_1.__exportStar(require("./peertube-problem-document.model"), exports); -tslib_1.__exportStar(require("./server-config.model"), exports); -tslib_1.__exportStar(require("./server-debug.model"), exports); -tslib_1.__exportStar(require("./server-error-code.enum"), exports); -tslib_1.__exportStar(require("./server-follow-create.model"), exports); -tslib_1.__exportStar(require("./server-stats.model"), exports); +(0, tslib_1.__exportStar)(require("./about.model"), exports); +(0, tslib_1.__exportStar)(require("./broadcast-message-level.type"), exports); +(0, tslib_1.__exportStar)(require("./contact-form.model"), exports); +(0, tslib_1.__exportStar)(require("./custom-config.model"), exports); +(0, tslib_1.__exportStar)(require("./debug.model"), exports); +(0, tslib_1.__exportStar)(require("./emailer.model"), exports); +(0, tslib_1.__exportStar)(require("./job.model"), exports); +(0, tslib_1.__exportStar)(require("./log-level.type"), exports); +(0, tslib_1.__exportStar)(require("./peertube-problem-document.model"), exports); +(0, tslib_1.__exportStar)(require("./server-config.model"), exports); +(0, tslib_1.__exportStar)(require("./server-debug.model"), exports); +(0, tslib_1.__exportStar)(require("./server-error-code.enum"), exports); +(0, tslib_1.__exportStar)(require("./server-follow-create.model"), exports); +(0, tslib_1.__exportStar)(require("./server-stats.model"), exports); diff --git a/dist/shared/models/tokens/index.js b/dist/shared/models/tokens/index.js index e51a1f18..d9472f9c 100644 --- a/dist/shared/models/tokens/index.js +++ b/dist/shared/models/tokens/index.js @@ -1,4 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./oauth-client-local.model"), exports); +(0, tslib_1.__exportStar)(require("./oauth-client-local.model"), exports); diff --git a/dist/shared/models/users/index.js b/dist/shared/models/users/index.js index 1c0dd0e7..1809e1b1 100644 --- a/dist/shared/models/users/index.js +++ b/dist/shared/models/users/index.js @@ -1,18 +1,18 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./user-create-result.model"), exports); -tslib_1.__exportStar(require("./user-create.model"), exports); -tslib_1.__exportStar(require("./user-flag.model"), exports); -tslib_1.__exportStar(require("./user-login.model"), exports); -tslib_1.__exportStar(require("./user-notification-setting.model"), exports); -tslib_1.__exportStar(require("./user-notification.model"), exports); -tslib_1.__exportStar(require("./user-refresh-token.model"), exports); -tslib_1.__exportStar(require("./user-register.model"), exports); -tslib_1.__exportStar(require("./user-right.enum"), exports); -tslib_1.__exportStar(require("./user-role"), exports); -tslib_1.__exportStar(require("./user-update-me.model"), exports); -tslib_1.__exportStar(require("./user-update.model"), exports); -tslib_1.__exportStar(require("./user-video-quota.model"), exports); -tslib_1.__exportStar(require("./user-watching-video.model"), exports); -tslib_1.__exportStar(require("./user.model"), exports); +(0, tslib_1.__exportStar)(require("./user-create-result.model"), exports); +(0, tslib_1.__exportStar)(require("./user-create.model"), exports); +(0, tslib_1.__exportStar)(require("./user-flag.model"), exports); +(0, tslib_1.__exportStar)(require("./user-login.model"), exports); +(0, tslib_1.__exportStar)(require("./user-notification-setting.model"), exports); +(0, tslib_1.__exportStar)(require("./user-notification.model"), exports); +(0, tslib_1.__exportStar)(require("./user-refresh-token.model"), exports); +(0, tslib_1.__exportStar)(require("./user-register.model"), exports); +(0, tslib_1.__exportStar)(require("./user-right.enum"), exports); +(0, tslib_1.__exportStar)(require("./user-role"), exports); +(0, tslib_1.__exportStar)(require("./user-update-me.model"), exports); +(0, tslib_1.__exportStar)(require("./user-update.model"), exports); +(0, tslib_1.__exportStar)(require("./user-video-quota.model"), exports); +(0, tslib_1.__exportStar)(require("./user-watching-video.model"), exports); +(0, tslib_1.__exportStar)(require("./user.model"), exports); diff --git a/dist/shared/models/videos/blacklist/index.js b/dist/shared/models/videos/blacklist/index.js index d6ae9460..1b405457 100644 --- a/dist/shared/models/videos/blacklist/index.js +++ b/dist/shared/models/videos/blacklist/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-blacklist.model"), exports); -tslib_1.__exportStar(require("./video-blacklist-create.model"), exports); -tslib_1.__exportStar(require("./video-blacklist-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist.model"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-blacklist-update.model"), exports); diff --git a/dist/shared/models/videos/caption/index.js b/dist/shared/models/videos/caption/index.js index 0e9c34cc..77f436fb 100644 --- a/dist/shared/models/videos/caption/index.js +++ b/dist/shared/models/videos/caption/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-caption.model"), exports); -tslib_1.__exportStar(require("./video-caption-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-caption.model"), exports); +(0, tslib_1.__exportStar)(require("./video-caption-update.model"), exports); diff --git a/dist/shared/models/videos/change-ownership/index.js b/dist/shared/models/videos/change-ownership/index.js index 9546b9ec..1965f978 100644 --- a/dist/shared/models/videos/change-ownership/index.js +++ b/dist/shared/models/videos/change-ownership/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-change-ownership-accept.model"), exports); -tslib_1.__exportStar(require("./video-change-ownership-create.model"), exports); -tslib_1.__exportStar(require("./video-change-ownership.model"), exports); +(0, tslib_1.__exportStar)(require("./video-change-ownership-accept.model"), exports); +(0, tslib_1.__exportStar)(require("./video-change-ownership-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-change-ownership.model"), exports); diff --git a/dist/shared/models/videos/channel/index.js b/dist/shared/models/videos/channel/index.js index 55122ee9..25cc64cc 100644 --- a/dist/shared/models/videos/channel/index.js +++ b/dist/shared/models/videos/channel/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-channel-create-result.model"), exports); -tslib_1.__exportStar(require("./video-channel-create.model"), exports); -tslib_1.__exportStar(require("./video-channel-update.model"), exports); -tslib_1.__exportStar(require("./video-channel.model"), exports); +(0, tslib_1.__exportStar)(require("./video-channel-create-result.model"), exports); +(0, tslib_1.__exportStar)(require("./video-channel-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-channel-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-channel.model"), exports); diff --git a/dist/shared/models/videos/comment/index.js b/dist/shared/models/videos/comment/index.js index 110da2b1..b1000f87 100644 --- a/dist/shared/models/videos/comment/index.js +++ b/dist/shared/models/videos/comment/index.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-comment-create.model"), exports); -tslib_1.__exportStar(require("./video-comment.model"), exports); +(0, tslib_1.__exportStar)(require("./video-comment-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-comment.model"), exports); diff --git a/dist/shared/models/videos/import/index.js b/dist/shared/models/videos/import/index.js index 7258cc4c..ea90a20e 100644 --- a/dist/shared/models/videos/import/index.js +++ b/dist/shared/models/videos/import/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-import-create.model"), exports); -tslib_1.__exportStar(require("./video-import-state.enum"), exports); -tslib_1.__exportStar(require("./video-import.model"), exports); +(0, tslib_1.__exportStar)(require("./video-import-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-import-state.enum"), exports); +(0, tslib_1.__exportStar)(require("./video-import.model"), exports); diff --git a/dist/shared/models/videos/index.js b/dist/shared/models/videos/index.js index 91588808..08f52dc9 100644 --- a/dist/shared/models/videos/index.js +++ b/dist/shared/models/videos/index.js @@ -1,33 +1,33 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./blacklist"), exports); -tslib_1.__exportStar(require("./caption"), exports); -tslib_1.__exportStar(require("./change-ownership"), exports); -tslib_1.__exportStar(require("./channel"), exports); -tslib_1.__exportStar(require("./comment"), exports); -tslib_1.__exportStar(require("./live"), exports); -tslib_1.__exportStar(require("./import"), exports); -tslib_1.__exportStar(require("./playlist"), exports); -tslib_1.__exportStar(require("./rate"), exports); -tslib_1.__exportStar(require("./nsfw-policy.type"), exports); -tslib_1.__exportStar(require("./thumbnail.type"), exports); -tslib_1.__exportStar(require("./video-constant.model"), exports); -tslib_1.__exportStar(require("./video-create.model"), exports); -tslib_1.__exportStar(require("./video-file-metadata.model"), exports); -tslib_1.__exportStar(require("./video-file.model"), exports); -tslib_1.__exportStar(require("./video-privacy.enum"), exports); -tslib_1.__exportStar(require("./video-query.type"), exports); -tslib_1.__exportStar(require("./video-rate.type"), exports); -tslib_1.__exportStar(require("./video-resolution.enum"), exports); -tslib_1.__exportStar(require("./video-schedule-update.model"), exports); -tslib_1.__exportStar(require("./video-sort-field.type"), exports); -tslib_1.__exportStar(require("./video-state.enum"), exports); -tslib_1.__exportStar(require("./video-storage.enum"), exports); -tslib_1.__exportStar(require("./video-streaming-playlist.model"), exports); -tslib_1.__exportStar(require("./video-streaming-playlist.type"), exports); -tslib_1.__exportStar(require("./video-transcoding.model"), exports); -tslib_1.__exportStar(require("./video-transcoding-fps.model"), exports); -tslib_1.__exportStar(require("./video-update.model"), exports); -tslib_1.__exportStar(require("./video.model"), exports); -tslib_1.__exportStar(require("./video-create-result.model"), exports); +(0, tslib_1.__exportStar)(require("./blacklist"), exports); +(0, tslib_1.__exportStar)(require("./caption"), exports); +(0, tslib_1.__exportStar)(require("./change-ownership"), exports); +(0, tslib_1.__exportStar)(require("./channel"), exports); +(0, tslib_1.__exportStar)(require("./comment"), exports); +(0, tslib_1.__exportStar)(require("./live"), exports); +(0, tslib_1.__exportStar)(require("./import"), exports); +(0, tslib_1.__exportStar)(require("./playlist"), exports); +(0, tslib_1.__exportStar)(require("./rate"), exports); +(0, tslib_1.__exportStar)(require("./nsfw-policy.type"), exports); +(0, tslib_1.__exportStar)(require("./thumbnail.type"), exports); +(0, tslib_1.__exportStar)(require("./video-constant.model"), exports); +(0, tslib_1.__exportStar)(require("./video-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-file-metadata.model"), exports); +(0, tslib_1.__exportStar)(require("./video-file.model"), exports); +(0, tslib_1.__exportStar)(require("./video-privacy.enum"), exports); +(0, tslib_1.__exportStar)(require("./video-query.type"), exports); +(0, tslib_1.__exportStar)(require("./video-rate.type"), exports); +(0, tslib_1.__exportStar)(require("./video-resolution.enum"), exports); +(0, tslib_1.__exportStar)(require("./video-schedule-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-sort-field.type"), exports); +(0, tslib_1.__exportStar)(require("./video-state.enum"), exports); +(0, tslib_1.__exportStar)(require("./video-storage.enum"), exports); +(0, tslib_1.__exportStar)(require("./video-streaming-playlist.model"), exports); +(0, tslib_1.__exportStar)(require("./video-streaming-playlist.type"), exports); +(0, tslib_1.__exportStar)(require("./video-transcoding.model"), exports); +(0, tslib_1.__exportStar)(require("./video-transcoding-fps.model"), exports); +(0, tslib_1.__exportStar)(require("./video-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video.model"), exports); +(0, tslib_1.__exportStar)(require("./video-create-result.model"), exports); diff --git a/dist/shared/models/videos/live/index.js b/dist/shared/models/videos/live/index.js index 414b662a..f3880b46 100644 --- a/dist/shared/models/videos/live/index.js +++ b/dist/shared/models/videos/live/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./live-video-create.model"), exports); -tslib_1.__exportStar(require("./live-video-event-payload.model"), exports); -tslib_1.__exportStar(require("./live-video-event.type"), exports); -tslib_1.__exportStar(require("./live-video-update.model"), exports); -tslib_1.__exportStar(require("./live-video.model"), exports); +(0, tslib_1.__exportStar)(require("./live-video-create.model"), exports); +(0, tslib_1.__exportStar)(require("./live-video-event-payload.model"), exports); +(0, tslib_1.__exportStar)(require("./live-video-event.type"), exports); +(0, tslib_1.__exportStar)(require("./live-video-update.model"), exports); +(0, tslib_1.__exportStar)(require("./live-video.model"), exports); diff --git a/dist/shared/models/videos/playlist/index.js b/dist/shared/models/videos/playlist/index.js index 8aa16793..f70fb75a 100644 --- a/dist/shared/models/videos/playlist/index.js +++ b/dist/shared/models/videos/playlist/index.js @@ -1,15 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./video-exist-in-playlist.model"), exports); -tslib_1.__exportStar(require("./video-playlist-create-result.model"), exports); -tslib_1.__exportStar(require("./video-playlist-create.model"), exports); -tslib_1.__exportStar(require("./video-playlist-element-create-result.model"), exports); -tslib_1.__exportStar(require("./video-playlist-element-create.model"), exports); -tslib_1.__exportStar(require("./video-playlist-element-update.model"), exports); -tslib_1.__exportStar(require("./video-playlist-element.model"), exports); -tslib_1.__exportStar(require("./video-playlist-privacy.model"), exports); -tslib_1.__exportStar(require("./video-playlist-reorder.model"), exports); -tslib_1.__exportStar(require("./video-playlist-type.model"), exports); -tslib_1.__exportStar(require("./video-playlist-update.model"), exports); -tslib_1.__exportStar(require("./video-playlist.model"), exports); +(0, tslib_1.__exportStar)(require("./video-exist-in-playlist.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-create-result.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-element-create-result.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-element-create.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-element-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-element.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-privacy.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-reorder.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-type.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist-update.model"), exports); +(0, tslib_1.__exportStar)(require("./video-playlist.model"), exports); diff --git a/dist/shared/models/videos/rate/index.js b/dist/shared/models/videos/rate/index.js index 15053ae3..0a2fcb6e 100644 --- a/dist/shared/models/videos/rate/index.js +++ b/dist/shared/models/videos/rate/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./user-video-rate-update.model"), exports); -tslib_1.__exportStar(require("./user-video-rate.model"), exports); -tslib_1.__exportStar(require("./account-video-rate.model"), exports); -tslib_1.__exportStar(require("./user-video-rate.type"), exports); +(0, tslib_1.__exportStar)(require("./user-video-rate-update.model"), exports); +(0, tslib_1.__exportStar)(require("./user-video-rate.model"), exports); +(0, tslib_1.__exportStar)(require("./account-video-rate.model"), exports); +(0, tslib_1.__exportStar)(require("./user-video-rate.type"), exports);