From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- shared/extra-utils/custom-pages/custom-pages-command.ts | 3 +-- shared/extra-utils/miscs/generate.ts | 2 +- shared/extra-utils/moderation/abuses-command.ts | 4 ++-- shared/extra-utils/overviews/overviews-command.ts | 3 +-- shared/extra-utils/requests/activitypub.ts | 2 +- shared/extra-utils/search/search-command.ts | 2 +- shared/extra-utils/server/config-command.ts | 2 +- shared/extra-utils/server/debug-command.ts | 3 +-- shared/extra-utils/server/follows-command.ts | 3 +-- shared/extra-utils/server/plugins-command.ts | 2 +- shared/extra-utils/server/redundancy-command.ts | 3 +-- shared/extra-utils/server/stats-command.ts | 3 +-- shared/extra-utils/users/accounts-command.ts | 3 +-- shared/extra-utils/users/blocklist-command.ts | 3 +-- shared/extra-utils/users/login-command.ts | 3 +-- shared/extra-utils/users/notifications-command.ts | 3 +-- shared/extra-utils/users/subscriptions-command.ts | 3 +-- shared/extra-utils/users/users-command.ts | 2 +- shared/extra-utils/videos/blacklist-command.ts | 3 +-- shared/extra-utils/videos/captions-command.ts | 3 +-- shared/extra-utils/videos/change-ownership-command.ts | 3 +-- shared/extra-utils/videos/channels-command.ts | 3 +-- shared/extra-utils/videos/comments-command.ts | 3 +-- shared/extra-utils/videos/history-command.ts | 3 +-- shared/extra-utils/videos/imports-command.ts | 3 +-- shared/extra-utils/videos/live-command.ts | 3 +-- shared/extra-utils/videos/playlists-command.ts | 2 +- shared/extra-utils/videos/streaming-playlists.ts | 3 +-- shared/extra-utils/videos/videos-command.ts | 15 ++++++++------- shared/extra-utils/videos/videos.ts | 2 +- 30 files changed, 38 insertions(+), 57 deletions(-) (limited to 'shared') diff --git a/shared/extra-utils/custom-pages/custom-pages-command.ts b/shared/extra-utils/custom-pages/custom-pages-command.ts index 6042233d4..cd869a8de 100644 --- a/shared/extra-utils/custom-pages/custom-pages-command.ts +++ b/shared/extra-utils/custom-pages/custom-pages-command.ts @@ -1,5 +1,4 @@ -import { CustomPage } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { CustomPage, HttpStatusCode } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class CustomPagesCommand extends AbstractCommand { diff --git a/shared/extra-utils/miscs/generate.ts b/shared/extra-utils/miscs/generate.ts index 4e70ab853..8d6435481 100644 --- a/shared/extra-utils/miscs/generate.ts +++ b/shared/extra-utils/miscs/generate.ts @@ -1,7 +1,7 @@ +import * as ffmpeg from 'fluent-ffmpeg' import { ensureDir, pathExists } from 'fs-extra' import { dirname } from 'path' import { buildAbsoluteFixturePath } from './tests' -import * as ffmpeg from 'fluent-ffmpeg' async function generateHighBitrateVideo () { const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts index 72f2c9951..7b3abb056 100644 --- a/shared/extra-utils/moderation/abuses-command.ts +++ b/shared/extra-utils/moderation/abuses-command.ts @@ -7,12 +7,12 @@ import { AbuseUpdate, AbuseVideoIs, AdminAbuse, + HttpStatusCode, ResultList, UserAbuse } from '@shared/models' -import { HttpStatusCode } from '@shared/models' -import { AbstractCommand, OverrideCommandOptions } from '../shared' import { unwrapBody } from '../requests/requests' +import { AbstractCommand, OverrideCommandOptions } from '../shared' export class AbusesCommand extends AbstractCommand { diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts index d4a2ac254..06b4892d2 100644 --- a/shared/extra-utils/overviews/overviews-command.ts +++ b/shared/extra-utils/overviews/overviews-command.ts @@ -1,5 +1,4 @@ -import { HttpStatusCode } from '@shared/models' -import { VideosOverview } from '@shared/models' +import { HttpStatusCode, VideosOverview } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class OverviewsCommand extends AbstractCommand { diff --git a/shared/extra-utils/requests/activitypub.ts b/shared/extra-utils/requests/activitypub.ts index ecd8ce823..4ae878384 100644 --- a/shared/extra-utils/requests/activitypub.ts +++ b/shared/extra-utils/requests/activitypub.ts @@ -1,7 +1,7 @@ +import { activityPubContextify } from '../../../server/helpers/activitypub' import { doRequest } from '../../../server/helpers/requests' import { HTTP_SIGNATURE } from '../../../server/initializers/constants' import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils' -import { activityPubContextify } from '../../../server/helpers/activitypub' function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { const options = { diff --git a/shared/extra-utils/search/search-command.ts b/shared/extra-utils/search/search-command.ts index 09f5d3f1d..0fbbcd6ef 100644 --- a/shared/extra-utils/search/search-command.ts +++ b/shared/extra-utils/search/search-command.ts @@ -1,4 +1,5 @@ import { + HttpStatusCode, ResultList, Video, VideoChannel, @@ -7,7 +8,6 @@ import { VideoPlaylistsSearchQuery, VideosSearchQuery } from '@shared/models' -import { HttpStatusCode } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class SearchCommand extends AbstractCommand { diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts index 6e875fdf6..11148aa46 100644 --- a/shared/extra-utils/server/config-command.ts +++ b/shared/extra-utils/server/config-command.ts @@ -1,6 +1,6 @@ import { merge } from 'lodash' import { DeepPartial } from '@shared/core-utils' -import { About, ServerConfig, HttpStatusCode } from '@shared/models' +import { About, HttpStatusCode, ServerConfig } from '@shared/models' import { CustomConfig } from '../../models/server/custom-config.model' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts index 36704836d..3c5a785bb 100644 --- a/shared/extra-utils/server/debug-command.ts +++ b/shared/extra-utils/server/debug-command.ts @@ -1,5 +1,4 @@ -import { Debug, SendDebugCommand } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { Debug, HttpStatusCode, SendDebugCommand } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class DebugCommand extends AbstractCommand { diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts index 694f5ea24..dce674ac5 100644 --- a/shared/extra-utils/server/follows-command.ts +++ b/shared/extra-utils/server/follows-command.ts @@ -1,6 +1,5 @@ import { pick } from 'lodash' -import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { ActivityPubActorType, ActorFollow, FollowState, HttpStatusCode, ResultList } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' import { PeerTubeServer } from './server' diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts index 59bc79b3d..b944475a2 100644 --- a/shared/extra-utils/server/plugins-command.ts +++ b/shared/extra-utils/server/plugins-command.ts @@ -3,8 +3,8 @@ import { readJSON, writeJSON } from 'fs-extra' import { join } from 'path' import { root } from '@server/helpers/core-utils' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, PeerTubePlugin, PeerTubePluginIndex, PeertubePluginIndexList, diff --git a/shared/extra-utils/server/redundancy-command.ts b/shared/extra-utils/server/redundancy-command.ts index 137d7f01c..e7a8b3c29 100644 --- a/shared/extra-utils/server/redundancy-command.ts +++ b/shared/extra-utils/server/redundancy-command.ts @@ -1,5 +1,4 @@ -import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class RedundancyCommand extends AbstractCommand { diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts index 6db473588..64a452306 100644 --- a/shared/extra-utils/server/stats-command.ts +++ b/shared/extra-utils/server/stats-command.ts @@ -1,5 +1,4 @@ -import { ServerStats } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ServerStats } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class StatsCommand extends AbstractCommand { diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts index 08977e58b..2f586104e 100644 --- a/shared/extra-utils/users/accounts-command.ts +++ b/shared/extra-utils/users/accounts-command.ts @@ -1,5 +1,4 @@ -import { ResultList } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { Account } from '../../models/actors' import { AccountVideoRate, VideoRateType } from '../../models/videos' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts index a9431acf3..14491a1ae 100644 --- a/shared/extra-utils/users/blocklist-command.ts +++ b/shared/extra-utils/users/blocklist-command.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { HttpStatusCode } from '@shared/models' -import { AccountBlock, ResultList, ServerBlock } from '@shared/models' +import { AccountBlock, HttpStatusCode, ResultList, ServerBlock } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' type ListBlocklistOptions = OverrideCommandOptions & { diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index b39577260..143f72a59 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts @@ -1,5 +1,4 @@ -import { HttpStatusCode } from '@shared/models' -import { PeerTubeProblemDocument } from '@shared/models' +import { HttpStatusCode, PeerTubeProblemDocument } from '@shared/models' import { unwrapBody } from '../requests' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/users/notifications-command.ts b/shared/extra-utils/users/notifications-command.ts index a51fcc3af..2d79a3747 100644 --- a/shared/extra-utils/users/notifications-command.ts +++ b/shared/extra-utils/users/notifications-command.ts @@ -1,5 +1,4 @@ -import { ResultList } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { UserNotification, UserNotificationSetting } from '../../models/users' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts index a69d2a194..edc60e612 100644 --- a/shared/extra-utils/users/subscriptions-command.ts +++ b/shared/extra-utils/users/subscriptions-command.ts @@ -1,5 +1,4 @@ -import { ResultList, Video, VideoChannel } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, Video, VideoChannel } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class SubscriptionsCommand extends AbstractCommand { diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index f3a251e65..d66ad15f2 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts @@ -1,6 +1,6 @@ import { omit, pick } from 'lodash' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, MyUser, ResultList, User, diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts index 9404d4c08..3a2ef89ba 100644 --- a/shared/extra-utils/videos/blacklist-command.ts +++ b/shared/extra-utils/videos/blacklist-command.ts @@ -1,6 +1,5 @@ -import { ResultList } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts index 04dd32f84..a0608e1a6 100644 --- a/shared/extra-utils/videos/captions-command.ts +++ b/shared/extra-utils/videos/captions-command.ts @@ -1,5 +1,4 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoCaption } from '@shared/models' +import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models' import { buildAbsoluteFixturePath } from '../miscs' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/videos/change-ownership-command.ts b/shared/extra-utils/videos/change-ownership-command.ts index ef6f07536..ad4c726ef 100644 --- a/shared/extra-utils/videos/change-ownership-command.ts +++ b/shared/extra-utils/videos/change-ownership-command.ts @@ -1,6 +1,5 @@ -import { ResultList, VideoChangeOwnership } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class ChangeOwnershipCommand extends AbstractCommand { diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts index e5393ff56..f8eb3f885 100644 --- a/shared/extra-utils/videos/channels-command.ts +++ b/shared/extra-utils/videos/channels-command.ts @@ -1,6 +1,5 @@ import { pick } from 'lodash' -import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' import { unwrapBody } from '../requests' diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts index 7368f3ea2..dd14e4b64 100644 --- a/shared/extra-utils/videos/comments-command.ts +++ b/shared/extra-utils/videos/comments-command.ts @@ -1,6 +1,5 @@ import { pick } from 'lodash' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' +import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' import { unwrapBody } from '../requests' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts index 41afc6bc6..13b7150c1 100644 --- a/shared/extra-utils/videos/history-command.ts +++ b/shared/extra-utils/videos/history-command.ts @@ -1,5 +1,4 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList, Video } from '@shared/models' +import { HttpStatusCode, ResultList, Video } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export class HistoryCommand extends AbstractCommand { diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts index d30f9745b..e4944694d 100644 --- a/shared/extra-utils/videos/imports-command.ts +++ b/shared/extra-utils/videos/imports-command.ts @@ -1,6 +1,5 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { VideoImport, VideoImportCreate } from '../../models/videos' import { unwrapBody } from '../requests' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index 9dfe3087e..bf9486a05 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts @@ -3,8 +3,7 @@ import { readdir } from 'fs-extra' import { omit } from 'lodash' import { join } from 'path' -import { HttpStatusCode } from '@shared/models' -import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' +import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' import { wait } from '../miscs' import { unwrapBody } from '../requests' import { AbstractCommand, OverrideCommandOptions } from '../shared' diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts index 40162c30d..6f329800e 100644 --- a/shared/extra-utils/videos/playlists-command.ts +++ b/shared/extra-utils/videos/playlists-command.ts @@ -1,7 +1,7 @@ import { omit, pick } from 'lodash' -import { HttpStatusCode } from '@shared/models' import { BooleanBothQuery, + HttpStatusCode, ResultList, VideoExistInPlaylist, VideoPlaylist, diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index 007d3d98d..1ae3fefc1 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts @@ -1,7 +1,6 @@ import { expect } from 'chai' import { sha256 } from '@server/helpers/core-utils' -import { HttpStatusCode } from '@shared/models' -import { VideoStreamingPlaylist } from '@shared/models' +import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models' import { PeerTubeServer } from '../server' async function checkSegmentHash (options: { diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index f46d386f4..40cc4dc28 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts @@ -7,8 +7,8 @@ import { omit, pick } from 'lodash' import validator from 'validator' import { buildUUID } from '@server/helpers/uuid' import { loadLanguages } from '@server/initializers/constants' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, ResultList, UserVideoRateType, Video, @@ -332,7 +332,7 @@ export class VideosCommand extends AbstractCommand { attributes?: VideoEdit mode?: 'legacy' | 'resumable' // default legacy } = {}) { - const { mode = 'legacy', expectedStatus } = options + const { mode = 'legacy' } = options let defaultChannelId = 1 try { @@ -360,22 +360,23 @@ export class VideosCommand extends AbstractCommand { ...options.attributes } - const res = mode === 'legacy' + const created = mode === 'legacy' ? await this.buildLegacyUpload({ ...options, attributes }) : await this.buildResumeUpload({ ...options, attributes }) // Wait torrent generation + const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 }) if (expectedStatus === HttpStatusCode.OK_200) { let video: VideoDetails do { - video = await this.getWithToken({ ...options, id: video.uuid }) + video = await this.getWithToken({ ...options, id: created.uuid }) await wait(50) } while (!video.files[0].torrentUrl) } - return res + return created } async buildLegacyUpload (options: OverrideCommandOptions & { @@ -535,13 +536,13 @@ export class VideosCommand extends AbstractCommand { async randomUpload (options: OverrideCommandOptions & { wait?: boolean // default true - additionalParams?: VideoEdit & { prefixName: string } + additionalParams?: VideoEdit & { prefixName?: string } } = {}) { const { wait = true, additionalParams } = options const prefixName = additionalParams?.prefixName || '' const name = prefixName + buildUUID() - const attributes = { name, additionalParams } + const attributes = { name, ...additionalParams } const result = await this.upload({ ...options, attributes }) diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index a96073c56..9a9bfb3cf 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts @@ -202,7 +202,7 @@ async function uploadRandomVideoOnServers ( additionalParams?: VideoEdit & { prefixName?: string } ) { const server = servers.find(s => s.serverNumber === serverNumber) - const res = await server.videos.randomUpload({ wait: false, ...additionalParams }) + const res = await server.videos.randomUpload({ wait: false, additionalParams }) await waitJobs(servers) -- cgit v1.2.3