From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- shared/extra-utils/miscs/checks.ts | 2 +- shared/extra-utils/miscs/webtorrent.ts | 2 +- shared/extra-utils/server/follows.ts | 4 +- shared/extra-utils/server/jobs.ts | 4 +- shared/extra-utils/server/plugins-command.ts | 2 +- shared/extra-utils/server/plugins.ts | 2 +- shared/extra-utils/server/servers-command.ts | 6 +- shared/extra-utils/server/servers.ts | 230 +++++++++++------------ shared/extra-utils/users/accounts.ts | 2 +- shared/extra-utils/users/login-command.ts | 12 +- shared/extra-utils/users/login.ts | 2 +- shared/extra-utils/users/notifications.ts | 20 +- shared/extra-utils/users/users-command.ts | 4 +- shared/extra-utils/videos/channels.ts | 4 +- shared/extra-utils/videos/live-command.ts | 8 +- shared/extra-utils/videos/live.ts | 4 +- shared/extra-utils/videos/playlists-command.ts | 2 +- shared/extra-utils/videos/streaming-playlists.ts | 6 +- shared/extra-utils/videos/videos-command.ts | 2 +- shared/extra-utils/videos/videos.ts | 10 +- 20 files changed, 164 insertions(+), 164 deletions(-) (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts index 86b861cd2..8f7bdb9b5 100644 --- a/shared/extra-utils/miscs/checks.ts +++ b/shared/extra-utils/miscs/checks.ts @@ -34,7 +34,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext } async function testFileExistsOrNot (server: ServerInfo, directory: string, filePath: string, exist: boolean) { - const base = server.serversCommand.buildDirectory(directory) + const base = server.servers.buildDirectory(directory) expect(await pathExists(join(base, filePath))).to.equal(exist) } diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts index 63e648309..84e390b2a 100644 --- a/shared/extra-utils/miscs/webtorrent.ts +++ b/shared/extra-utils/miscs/webtorrent.ts @@ -17,7 +17,7 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) { async function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { const torrentName = videoUUID + '-' + resolution + '.torrent' - const torrentPath = server.serversCommand.buildDirectory(join('torrents', torrentName)) + const torrentPath = server.servers.buildDirectory(join('torrents', torrentName)) const data = await readFile(torrentPath) diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index c23cebd81..50ae898cc 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts @@ -3,8 +3,8 @@ import { ServerInfo } from './servers' async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { await Promise.all([ - server1.followsCommand.follow({ targets: [ server2.url ] }), - server2.followsCommand.follow({ targets: [ server1.url ] }) + server1.follows.follow({ targets: [ server2.url ] }), + server2.follows.follow({ targets: [ server1.url ] }) ]) // Wait request propagation diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 36ef882b3..754530977 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts @@ -23,7 +23,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { // Check if each server has pending request for (const server of servers) { for (const state of states) { - const p = server.jobsCommand.getJobsList({ + const p = server.jobs.getJobsList({ state, start: 0, count: 10, @@ -39,7 +39,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { tasks.push(p) } - const p = server.debugCommand.getDebug() + const p = server.debug.getDebug() .then(obj => { if (obj.activityPubMessagesWaiting !== 0) { pendingRequests = true diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts index 5bed51d1a..98049ce19 100644 --- a/shared/extra-utils/server/plugins-command.ts +++ b/shared/extra-utils/server/plugins-command.ts @@ -251,6 +251,6 @@ export class PluginsCommand extends AbstractCommand { } private getPackageJSONPath (npmName: string) { - return this.server.serversCommand.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json')) + return this.server.servers.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json')) } } diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 1084ea4f4..d1cc7e383 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts @@ -4,7 +4,7 @@ import { expect } from 'chai' import { ServerInfo } from '../server/servers' async function testHelloWorldRegisteredSettings (server: ServerInfo) { - const body = await server.pluginsCommand.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) + const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) const registeredSettings = body.registeredSettings expect(registeredSettings).to.have.length.at.least(1) diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts index 9ef68fede..a7c5a868d 100644 --- a/shared/extra-utils/server/servers-command.ts +++ b/shared/extra-utils/server/servers-command.ts @@ -37,7 +37,7 @@ export class ServersCommand extends AbstractCommand { if (isGithubCI()) { await ensureDir('artifacts') - const origin = this.server.serversCommand.buildDirectory('logs/peertube.log') + const origin = this.server.servers.buildDirectory('logs/peertube.log') const destname = `peertube-${this.server.internalServerNumber}.log` console.log('Saving logs %s.', destname) @@ -56,7 +56,7 @@ export class ServersCommand extends AbstractCommand { } async waitUntilLog (str: string, count = 1, strictCount = true) { - const logfile = this.server.serversCommand.buildDirectory('logs/peertube.log') + const logfile = this.server.servers.buildDirectory('logs/peertube.log') while (true) { const buf = await readFile(logfile) @@ -74,7 +74,7 @@ export class ServersCommand extends AbstractCommand { } async getServerFileSize (subPath: string) { - const path = this.server.serversCommand.buildDirectory(subPath) + const path = this.server.servers.buildDirectory(subPath) return getFileSize(path) } diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index fda5c3d6d..ea3f19a92 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -53,83 +53,81 @@ interface ServerInfo { parallel?: boolean internalServerNumber: number + serverNumber?: number + customConfigFile?: string - client?: { - id?: string - secret?: string - } + store?: { + client?: { + id?: string + secret?: string + } - user?: { - username: string - password: string - email?: string - } + user?: { + username: string + password: string + email?: string + } - customConfigFile?: string + channel?: VideoChannel - accessToken?: string - refreshToken?: string - videoChannel?: VideoChannel + video?: { + id: number + uuid: string + shortUUID: string + name?: string + url?: string - video?: { - id: number - uuid: string - shortUUID: string - name?: string - url?: string + account?: { + name: string + } - account?: { - name: string + embedPath?: string } - embedPath?: string + videos?: { id: number, uuid: string }[] } - remoteVideo?: { - id: number - uuid: string - } + accessToken?: string + refreshToken?: string - videos?: { id: number, uuid: string }[] - - bulkCommand?: BulkCommand - cliCommand?: CLICommand - customPageCommand?: CustomPagesCommand - feedCommand?: FeedCommand - logsCommand?: LogsCommand - abusesCommand?: AbusesCommand - overviewsCommand?: OverviewsCommand - searchCommand?: SearchCommand - contactFormCommand?: ContactFormCommand - debugCommand?: DebugCommand - followsCommand?: FollowsCommand - jobsCommand?: JobsCommand - pluginsCommand?: PluginsCommand - redundancyCommand?: RedundancyCommand - statsCommand?: StatsCommand - configCommand?: ConfigCommand - socketIOCommand?: SocketIOCommand - accountsCommand?: AccountsCommand - blocklistCommand?: BlocklistCommand - subscriptionsCommand?: SubscriptionsCommand - liveCommand?: LiveCommand - servicesCommand?: ServicesCommand - blacklistCommand?: BlacklistCommand - captionsCommand?: CaptionsCommand - changeOwnershipCommand?: ChangeOwnershipCommand - playlistsCommand?: PlaylistsCommand - historyCommand?: HistoryCommand - importsCommand?: ImportsCommand - streamingPlaylistsCommand?: StreamingPlaylistsCommand - channelsCommand?: ChannelsCommand - commentsCommand?: CommentsCommand - sqlCommand?: SQLCommand - notificationsCommand?: NotificationsCommand - serversCommand?: ServersCommand - loginCommand?: LoginCommand - usersCommand?: UsersCommand - videosCommand?: VideosCommand + bulk?: BulkCommand + cli?: CLICommand + customPage?: CustomPagesCommand + feed?: FeedCommand + logs?: LogsCommand + abuses?: AbusesCommand + overviews?: OverviewsCommand + search?: SearchCommand + contactForm?: ContactFormCommand + debug?: DebugCommand + follows?: FollowsCommand + jobs?: JobsCommand + plugins?: PluginsCommand + redundancy?: RedundancyCommand + stats?: StatsCommand + config?: ConfigCommand + socketIO?: SocketIOCommand + accounts?: AccountsCommand + blocklist?: BlocklistCommand + subscriptions?: SubscriptionsCommand + live?: LiveCommand + services?: ServicesCommand + blacklist?: BlacklistCommand + captions?: CaptionsCommand + changeOwnership?: ChangeOwnershipCommand + playlists?: PlaylistsCommand + history?: HistoryCommand + imports?: ImportsCommand + streamingPlaylists?: StreamingPlaylistsCommand + channels?: ChannelsCommand + comments?: CommentsCommand + sql?: SQLCommand + notifications?: NotificationsCommand + servers?: ServersCommand + login?: LoginCommand + users?: UsersCommand + videos?: VideosCommand } function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { @@ -189,13 +187,15 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object, url: `http://localhost:${port}`, host: `localhost:${port}`, hostname: 'localhost', - client: { - id: null, - secret: null - }, - user: { - username: null, - password: null + store: { + client: { + id: null, + secret: null + }, + user: { + username: null, + password: null + } } } @@ -291,10 +291,10 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] const regexp = regexps[key] const matches = data.toString().match(regexp) if (matches !== null) { - if (key === 'client_id') server.client.id = matches[1] - else if (key === 'client_secret') server.client.secret = matches[1] - else if (key === 'user_username') server.user.username = matches[1] - else if (key === 'user_password') server.user.password = matches[1] + if (key === 'client_id') server.store.client.id = matches[1] + else if (key === 'client_secret') server.store.client.secret = matches[1] + else if (key === 'user_username') server.store.user.username = matches[1] + else if (key === 'user_password') server.store.user.password = matches[1] } } @@ -327,43 +327,43 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] } function assignCommands (server: ServerInfo) { - server.bulkCommand = new BulkCommand(server) - server.cliCommand = new CLICommand(server) - server.customPageCommand = new CustomPagesCommand(server) - server.feedCommand = new FeedCommand(server) - server.logsCommand = new LogsCommand(server) - server.abusesCommand = new AbusesCommand(server) - server.overviewsCommand = new OverviewsCommand(server) - server.searchCommand = new SearchCommand(server) - server.contactFormCommand = new ContactFormCommand(server) - server.debugCommand = new DebugCommand(server) - server.followsCommand = new FollowsCommand(server) - server.jobsCommand = new JobsCommand(server) - server.pluginsCommand = new PluginsCommand(server) - server.redundancyCommand = new RedundancyCommand(server) - server.statsCommand = new StatsCommand(server) - server.configCommand = new ConfigCommand(server) - server.socketIOCommand = new SocketIOCommand(server) - server.accountsCommand = new AccountsCommand(server) - server.blocklistCommand = new BlocklistCommand(server) - server.subscriptionsCommand = new SubscriptionsCommand(server) - server.liveCommand = new LiveCommand(server) - server.servicesCommand = new ServicesCommand(server) - server.blacklistCommand = new BlacklistCommand(server) - server.captionsCommand = new CaptionsCommand(server) - server.changeOwnershipCommand = new ChangeOwnershipCommand(server) - server.playlistsCommand = new PlaylistsCommand(server) - server.historyCommand = new HistoryCommand(server) - server.importsCommand = new ImportsCommand(server) - server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server) - server.channelsCommand = new ChannelsCommand(server) - server.commentsCommand = new CommentsCommand(server) - server.sqlCommand = new SQLCommand(server) - server.notificationsCommand = new NotificationsCommand(server) - server.serversCommand = new ServersCommand(server) - server.loginCommand = new LoginCommand(server) - server.usersCommand = new UsersCommand(server) - server.videosCommand = new VideosCommand(server) + server.bulk = new BulkCommand(server) + server.cli = new CLICommand(server) + server.customPage = new CustomPagesCommand(server) + server.feed = new FeedCommand(server) + server.logs = new LogsCommand(server) + server.abuses = new AbusesCommand(server) + server.overviews = new OverviewsCommand(server) + server.search = new SearchCommand(server) + server.contactForm = new ContactFormCommand(server) + server.debug = new DebugCommand(server) + server.follows = new FollowsCommand(server) + server.jobs = new JobsCommand(server) + server.plugins = new PluginsCommand(server) + server.redundancy = new RedundancyCommand(server) + server.stats = new StatsCommand(server) + server.config = new ConfigCommand(server) + server.socketIO = new SocketIOCommand(server) + server.accounts = new AccountsCommand(server) + server.blocklist = new BlocklistCommand(server) + server.subscriptions = new SubscriptionsCommand(server) + server.live = new LiveCommand(server) + server.services = new ServicesCommand(server) + server.blacklist = new BlacklistCommand(server) + server.captions = new CaptionsCommand(server) + server.changeOwnership = new ChangeOwnershipCommand(server) + server.playlists = new PlaylistsCommand(server) + server.history = new HistoryCommand(server) + server.imports = new ImportsCommand(server) + server.streamingPlaylists = new StreamingPlaylistsCommand(server) + server.channels = new ChannelsCommand(server) + server.comments = new CommentsCommand(server) + server.sql = new SQLCommand(server) + server.notifications = new NotificationsCommand(server) + server.servers = new ServersCommand(server) + server.login = new LoginCommand(server) + server.users = new UsersCommand(server) + server.videos = new VideosCommand(server) } async function reRunServer (server: ServerInfo, configOverride?: any) { @@ -377,7 +377,7 @@ async function killallServers (servers: ServerInfo[]) { for (const server of servers) { if (!server.app) continue - await server.sqlCommand.cleanup() + await server.sql.cleanup() process.kill(-server.app.pid) @@ -394,7 +394,7 @@ async function cleanupTests (servers: ServerInfo[]) { let p: Promise[] = [] for (const server of servers) { - p = p.concat(server.serversCommand.cleanupTests()) + p = p.concat(server.servers.cleanupTests()) } return Promise.all(p) diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index ee94351e8..2c9a4b71c 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts @@ -14,7 +14,7 @@ async function expectAccountFollows (options: { }) { const { server, handle, followers, following } = options - const body = await server.accountsCommand.list() + const body = await server.accounts.list() const account = body.data.find(a => a.name + '@' + a.host === handle) const message = `${handle} on ${server.url}` diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index b4e3bb602..10c3db851 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts @@ -9,7 +9,7 @@ export class LoginCommand extends AbstractCommand { client?: { id?: string, secret?: string } user?: { username: string, password?: string } } = {}) { - const { client = this.server.client, user = this.server.user } = options + const { client = this.server.store.client, user = this.server.store.user } = options const path = '/api/v1/users/token' const body = { @@ -38,7 +38,7 @@ export class LoginCommand extends AbstractCommand { async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) { let user: { username: string, password?: string } - if (!arg1) user = this.server.user + if (!arg1) user = this.server.store.user else if (typeof arg1 === 'object') user = arg1 else user = { username: arg1, password } @@ -59,8 +59,8 @@ export class LoginCommand extends AbstractCommand { const path = '/api/v1/users/token' const body = { - client_id: this.server.client.id, - client_secret: this.server.client.secret, + client_id: this.server.store.client.id, + client_secret: this.server.store.client.secret, username: username, response_type: 'code', grant_type: 'password', @@ -100,8 +100,8 @@ export class LoginCommand extends AbstractCommand { const path = '/api/v1/users/token' const body = { - client_id: this.server.client.id, - client_secret: this.server.client.secret, + client_id: this.server.store.client.id, + client_secret: this.server.store.client.secret, refresh_token: options.refreshToken, response_type: 'code', grant_type: 'refresh_token' diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts index d4ee8e517..d0c26a4f0 100644 --- a/shared/extra-utils/users/login.ts +++ b/shared/extra-utils/users/login.ts @@ -4,7 +4,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) { const tasks: Promise[] = [] for (const server of servers) { - const p = server.loginCommand.getAccessToken() + const p = server.login.getAccessToken() .then(t => { server.accessToken = t }) tasks.push(p) } diff --git a/shared/extra-utils/users/notifications.ts b/shared/extra-utils/users/notifications.ts index 0af7d8a18..9196f0bf5 100644 --- a/shared/extra-utils/users/notifications.ts +++ b/shared/extra-utils/users/notifications.ts @@ -49,7 +49,7 @@ async function checkNotification ( const check = base.check || { web: true, mail: true } if (check.web) { - const notification = await base.server.notificationsCommand.getLastest({ token: base.token }) + const notification = await base.server.notifications.getLastest({ token: base.token }) if (notification || checkType !== 'absence') { notificationChecker(notification, checkType) @@ -651,31 +651,31 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an } const user = { username: 'user_1', password: 'super password' } - await servers[0].usersCommand.create({ ...user, videoQuota: 10 * 1000 * 1000 }) - const userAccessToken = await servers[0].loginCommand.getAccessToken(user) + await servers[0].users.create({ ...user, videoQuota: 10 * 1000 * 1000 }) + const userAccessToken = await servers[0].login.getAccessToken(user) - await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) - await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() }) + await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) + await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) if (serversCount > 1) { - await servers[1].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() }) + await servers[1].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) } { - const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken }) + const socket = servers[0].socketIO.getUserNotificationSocket({ token: userAccessToken }) socket.on('new-notification', n => userNotifications.push(n)) } { - const socket = servers[0].socketIOCommand.getUserNotificationSocket() + const socket = servers[0].socketIO.getUserNotificationSocket() socket.on('new-notification', n => adminNotifications.push(n)) } if (serversCount > 1) { - const socket = servers[1].socketIOCommand.getUserNotificationSocket() + const socket = servers[1].socketIO.getUserNotificationSocket() socket.on('new-notification', n => adminNotificationsServer2.push(n)) } - const { videoChannels } = await servers[0].usersCommand.getMyInfo() + const { videoChannels } = await servers[0].users.getMyInfo() const channelId = videoChannels[0].id return { diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index 202528b8d..59dc6d018 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts @@ -194,7 +194,7 @@ export class UsersCommand extends AbstractCommand { const password = 'password' const user = await this.create({ username, password }) - const token = await this.server.loginCommand.getAccessToken({ username, password }) + const token = await this.server.login.getAccessToken({ username, password }) const me = await this.getMyInfo({ token }) @@ -209,7 +209,7 @@ export class UsersCommand extends AbstractCommand { const password = 'password' await this.create({ username, password }) - return this.server.loginCommand.getAccessToken({ username, password }) + return this.server.login.getAccessToken({ username, password }) } register (options: OverrideCommandOptions & { diff --git a/shared/extra-utils/videos/channels.ts b/shared/extra-utils/videos/channels.ts index 9e7ec565d..81e818094 100644 --- a/shared/extra-utils/videos/channels.ts +++ b/shared/extra-utils/videos/channels.ts @@ -4,8 +4,8 @@ function setDefaultVideoChannel (servers: ServerInfo[]) { const tasks: Promise[] = [] for (const server of servers) { - const p = server.usersCommand.getMyInfo() - .then(user => { server.videoChannel = user.videoChannels[0] }) + const p = server.users.getMyInfo() + .then(user => { server.store.channel = user.videoChannels[0] }) tasks.push(p) } diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index 5adf601cc..fd66c9924 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts @@ -114,7 +114,7 @@ export class LiveCommand extends AbstractCommand { const { resolution, segment, videoUUID } = options const segmentName = `${resolution}-00000${segment}.ts` - return this.server.serversCommand.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false) + return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false) } async waitUntilSaved (options: OverrideCommandOptions & { @@ -123,7 +123,7 @@ export class LiveCommand extends AbstractCommand { let video: VideoDetails do { - video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId }) + video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId }) await wait(500) } while (video.isLive === true && video.state.id !== VideoState.PUBLISHED) @@ -132,7 +132,7 @@ export class LiveCommand extends AbstractCommand { async countPlaylists (options: OverrideCommandOptions & { videoUUID: string }) { - const basePath = this.server.serversCommand.buildDirectory('streaming-playlists') + const basePath = this.server.servers.buildDirectory('streaming-playlists') const hlsPath = join(basePath, 'hls', options.videoUUID) const files = await readdir(hlsPath) @@ -147,7 +147,7 @@ export class LiveCommand extends AbstractCommand { let video: VideoDetails do { - video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId }) + video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId }) await wait(500) } while (video.state.id !== options.state) diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts index 0efcc2883..353595811 100644 --- a/shared/extra-utils/videos/live.ts +++ b/shared/extra-utils/videos/live.ts @@ -72,12 +72,12 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) { async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoId: string) { for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId }) + await server.live.waitUntilPublished({ videoId }) } } async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { - const basePath = server.serversCommand.buildDirectory('streaming-playlists') + const basePath = server.servers.buildDirectory('streaming-playlists') const hlsPath = join(basePath, 'hls', videoUUID) if (resolutions.length === 0) { diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts index 75c8f2433..cbfc7e10f 100644 --- a/shared/extra-utils/videos/playlists-command.ts +++ b/shared/extra-utils/videos/playlists-command.ts @@ -184,7 +184,7 @@ export class PlaylistsCommand extends AbstractCommand { const attributes = { ...options.attributes, - videoId: await this.server.videosCommand.getId({ ...options, uuid: options.attributes.videoId }) + videoId: await this.server.videos.getId({ ...options, uuid: options.attributes.videoId }) } const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index 0324c739a..e8fd2f232 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts @@ -13,7 +13,7 @@ async function checkSegmentHash (options: { hlsPlaylist: VideoStreamingPlaylist }) { const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options - const command = server.streamingPlaylistsCommand + const command = server.streamingPlaylists const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8` }) @@ -43,7 +43,7 @@ async function checkLiveSegmentHash (options: { hlsPlaylist: VideoStreamingPlaylist }) { const { server, baseUrlSegment, videoUUID, segmentName, hlsPlaylist } = options - const command = server.streamingPlaylistsCommand + const command = server.streamingPlaylists const segmentBody = await command.getSegment({ url: `${baseUrlSegment}/${videoUUID}/${segmentName}` }) const shaBody = await command.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url }) @@ -58,7 +58,7 @@ async function checkResolutionsInMasterPlaylist (options: { }) { const { server, playlistUrl, resolutions } = options - const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: playlistUrl }) + const masterPlaylist = await server.streamingPlaylists.get({ url: playlistUrl }) for (const resolution of resolutions) { const reg = new RegExp( diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index 574705474..5556cddf6 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts @@ -336,7 +336,7 @@ export class VideosCommand extends AbstractCommand { let defaultChannelId = 1 try { - const { videoChannels } = await this.server.usersCommand.getMyInfo({ token: options.token }) + const { videoChannels } = await this.server.users.getMyInfo({ token: options.token }) defaultChannelId = videoChannels[0].id } catch (e) { /* empty */ } diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 19f0df8b8..86f49384d 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts @@ -27,7 +27,7 @@ async function checkVideoFilesWereRemoved ( ] ) { for (const directory of directories) { - const directoryPath = server.serversCommand.buildDirectory(directory) + const directoryPath = server.servers.buildDirectory(directory) const directoryExists = await pathExists(directoryPath) if (directoryExists === false) continue @@ -47,8 +47,8 @@ function checkUploadVideoParam ( mode: 'legacy' | 'resumable' = 'legacy' ) { return mode === 'legacy' - ? server.videosCommand.buildLegacyUpload({ token, attributes, expectedStatus }) - : server.videosCommand.buildResumeUpload({ token, attributes, expectedStatus }) + ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus }) + : server.videos.buildResumeUpload({ token, attributes, expectedStatus }) } async function completeVideoCheck ( @@ -131,7 +131,7 @@ async function completeVideoCheck ( expect(video.originallyPublishedAt).to.be.null } - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(attributes.files.length) expect(videoDetails.tags).to.deep.equal(attributes.tags) @@ -202,7 +202,7 @@ async function uploadRandomVideoOnServers ( additionalParams?: VideoEdit & { prefixName?: string } ) { const server = servers.find(s => s.serverNumber === serverNumber) - const res = await server.videosCommand.randomUpload({ wait: false, ...additionalParams }) + const res = await server.videos.randomUpload({ wait: false, ...additionalParams }) await waitJobs(servers) -- cgit v1.2.3