mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-10-27 14:39:32 +03:00
Fix server lint
This commit is contained in:
parent
4638cd713d
commit
99b757488c
@ -4,6 +4,7 @@ import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
|
|||||||
import { Hooks } from '@server/lib/plugins/hooks'
|
import { Hooks } from '@server/lib/plugins/hooks'
|
||||||
import { getServerActor } from '@server/models/application/application'
|
import { getServerActor } from '@server/models/application/application'
|
||||||
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
|
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
|
||||||
|
import { forceNumber } from '@shared/core-utils'
|
||||||
import { uuidToShort } from '@shared/extra-utils'
|
import { uuidToShort } from '@shared/extra-utils'
|
||||||
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
|
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
|
||||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||||
@ -46,7 +47,6 @@ import {
|
|||||||
import { AccountModel } from '../../models/account/account'
|
import { AccountModel } from '../../models/account/account'
|
||||||
import { VideoPlaylistModel } from '../../models/video/video-playlist'
|
import { VideoPlaylistModel } from '../../models/video/video-playlist'
|
||||||
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
|
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
|
||||||
import { forceNumber } from '@shared/core-utils'
|
|
||||||
|
|
||||||
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)
|
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)
|
||||||
|
|
||||||
@ -425,7 +425,13 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
|
|||||||
|
|
||||||
const endOldPosition = oldPosition + reorderLength - 1
|
const endOldPosition = oldPosition + reorderLength - 1
|
||||||
// Insert our reordered elements in their place (update)
|
// Insert our reordered elements in their place (update)
|
||||||
await VideoPlaylistElementModel.reassignPositionOf({ videoPlaylistId: videoPlaylist.id, firstPosition: oldPosition, endPosition: endOldPosition, newPosition, transaction: t })
|
await VideoPlaylistElementModel.reassignPositionOf({
|
||||||
|
videoPlaylistId: videoPlaylist.id,
|
||||||
|
firstPosition: oldPosition,
|
||||||
|
endPosition: endOldPosition,
|
||||||
|
newPosition,
|
||||||
|
transaction: t
|
||||||
|
})
|
||||||
|
|
||||||
// Decrease positions of elements after the old position of our ordered elements (decrease)
|
// Decrease positions of elements after the old position of our ordered elements (decrease)
|
||||||
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, -reorderLength, t)
|
await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, -reorderLength, t)
|
||||||
|
@ -86,7 +86,7 @@ function isFileValid (options: {
|
|||||||
|
|
||||||
// The file exists
|
// The file exists
|
||||||
const file = fileArray[0]
|
const file = fileArray[0]
|
||||||
if (!file || !file.originalname) return false
|
if (!file?.originalname) return false
|
||||||
|
|
||||||
// Check size
|
// Check size
|
||||||
if ((maxSize !== null) && file.size > maxSize) return false
|
if ((maxSize !== null) && file.size > maxSize) return false
|
||||||
|
@ -38,7 +38,7 @@ function getFFmpegVersion () {
|
|||||||
return execPromise(`${ffmpegPath} -version`)
|
return execPromise(`${ffmpegPath} -version`)
|
||||||
.then(stdout => {
|
.then(stdout => {
|
||||||
const parsed = stdout.match(/ffmpeg version .?(\d+\.\d+(\.\d+)?)/)
|
const parsed = stdout.match(/ffmpeg version .?(\d+\.\d+(\.\d+)?)/)
|
||||||
if (!parsed || !parsed[1]) return rej(new Error(`Could not find ffmpeg version in ${stdout}`))
|
if (!parsed?.[1]) return rej(new Error(`Could not find ffmpeg version in ${stdout}`))
|
||||||
|
|
||||||
// Fix ffmpeg version that does not include patch version (4.4 for example)
|
// Fix ffmpeg version that does not include patch version (4.4 for example)
|
||||||
let version = parsed[1]
|
let version = parsed[1]
|
||||||
|
@ -77,7 +77,7 @@ class YoutubeDLWrapper {
|
|||||||
|
|
||||||
const subtitles = files.reduce((acc, filename) => {
|
const subtitles = files.reduce((acc, filename) => {
|
||||||
const matched = filename.match(/\.([a-z]{2})(-[a-z]+)?\.(vtt|ttml)/i)
|
const matched = filename.match(/\.([a-z]{2})(-[a-z]+)?\.(vtt|ttml)/i)
|
||||||
if (!matched || !matched[1]) return acc
|
if (!matched?.[1]) return acc
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...acc,
|
...acc,
|
||||||
|
@ -711,7 +711,7 @@ const PREVIEWS_SIZE = {
|
|||||||
height: 480,
|
height: 480,
|
||||||
minWidth: 400
|
minWidth: 400
|
||||||
}
|
}
|
||||||
const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[]} = {
|
const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[] } = {
|
||||||
[ActorImageType.AVATAR]: [
|
[ActorImageType.AVATAR]: [
|
||||||
{
|
{
|
||||||
width: 120,
|
width: 120,
|
||||||
|
@ -57,7 +57,7 @@ export {
|
|||||||
|
|
||||||
async function addVideoShare (shareUrl: string, video: MVideoId) {
|
async function addVideoShare (shareUrl: string, video: MVideoId) {
|
||||||
const { body } = await doJSONRequest<any>(shareUrl, { activityPub: true })
|
const { body } = await doJSONRequest<any>(shareUrl, { activityPub: true })
|
||||||
if (!body || !body.actor) throw new Error('Body or body actor is invalid')
|
if (!body?.actor) throw new Error('Body or body actor is invalid')
|
||||||
|
|
||||||
const actorUrl = getAPId(body.actor)
|
const actorUrl = getAPId(body.actor)
|
||||||
if (checkUrlsSameHost(shareUrl, actorUrl) !== true) {
|
if (checkUrlsSameHost(shareUrl, actorUrl) !== true) {
|
||||||
|
@ -88,7 +88,7 @@ async function updateObjectIfNeeded <T> (options: {
|
|||||||
const { body } = await doJSONRequest<any>(url, { activityPub: true })
|
const { body } = await doJSONRequest<any>(url, { activityPub: true })
|
||||||
|
|
||||||
// If not same id, check same host and update
|
// If not same id, check same host and update
|
||||||
if (!body || !body.id || !bodyValidator(body)) throw new Error(`Body or body id of ${url} is invalid`)
|
if (!body?.id || !bodyValidator(body)) throw new Error(`Body or body id of ${url} is invalid`)
|
||||||
|
|
||||||
if (body.type === 'Tombstone') {
|
if (body.type === 'Tombstone') {
|
||||||
return on404OrTombstone()
|
return on404OrTombstone()
|
||||||
|
@ -107,7 +107,7 @@ async function processYoutubeDLImport (job: Job, videoImport: MVideoImportDefaul
|
|||||||
|
|
||||||
async function getVideoImportOrDie (payload: VideoImportPayload) {
|
async function getVideoImportOrDie (payload: VideoImportPayload) {
|
||||||
const videoImport = await VideoImportModel.loadAndPopulateVideo(payload.videoImportId)
|
const videoImport = await VideoImportModel.loadAndPopulateVideo(payload.videoImportId)
|
||||||
if (!videoImport || !videoImport.Video) {
|
if (!videoImport?.Video) {
|
||||||
throw new Error(`Cannot import video ${payload.videoImportId}: the video import or video linked to this import does not exist anymore.`)
|
throw new Error(`Cannot import video ${payload.videoImportId}: the video import or video linked to this import does not exist anymore.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ async function createAbuse (options: {
|
|||||||
base: FilteredModelAttributes<AbuseModel>
|
base: FilteredModelAttributes<AbuseModel>
|
||||||
reporterAccount: MAccountDefault
|
reporterAccount: MAccountDefault
|
||||||
flaggedAccount: MAccountLight
|
flaggedAccount: MAccountLight
|
||||||
associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} >
|
associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean }>
|
||||||
skipNotification: boolean
|
skipNotification: boolean
|
||||||
transaction: Transaction
|
transaction: Transaction
|
||||||
}) {
|
}) {
|
||||||
|
@ -33,7 +33,7 @@ export class PluginsCheckScheduler extends AbstractScheduler {
|
|||||||
const chunks = chunk(plugins, 10)
|
const chunks = chunk(plugins, 10)
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
// Find plugins according to their npm name
|
// Find plugins according to their npm name
|
||||||
const pluginIndex: { [npmName: string]: PluginModel} = {}
|
const pluginIndex: { [npmName: string]: PluginModel } = {}
|
||||||
for (const plugin of chunk) {
|
for (const plugin of chunk) {
|
||||||
pluginIndex[PluginModel.buildNpmName(plugin.name, plugin.type)] = plugin
|
pluginIndex[PluginModel.buildNpmName(plugin.name, plugin.type)] = plugin
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ async function checkJsonLDSignature (req: Request, res: Response) {
|
|||||||
return wrapWithSpanAndContext('peertube.activitypub.JSONLDSignature', async () => {
|
return wrapWithSpanAndContext('peertube.activitypub.JSONLDSignature', async () => {
|
||||||
const signatureObject: ActivityPubSignature = req.body.signature
|
const signatureObject: ActivityPubSignature = req.body.signature
|
||||||
|
|
||||||
if (!signatureObject || !signatureObject.creator) {
|
if (!signatureObject?.creator) {
|
||||||
res.fail({
|
res.fail({
|
||||||
status: HttpStatusCode.FORBIDDEN_403,
|
status: HttpStatusCode.FORBIDDEN_403,
|
||||||
message: 'Object and creator signature do not match'
|
message: 'Object and creator signature do not match'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { arrayify } from '@shared/core-utils'
|
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { body, param, query } from 'express-validator'
|
import { body, param, query } from 'express-validator'
|
||||||
|
import { arrayify } from '@shared/core-utils'
|
||||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||||
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||||
import { WEBSERVER } from '../../initializers/constants'
|
import { WEBSERVER } from '../../initializers/constants'
|
||||||
@ -60,7 +60,7 @@ const userSubscriptionGetValidator = [
|
|||||||
state: 'accepted'
|
state: 'accepted'
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!subscription || !subscription.ActorFollowing.VideoChannel) {
|
if (!subscription?.ActorFollowing.VideoChannel) {
|
||||||
return res.fail({
|
return res.fail({
|
||||||
status: HttpStatusCode.NOT_FOUND_404,
|
status: HttpStatusCode.NOT_FOUND_404,
|
||||||
message: `Subscription ${req.params.uri} not found.`
|
message: `Subscription ${req.params.uri} not found.`
|
||||||
|
@ -436,7 +436,7 @@ export class AbuseModel extends Model<Partial<AttributesOnly<AbuseModel>>> {
|
|||||||
|
|
||||||
buildBaseVideoCommentAbuse (this: MAbuseUserFormattable) {
|
buildBaseVideoCommentAbuse (this: MAbuseUserFormattable) {
|
||||||
// Associated video comment could have been destroyed if the video has been deleted
|
// Associated video comment could have been destroyed if the video has been deleted
|
||||||
if (!this.VideoCommentAbuse || !this.VideoCommentAbuse.VideoComment) return null
|
if (!this.VideoCommentAbuse?.VideoComment) return null
|
||||||
|
|
||||||
const entity = this.VideoCommentAbuse.VideoComment
|
const entity = this.VideoCommentAbuse.VideoComment
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export class PluginModel extends Model<Partial<AttributesOnly<PluginModel>>> {
|
|||||||
|
|
||||||
return PluginModel.findOne(query)
|
return PluginModel.findOne(query)
|
||||||
.then(p => {
|
.then(p => {
|
||||||
if (!p || !p.settings || p.settings === undefined) {
|
if (!p?.settings || p.settings === undefined) {
|
||||||
const registered = registeredSettings.find(s => s.name === settingName)
|
const registered = registeredSettings.find(s => s.name === settingName)
|
||||||
if (!registered || registered.default === undefined) return undefined
|
if (!registered || registered.default === undefined) return undefined
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ export class PluginModel extends Model<Partial<AttributesOnly<PluginModel>>> {
|
|||||||
const result: SettingEntries = {}
|
const result: SettingEntries = {}
|
||||||
|
|
||||||
for (const name of settingNames) {
|
for (const name of settingNames) {
|
||||||
if (!p || !p.settings || p.settings[name] === undefined) {
|
if (!p?.settings || p.settings[name] === undefined) {
|
||||||
const registered = registeredSettings.find(s => s.name === name)
|
const registered = registeredSettings.find(s => s.name === name)
|
||||||
|
|
||||||
if (registered?.default !== undefined) {
|
if (registered?.default !== undefined) {
|
||||||
|
@ -58,7 +58,7 @@ export type VideoFormattingJSONOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSanitize): VideoFormattingJSONOptions {
|
function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSanitize): VideoFormattingJSONOptions {
|
||||||
if (!query || !query.include) return {}
|
if (!query?.include) return {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
additionalAttributes: {
|
additionalAttributes: {
|
||||||
|
@ -302,7 +302,7 @@ export class AbstractVideoQueryBuilder extends AbstractRunQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected buildAttributesObject (prefixKey: string, attributeKeys: string[]) {
|
protected buildAttributesObject (prefixKey: string, attributeKeys: string[]) {
|
||||||
const result: { [id: string]: string} = {}
|
const result: { [id: string]: string } = {}
|
||||||
|
|
||||||
const prefixValue = prefixKey.replace(/->/g, '.')
|
const prefixValue = prefixKey.replace(/->/g, '.')
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ describe('Fast restream in live', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Should correctly fast reastream in a permanent live with and without save replay', async function () {
|
it('Should correctly fast reastream in a permanent live with and without save replay', async function () {
|
||||||
this.timeout(240000)
|
this.timeout(480000)
|
||||||
|
|
||||||
// A test can take a long time, so prefer to run them in parallel
|
// A test can take a long time, so prefer to run them in parallel
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -82,7 +82,7 @@ export function isDefaultLocale (locale: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
|
export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
|
||||||
if (!translations || !translations[str]) return str
|
if (!translations?.[str]) return str
|
||||||
|
|
||||||
return translations[str]
|
return translations[str]
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ export class PeerTubeServer {
|
|||||||
|
|
||||||
const onPeerTubeExit = () => rej(new Error('Process exited:\n' + aggregatedLogs))
|
const onPeerTubeExit = () => rej(new Error('Process exited:\n' + aggregatedLogs))
|
||||||
const onParentExit = () => {
|
const onParentExit = () => {
|
||||||
if (!this.app || !this.app.pid) return
|
if (!this.app?.pid) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.kill(self.app.pid)
|
process.kill(self.app.pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user