mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-08-17 17:30:32 +03:00
esModuleInterop to true
This commit is contained in:
parent
40e7ed0714
commit
41fb13c330
@ -151,6 +151,7 @@
|
||||
"@types/async": "^3.0.0",
|
||||
"@types/async-lock": "^1.1.0",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/bencode": "^2.0.0",
|
||||
"@types/bluebird": "^3.5.33",
|
||||
"@types/body-parser": "^1.16.3",
|
||||
"@types/bull": "^3.15.0",
|
||||
@ -159,6 +160,7 @@
|
||||
"@types/chai-json-schema": "^1.4.3",
|
||||
"@types/chai-xml": "^0.3.1",
|
||||
"@types/config": "^0.0.39",
|
||||
"@types/create-torrent": "^5.0.0",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/express-rate-limit": "^5.0.0",
|
||||
"@types/fluent-ffmpeg": "^2.1.16",
|
||||
|
@ -8,7 +8,7 @@ import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@serv
|
||||
import { pathExists, stat, writeFile } from 'fs-extra'
|
||||
import { createTorrentPromise } from '@server/helpers/webtorrent'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import * as parseTorrent from 'parse-torrent'
|
||||
import parseTorrent from 'parse-torrent'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
|
||||
run()
|
||||
|
@ -2,7 +2,7 @@ import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
||||
registerTSPaths()
|
||||
|
||||
import { program } from 'commander'
|
||||
import * as ffmpeg from 'fluent-ffmpeg'
|
||||
import ffmpeg from 'fluent-ffmpeg'
|
||||
import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
|
||||
import { exit } from 'process'
|
||||
import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles'
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
||||
registerTSPaths()
|
||||
|
||||
import * as prompt from 'prompt'
|
||||
import { start, get } from 'prompt'
|
||||
import { join, basename } from 'path'
|
||||
import { CONFIG } from '../server/initializers/config'
|
||||
import { VideoModel } from '../server/models/video/video'
|
||||
import { initDatabaseModels } from '../server/initializers/database'
|
||||
import { readdir, remove, stat } from 'fs-extra'
|
||||
import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { getUUIDFromFilename } from '../server/helpers/utils'
|
||||
import { ThumbnailModel } from '../server/models/video/thumbnail'
|
||||
import { ActorImageModel } from '../server/models/actor/actor-image'
|
||||
@ -78,7 +78,7 @@ async function pruneDirectory (directory: string, existFun: ExistFun) {
|
||||
const files = await readdir(directory)
|
||||
|
||||
const toDelete: string[] = []
|
||||
await Bluebird.map(files, async file => {
|
||||
await map(files, async file => {
|
||||
const filePath = join(directory, file)
|
||||
|
||||
if (await existFun(filePath) !== true) {
|
||||
@ -141,7 +141,7 @@ async function doesRedundancyExist (filePath: string) {
|
||||
|
||||
async function askConfirmation () {
|
||||
return new Promise((res, rej) => {
|
||||
prompt.start()
|
||||
start()
|
||||
const schema = {
|
||||
properties: {
|
||||
confirm: {
|
||||
@ -154,7 +154,7 @@ async function askConfirmation () {
|
||||
}
|
||||
}
|
||||
}
|
||||
prompt.get(schema, function (err, result) {
|
||||
get(schema, function (err, result) {
|
||||
if (err) return rej(err)
|
||||
|
||||
return res(result.confirm?.match(/y/) !== null)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
||||
registerTSPaths()
|
||||
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { program } from 'commander'
|
||||
import { pathExists, remove } from 'fs-extra'
|
||||
import { generateImageFilename, processImage } from '@server/helpers/image-utils'
|
||||
@ -23,7 +23,7 @@ async function run () {
|
||||
|
||||
const videos = await VideoModel.listLocal()
|
||||
|
||||
await Bluebird.map(videos, v => {
|
||||
await map(videos, v => {
|
||||
return processVideo(v)
|
||||
.catch(err => console.error('Cannot process video %s.', v.url, err))
|
||||
}, { concurrency: 20 })
|
||||
|
22
server.ts
22
server.ts
@ -7,13 +7,13 @@ if (isTestInstance()) {
|
||||
}
|
||||
|
||||
// ----------- Node modules -----------
|
||||
import * as express from 'express'
|
||||
import * as morgan from 'morgan'
|
||||
import * as cors from 'cors'
|
||||
import * as cookieParser from 'cookie-parser'
|
||||
import * as helmet from 'helmet'
|
||||
import * as useragent from 'useragent'
|
||||
import * as anonymize from 'ip-anonymize'
|
||||
import express from 'express'
|
||||
import morgan, { token } from 'morgan'
|
||||
import cors from 'cors'
|
||||
import cookieParser from 'cookie-parser'
|
||||
import { frameguard } from 'helmet'
|
||||
import { parse } from 'useragent'
|
||||
import anonymize from 'ip-anonymize'
|
||||
import { program as cli } from 'commander'
|
||||
|
||||
process.title = 'peertube'
|
||||
@ -61,7 +61,7 @@ if (CONFIG.CSP.ENABLED) {
|
||||
}
|
||||
|
||||
if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) {
|
||||
app.use(helmet.frameguard({
|
||||
app.use(frameguard({
|
||||
action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts
|
||||
}))
|
||||
}
|
||||
@ -148,16 +148,16 @@ if (isTestInstance()) {
|
||||
}
|
||||
|
||||
// For the logger
|
||||
morgan.token('remote-addr', (req: express.Request) => {
|
||||
token('remote-addr', (req: express.Request) => {
|
||||
if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') {
|
||||
return anonymize(req.ip, 16, 16)
|
||||
}
|
||||
|
||||
return req.ip
|
||||
})
|
||||
morgan.token('user-agent', (req: express.Request) => {
|
||||
token('user-agent', (req: express.Request) => {
|
||||
if (req.get('DNT') === '1') {
|
||||
return useragent.parse(req.get('user-agent')).family
|
||||
return parse(req.get('user-agent')).family
|
||||
}
|
||||
|
||||
return req.get('user-agent')
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
|
||||
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
|
||||
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { activityPubClientRouter } from './client'
|
||||
import { inboxRouter } from './inbox'
|
||||
import { outboxRouter } from './outbox'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { Activity } from '../../../shared/models/activitypub/activity'
|
||||
import { VideoPrivacy } from '../../../shared/models/videos'
|
||||
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
|
||||
function activityPubResponse (data: any, res: express.Response) {
|
||||
return res.type('application/activity+json; charset=utf-8')
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation'
|
||||
import { Notifier } from '@server/lib/notifier'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { pickCommonVideoQuery } from '@server/helpers/query'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { removeComment } from '@server/lib/video-comment'
|
||||
import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk'
|
||||
import { VideoCommentModel } from '@server/models/video/video-comment'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { remove, writeJSON } from 'fs-extra'
|
||||
import { snakeCase } from 'lodash'
|
||||
import validator from 'validator'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { ServerConfigManager } from '@server/lib/server-config-manager'
|
||||
import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
|
||||
import { HttpStatusCode, UserRight } from '@shared/models'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import * as RateLimit from 'express-rate-limit'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import RateLimit from 'express-rate-limit'
|
||||
import { HttpStatusCode } from '../../../shared/models'
|
||||
import { badRequest } from '../../helpers/express-utils'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { ResultList } from '../../../shared'
|
||||
import { Job, JobState, JobType } from '../../../shared/models'
|
||||
import { UserRight } from '../../../shared/models/users'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { OAuthClientLocal } from '../../../shared'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { logger } from '../../helpers/logger'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import * as memoizee from 'memoizee'
|
||||
import express from 'express'
|
||||
import memoizee from 'memoizee'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { getFormattedObjects } from '@server/helpers/utils'
|
||||
import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { searchChannelsRouter } from './search-video-channels'
|
||||
import { searchPlaylistsRouter } from './search-video-playlists'
|
||||
import { searchVideosRouter } from './search-videos'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { sanitizeUrl } from '@server/helpers/core-utils'
|
||||
import { pickSearchChannelQuery } from '@server/helpers/query'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { sanitizeUrl } from '@server/helpers/core-utils'
|
||||
import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { sanitizeUrl } from '@server/helpers/core-utils'
|
||||
import { pickSearchVideoQuery } from '@server/helpers/query'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { ContactForm } from '../../../../shared/models/server'
|
||||
import { Emailer } from '../../../lib/emailer'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
|
||||
import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
|
||||
import { Debug, SendDebugCommand } from '@shared/models'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { contactRouter } from './contact'
|
||||
import { debugRouter } from './debug'
|
||||
import { serverFollowsRouter } from './follows'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { readdir, readFile } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { logger, mtimeSortFilesDesc } from '@server/helpers/logger'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { StatsManager } from '@server/lib/stat-manager'
|
||||
import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
|
||||
import { asyncMiddleware } from '../../../middlewares'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import * as RateLimit from 'express-rate-limit'
|
||||
import express from 'express'
|
||||
import RateLimit from 'express-rate-limit'
|
||||
import { tokensRouter } from '@server/controllers/api/users/token'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { AttributesOnly } from '@shared/core-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { AbuseModel } from '@server/models/abuse/abuse'
|
||||
import {
|
||||
abuseListForUserValidator,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserNotificationSetting } from '../../../../shared/models/users'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { pickCommonVideoQuery } from '@server/helpers/query'
|
||||
import { sendUndoFollow } from '@server/lib/activitypub/send'
|
||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
|
||||
import { asyncMiddleware, authenticate } from '../../../middlewares'
|
||||
import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import * as RateLimit from 'express-rate-limit'
|
||||
import express from 'express'
|
||||
import RateLimit from 'express-rate-limit'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { buildUUID } from '@server/helpers/uuid'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { pickCommonVideoQuery } from '@server/helpers/query'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { join } from 'path'
|
||||
import { uuidToShort } from '@server/helpers/uuid'
|
||||
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist'
|
||||
import { UserRight, VideoBlacklistCreate } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { MVideoCaption } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { move, readFile } from 'fs-extra'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import * as parseTorrent from 'parse-torrent'
|
||||
import { decode } from 'magnet-uri'
|
||||
import parseTorrent, { Instance } from 'parse-torrent'
|
||||
import { join } from 'path'
|
||||
import { ServerConfigManager } from '@server/lib/server-config-manager'
|
||||
import { setVideoTags } from '@server/lib/video'
|
||||
@ -329,7 +329,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
|
||||
torrentfile.path = newTorrentPath
|
||||
|
||||
const buf = await readFile(torrentfile.path)
|
||||
const parsedTorrent = parseTorrent(buf) as parseTorrent.Instance
|
||||
const parsedTorrent = parseTorrent(buf) as Instance
|
||||
|
||||
if (parsedTorrent.files.length !== 1) {
|
||||
cleanUpReqFiles(req)
|
||||
@ -349,7 +349,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
|
||||
|
||||
function processMagnetURI (body: VideoImportCreate) {
|
||||
const magnetUri = body.magnetUri
|
||||
const parsed = magnetUtil.decode(magnetUri)
|
||||
const parsed = decode(magnetUri)
|
||||
|
||||
return {
|
||||
name: extractNameFromArray(parsed.name),
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import toInt from 'validator/lib/toInt'
|
||||
import { pickCommonVideoQuery } from '@server/helpers/query'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { createReqFiles } from '@server/helpers/express-utils'
|
||||
import { buildUUID, uuidToShort } from '@server/helpers/uuid'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { MVideoFullLight } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { UserVideoRateUpdate } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { Transaction } from 'sequelize/types'
|
||||
import { changeVideoChannelShare } from '@server/lib/activitypub/share'
|
||||
import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { move } from 'fs-extra'
|
||||
import { basename } from 'path'
|
||||
import { getLowercaseExtension } from '@server/helpers/core-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { UserWatchingVideo } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { truncate } from 'lodash'
|
||||
import { SitemapStream, streamToPromise } from 'sitemap'
|
||||
import { buildNSFWFilter } from '../helpers/express-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { constants, promises as fs } from 'fs'
|
||||
import { readFile } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import * as Feed from 'pfeed'
|
||||
import express from 'express'
|
||||
import Feed from 'pfeed'
|
||||
import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
|
||||
import { VideoFilter } from '../../shared/models/videos/video-query.type'
|
||||
import { buildNSFWFilter } from '../helpers/express-utils'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
|
||||
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
|
||||
import { logger } from '../helpers/logger'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { mapToJSON } from '@server/helpers/core-utils'
|
||||
import { LiveSegmentShaStore } from '@server/lib/live'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { join } from 'path'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { optionalAuthenticate } from '@server/middlewares/auth'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants'
|
||||
import { asyncMiddleware, oembedValidator } from '../middlewares'
|
||||
import { accountNameWithHostGetValidator } from '../middlewares/validators'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { join } from 'path'
|
||||
import { serveIndexHTML } from '@server/lib/client-html'
|
||||
import { ServerConfigManager } from '@server/lib/server-config-manager'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as bitTorrentTracker from 'bittorrent-tracker'
|
||||
import * as express from 'express'
|
||||
import * as http from 'http'
|
||||
import * as proxyAddr from 'proxy-addr'
|
||||
import { Server as TrackerServer } from 'bittorrent-tracker'
|
||||
import express from 'express'
|
||||
import { createServer } from 'http'
|
||||
import proxyAddr from 'proxy-addr'
|
||||
import { Server as WebSocketServer } from 'ws'
|
||||
import { Redis } from '@server/lib/redis'
|
||||
import { logger } from '../helpers/logger'
|
||||
@ -10,8 +10,6 @@ import { TRACKER_RATE_LIMITS } from '../initializers/constants'
|
||||
import { VideoFileModel } from '../models/video/video-file'
|
||||
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
|
||||
|
||||
const TrackerServer = bitTorrentTracker.Server
|
||||
|
||||
const trackerRouter = express.Router()
|
||||
|
||||
let peersIps = {}
|
||||
@ -86,7 +84,7 @@ trackerRouter.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { a
|
||||
trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' }))
|
||||
|
||||
function createWebsocketTrackerServer (app: express.Application) {
|
||||
const server = http.createServer(app)
|
||||
const server = createServer(app)
|
||||
const wss = new WebSocketServer({ noServer: true })
|
||||
|
||||
wss.on('connection', function (ws, req) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { WEBSERVER } from '@server/initializers/constants'
|
||||
import { asyncMiddleware } from '../middlewares'
|
||||
import { webfingerValidator } from '../middlewares/validators'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import Bluebird from 'bluebird'
|
||||
import { URL } from 'url'
|
||||
import validator from 'validator'
|
||||
import { ContextType } from '@shared/models/activitypub/context'
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { diff } from 'deep-object-diff'
|
||||
import * as express from 'express'
|
||||
import * as flatten from 'flat'
|
||||
import express from 'express'
|
||||
import flatten from 'flat'
|
||||
import { chain } from 'lodash'
|
||||
import * as path from 'path'
|
||||
import * as winston from 'winston'
|
||||
import { join } from 'path'
|
||||
import { addColors, config, createLogger, format, transports } from 'winston'
|
||||
import { AUDIT_LOG_FILENAME } from '@server/initializers/constants'
|
||||
import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
|
||||
import { CustomConfig } from '../../shared/models/server/custom-config.model'
|
||||
@ -21,23 +21,23 @@ enum AUDIT_TYPE {
|
||||
DELETE = 'delete'
|
||||
}
|
||||
|
||||
const colors = winston.config.npm.colors
|
||||
colors.audit = winston.config.npm.colors.info
|
||||
const colors = config.npm.colors
|
||||
colors.audit = config.npm.colors.info
|
||||
|
||||
winston.addColors(colors)
|
||||
addColors(colors)
|
||||
|
||||
const auditLogger = winston.createLogger({
|
||||
const auditLogger = createLogger({
|
||||
levels: { audit: 0 },
|
||||
transports: [
|
||||
new winston.transports.File({
|
||||
filename: path.join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME),
|
||||
new transports.File({
|
||||
filename: join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME),
|
||||
level: 'audit',
|
||||
maxsize: 5242880,
|
||||
maxFiles: 5,
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
format: format.combine(
|
||||
format.timestamp(),
|
||||
labelFormatter(),
|
||||
winston.format.splat(),
|
||||
format.splat(),
|
||||
jsonLoggerFormat
|
||||
)
|
||||
})
|
||||
@ -84,9 +84,9 @@ abstract class EntityAuditView {
|
||||
constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { }
|
||||
|
||||
toLogKeys (): object {
|
||||
return chain(flatten(this.entityInfos, { delimiter: '-', safe: true }))
|
||||
return chain(flatten<object, any>(this.entityInfos, { delimiter: '-', safe: true }))
|
||||
.pick(this.keysToKeep)
|
||||
.mapKeys((value, key) => `${this.prefix}-${key}`)
|
||||
.mapKeys((_value, key) => `${this.prefix}-${key}`)
|
||||
.value()
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { createReadStream, createWriteStream, move, remove } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import * as srt2vtt from 'srt-to-vtt'
|
||||
import srt2vtt from 'srt-to-vtt'
|
||||
import { Transform } from 'stream'
|
||||
import { MVideoCaption } from '@server/types/models'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { pipelinePromise } from './core-utils'
|
||||
import { Transform } from 'stream'
|
||||
|
||||
async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) {
|
||||
const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
|
||||
|
@ -9,7 +9,7 @@ import { exec, ExecOptions } from 'child_process'
|
||||
import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto'
|
||||
import { truncate } from 'lodash'
|
||||
import { basename, extname, isAbsolute, join, resolve } from 'path'
|
||||
import * as pem from 'pem'
|
||||
import { createPrivateKey as createPrivateKey_1, getPublicKey as getPublicKey_1 } from 'pem'
|
||||
import { pipeline } from 'stream'
|
||||
import { URL } from 'url'
|
||||
import { promisify } from 'util'
|
||||
@ -281,8 +281,8 @@ function promisify2<T, U, A> (func: (arg1: T, arg2: U, cb: (err: any, result: A)
|
||||
}
|
||||
|
||||
const randomBytesPromise = promisify1<number, Buffer>(randomBytes)
|
||||
const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
|
||||
const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
|
||||
const createPrivateKey = promisify1<number, { key: string }>(createPrivateKey_1)
|
||||
const getPublicKey = promisify1<string, { publicKey: string }>(getPublicKey_1)
|
||||
const execPromise2 = promisify2<string, any, string>(exec)
|
||||
const execPromise = promisify1<string, string>(exec)
|
||||
const pipelinePromise = promisify(pipeline)
|
||||
|
@ -1,7 +1,8 @@
|
||||
import * as AsyncLRU from 'async-lru'
|
||||
import * as jsonld from 'jsonld'
|
||||
import AsyncLRU from 'async-lru'
|
||||
import { logger } from './logger'
|
||||
|
||||
import jsonld = require('jsonld')
|
||||
|
||||
const CACHE = {
|
||||
'https://w3id.org/security/v1': {
|
||||
'@context': {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { UploadFilesForCheck } from 'express'
|
||||
import { values } from 'lodash'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import magnetUtil from 'magnet-uri'
|
||||
import validator from 'validator'
|
||||
import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
|
||||
import {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as retry from 'async/retry'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import retry from 'async/retry'
|
||||
import Bluebird from 'bluebird'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { Model } from 'sequelize-typescript'
|
||||
import { sequelizeTypescript } from '@server/initializers/database'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import * as multer from 'multer'
|
||||
import express from 'express'
|
||||
import multer, { diskStorage } from 'multer'
|
||||
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { REMOTE_SCHEME } from '../initializers/constants'
|
||||
@ -70,7 +70,7 @@ function createReqFiles (
|
||||
mimeTypes: { [id: string]: string | string[] },
|
||||
destinations: { [fieldName: string]: string }
|
||||
) {
|
||||
const storage = multer.diskStorage({
|
||||
const storage = diskStorage({
|
||||
destination: (req, file, cb) => {
|
||||
cb(null, destinations[file.fieldname])
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Job } from 'bull'
|
||||
import * as ffmpeg from 'fluent-ffmpeg'
|
||||
import ffmpeg, { FfmpegCommand, FilterSpecification, getAvailableEncoders } from 'fluent-ffmpeg'
|
||||
import { readFile, remove, writeFile } from 'fs-extra'
|
||||
import { dirname, join } from 'path'
|
||||
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
|
||||
@ -42,7 +42,7 @@ async function checkFFmpegEncoders (peertubeAvailableEncoders: AvailableEncoders
|
||||
return supportedEncoders
|
||||
}
|
||||
|
||||
const getAvailableEncodersPromise = promisify0(ffmpeg.getAvailableEncoders)
|
||||
const getAvailableEncodersPromise = promisify0(getAvailableEncoders)
|
||||
const availableFFmpegEncoders = await getAvailableEncodersPromise()
|
||||
|
||||
const searchEncoders = new Set<string>()
|
||||
@ -191,7 +191,7 @@ type TranscodeOptions =
|
||||
| QuickTranscodeOptions
|
||||
|
||||
const builders: {
|
||||
[ type in TranscodeOptionsType ]: (c: ffmpeg.FfmpegCommand, o?: TranscodeOptions) => Promise<ffmpeg.FfmpegCommand> | ffmpeg.FfmpegCommand
|
||||
[ type in TranscodeOptionsType ]: (c: FfmpegCommand, o?: TranscodeOptions) => Promise<FfmpegCommand> | FfmpegCommand
|
||||
} = {
|
||||
'quick-transcode': buildQuickTranscodeCommand,
|
||||
'hls': buildHLSVODCommand,
|
||||
@ -241,7 +241,7 @@ async function getLiveTranscodingCommand (options: {
|
||||
|
||||
const varStreamMap: string[] = []
|
||||
|
||||
const complexFilter: ffmpeg.FilterSpecification[] = [
|
||||
const complexFilter: FilterSpecification[] = [
|
||||
{
|
||||
inputs: '[v:0]',
|
||||
filter: 'split',
|
||||
@ -353,7 +353,7 @@ function buildStreamSuffix (base: string, streamNum?: number) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function addDefaultEncoderGlobalParams (options: {
|
||||
command: ffmpeg.FfmpegCommand
|
||||
command: FfmpegCommand
|
||||
}) {
|
||||
const { command } = options
|
||||
|
||||
@ -370,7 +370,7 @@ function addDefaultEncoderGlobalParams (options: {
|
||||
}
|
||||
|
||||
function addDefaultEncoderParams (options: {
|
||||
command: ffmpeg.FfmpegCommand
|
||||
command: FfmpegCommand
|
||||
encoder: 'libx264' | string
|
||||
streamNum?: number
|
||||
fps?: number
|
||||
@ -390,7 +390,7 @@ function addDefaultEncoderParams (options: {
|
||||
}
|
||||
}
|
||||
|
||||
function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, masterPlaylistName: string) {
|
||||
function addDefaultLiveHLSParams (command: FfmpegCommand, outPath: string, masterPlaylistName: string) {
|
||||
command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS)
|
||||
command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE)
|
||||
command.outputOption('-hls_flags delete_segments+independent_segments')
|
||||
@ -405,7 +405,7 @@ function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string
|
||||
// Transcode VOD command builders
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: TranscodeOptions) {
|
||||
async function buildx264VODCommand (command: FfmpegCommand, options: TranscodeOptions) {
|
||||
let fps = await getVideoFileFPS(options.inputPath)
|
||||
fps = computeFPS(fps, options.resolution)
|
||||
|
||||
@ -422,7 +422,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran
|
||||
return command
|
||||
}
|
||||
|
||||
async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) {
|
||||
async function buildAudioMergeCommand (command: FfmpegCommand, options: MergeAudioTranscodeOptions) {
|
||||
command = command.loop(undefined)
|
||||
|
||||
const scaleFilterValue = getScaleCleanerValue()
|
||||
@ -437,13 +437,13 @@ async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: M
|
||||
return command
|
||||
}
|
||||
|
||||
function buildOnlyAudioCommand (command: ffmpeg.FfmpegCommand, _options: OnlyAudioTranscodeOptions) {
|
||||
function buildOnlyAudioCommand (command: FfmpegCommand, _options: OnlyAudioTranscodeOptions) {
|
||||
command = presetOnlyAudio(command)
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) {
|
||||
function buildQuickTranscodeCommand (command: FfmpegCommand) {
|
||||
command = presetCopy(command)
|
||||
|
||||
command = command.outputOption('-map_metadata -1') // strip all metadata
|
||||
@ -452,7 +452,7 @@ function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) {
|
||||
return command
|
||||
}
|
||||
|
||||
function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPath: string) {
|
||||
function addCommonHLSVODCommandOptions (command: FfmpegCommand, outputPath: string) {
|
||||
return command.outputOption('-hls_time 4')
|
||||
.outputOption('-hls_list_size 0')
|
||||
.outputOption('-hls_playlist_type vod')
|
||||
@ -462,7 +462,7 @@ function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPat
|
||||
.outputOption('-hls_flags single_file')
|
||||
}
|
||||
|
||||
async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTranscodeOptions) {
|
||||
async function buildHLSVODCommand (command: FfmpegCommand, options: HLSTranscodeOptions) {
|
||||
const videoPath = getHLSVideoPath(options)
|
||||
|
||||
if (options.copyCodecs) command = presetCopy(command)
|
||||
@ -474,7 +474,7 @@ async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTr
|
||||
return command
|
||||
}
|
||||
|
||||
function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) {
|
||||
function buildHLSVODFromTSCommand (command: FfmpegCommand, options: HLSFromTSTranscodeOptions) {
|
||||
const videoPath = getHLSVideoPath(options)
|
||||
|
||||
command.outputOption('-c copy')
|
||||
@ -571,7 +571,7 @@ async function getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
|
||||
}
|
||||
|
||||
async function presetVideo (options: {
|
||||
command: ffmpeg.FfmpegCommand
|
||||
command: FfmpegCommand
|
||||
input: string
|
||||
transcodeOptions: TranscodeOptions
|
||||
fps?: number
|
||||
@ -640,21 +640,21 @@ async function presetVideo (options: {
|
||||
return localCommand
|
||||
}
|
||||
|
||||
function presetCopy (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
|
||||
function presetCopy (command: FfmpegCommand): FfmpegCommand {
|
||||
return command
|
||||
.format('mp4')
|
||||
.videoCodec('copy')
|
||||
.audioCodec('copy')
|
||||
}
|
||||
|
||||
function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
|
||||
function presetOnlyAudio (command: FfmpegCommand): FfmpegCommand {
|
||||
return command
|
||||
.format('mp4')
|
||||
.audioCodec('copy')
|
||||
.noVideo()
|
||||
}
|
||||
|
||||
function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand {
|
||||
function applyEncoderOptions (command: FfmpegCommand, options: EncoderOptions): FfmpegCommand {
|
||||
return command
|
||||
.inputOptions(options.inputOptions ?? [])
|
||||
.outputOptions(options.outputOptions ?? [])
|
||||
@ -714,7 +714,7 @@ function getFFmpegVersion () {
|
||||
}
|
||||
|
||||
async function runCommand (options: {
|
||||
command: ffmpeg.FfmpegCommand
|
||||
command: FfmpegCommand
|
||||
silent?: boolean // false
|
||||
job?: Job
|
||||
}) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as ffmpeg from 'fluent-ffmpeg'
|
||||
import { ffprobe, FfprobeData } from 'fluent-ffmpeg'
|
||||
import { getMaxBitrate } from '@shared/core-utils'
|
||||
import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
@ -12,8 +12,8 @@ import { logger } from './logger'
|
||||
*/
|
||||
|
||||
function ffprobePromise (path: string) {
|
||||
return new Promise<ffmpeg.FfprobeData>((res, rej) => {
|
||||
ffmpeg.ffprobe(path, (err, data) => {
|
||||
return new Promise<FfprobeData>((res, rej) => {
|
||||
ffprobe(path, (err, data) => {
|
||||
if (err) return rej(err)
|
||||
|
||||
return res(data)
|
||||
@ -21,7 +21,7 @@ function ffprobePromise (path: string) {
|
||||
})
|
||||
}
|
||||
|
||||
async function getAudioStream (videoPath: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getAudioStream (videoPath: string, existingProbe?: FfprobeData) {
|
||||
// without position, ffprobe considers the last input only
|
||||
// we make it consider the first input only
|
||||
// if you pass a file path to pos, then ffprobe acts on that file directly
|
||||
@ -76,7 +76,7 @@ function getMaxAudioBitrate (type: 'aac' | 'mp3' | string, bitrate: number) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<{ width: number, height: number }> {
|
||||
async function getVideoStreamSize (path: string, existingProbe?: FfprobeData): Promise<{ width: number, height: number }> {
|
||||
const videoStream = await getVideoStreamFromFile(path, existingProbe)
|
||||
|
||||
return videoStream === null
|
||||
@ -127,7 +127,7 @@ async function getVideoStreamCodec (path: string) {
|
||||
return `${videoCodec}.${baseProfile}${level}`
|
||||
}
|
||||
|
||||
async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) {
|
||||
const { audioStream } = await getAudioStream(path, existingProbe)
|
||||
|
||||
if (!audioStream) return ''
|
||||
@ -143,7 +143,7 @@ async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.Ffprobe
|
||||
return 'mp4a.40.2' // Fallback
|
||||
}
|
||||
|
||||
async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getVideoFileResolution (path: string, existingProbe?: FfprobeData) {
|
||||
const size = await getVideoStreamSize(path, existingProbe)
|
||||
|
||||
return {
|
||||
@ -155,7 +155,7 @@ async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.Ffpr
|
||||
}
|
||||
}
|
||||
|
||||
async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getVideoFileFPS (path: string, existingProbe?: FfprobeData) {
|
||||
const videoStream = await getVideoStreamFromFile(path, existingProbe)
|
||||
if (videoStream === null) return 0
|
||||
|
||||
@ -173,13 +173,13 @@ async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData
|
||||
return 0
|
||||
}
|
||||
|
||||
async function getMetadataFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getMetadataFromFile (path: string, existingProbe?: FfprobeData) {
|
||||
const metadata = existingProbe || await ffprobePromise(path)
|
||||
|
||||
return new VideoFileMetadata(metadata)
|
||||
}
|
||||
|
||||
async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<number> {
|
||||
async function getVideoFileBitrate (path: string, existingProbe?: FfprobeData): Promise<number> {
|
||||
const metadata = await getMetadataFromFile(path, existingProbe)
|
||||
|
||||
let bitrate = metadata.format.bit_rate as number
|
||||
@ -194,13 +194,13 @@ async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.Ffprobe
|
||||
return undefined
|
||||
}
|
||||
|
||||
async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getDurationFromVideoFile (path: string, existingProbe?: FfprobeData) {
|
||||
const metadata = await getMetadataFromFile(path, existingProbe)
|
||||
|
||||
return Math.round(metadata.format.duration)
|
||||
}
|
||||
|
||||
async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||
async function getVideoStreamFromFile (path: string, existingProbe?: FfprobeData) {
|
||||
const metadata = await getMetadataFromFile(path, existingProbe)
|
||||
|
||||
return metadata.streams.find(s => s.codec_type === 'video') || null
|
||||
@ -243,7 +243,7 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
|
||||
await canDoQuickAudioTranscode(path, probe)
|
||||
}
|
||||
|
||||
async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
|
||||
async function canDoQuickVideoTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
|
||||
const videoStream = await getVideoStreamFromFile(path, probe)
|
||||
const fps = await getVideoFileFPS(path, probe)
|
||||
const bitRate = await getVideoFileBitrate(path, probe)
|
||||
@ -262,7 +262,7 @@ async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeDat
|
||||
return true
|
||||
}
|
||||
|
||||
async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
|
||||
async function canDoQuickAudioTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
|
||||
const parsedAudio = await getAudioStream(path, probe)
|
||||
|
||||
if (!parsedAudio.audioStream) return true
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { copy, readFile, remove, rename } from 'fs-extra'
|
||||
import * as Jimp from 'jimp'
|
||||
import Jimp, { read } from 'jimp'
|
||||
import { getLowercaseExtension } from './core-utils'
|
||||
import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
|
||||
import { logger } from './logger'
|
||||
@ -47,7 +47,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
|
||||
const inputBuffer = await readFile(path)
|
||||
|
||||
try {
|
||||
jimpInstance = await Jimp.read(inputBuffer)
|
||||
jimpInstance = await read(inputBuffer)
|
||||
} catch (err) {
|
||||
logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err })
|
||||
|
||||
@ -55,7 +55,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
|
||||
await convertWebPToJPG(path, newName)
|
||||
await rename(newName, path)
|
||||
|
||||
jimpInstance = await Jimp.read(path)
|
||||
jimpInstance = await read(path)
|
||||
}
|
||||
|
||||
await remove(destination)
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
|
||||
import { mkdirpSync, stat } from 'fs-extra'
|
||||
import { omit } from 'lodash'
|
||||
import * as path from 'path'
|
||||
import { join } from 'path'
|
||||
import { format as sqlFormat } from 'sql-formatter'
|
||||
import * as winston from 'winston'
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
import { FileTransportOptions } from 'winston/lib/winston/transports'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { LOG_FILENAME } from '../initializers/constants'
|
||||
@ -47,7 +47,7 @@ function getLoggerReplacer () {
|
||||
}
|
||||
}
|
||||
|
||||
const consoleLoggerFormat = winston.format.printf(info => {
|
||||
const consoleLoggerFormat = format.printf(info => {
|
||||
const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
|
||||
|
||||
const obj = omit(info, ...toOmit)
|
||||
@ -71,24 +71,24 @@ const consoleLoggerFormat = winston.format.printf(info => {
|
||||
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
|
||||
})
|
||||
|
||||
const jsonLoggerFormat = winston.format.printf(info => {
|
||||
const jsonLoggerFormat = format.printf(info => {
|
||||
return JSON.stringify(info, getLoggerReplacer())
|
||||
})
|
||||
|
||||
const timestampFormatter = winston.format.timestamp({
|
||||
const timestampFormatter = format.timestamp({
|
||||
format: 'YYYY-MM-DD HH:mm:ss.SSS'
|
||||
})
|
||||
const labelFormatter = (suffix?: string) => {
|
||||
return winston.format.label({
|
||||
return format.label({
|
||||
label: suffix ? `${label} ${suffix}` : label
|
||||
})
|
||||
}
|
||||
|
||||
const fileLoggerOptions: FileTransportOptions = {
|
||||
filename: path.join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME),
|
||||
filename: join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME),
|
||||
handleExceptions: true,
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
format: format.combine(
|
||||
format.timestamp(),
|
||||
jsonLoggerFormat
|
||||
)
|
||||
}
|
||||
@ -101,19 +101,19 @@ if (CONFIG.LOG.ROTATION.ENABLED) {
|
||||
const logger = buildLogger()
|
||||
|
||||
function buildLogger (labelSuffix?: string) {
|
||||
return winston.createLogger({
|
||||
return createLogger({
|
||||
level: CONFIG.LOG.LEVEL,
|
||||
format: winston.format.combine(
|
||||
format: format.combine(
|
||||
labelFormatter(labelSuffix),
|
||||
winston.format.splat()
|
||||
format.splat()
|
||||
),
|
||||
transports: [
|
||||
new winston.transports.File(fileLoggerOptions),
|
||||
new winston.transports.Console({
|
||||
new transports.File(fileLoggerOptions),
|
||||
new transports.Console({
|
||||
handleExceptions: true,
|
||||
format: winston.format.combine(
|
||||
format: format.combine(
|
||||
timestampFormatter,
|
||||
winston.format.colorize(),
|
||||
format.colorize(),
|
||||
consoleLoggerFormat
|
||||
)
|
||||
})
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { compare, genSalt, hash } from 'bcrypt'
|
||||
import { createSign, createVerify } from 'crypto'
|
||||
import { Request } from 'express'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
|
||||
import { MActor } from '../types/models'
|
||||
import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils'
|
||||
import { jsonld } from './custom-jsonld-signature'
|
||||
import { logger } from './logger'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { createSign, createVerify } from 'crypto'
|
||||
import * as bcrypt from 'bcrypt'
|
||||
import { MActor } from '../types/models'
|
||||
|
||||
const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
|
||||
const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
|
||||
const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
|
||||
const bcryptComparePromise = promisify2<any, string, boolean>(compare)
|
||||
const bcryptGenSaltPromise = promisify1<number, string>(genSalt)
|
||||
const bcryptHashPromise = promisify2<any, string | number, string>(hash)
|
||||
|
||||
const httpSignature = require('http-signature')
|
||||
|
||||
@ -129,7 +129,7 @@ export {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function hash (obj: any): Promise<any> {
|
||||
function hashObject (obj: any): Promise<any> {
|
||||
return jsonld.promises
|
||||
.normalize(obj, {
|
||||
algorithm: 'URDNA2015',
|
||||
@ -151,12 +151,12 @@ function createSignatureHash (signature: any) {
|
||||
delete signatureCopy.id
|
||||
delete signatureCopy.signatureValue
|
||||
|
||||
return hash(signatureCopy)
|
||||
return hashObject(signatureCopy)
|
||||
}
|
||||
|
||||
function createDocWithoutSignatureHash (doc: any) {
|
||||
const docWithoutSignature = cloneDeep(doc)
|
||||
delete docWithoutSignature.signature
|
||||
|
||||
return hash(docWithoutSignature)
|
||||
return hashObject(docWithoutSignature)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as short from 'short-uuid'
|
||||
import short, { uuid } from 'short-uuid'
|
||||
|
||||
const translator = short()
|
||||
|
||||
function buildUUID () {
|
||||
return short.uuid()
|
||||
return uuid()
|
||||
}
|
||||
|
||||
function uuidToShort (uuid: string) {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import * as bencode from 'bencode'
|
||||
import * as createTorrent from 'create-torrent'
|
||||
import { decode, encode } from 'bencode'
|
||||
import createTorrent from 'create-torrent'
|
||||
import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import * as parseTorrent from 'parse-torrent'
|
||||
import magnetUtil from 'magnet-uri'
|
||||
import parseTorrent from 'parse-torrent'
|
||||
import { dirname, join } from 'path'
|
||||
import * as WebTorrent from 'webtorrent'
|
||||
import { pipeline } from 'stream'
|
||||
import WebTorrent, { Instance, TorrentFile } from 'webtorrent'
|
||||
import { isArray } from '@server/helpers/custom-validators/misc'
|
||||
import { WEBSERVER } from '@server/initializers/constants'
|
||||
import { generateTorrentFileName } from '@server/lib/paths'
|
||||
@ -17,7 +18,6 @@ import { promisify2 } from './core-utils'
|
||||
import { logger } from './logger'
|
||||
import { generateVideoImportTmpPath } from './utils'
|
||||
import { extractVideo } from './video'
|
||||
import { pipeline } from 'stream'
|
||||
|
||||
const createTorrentPromise = promisify2<string, any, any>(createTorrent)
|
||||
|
||||
@ -33,7 +33,7 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
|
||||
|
||||
return new Promise<string>((res, rej) => {
|
||||
const webtorrent = new WebTorrent()
|
||||
let file: WebTorrent.TorrentFile
|
||||
let file: TorrentFile
|
||||
|
||||
const torrentId = target.magnetUri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName)
|
||||
|
||||
@ -126,7 +126,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
|
||||
const oldTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)
|
||||
|
||||
const torrentContent = await readFile(oldTorrentPath)
|
||||
const decoded = bencode.decode(torrentContent)
|
||||
const decoded = decode(torrentContent)
|
||||
|
||||
decoded['announce-list'] = buildAnnounceList()
|
||||
decoded.announce = decoded['announce-list'][0][0]
|
||||
@ -138,7 +138,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
|
||||
|
||||
logger.info('Updating torrent URLs %s -> %s.', oldTorrentPath, newTorrentPath)
|
||||
|
||||
await writeFile(newTorrentPath, bencode.encode(decoded))
|
||||
await writeFile(newTorrentPath, encode(decoded))
|
||||
await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename))
|
||||
|
||||
videoFile.torrentFilename = newTorrentFilename
|
||||
@ -180,7 +180,7 @@ export {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function safeWebtorrentDestroy (
|
||||
webtorrent: WebTorrent.Instance,
|
||||
webtorrent: Instance,
|
||||
torrentId: string,
|
||||
downloadedFile?: { directoryPath: string, filepath: string },
|
||||
torrentName?: string
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as config from 'config'
|
||||
import { util, has, get } from 'config'
|
||||
import { uniq } from 'lodash'
|
||||
import { URL } from 'url'
|
||||
import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
|
||||
@ -18,8 +18,8 @@ async function checkActivityPubUrls () {
|
||||
|
||||
const parsed = new URL(actor.url)
|
||||
if (WEBSERVER.HOST !== parsed.host) {
|
||||
const NODE_ENV = config.util.getEnv('NODE_ENV')
|
||||
const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR')
|
||||
const NODE_ENV = util.getEnv('NODE_ENV')
|
||||
const NODE_CONFIG_DIR = util.getEnv('NODE_CONFIG_DIR')
|
||||
|
||||
logger.warn(
|
||||
'It seems PeerTube was started (and created some data) with another domain name. ' +
|
||||
@ -36,7 +36,7 @@ async function checkActivityPubUrls () {
|
||||
function checkConfig () {
|
||||
|
||||
// Moved configuration keys
|
||||
if (config.has('services.csp-logger')) {
|
||||
if (has('services.csp-logger')) {
|
||||
logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ function checkConfig () {
|
||||
|
||||
// Check storage directory locations
|
||||
if (isProdInstance()) {
|
||||
const configStorage = config.get('storage')
|
||||
const configStorage = get('storage')
|
||||
for (const key of Object.keys(configStorage)) {
|
||||
if (configStorage[key].startsWith('storage/')) {
|
||||
logger.warn(
|
||||
|
@ -1,7 +1,10 @@
|
||||
import * as config from 'config'
|
||||
import { IConfig } from 'config'
|
||||
import { parseSemVersion, promisify0 } from '../helpers/core-utils'
|
||||
import { logger } from '../helpers/logger'
|
||||
|
||||
// Special behaviour for config because we can reload it
|
||||
const config: IConfig = require('config')
|
||||
|
||||
// ONLY USE CORE MODULES IN THIS FILE!
|
||||
|
||||
// Check the config files
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as bytes from 'bytes'
|
||||
import bytes from 'bytes'
|
||||
import { IConfig } from 'config'
|
||||
import decache from 'decache'
|
||||
import { dirname, join } from 'path'
|
||||
|
@ -1,15 +1,15 @@
|
||||
import * as passwordGenerator from 'password-generator'
|
||||
import { ensureDir, remove } from 'fs-extra'
|
||||
import passwordGenerator from 'password-generator'
|
||||
import { UserRole } from '../../shared'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
|
||||
import { UserModel } from '../models/user/user'
|
||||
import { ApplicationModel } from '../models/application/application'
|
||||
import { OAuthClientModel } from '../models/oauth/oauth-client'
|
||||
import { UserModel } from '../models/user/user'
|
||||
import { applicationExist, clientsExist, usersExist } from './checker-after-init'
|
||||
import { CONFIG } from './config'
|
||||
import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
|
||||
import { sequelizeTypescript } from './database'
|
||||
import { ensureDir, remove } from 'fs-extra'
|
||||
import { CONFIG } from './config'
|
||||
|
||||
async function installApplication () {
|
||||
try {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as path from 'path'
|
||||
import { readdir } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { QueryTypes } from 'sequelize'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { LAST_MIGRATION_VERSION } from './constants'
|
||||
import { sequelizeTypescript } from './database'
|
||||
import { readdir } from 'fs-extra'
|
||||
import { QueryTypes } from 'sequelize'
|
||||
|
||||
async function migrate () {
|
||||
const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
|
||||
@ -58,7 +58,7 @@ export {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function getMigrationScripts () {
|
||||
const files = await readdir(path.join(__dirname, 'migrations'))
|
||||
const files = await readdir(join(__dirname, 'migrations'))
|
||||
const filesToMigrate: {
|
||||
version: string
|
||||
script: string
|
||||
@ -88,7 +88,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin
|
||||
const migrationScriptName = entity.script
|
||||
logger.info('Executing %s migration script.', migrationScriptName)
|
||||
|
||||
const migrationScript = require(path.join(__dirname, 'migrations', migrationScriptName))
|
||||
const migrationScript = require(join(__dirname, 'migrations', migrationScriptName))
|
||||
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
const options = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as WebFinger from 'webfinger.js'
|
||||
import WebFinger from 'webfinger.js'
|
||||
import { isProdInstance } from '@server/helpers/core-utils'
|
||||
import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
|
||||
import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants'
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import Bluebird from 'bluebird'
|
||||
import { URL } from 'url'
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { doJSONRequest } from '../../helpers/requests'
|
||||
import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants'
|
||||
|
||||
type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
|
||||
type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>)
|
||||
type CleanerFunction = (startedDate: Date) => Promise<any>
|
||||
|
||||
async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
|
||||
let url = argUrl
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { isArray } from '@server/helpers/custom-validators/misc'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
@ -24,7 +24,7 @@ import {
|
||||
const lTags = loggerTagsFactory('ap', 'video-playlist')
|
||||
|
||||
async function createAccountPlaylists (playlistUrls: string[]) {
|
||||
await Bluebird.map(playlistUrls, async playlistUrl => {
|
||||
await map(playlistUrls, async playlistUrl => {
|
||||
try {
|
||||
const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl)
|
||||
if (exists === true) return
|
||||
@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV
|
||||
async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) {
|
||||
const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = []
|
||||
|
||||
await Bluebird.map(elementUrls, async elementUrl => {
|
||||
await map(elementUrls, async elementUrl => {
|
||||
try {
|
||||
const { elementObject } = await fetchRemotePlaylistElement(elementUrl)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
|
||||
@ -38,7 +38,7 @@ async function changeVideoChannelShare (
|
||||
}
|
||||
|
||||
async function addVideoShares (shareUrls: string[], video: MVideoId) {
|
||||
await Bluebird.map(shareUrls, async shareUrl => {
|
||||
await map(shareUrls, async shareUrl => {
|
||||
try {
|
||||
await addVideoShare(shareUrl, video)
|
||||
} catch (err) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { checkUrlsSameHost } from '../../helpers/activitypub'
|
||||
import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
|
||||
import { logger } from '../../helpers/logger'
|
||||
@ -18,7 +18,7 @@ type ResolveThreadParams = {
|
||||
type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
|
||||
|
||||
async function addVideoComments (commentUrls: string[]) {
|
||||
return Bluebird.map(commentUrls, async commentUrl => {
|
||||
return map(commentUrls, async commentUrl => {
|
||||
try {
|
||||
await resolveThread({ url: commentUrl, isVideo: false })
|
||||
} catch (err) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { map } from 'bluebird'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { VideoRateType } from '../../../shared/models/videos'
|
||||
@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy
|
||||
const lTags = loggerTagsFactory('ap', 'video-rate', 'create')
|
||||
|
||||
async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) {
|
||||
await Bluebird.map(ratesUrl, async rateUrl => {
|
||||
await map(ratesUrl, async rateUrl => {
|
||||
try {
|
||||
await createRate(rateUrl, video, rate)
|
||||
} catch (err) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { maxBy, minBy } from 'lodash'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import magnetUtil from 'magnet-uri'
|
||||
import { basename } from 'path'
|
||||
import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos'
|
||||
import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { AccessDeniedError } from 'oauth2-server'
|
||||
import { PluginManager } from '@server/lib/plugins/plugin-manager'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import {
|
||||
InvalidClientError,
|
||||
InvalidGrantError,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as LRUCache from 'lru-cache'
|
||||
import LRUCache from 'lru-cache'
|
||||
import { MOAuthTokenUser } from '@server/types/models'
|
||||
import { LRU_CACHE } from '../../initializers/constants'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as express from 'express'
|
||||
import express from 'express'
|
||||
import { readFile } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import validator from 'validator'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { remove } from 'fs-extra'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import * as memoizee from 'memoizee'
|
||||
import memoizee from 'memoizee'
|
||||
|
||||
type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import * as Bull from 'bull'
|
||||
import { map } from 'bluebird'
|
||||
import { Job } from 'bull'
|
||||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import {
|
||||
isAnnounceActivityValid,
|
||||
@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
|
||||
|
||||
// Job to clean remote interactions off local videos
|
||||
|
||||
async function processActivityPubCleaner (_job: Bull.Job) {
|
||||
async function processActivityPubCleaner (_job: Job) {
|
||||
logger.info('Processing ActivityPub cleaner.')
|
||||
|
||||
{
|
||||
const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos()
|
||||
const { bodyValidator, deleter, updater } = rateOptionsFactory()
|
||||
|
||||
await Bluebird.map(rateUrls, async rateUrl => {
|
||||
await map(rateUrls, async rateUrl => {
|
||||
try {
|
||||
const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter)
|
||||
|
||||
@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
|
||||
const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos()
|
||||
const { bodyValidator, deleter, updater } = shareOptionsFactory()
|
||||
|
||||
await Bluebird.map(shareUrls, async shareUrl => {
|
||||
await map(shareUrls, async shareUrl => {
|
||||
try {
|
||||
await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter)
|
||||
} catch (err) {
|
||||
@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
|
||||
const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos()
|
||||
const { bodyValidator, deleter, updater } = commentOptionsFactory()
|
||||
|
||||
await Bluebird.map(commentUrls, async commentUrl => {
|
||||
await map(commentUrls, async commentUrl => {
|
||||
try {
|
||||
await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter)
|
||||
} catch (err) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Bull from 'bull'
|
||||
import { Job } from 'bull'
|
||||
import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url'
|
||||
import { ActivitypubFollowPayload } from '@shared/models'
|
||||
import { sanitizeHost } from '../../../helpers/core-utils'
|
||||
@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi
|
||||
import { sendFollow } from '../../activitypub/send'
|
||||
import { Notifier } from '../../notifier'
|
||||
|
||||
async function processActivityPubFollow (job: Bull.Job) {
|
||||
async function processActivityPubFollow (job: Job) {
|
||||
const payload = job.data as ActivitypubFollowPayload
|
||||
const host = payload.host
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user