mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Move to eslint
This commit is contained in:
parent
a22046d166
commit
a15871560f
390 changed files with 3950 additions and 3615 deletions
|
@ -16,21 +16,17 @@ import {
|
|||
accountNameWithHostGetValidator,
|
||||
accountsSortValidator,
|
||||
ensureAuthUserOwnsAccountValidator,
|
||||
videosSortValidator,
|
||||
videoChannelsSortValidator
|
||||
videoChannelsSortValidator,
|
||||
videosSortValidator
|
||||
} from '../../middlewares/validators'
|
||||
import { AccountModel } from '../../models/account/account'
|
||||
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
import { buildNSFWFilter, isUserAbleToSearchRemoteURI, getCountVideos } from '../../helpers/express-utils'
|
||||
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
||||
import { JobQueue } from '../../lib/job-queue'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { VideoPlaylistModel } from '../../models/video/video-playlist'
|
||||
import {
|
||||
commonVideoPlaylistFiltersValidator,
|
||||
videoPlaylistsSearchValidator
|
||||
} from '../../middlewares/validators/videos/video-playlists'
|
||||
import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists'
|
||||
|
||||
const accountsRouter = express.Router()
|
||||
|
||||
|
@ -104,7 +100,6 @@ function getAccount (req: express.Request, res: express.Response) {
|
|||
|
||||
if (account.isOutdated()) {
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: account.Actor.url } })
|
||||
.catch(err => logger.error('Cannot create AP refresher job for actor %s.', account.Actor.url, { err }))
|
||||
}
|
||||
|
||||
return res.json(account.toFormattedJSON())
|
||||
|
|
|
@ -31,12 +31,12 @@ configRouter.get('/',
|
|||
configRouter.get('/custom',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
asyncMiddleware(getCustomConfig)
|
||||
getCustomConfig
|
||||
)
|
||||
configRouter.put('/custom',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
asyncMiddleware(customConfigUpdateValidator),
|
||||
customConfigUpdateValidator,
|
||||
asyncMiddleware(updateCustomConfig)
|
||||
)
|
||||
configRouter.delete('/custom',
|
||||
|
@ -196,7 +196,7 @@ function getAbout (req: express.Request, res: express.Response) {
|
|||
return res.json(about).end()
|
||||
}
|
||||
|
||||
async function getCustomConfig (req: express.Request, res: express.Response) {
|
||||
function getCustomConfig (req: express.Request, res: express.Response) {
|
||||
const data = customConfig()
|
||||
|
||||
return res.json(data).end()
|
||||
|
@ -250,7 +250,7 @@ function getRegisteredThemes () {
|
|||
|
||||
function getEnabledResolutions () {
|
||||
return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
|
||||
.filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
|
||||
.filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
|
||||
.map(r => parseInt(r, 10))
|
||||
}
|
||||
|
||||
|
@ -340,13 +340,13 @@ function customConfig (): CustomConfig {
|
|||
allowAudioFiles: CONFIG.TRANSCODING.ALLOW_AUDIO_FILES,
|
||||
threads: CONFIG.TRANSCODING.THREADS,
|
||||
resolutions: {
|
||||
'0p': CONFIG.TRANSCODING.RESOLUTIONS[ '0p' ],
|
||||
'240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ],
|
||||
'360p': CONFIG.TRANSCODING.RESOLUTIONS[ '360p' ],
|
||||
'480p': CONFIG.TRANSCODING.RESOLUTIONS[ '480p' ],
|
||||
'720p': CONFIG.TRANSCODING.RESOLUTIONS[ '720p' ],
|
||||
'1080p': CONFIG.TRANSCODING.RESOLUTIONS[ '1080p' ],
|
||||
'2160p': CONFIG.TRANSCODING.RESOLUTIONS[ '2160p' ]
|
||||
'0p': CONFIG.TRANSCODING.RESOLUTIONS['0p'],
|
||||
'240p': CONFIG.TRANSCODING.RESOLUTIONS['240p'],
|
||||
'360p': CONFIG.TRANSCODING.RESOLUTIONS['360p'],
|
||||
'480p': CONFIG.TRANSCODING.RESOLUTIONS['480p'],
|
||||
'720p': CONFIG.TRANSCODING.RESOLUTIONS['720p'],
|
||||
'1080p': CONFIG.TRANSCODING.RESOLUTIONS['1080p'],
|
||||
'2160p': CONFIG.TRANSCODING.RESOLUTIONS['2160p']
|
||||
},
|
||||
webtorrent: {
|
||||
enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
|
||||
|
|
|
@ -50,7 +50,7 @@ async function listJobs (req: express.Request, res: express.Response) {
|
|||
})
|
||||
const total = await JobQueue.Instance.count(state)
|
||||
|
||||
const result: ResultList<any> = {
|
||||
const result: ResultList<Job> = {
|
||||
total,
|
||||
data: jobs.map(j => formatJob(j, state))
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export { overviewsRouter }
|
|||
const buildSamples = memoizee(async function () {
|
||||
const [ categories, channels, tags ] = await Promise.all([
|
||||
VideoModel.getRandomFieldSamples('category', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT),
|
||||
VideoModel.getRandomFieldSamples('channelId', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD ,OVERVIEWS.VIDEOS.SAMPLES_COUNT),
|
||||
VideoModel.getRandomFieldSamples('channelId', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT),
|
||||
TagModel.getRandomSamples(OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT)
|
||||
])
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as express from 'express'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
|
||||
import { authenticate, ensureUserHasRight } from '../../../middlewares'
|
||||
|
||||
const debugRouter = express.Router()
|
||||
|
||||
debugRouter.get('/debug',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_DEBUG),
|
||||
asyncMiddleware(getDebug)
|
||||
getDebug
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -18,7 +18,7 @@ export {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function getDebug (req: express.Request, res: express.Response) {
|
||||
function getDebug (req: express.Request, res: express.Response) {
|
||||
return res.json({
|
||||
ip: req.ip
|
||||
}).end()
|
||||
|
|
|
@ -135,7 +135,6 @@ async function followInstance (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-follow', payload })
|
||||
.catch(err => logger.error('Cannot create follow job for %s.', host, err))
|
||||
}
|
||||
|
||||
return res.status(204).end()
|
||||
|
|
|
@ -59,9 +59,9 @@ async function getLogs (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
async function generateOutput (options: {
|
||||
startDateQuery: string,
|
||||
endDateQuery?: string,
|
||||
level: LogLevel,
|
||||
startDateQuery: string
|
||||
endDateQuery?: string
|
||||
level: LogLevel
|
||||
nameFilter: RegExp
|
||||
}) {
|
||||
const { startDateQuery, level, nameFilter } = options
|
||||
|
@ -111,7 +111,7 @@ async function getOutputFromFile (path: string, startDate: Date, endDate: Date,
|
|||
const output: any[] = []
|
||||
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
const line = lines[ i ]
|
||||
const line = lines[i]
|
||||
let log: any
|
||||
|
||||
try {
|
||||
|
@ -122,7 +122,7 @@ async function getOutputFromFile (path: string, startDate: Date, endDate: Date,
|
|||
}
|
||||
|
||||
logTime = new Date(log.timestamp).getTime()
|
||||
if (logTime >= startTime && logTime <= endTime && logsLevel[ log.level ] >= logsLevel[ level ]) {
|
||||
if (logTime >= startTime && logTime <= endTime && logsLevel[log.level] >= logsLevel[level]) {
|
||||
output.push(log)
|
||||
|
||||
currentSize += line.length
|
||||
|
|
|
@ -84,7 +84,7 @@ async function addVideoRedundancy (req: express.Request, res: express.Response)
|
|||
videoId: res.locals.onlyVideo.id
|
||||
}
|
||||
|
||||
await JobQueue.Instance.createJob({
|
||||
await JobQueue.Instance.createJobWithPromise({
|
||||
type: 'video-redundancy',
|
||||
payload
|
||||
})
|
||||
|
|
|
@ -39,7 +39,7 @@ meRouter.get('/me',
|
|||
)
|
||||
meRouter.delete('/me',
|
||||
authenticate,
|
||||
asyncMiddleware(deleteMeValidator),
|
||||
deleteMeValidator,
|
||||
asyncMiddleware(deleteMe)
|
||||
)
|
||||
|
||||
|
@ -214,7 +214,7 @@ async function updateMe (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
async function updateMyAvatar (req: express.Request, res: express.Response) {
|
||||
const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
|
||||
const avatarPhysicalFile = req.files['avatarfile'][0]
|
||||
const user = res.locals.oauth.token.user
|
||||
|
||||
const userAccount = await AccountModel.load(user.Account.id)
|
||||
|
|
|
@ -19,7 +19,6 @@ import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
|
|||
import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
|
||||
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
||||
import { JobQueue } from '../../../lib/job-queue'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
|
||||
const mySubscriptionsRouter = express.Router()
|
||||
|
@ -52,7 +51,7 @@ mySubscriptionsRouter.get('/me/subscriptions',
|
|||
mySubscriptionsRouter.post('/me/subscriptions',
|
||||
authenticate,
|
||||
userSubscriptionAddValidator,
|
||||
asyncMiddleware(addUserSubscription)
|
||||
addUserSubscription
|
||||
)
|
||||
|
||||
mySubscriptionsRouter.get('/me/subscriptions/:uri',
|
||||
|
@ -106,7 +105,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons
|
|||
return res.json(existObject)
|
||||
}
|
||||
|
||||
async function addUserSubscription (req: express.Request, res: express.Response) {
|
||||
function addUserSubscription (req: express.Request, res: express.Response) {
|
||||
const user = res.locals.oauth.token.User
|
||||
const [ name, host ] = req.body.uri.split('@')
|
||||
|
||||
|
@ -117,7 +116,6 @@ async function addUserSubscription (req: express.Request, res: express.Response)
|
|||
}
|
||||
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-follow', payload })
|
||||
.catch(err => logger.error('Cannot create follow job for subscription %s.', req.body.uri, err))
|
||||
|
||||
return res.status(204).end()
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ async function listVideoChannels (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
async function updateVideoChannelAvatar (req: express.Request, res: express.Response) {
|
||||
const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
|
||||
const avatarPhysicalFile = req.files['avatarfile'][0]
|
||||
const videoChannel = res.locals.videoChannel
|
||||
const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON())
|
||||
|
||||
|
@ -232,7 +232,6 @@ async function getVideoChannel (req: express.Request, res: express.Response) {
|
|||
|
||||
if (videoChannelWithVideos.isOutdated()) {
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: videoChannelWithVideos.Actor.url } })
|
||||
.catch(err => logger.error('Cannot create AP refresher job for actor %s.', videoChannelWithVideos.Actor.url, { err }))
|
||||
}
|
||||
|
||||
return res.json(videoChannelWithVideos.toFormattedJSON())
|
||||
|
|
|
@ -144,7 +144,6 @@ function getVideoPlaylist (req: express.Request, res: express.Response) {
|
|||
|
||||
if (videoPlaylist.isOutdated()) {
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video-playlist', url: videoPlaylist.url } })
|
||||
.catch(err => logger.error('Cannot create AP refresher job for playlist %s.', videoPlaylist.url, { err }))
|
||||
}
|
||||
|
||||
return res.json(videoPlaylist.toFormattedJSON())
|
||||
|
|
|
@ -88,12 +88,12 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
|
|||
const buf = await readFile(torrentfile.path)
|
||||
const parsedTorrent = parseTorrent(buf)
|
||||
|
||||
videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[ 0 ] : parsedTorrent.name as string
|
||||
videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[0] : parsedTorrent.name as string
|
||||
} else {
|
||||
magnetUri = body.magnetUri
|
||||
|
||||
const parsed = magnetUtil.decode(magnetUri)
|
||||
videoName = isArray(parsed.name) ? parsed.name[ 0 ] : parsed.name as string
|
||||
videoName = isArray(parsed.name) ? parsed.name[0] : parsed.name as string
|
||||
}
|
||||
|
||||
const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName })
|
||||
|
@ -124,7 +124,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
|
|||
videoImportId: videoImport.id,
|
||||
magnetUri
|
||||
}
|
||||
await JobQueue.Instance.createJob({ type: 'video-import', payload })
|
||||
await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload })
|
||||
|
||||
auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON()))
|
||||
|
||||
|
@ -176,7 +176,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
|
|||
downloadThumbnail: !thumbnailModel,
|
||||
downloadPreview: !previewModel
|
||||
}
|
||||
await JobQueue.Instance.createJob({ type: 'video-import', payload })
|
||||
await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload })
|
||||
|
||||
auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON()))
|
||||
|
||||
|
@ -211,7 +211,7 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
|
|||
async function processThumbnail (req: express.Request, video: VideoModel) {
|
||||
const thumbnailField = req.files ? req.files['thumbnailfile'] : undefined
|
||||
if (thumbnailField) {
|
||||
const thumbnailPhysicalFile = thumbnailField[ 0 ]
|
||||
const thumbnailPhysicalFile = thumbnailField[0]
|
||||
|
||||
return createVideoMiniatureFromExisting(thumbnailPhysicalFile.path, video, ThumbnailType.MINIATURE, false)
|
||||
}
|
||||
|
@ -231,12 +231,12 @@ async function processPreview (req: express.Request, video: VideoModel) {
|
|||
}
|
||||
|
||||
function insertIntoDB (parameters: {
|
||||
video: MVideoThumbnailAccountDefault,
|
||||
thumbnailModel: MThumbnail,
|
||||
previewModel: MThumbnail,
|
||||
videoChannel: MChannelAccountDefault,
|
||||
tags: string[],
|
||||
videoImportAttributes: Partial<MVideoImport>,
|
||||
video: MVideoThumbnailAccountDefault
|
||||
thumbnailModel: MThumbnail
|
||||
previewModel: MThumbnail
|
||||
videoChannel: MChannelAccountDefault
|
||||
tags: string[]
|
||||
videoImportAttributes: Partial<MVideoImport>
|
||||
user: MUser
|
||||
}): Bluebird<MVideoImportFormattable> {
|
||||
const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters
|
||||
|
|
|
@ -12,8 +12,7 @@ import {
|
|||
VIDEO_CATEGORIES,
|
||||
VIDEO_LANGUAGES,
|
||||
VIDEO_LICENCES,
|
||||
VIDEO_PRIVACIES,
|
||||
VIDEO_TRANSCODING_FPS
|
||||
VIDEO_PRIVACIES
|
||||
} from '../../../initializers/constants'
|
||||
import {
|
||||
changeVideoChannelShare,
|
||||
|
@ -308,7 +307,7 @@ async function addVideo (req: express.Request, res: express.Response) {
|
|||
}
|
||||
}
|
||||
|
||||
await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
|
||||
await JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput })
|
||||
}
|
||||
|
||||
Hooks.runAction('action:api.video.uploaded', { video: videoCreated })
|
||||
|
@ -453,7 +452,6 @@ async function getVideo (req: express.Request, res: express.Response) {
|
|||
|
||||
if (video.isOutdated()) {
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })
|
||||
.catch(err => logger.error('Cannot create AP refresher job for video %s.', video.url, { err }))
|
||||
}
|
||||
|
||||
return res.json(video.toFormattedDetailsJSON())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue