mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Update dependencies
This commit is contained in:
@@ -56,9 +56,9 @@ function inboxController (req: express.Request, res: express.Response) {
|
||||
const rootActivity: RootActivity = req.body
|
||||
let activities: Activity[]
|
||||
|
||||
if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) {
|
||||
if ([ 'Collection', 'CollectionPage' ].includes(rootActivity.type)) {
|
||||
activities = (rootActivity as ActivityPubCollection).items
|
||||
} else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].indexOf(rootActivity.type) !== -1) {
|
||||
} else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].includes(rootActivity.type)) {
|
||||
activities = (rootActivity as ActivityPubOrderedCollection<Activity>).orderedItems
|
||||
} else {
|
||||
activities = [ rootActivity as Activity ]
|
||||
|
||||
@@ -60,7 +60,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) {
|
||||
|
||||
// Handle strings like @toto@example.com
|
||||
if (parts.length === 3 && parts[0].length === 0) parts.shift()
|
||||
const isWebfingerSearch = parts.length === 2 && parts.every(p => p && p.indexOf(' ') === -1)
|
||||
const isWebfingerSearch = parts.length === 2 && parts.every(p => p && !p.includes(' '))
|
||||
|
||||
if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res)
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) {
|
||||
const locale = req.params.locale
|
||||
const file = req.params.file
|
||||
|
||||
if (is18nLocale(locale) && LOCALE_FILES.indexOf(file) !== -1) {
|
||||
if (is18nLocale(locale) && LOCALE_FILES.includes(file)) {
|
||||
const completeLocale = getCompleteLocale(locale)
|
||||
const completeFileLocale = buildFileLocale(completeLocale)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ function isActorPublicKeyValid (publicKey: string) {
|
||||
return exists(publicKey) &&
|
||||
typeof publicKey === 'string' &&
|
||||
publicKey.startsWith('-----BEGIN PUBLIC KEY-----') &&
|
||||
publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 &&
|
||||
publicKey.includes('-----END PUBLIC KEY-----') &&
|
||||
validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ function isActorPrivateKeyValid (privateKey: string) {
|
||||
typeof privateKey === 'string' &&
|
||||
privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
|
||||
// Sometimes there is a \n at the end, so just assert the string contains the end mark
|
||||
privateKey.indexOf('-----END RSA PRIVATE KEY-----') !== -1 &&
|
||||
privateKey.includes('-----END RSA PRIVATE KEY-----') &&
|
||||
validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,19 +84,19 @@ function sanitizeAndCheckVideoTorrentObject (video: any) {
|
||||
function isRemoteVideoUrlValid (url: any) {
|
||||
return url.type === 'Link' &&
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mediaType) !== -1 &&
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.includes(url.mediaType) &&
|
||||
isActivityPubUrlValid(url.href) &&
|
||||
validator.isInt(url.height + '', { min: 0 }) &&
|
||||
validator.isInt(url.size + '', { min: 0 }) &&
|
||||
(!url.fps || validator.isInt(url.fps + '', { min: -1 }))
|
||||
) ||
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mediaType) !== -1 &&
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.includes(url.mediaType) &&
|
||||
isActivityPubUrlValid(url.href) &&
|
||||
validator.isInt(url.height + '', { min: 0 })
|
||||
) ||
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mediaType) !== -1 &&
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.includes(url.mediaType) &&
|
||||
validator.isLength(url.href, { min: 5 }) &&
|
||||
validator.isInt(url.height + '', { min: 0 })
|
||||
) ||
|
||||
|
||||
@@ -13,7 +13,7 @@ function isValidRSSFeed (value: string) {
|
||||
'atom1'
|
||||
]
|
||||
|
||||
return feedExtensions.indexOf(value) !== -1
|
||||
return feedExtensions.includes(value)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -4,7 +4,7 @@ import { LogLevel } from '../../../shared/models/server/log-level.type'
|
||||
const logLevels: LogLevel[] = [ 'debug', 'info', 'warn', 'error' ]
|
||||
|
||||
function isValidLogLevel (value: any) {
|
||||
return exists(value) && logLevels.indexOf(value) !== -1
|
||||
return exists(value) && logLevels.includes(value)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -46,7 +46,7 @@ function isUserEmailVerifiedValid (value: any) {
|
||||
|
||||
const nsfwPolicies = values(NSFW_POLICY_TYPES)
|
||||
function isUserNSFWPolicyValid (value: any) {
|
||||
return exists(value) && nsfwPolicies.indexOf(value) !== -1
|
||||
return exists(value) && nsfwPolicies.includes(value)
|
||||
}
|
||||
|
||||
function isUserWebTorrentEnabledValid (value: any) {
|
||||
|
||||
@@ -73,7 +73,7 @@ function isVideoViewsValid (value: string) {
|
||||
}
|
||||
|
||||
function isVideoRatingTypeValid (value: string) {
|
||||
return value === 'none' || values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1
|
||||
return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType)
|
||||
}
|
||||
|
||||
function isVideoFileExtnameValid (value: string) {
|
||||
|
||||
@@ -257,7 +257,7 @@ function getTags (tags: any) {
|
||||
function getLicence (licence: string) {
|
||||
if (!licence) return undefined
|
||||
|
||||
if (licence.indexOf('Creative Commons Attribution') !== -1) return 1
|
||||
if (licence.includes('Creative Commons Attribution')) return 1
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ function checkConfig () {
|
||||
const defaultNSFWPolicy = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY
|
||||
{
|
||||
const available = [ 'do_not_list', 'blur', 'display' ]
|
||||
if (available.indexOf(defaultNSFWPolicy) === -1) {
|
||||
if (available.includes(defaultNSFWPolicy) === false) {
|
||||
return 'NSFW policy setting should be ' + available.join(' or ') + ' instead of ' + defaultNSFWPolicy
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ function checkConfig () {
|
||||
if (isArray(redundancyVideos)) {
|
||||
const available = [ 'most-views', 'trending', 'recently-added' ]
|
||||
for (const r of redundancyVideos) {
|
||||
if (available.indexOf(r.strategy) === -1) {
|
||||
if (available.includes(r.strategy) === false) {
|
||||
return 'Videos redundancy should have ' + available.join(' or ') + ' strategy instead of ' + r.strategy
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ export function reloadConfig () {
|
||||
|
||||
function purge () {
|
||||
for (const fileName in require.cache) {
|
||||
if (fileName.indexOf(directory()) === -1) {
|
||||
if (fileName.includes(directory()) === false) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Sequelize from 'sequelize'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Sequelize from 'sequelize'
|
||||
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { WEBSERVER } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { URL } from 'url'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { ActivityPubActor, ActivityPubActorType, ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
|
||||
import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
|
||||
import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
|
||||
import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor'
|
||||
@@ -207,7 +207,7 @@ async function fetchActorTotalItems (url: string) {
|
||||
}
|
||||
|
||||
try {
|
||||
const { body } = await doRequest(options)
|
||||
const { body } = await doRequest<ActivityPubOrderedCollection<unknown>>(options)
|
||||
return body.totalItems ? body.totalItems : 0
|
||||
} catch (err) {
|
||||
logger.warn('Cannot fetch remote actor count %s.', url, { err })
|
||||
|
||||
@@ -20,7 +20,9 @@ import { MAccountDefault, MAccountId, MVideoId } from '../../typings/models'
|
||||
import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist'
|
||||
|
||||
function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: MAccountId, to: string[]) {
|
||||
const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED
|
||||
const privacy = to.includes(ACTIVITY_PUB.PUBLIC)
|
||||
? VideoPlaylistPrivacy.PUBLIC
|
||||
: VideoPlaylistPrivacy.UNLISTED
|
||||
|
||||
return {
|
||||
name: playlistObject.name,
|
||||
@@ -205,7 +207,7 @@ async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusC
|
||||
|
||||
logger.info('Fetching remote playlist %s.', playlistUrl)
|
||||
|
||||
const { response, body } = await doRequest(options)
|
||||
const { response, body } = await doRequest<any>(options)
|
||||
|
||||
if (isPlaylistObjectValid(body) === false || checkUrlsSameHost(body.id, playlistUrl) !== true) {
|
||||
logger.debug('Remote video playlist JSON is not valid.', { body })
|
||||
|
||||
@@ -44,7 +44,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
|
||||
async function forwardVideoRelatedActivity (
|
||||
activity: Activity,
|
||||
t: Transaction,
|
||||
followersException: MActorWithInboxes[] = [],
|
||||
followersException: MActorWithInboxes[],
|
||||
video: MVideoId
|
||||
) {
|
||||
// Mastodon does not add our announces in audience, so we forward to them manually
|
||||
@@ -161,7 +161,7 @@ async function computeFollowerUris (toFollowersOf: MActorId[], actorsException:
|
||||
const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t)
|
||||
const sharedInboxesException = await buildSharedInboxesException(actorsException)
|
||||
|
||||
return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
|
||||
return result.data.filter(sharedInbox => sharedInboxesException.includes(sharedInbox) === false)
|
||||
}
|
||||
|
||||
async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) {
|
||||
@@ -174,7 +174,7 @@ async function computeUris (toActors: MActor[], actorsException: MActorWithInbox
|
||||
|
||||
const sharedInboxesException = await buildSharedInboxesException(actorsException)
|
||||
return Array.from(toActorSharedInboxesSet)
|
||||
.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
|
||||
.filter(sharedInbox => sharedInboxesException.includes(sharedInbox) === false)
|
||||
}
|
||||
|
||||
async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) {
|
||||
|
||||
@@ -111,7 +111,7 @@ async function fetchRemoteVideo (videoUrl: string): Promise<{ response: request.
|
||||
|
||||
logger.info('Fetching remote video %s.', videoUrl)
|
||||
|
||||
const { response, body } = await doRequest(options)
|
||||
const { response, body } = await doRequest<any>(options)
|
||||
|
||||
if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) {
|
||||
logger.debug('Remote video JSON is not valid.', { body })
|
||||
@@ -129,7 +129,7 @@ async function fetchRemoteVideoDescription (video: MVideoAccountLight) {
|
||||
json: true
|
||||
}
|
||||
|
||||
const { body } = await doRequest(options)
|
||||
const { body } = await doRequest<any>(options)
|
||||
return body.description ? body.description : ''
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ function isAPVideoUrlObject (url: any): url is ActivityVideoUrlObject {
|
||||
const mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
|
||||
|
||||
const urlMediaType = url.mediaType
|
||||
return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/')
|
||||
return mimeTypes.includes(urlMediaType) && urlMediaType.startsWith('video/')
|
||||
}
|
||||
|
||||
function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject {
|
||||
@@ -623,9 +623,11 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
|
||||
}
|
||||
|
||||
function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) {
|
||||
const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
|
||||
const duration = videoObject.duration.replace(/[^\d]+/, '')
|
||||
const privacy = to.includes(ACTIVITY_PUB.PUBLIC)
|
||||
? VideoPrivacy.PUBLIC
|
||||
: VideoPrivacy.UNLISTED
|
||||
|
||||
const duration = videoObject.duration.replace(/[^\d]+/, '')
|
||||
const language = videoObject.language?.identifier
|
||||
|
||||
const category = videoObject.category
|
||||
|
||||
@@ -5,7 +5,7 @@ import { updateActorAvatarInstance } from './activitypub'
|
||||
import { processImage } from '../helpers/image-utils'
|
||||
import { extname, join } from 'path'
|
||||
import { retryTransactionWrapper } from '../helpers/database-utils'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { sequelizeTypescript } from '../initializers/database'
|
||||
import * as LRUCache from 'lru-cache'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { ActivityPubActorType } from '../../shared/models/activitypub'
|
||||
import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
|
||||
import { AccountModel } from '../models/account/account'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Sequelize from 'sequelize'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { VideoChannelCreate } from '../../shared/models'
|
||||
import { VideoChannelModel } from '../models/video/video-channel'
|
||||
import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub'
|
||||
|
||||
@@ -38,7 +38,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
|
||||
|
||||
function executeIfActivityPub (req: Request, res: Response, next: NextFunction) {
|
||||
const accepted = req.accepts(ACCEPT_HEADERS)
|
||||
if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
|
||||
if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.includes(accepted) === false) {
|
||||
// Bypass this route
|
||||
return next('route')
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ import { addUserSubscription, removeUserSubscription } from '../../../../shared/
|
||||
import { VideoPrivacy } from '../../../../shared/models/videos'
|
||||
import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
|
||||
import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist'
|
||||
import { CustomConfig } from '../../../../shared/models/server'
|
||||
import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('Test tracker', function () {
|
||||
torrent.on('error', done)
|
||||
torrent.on('warning', warn => {
|
||||
const message = typeof warn === 'string' ? warn : warn.message
|
||||
if (message.indexOf('Unknown infoHash ') !== -1) return done()
|
||||
if (message.includes('Unknown infoHash ')) return done()
|
||||
})
|
||||
|
||||
torrent.on('done', () => done(new Error('No error on infohash')))
|
||||
@@ -64,7 +64,7 @@ describe('Test tracker', function () {
|
||||
torrent.on('error', done)
|
||||
torrent.on('warning', warn => {
|
||||
const message = typeof warn === 'string' ? warn : warn.message
|
||||
if (message.indexOf('Unknown infoHash ') !== -1) return done(new Error('Error on infohash'))
|
||||
if (message.includes('Unknown infoHash ')) return done(new Error('Error on infohash'))
|
||||
})
|
||||
|
||||
torrent.on('done', done)
|
||||
@@ -83,7 +83,7 @@ describe('Test tracker', function () {
|
||||
torrent.on('error', done)
|
||||
torrent.on('warning', warn => {
|
||||
const message = typeof warn === 'string' ? warn : warn.message
|
||||
if (message.indexOf('disabled ') !== -1) return done()
|
||||
if (message.includes('disabled ')) return done()
|
||||
})
|
||||
|
||||
torrent.on('done', () => done(new Error('Tracker is enabled')))
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
} from '../../../shared/extra-utils'
|
||||
import { Account, VideoPlaylistPrivacy } from '../../../shared/models'
|
||||
import { createFile, readdir } from 'fs-extra'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { join } from 'path'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
@@ -133,7 +133,7 @@ program
|
||||
.description('set an existing entry as default')
|
||||
.action(async url => {
|
||||
const settings = await getSettings()
|
||||
const instanceExists = settings.remotes.indexOf(url) !== -1
|
||||
const instanceExists = settings.remotes.includes(url)
|
||||
|
||||
if (instanceExists) {
|
||||
settings.default = settings.remotes.indexOf(url)
|
||||
|
||||
@@ -274,7 +274,7 @@ async function getCategory (categories: string[], url: string) {
|
||||
function getLicence (licence: string) {
|
||||
if (!licence) return undefined
|
||||
|
||||
if (licence.indexOf('Creative Commons Attribution licence') !== -1) return 1
|
||||
if (licence.includes('Creative Commons Attribution licence')) return 1
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
|
||||
import * as repl from 'repl'
|
||||
import * as path from 'path'
|
||||
import * as _ from 'lodash'
|
||||
import * as uuidv1 from 'uuid/v1'
|
||||
import * as uuidv3 from 'uuid/v3'
|
||||
import * as uuidv4 from 'uuid/v4'
|
||||
import * as uuidv5 from 'uuid/v5'
|
||||
import { uuidv1, uuidv3, uuidv4, uuidv5 } from 'uuid'
|
||||
import * as Sequelize from 'sequelize'
|
||||
import * as YoutubeDL from 'youtube-dl'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user