diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
index dfbbfbb29..fd4d3d9c9 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
@@ -87,15 +87,19 @@
Signup
-
+
+
+
-
+
+
+
-
+
+
+
@@ -199,11 +209,13 @@
Transcoding
-
+
+
+
@@ -226,7 +238,6 @@
[inputName]="getResolutionKey(resolution)" [formControlName]="getResolutionKey(resolution)"
i18n-labelText labelText="Resolution {{resolution}} enabled"
>
-
diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html
index 8be8a66cc..049119fa8 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html
+++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html
@@ -15,15 +15,19 @@
-
+
+
+
-
+
+
+
diff --git a/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts b/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts
index 26b3bf4b1..e4a5522c8 100644
--- a/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts
+++ b/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts
@@ -25,7 +25,6 @@ export class VerifyAccountEmailComponent implements OnInit {
}
ngOnInit () {
-
this.userId = this.route.snapshot.queryParams['userId']
this.verificationString = this.route.snapshot.queryParams['verificationString']
diff --git a/scripts/travis.sh b/scripts/travis.sh
index 49b7233e1..509b40d87 100755
--- a/scripts/travis.sh
+++ b/scripts/travis.sh
@@ -11,28 +11,25 @@ killall -q peertube || true
if [ "$1" = "misc" ]; then
npm run build -- --light-fr
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts \
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/client.ts \
server/tests/feeds/index.ts \
server/tests/misc-endpoints.ts \
server/tests/helpers/index.ts
-elif [ "$1" = "api" ]; then
- npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts
elif [ "$1" = "cli" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/cli/index.ts
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts
elif [ "$1" = "api-1" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-1.ts
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-1.ts
elif [ "$1" = "api-2" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-2.ts
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts
elif [ "$1" = "api-3" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-3.ts
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts
elif [ "$1" = "api-4" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-4.ts
+ mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts
elif [ "$1" = "lint" ]; then
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
diff --git a/server.ts b/server.ts
index f3514cf9c..3025a6fd7 100644
--- a/server.ts
+++ b/server.ts
@@ -204,9 +204,11 @@ async function startApplication () {
// Email initialization
Emailer.Instance.init()
- await Emailer.Instance.checkConnectionOrDie()
- await JobQueue.Instance.init()
+ await Promise.all([
+ Emailer.Instance.checkConnectionOrDie(),
+ JobQueue.Instance.init()
+ ])
// Caches initializations
VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE, CACHE.PREVIEWS.MAX_AGE)
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts
index bcbd9be59..79b76fa0b 100644
--- a/server/helpers/activitypub.ts
+++ b/server/helpers/activitypub.ts
@@ -1,7 +1,7 @@
import * as Bluebird from 'bluebird'
import * as validator from 'validator'
import { ResultList } from '../../shared/models'
-import { Activity, ActivityPubActor } from '../../shared/models/activitypub'
+import { Activity } from '../../shared/models/activitypub'
import { ACTIVITY_PUB } from '../initializers'
import { ActorModel } from '../models/activitypub/actor'
import { signJsonLDObject } from './peertube-crypto'
@@ -106,10 +106,10 @@ function buildSignedActivity (byActor: ActorModel, data: Object) {
return signJsonLDObject(byActor, activity) as Promise
}
-function getActorUrl (activityActor: string | ActivityPubActor) {
- if (typeof activityActor === 'string') return activityActor
+function getAPUrl (activity: string | { id: string }) {
+ if (typeof activity === 'string') return activity
- return activityActor.id
+ return activity.id
}
function checkUrlsSameHost (url1: string, url2: string) {
@@ -123,7 +123,7 @@ function checkUrlsSameHost (url1: string, url2: string) {
export {
checkUrlsSameHost,
- getActorUrl,
+ getAPUrl,
activityPubContextify,
activityPubCollectionPagination,
buildSignedActivity
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 8b9045038..b59e7e40e 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -1,7 +1,7 @@
import * as ffmpeg from 'fluent-ffmpeg'
import { join } from 'path'
import { getTargetBitrate, VideoResolution } from '../../shared/models/videos'
-import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers'
+import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
import { processImage } from './image-utils'
import { logger } from './logger'
import { checkFFmpegEncoders } from '../initializers/checker-before-init'
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index 3eaa674ed..da3285b13 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -1,13 +1,28 @@
import 'multer'
import * as sharp from 'sharp'
-import { remove } from 'fs-extra'
+import { move, remove } from 'fs-extra'
async function processImage (
physicalFile: { path: string },
destination: string,
newSize: { width: number, height: number }
) {
- await sharp(physicalFile.path)
+ if (physicalFile.path === destination) {
+ throw new Error('Sharp needs an input path different that the output path.')
+ }
+
+ const sharpInstance = sharp(physicalFile.path)
+ const metadata = await sharpInstance.metadata()
+
+ // No need to resize
+ if (metadata.width === newSize.width && metadata.height === newSize.height) {
+ await move(physicalFile.path, destination, { overwrite: true })
+ return
+ }
+
+ await remove(destination)
+
+ await sharpInstance
.resize(newSize.width, newSize.height)
.toFile(destination)
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index dd5b9bf67..40cd659ab 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -119,25 +119,27 @@ export {
// ---------------------------------------------------------------------------
async function checkPostgresExtensions () {
- const extensions = [
- 'pg_trgm',
- 'unaccent'
+ const promises = [
+ checkPostgresExtension('pg_trgm'),
+ checkPostgresExtension('unaccent')
]
- for (const extension of extensions) {
- const query = `SELECT true AS enabled FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`
- const [ res ] = await sequelizeTypescript.query(query, { raw: true })
+ return Promise.all(promises)
+}
- if (!res || res.length === 0 || res[ 0 ][ 'enabled' ] !== true) {
- // Try to create the extension ourself
- try {
- await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true })
+async function checkPostgresExtension (extension: string) {
+ const query = `SELECT true AS enabled FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`
+ const [ res ] = await sequelizeTypescript.query(query, { raw: true })
- } catch {
- const errorMessage = `You need to enable ${extension} extension in PostgreSQL. ` +
- `You can do so by running 'CREATE EXTENSION ${extension};' as a PostgreSQL super user in ${CONFIG.DATABASE.DBNAME} database.`
- throw new Error(errorMessage)
- }
+ if (!res || res.length === 0 || res[ 0 ][ 'enabled' ] !== true) {
+ // Try to create the extension ourself
+ try {
+ await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true })
+
+ } catch {
+ const errorMessage = `You need to enable ${extension} extension in PostgreSQL. ` +
+ `You can do so by running 'CREATE EXTENSION ${extension};' as a PostgreSQL super user in ${CONFIG.DATABASE.DBNAME} database.`
+ throw new Error(errorMessage)
}
}
}
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index c952ad46c..b9a9da183 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -12,12 +12,21 @@ import { remove, ensureDir } from 'fs-extra'
async function installApplication () {
try {
- await sequelizeTypescript.sync()
- await removeCacheDirectories()
- await createDirectoriesIfNotExist()
- await createApplicationIfNotExist()
- await createOAuthClientIfNotExist()
- await createOAuthAdminIfNotExist()
+ await Promise.all([
+ // Database related
+ sequelizeTypescript.sync()
+ .then(() => {
+ return Promise.all([
+ createApplicationIfNotExist(),
+ createOAuthClientIfNotExist(),
+ createOAuthAdminIfNotExist()
+ ])
+ }),
+
+ // Directories
+ removeCacheDirectories()
+ .then(() => createDirectoriesIfNotExist())
+ ])
} catch (err) {
logger.error('Cannot install application.', { err })
process.exit(-1)
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 218dbc6a7..504263c99 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -5,15 +5,15 @@ import * as url from 'url'
import * as uuidv4 from 'uuid/v4'
import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub'
import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
-import { checkUrlsSameHost, getActorUrl } from '../../helpers/activitypub'
+import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub'
import { isActorObjectValid, normalizeActor } from '../../helpers/custom-validators/activitypub/actor'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { retryTransactionWrapper, updateInstanceWithAnother } from '../../helpers/database-utils'
import { logger } from '../../helpers/logger'
import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
-import { doRequest, doRequestAndSaveToFile, downloadImage } from '../../helpers/requests'
+import { doRequest, downloadImage } from '../../helpers/requests'
import { getUrlFromWebfinger } from '../../helpers/webfinger'
-import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript } from '../../initializers'
+import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers'
import { AccountModel } from '../../models/account/account'
import { ActorModel } from '../../models/activitypub/actor'
import { AvatarModel } from '../../models/avatar/avatar'
@@ -43,7 +43,7 @@ async function getOrCreateActorAndServerAndModel (
recurseIfNeeded = true,
updateCollections = false
) {
- const actorUrl = getActorUrl(activityActor)
+ const actorUrl = getAPUrl(activityActor)
let created = false
let actor = await fetchActorByUrl(actorUrl, fetchType)
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index b9b255ddf..bcc5cac7a 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -1,5 +1,5 @@
import { Activity, ActivityType } from '../../../../shared/models/activitypub'
-import { checkUrlsSameHost, getActorUrl } from '../../../helpers/activitypub'
+import { checkUrlsSameHost, getAPUrl } from '../../../helpers/activitypub'
import { logger } from '../../../helpers/logger'
import { ActorModel } from '../../../models/activitypub/actor'
import { processAcceptActivity } from './process-accept'
@@ -40,7 +40,7 @@ async function processActivities (
continue
}
- const actorUrl = getActorUrl(activity.actor)
+ const actorUrl = getAPUrl(activity.actor)
// When we fetch remote data, we don't have signature
if (options.signatureActor && actorUrl !== options.signatureActor.url) {
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index d2649e2d5..5dcba778c 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -11,7 +11,7 @@ import { doRequest } from '../../helpers/requests'
import { getOrCreateActorAndServerAndModel } from './actor'
import { logger } from '../../helpers/logger'
import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers'
-import { checkUrlsSameHost, getActorUrl } from '../../helpers/activitypub'
+import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub'
async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) {
if (video.privacy === VideoPrivacy.PRIVATE) return undefined
@@ -41,7 +41,7 @@ async function addVideoShares (shareUrls: string[], instance: VideoModel) {
})
if (!body || !body.actor) throw new Error('Body or body actor is invalid')
- const actorUrl = getActorUrl(body.actor)
+ const actorUrl = getAPUrl(body.actor)
if (checkUrlsSameHost(shareUrl, actorUrl) !== true) {
throw new Error(`Actor url ${actorUrl} has not the same host than the share url ${shareUrl}`)
}
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts
index 1854b44c4..2cce67f0c 100644
--- a/server/lib/activitypub/video-rates.ts
+++ b/server/lib/activitypub/video-rates.ts
@@ -9,7 +9,7 @@ import { AccountVideoRateModel } from '../../models/account/account-video-rate'
import { logger } from '../../helpers/logger'
import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers'
import { doRequest } from '../../helpers/requests'
-import { checkUrlsSameHost, getActorUrl } from '../../helpers/activitypub'
+import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub'
import { ActorModel } from '../../models/activitypub/actor'
import { getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from './url'
@@ -26,7 +26,7 @@ async function createRates (ratesUrl: string[], video: VideoModel, rate: VideoRa
})
if (!body || !body.actor) throw new Error('Body or body actor is invalid')
- const actorUrl = getActorUrl(body.actor)
+ const actorUrl = getAPUrl(body.actor)
if (checkUrlsSameHost(actorUrl, rateUrl) !== true) {
throw new Error(`Rate url ${rateUrl} has not the same host than actor url ${actorUrl}`)
}
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 80de92f24..4cecf9345 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -29,7 +29,7 @@ import { createRates } from './video-rates'
import { addVideoShares, shareVideoByServerAndChannel } from './share'
import { AccountModel } from '../../models/account/account'
import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video'
-import { checkUrlsSameHost } from '../../helpers/activitypub'
+import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub'
async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
// If the video is not private and published, we federate it
@@ -167,7 +167,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
const refreshViews = options.refreshViews || false
// Get video url
- const videoUrl = typeof options.videoObject === 'string' ? options.videoObject : options.videoObject.id
+ const videoUrl = getAPUrl(options.videoObject)
let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
if (videoFromDatabase) {
@@ -242,10 +242,6 @@ async function updateVideoFromAP (options: {
if (options.updateViews === true) options.video.set('views', videoData.views)
await options.video.save(sequelizeOptions)
- // Don't block on request
- generateThumbnailFromUrl(options.video, options.videoObject.icon)
- .catch(err => logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err }))
-
{
const videoFileAttributes = videoFileActivityUrlToDBAttributes(options.video, options.videoObject)
const newVideoFiles = videoFileAttributes.map(a => new VideoFileModel(a))
@@ -293,6 +289,12 @@ async function updateVideoFromAP (options: {
logger.debug('Cannot update the remote video.', { err })
throw err
}
+
+ try {
+ await generateThumbnailFromUrl(options.video, options.videoObject.icon)
+ } catch (err) {
+ logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err })
+ }
}
export {
diff --git a/server/lib/user.ts b/server/lib/user.ts
index db29469eb..29d6d087d 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -18,7 +18,7 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse
}
const userCreated = await userToCreate.save(userOptions)
- const accountCreated = await createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t)
+ const accountCreated = await createLocalAccountWithoutKeys(userCreated.username, userCreated.id, null, t)
userCreated.Account = accountCreated
let channelName = userCreated.username + '_channel'
@@ -37,8 +37,13 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse
return { user: userCreated, account: accountCreated, videoChannel }
})
- account.Actor = await setAsyncActorKeys(account.Actor)
- videoChannel.Actor = await setAsyncActorKeys(videoChannel.Actor)
+ const [ accountKeys, channelKeys ] = await Promise.all([
+ setAsyncActorKeys(account.Actor),
+ setAsyncActorKeys(videoChannel.Actor)
+ ])
+
+ account.Actor = accountKeys
+ videoChannel.Actor = channelKeys
return { user, account, videoChannel } as { user: UserModel, account: AccountModel, videoChannel: VideoChannelModel }
}
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 34aafa1a7..1843603f1 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -1,6 +1,6 @@
import * as Sequelize from 'sequelize'
import {
- AfterDelete,
+ AfterDestroy,
AfterUpdate,
AllowNull,
BeforeCreate,
@@ -179,7 +179,7 @@ export class UserModel extends Model {
}
@AfterUpdate
- @AfterDelete
+ @AfterDestroy
static removeTokenCache (instance: UserModel) {
return clearCacheByUserId(instance.id)
}
diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts
index ecf846821..08d892da4 100644
--- a/server/models/oauth/oauth-token.ts
+++ b/server/models/oauth/oauth-token.ts
@@ -1,5 +1,5 @@
import {
- AfterDelete,
+ AfterDestroy,
AfterUpdate,
AllowNull,
BelongsTo,
@@ -126,7 +126,7 @@ export class OAuthTokenModel extends Model {
OAuthClients: OAuthClientModel[]
@AfterUpdate
- @AfterDelete
+ @AfterDestroy
static removeTokenCache (token: OAuthTokenModel) {
return clearCacheByToken(token.accessToken)
}
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index 69b7c0148..b71a61c8c 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -8,15 +8,12 @@ import {
killallServers,
ServerInfo
} from '../../../../shared/utils'
-import {
- makePOSTAPRequest,
- makeFollowRequest,
-} from '../../utils/requests/activitypub'
import { HTTP_SIGNATURE } from '../../../initializers'
import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
import * as chai from 'chai'
import { setActorField } from '../../utils/miscs/sql'
import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
+import { makeFollowRequest, makePOSTAPRequest } from '../../utils/requests/activitypub'
const expect = chai.expect
diff --git a/server/tests/api/users/index.ts b/server/tests/api/users/index.ts
index 0a1b8b0b2..ff433315d 100644
--- a/server/tests/api/users/index.ts
+++ b/server/tests/api/users/index.ts
@@ -1,5 +1,5 @@
import './blocklist'
import './user-subscriptions'
import './users'
-import './users-verification'
import './users-multiple-servers'
+import './users-verification'
diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts
index 06d80a270..61411e30d 100644
--- a/server/tests/api/videos/video-blacklist-management.ts
+++ b/server/tests/api/videos/video-blacklist-management.ts
@@ -1,7 +1,7 @@
/* tslint:disable:no-unused-expression */
import * as chai from 'chai'
-import * as lodash from 'lodash'
+import { orderBy } from 'lodash'
import 'mocha'
import {
addVideoToBlacklist,
@@ -22,7 +22,6 @@ import { waitJobs } from '../../../../shared/utils/server/jobs'
import { VideoAbuse } from '../../../../shared/models/videos'
const expect = chai.expect
-const orderBy = lodash.orderBy
describe('Test video blacklist management', function () {
let servers: ServerInfo[] = []
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 5bffffc66..63514d69c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -7,10 +7,12 @@ import {
createUser,
doubleFollow,
flushAndRunMultipleServers,
- getVideoChannelVideos, serverLogin, testImage,
+ getVideoChannelVideos,
+ testImage,
updateVideo,
updateVideoChannelAvatar,
- uploadVideo, wait, userLogin
+ uploadVideo,
+ userLogin
} from '../../../../shared/utils'
import {
addVideoChannel,
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts
index ecfc5e034..632c4244c 100644
--- a/server/tests/api/videos/video-schedule-update.ts
+++ b/server/tests/api/videos/video-schedule-update.ts
@@ -16,7 +16,6 @@ import {
uploadVideo,
wait
} from '../../../../shared/utils'
-import { join } from 'path'
import { waitJobs } from '../../../../shared/utils/server/jobs'
const expect = chai.expect
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index f9458f0ec..68cf00194 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -3,13 +3,13 @@
import * as chai from 'chai'
import 'mocha'
import { omit } from 'lodash'
-import * as ffmpeg from 'fluent-ffmpeg'
import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import {
buildAbsoluteFixturePath,
doubleFollow,
flushAndRunMultipleServers,
+ generateHighBitrateVideo,
getMyVideos,
getVideo,
getVideosList,
@@ -18,8 +18,7 @@ import {
ServerInfo,
setAccessTokensToServers,
uploadVideo,
- webtorrentAdd,
- generateHighBitrateVideo
+ webtorrentAdd
} from '../../../../shared/utils'
import { join } from 'path'
import { waitJobs } from '../../../../shared/utils/server/jobs'
diff --git a/shared/utils/requests/check-api-params.ts b/shared/utils/requests/check-api-params.ts
index edb47e0e9..a2a549682 100644
--- a/shared/utils/requests/check-api-params.ts
+++ b/shared/utils/requests/check-api-params.ts
@@ -1,5 +1,5 @@
import { makeGetRequest } from './requests'
-import { immutableAssign } from '..'
+import { immutableAssign } from '../miscs/miscs'
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
return makeGetRequest({
diff --git a/shared/utils/search/videos.ts b/shared/utils/search/videos.ts
index 115b3ff9a..ba4627017 100644
--- a/shared/utils/search/videos.ts
+++ b/shared/utils/search/videos.ts
@@ -2,7 +2,7 @@
import * as request from 'supertest'
import { VideosSearchQuery } from '../../models/search'
-import { immutableAssign } from '..'
+import { immutableAssign } from '../miscs/miscs'
function searchVideo (url: string, search: string) {
const path = '/api/v1/search/videos'
diff --git a/shared/utils/server/config.ts b/shared/utils/server/config.ts
index 15a94432b..5b888b061 100644
--- a/shared/utils/server/config.ts
+++ b/shared/utils/server/config.ts
@@ -1,4 +1,4 @@
-import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
+import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
import { CustomConfig } from '../../models/server/custom-config.model'
function getConfig (url: string) {
diff --git a/shared/utils/server/jobs.ts b/shared/utils/server/jobs.ts
index 3eec1d7d7..7c7e89824 100644
--- a/shared/utils/server/jobs.ts
+++ b/shared/utils/server/jobs.ts
@@ -1,6 +1,7 @@
import * as request from 'supertest'
import { Job, JobState } from '../../models'
-import { ServerInfo, wait } from '../index'
+import { wait } from '../miscs/miscs'
+import { ServerInfo } from './servers'
function getJobsList (url: string, accessToken: string, state: JobState) {
const path = '/api/v1/jobs/' + state
diff --git a/shared/utils/server/stats.ts b/shared/utils/server/stats.ts
index 01989d952..6f079ad18 100644
--- a/shared/utils/server/stats.ts
+++ b/shared/utils/server/stats.ts
@@ -1,4 +1,4 @@
-import { makeGetRequest } from '../'
+import { makeGetRequest } from '../requests/requests'
function getStats (url: string, useCache = false) {
const path = '/api/v1/server/stats'
diff --git a/shared/utils/users/accounts.ts b/shared/utils/users/accounts.ts
index 5601f2a77..388eb6973 100644
--- a/shared/utils/users/accounts.ts
+++ b/shared/utils/users/accounts.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
import { existsSync, readdir } from 'fs-extra'
import { join } from 'path'
import { Account } from '../../models/actors'
-import { root } from '../index'
+import { root } from '../miscs/miscs'
import { makeGetRequest } from '../requests/requests'
function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) {
diff --git a/shared/utils/users/blocklist.ts b/shared/utils/users/blocklist.ts
index 35b537571..0ead5e5f6 100644
--- a/shared/utils/users/blocklist.ts
+++ b/shared/utils/users/blocklist.ts
@@ -1,6 +1,6 @@
/* tslint:disable:no-unused-expression */
-import { makeDeleteRequest, makePostBodyRequest } from '../index'
+import { makeDeleteRequest, makePostBodyRequest } from '../requests/requests'
import { makeGetRequest } from '../requests/requests'
function getAccountBlocklistByAccount (
diff --git a/shared/utils/users/user-subscriptions.ts b/shared/utils/users/user-subscriptions.ts
index b0e7da7cc..7148fbfca 100644
--- a/shared/utils/users/user-subscriptions.ts
+++ b/shared/utils/users/user-subscriptions.ts
@@ -1,4 +1,4 @@
-import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../'
+import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../requests/requests'
function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = 204) {
const path = '/api/v1/users/me/subscriptions'
diff --git a/shared/utils/users/users.ts b/shared/utils/users/users.ts
index 1b385aaf7..d5d62a507 100644
--- a/shared/utils/users/users.ts
+++ b/shared/utils/users/users.ts
@@ -1,5 +1,5 @@
import * as request from 'supertest'
-import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../'
+import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
import { UserRole } from '../../index'
import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type'
diff --git a/shared/utils/videos/video-abuses.ts b/shared/utils/videos/video-abuses.ts
index 8be891a9b..7f011ec0f 100644
--- a/shared/utils/videos/video-abuses.ts
+++ b/shared/utils/videos/video-abuses.ts
@@ -1,6 +1,6 @@
import * as request from 'supertest'
import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model'
-import { makeDeleteRequest, makePutBodyRequest } from '..'
+import { makeDeleteRequest, makePutBodyRequest } from '../requests/requests'
function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) {
const path = '/api/v1/videos/' + videoId + '/abuse'
diff --git a/shared/utils/videos/video-captions.ts b/shared/utils/videos/video-captions.ts
index 41e52be07..8d67f617b 100644
--- a/shared/utils/videos/video-captions.ts
+++ b/shared/utils/videos/video-captions.ts
@@ -1,7 +1,7 @@
-import { makeDeleteRequest, makeGetRequest } from '../'
-import { buildAbsoluteFixturePath, makeUploadRequest } from '../index'
+import { makeDeleteRequest, makeGetRequest, makeUploadRequest } from '../requests/requests'
import * as request from 'supertest'
import * as chai from 'chai'
+import { buildAbsoluteFixturePath } from '../miscs/miscs'
const expect = chai.expect
diff --git a/shared/utils/videos/video-channels.ts b/shared/utils/videos/video-channels.ts
index 3d37f0e4c..3935c261e 100644
--- a/shared/utils/videos/video-channels.ts
+++ b/shared/utils/videos/video-channels.ts
@@ -1,6 +1,6 @@
import * as request from 'supertest'
import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos'
-import { updateAvatarRequest } from '../index'
+import { updateAvatarRequest } from '../requests/requests'
function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
const path = '/api/v1/video-channels'
diff --git a/shared/utils/videos/video-comments.ts b/shared/utils/videos/video-comments.ts
index 7d4cae364..0ebf69ced 100644
--- a/shared/utils/videos/video-comments.ts
+++ b/shared/utils/videos/video-comments.ts
@@ -1,5 +1,5 @@
import * as request from 'supertest'
-import { makeDeleteRequest } from '../'
+import { makeDeleteRequest } from '../requests/requests'
function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) {
const path = '/api/v1/videos/' + videoId + '/comment-threads'
diff --git a/shared/utils/videos/video-imports.ts b/shared/utils/videos/video-imports.ts
index bf5062cd1..3fa49b432 100644
--- a/shared/utils/videos/video-imports.ts
+++ b/shared/utils/videos/video-imports.ts
@@ -1,5 +1,6 @@
+
import { VideoImportCreate } from '../../models/videos'
-import { makeGetRequest, makeUploadRequest } from '..'
+import { makeGetRequest, makeUploadRequest } from '../requests/requests'
function getYoutubeVideoUrl () {
return 'https://youtu.be/msX3jv1XdvM'
diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts
index b3206e566..1ab3e7c4b 100644
--- a/shared/utils/videos/videos.ts
+++ b/shared/utils/videos/videos.ts
@@ -16,9 +16,10 @@ import {
ServerInfo,
testImage
} from '../'
+
import { VideoDetails, VideoPrivacy } from '../../models/videos'
-import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers'
-import { dateIsValid, webtorrentAdd } from '../index'
+import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
+import { dateIsValid, webtorrentAdd } from '../miscs/miscs'
type VideoAttributes = {
name?: string
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index af829cc62..aa6be7e87 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -101,14 +101,13 @@ x-tagGroups:
- Video
- Video Channel
- Video Comment
- - Video Abuse
- Video Following
- Video Rate
- name: Moderation
tags:
- Video Abuse
- Video Blacklist
- - name: Public Instance Information
+ - name: Instance Configuration
tags:
- Config
- Server Following
@@ -301,7 +300,7 @@ paths:
responses:
'200':
description: successful operation
- /jobs:
+ /jobs/{state}:
get:
summary: Get list of jobs
security:
@@ -316,6 +315,12 @@ paths:
description: The state of the job
schema:
type: string
+ enum:
+ - active
+ - completed
+ - failed
+ - waiting
+ - delayed
- $ref: '#/components/parameters/start'
- $ref: '#/components/parameters/count'
- $ref: '#/components/parameters/sort'
diff --git a/support/doc/api/quickstart.md b/support/doc/api/quickstart.md
index 844248a7f..6c19b59ee 100644
--- a/support/doc/api/quickstart.md
+++ b/support/doc/api/quickstart.md
@@ -43,7 +43,7 @@ Response example:
Just use the `access_token` in the `Authorization` header:
```
-$ curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/complete
+$ curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
```
@@ -51,4 +51,4 @@ $ curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https
```
$ curl https://peertube.example.com/api/v1/videos
-```
\ No newline at end of file
+```