Update dependencies

This commit is contained in:
Chocobozzz 2020-02-28 16:03:39 +01:00
parent 9d94e5d7b9
commit bdd428a6d9
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
33 changed files with 347 additions and 343 deletions

View File

@ -63,11 +63,13 @@
"allowNumber": "true" "allowNumber": "true"
} }
], ],
"@typescript-eslint/quotes": "off", "@typescript-eslint/quotes": "off",
"@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/promise-function-async": "off", "@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/no-dynamic-delete": "off", "@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
"@typescript-eslint/strict-boolean-expressions": "off", "@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/no-misused-promises": "off", "@typescript-eslint/no-misused-promises": "off",

View File

@ -82,7 +82,7 @@
"apicache": "^1.4.0", "apicache": "^1.4.0",
"async": "^3.0.1", "async": "^3.0.1",
"async-lru": "^1.1.1", "async-lru": "^1.1.1",
"bcrypt": "3.0.7", "bcrypt": "4.0.0",
"bittorrent-tracker": "^9.0.0", "bittorrent-tracker": "^9.0.0",
"bluebird": "^3.5.0", "bluebird": "^3.5.0",
"body-parser": "^1.12.4", "body-parser": "^1.12.4",
@ -102,7 +102,7 @@
"fluent-ffmpeg": "^2.1.0", "fluent-ffmpeg": "^2.1.0",
"fs-extra": "^8.0.1", "fs-extra": "^8.0.1",
"helmet": "^3.12.1", "helmet": "^3.12.1",
"http-signature": "1.3.1", "http-signature": "1.3.2",
"ip-anonymize": "^0.1.0", "ip-anonymize": "^0.1.0",
"ipaddr.js": "1.9.1", "ipaddr.js": "1.9.1",
"is-cidr": "^3.0.0", "is-cidr": "^3.0.0",
@ -122,11 +122,11 @@
"pfeed": "1.1.11", "pfeed": "1.1.11",
"pg": "^7.4.1", "pg": "^7.4.1",
"prompt": "^1.0.0", "prompt": "^1.0.0",
"redis": "^2.8.0", "redis": "^3.0.2",
"reflect-metadata": "^0.1.12", "reflect-metadata": "^0.1.12",
"request": "^2.81.0", "request": "^2.81.0",
"scripty": "^1.5.0", "scripty": "^1.5.0",
"sequelize": "5.21.3", "sequelize": "5.21.5",
"sequelize-typescript": "^1.0.0-beta.4", "sequelize-typescript": "^1.0.0-beta.4",
"sharp": "^0.24.0", "sharp": "^0.24.0",
"sitemap": "^5.0.0", "sitemap": "^5.0.0",
@ -134,7 +134,7 @@
"srt-to-vtt": "^1.1.2", "srt-to-vtt": "^1.1.2",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"useragent": "^2.3.0", "useragent": "^2.3.0",
"uuid": "^3.1.0", "uuid": "^7.0.1",
"validator": "^12.1.0", "validator": "^12.1.0",
"webfinger.js": "^2.6.6", "webfinger.js": "^2.6.6",
"webtorrent": "^0.107.16", "webtorrent": "^0.107.16",
@ -150,14 +150,14 @@
"@types/bcrypt": "^3.0.0", "@types/bcrypt": "^3.0.0",
"@types/bluebird": "3.5.29", "@types/bluebird": "3.5.29",
"@types/body-parser": "^1.16.3", "@types/body-parser": "^1.16.3",
"@types/bull": "3.12.0", "@types/bull": "3.12.1",
"@types/bytes": "^3.0.0", "@types/bytes": "^3.0.0",
"@types/chai": "^4.0.4", "@types/chai": "^4.0.4",
"@types/chai-json-schema": "^1.4.3", "@types/chai-json-schema": "^1.4.3",
"@types/chai-xml": "^0.3.1", "@types/chai-xml": "^0.3.1",
"@types/config": "^0.0.36", "@types/config": "^0.0.36",
"@types/express": "^4.0.35", "@types/express": "^4.0.35",
"@types/express-rate-limit": "^3.3.0", "@types/express-rate-limit": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.8", "@types/fluent-ffmpeg": "^2.1.8",
"@types/fs-extra": "^8.0.0", "@types/fs-extra": "^8.0.0",
"@types/libxmljs": "^0.18.0", "@types/libxmljs": "^0.18.0",
@ -166,7 +166,7 @@
"@types/magnet-uri": "^5.1.1", "@types/magnet-uri": "^5.1.1",
"@types/maildev": "^0.0.1", "@types/maildev": "^0.0.1",
"@types/memoizee": "^0.4.2", "@types/memoizee": "^0.4.2",
"@types/mkdirp": "^0.5.1", "@types/mkdirp": "^1.0.0",
"@types/mocha": "^7.0.1", "@types/mocha": "^7.0.1",
"@types/morgan": "^1.7.32", "@types/morgan": "^1.7.32",
"@types/multer": "^1.3.3", "@types/multer": "^1.3.3",
@ -188,7 +188,7 @@
"chai-xml": "^0.3.2", "chai-xml": "^0.3.2",
"concurrently": "^5.0.0", "concurrently": "^5.0.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-standard-with-typescript": "^12.0.1", "eslint-config-standard-with-typescript": "^14.0.0",
"eslint-plugin-import": "^2.20.1", "eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0", "eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",

View File

@ -56,9 +56,9 @@ function inboxController (req: express.Request, res: express.Response) {
const rootActivity: RootActivity = req.body const rootActivity: RootActivity = req.body
let activities: Activity[] let activities: Activity[]
if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) { if ([ 'Collection', 'CollectionPage' ].includes(rootActivity.type)) {
activities = (rootActivity as ActivityPubCollection).items 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 activities = (rootActivity as ActivityPubOrderedCollection<Activity>).orderedItems
} else { } else {
activities = [ rootActivity as Activity ] activities = [ rootActivity as Activity ]

View File

@ -60,7 +60,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) {
// Handle strings like @toto@example.com // Handle strings like @toto@example.com
if (parts.length === 3 && parts[0].length === 0) parts.shift() 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) if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res)

View File

@ -76,7 +76,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) {
const locale = req.params.locale const locale = req.params.locale
const file = req.params.file 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 completeLocale = getCompleteLocale(locale)
const completeFileLocale = buildFileLocale(completeLocale) const completeFileLocale = buildFileLocale(completeLocale)

View File

@ -28,7 +28,7 @@ function isActorPublicKeyValid (publicKey: string) {
return exists(publicKey) && return exists(publicKey) &&
typeof publicKey === 'string' && typeof publicKey === 'string' &&
publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && publicKey.startsWith('-----BEGIN PUBLIC KEY-----') &&
publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 && publicKey.includes('-----END PUBLIC KEY-----') &&
validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY)
} }
@ -43,7 +43,7 @@ function isActorPrivateKeyValid (privateKey: string) {
typeof privateKey === 'string' && typeof privateKey === 'string' &&
privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') && privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
// Sometimes there is a \n at the end, so just assert the string contains the end mark // 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) validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
} }

View File

@ -84,19 +84,19 @@ function sanitizeAndCheckVideoTorrentObject (video: any) {
function isRemoteVideoUrlValid (url: any) { function isRemoteVideoUrlValid (url: any) {
return url.type === 'Link' && 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) && isActivityPubUrlValid(url.href) &&
validator.isInt(url.height + '', { min: 0 }) && validator.isInt(url.height + '', { min: 0 }) &&
validator.isInt(url.size + '', { min: 0 }) && validator.isInt(url.size + '', { min: 0 }) &&
(!url.fps || validator.isInt(url.fps + '', { min: -1 })) (!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) && isActivityPubUrlValid(url.href) &&
validator.isInt(url.height + '', { min: 0 }) 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.isLength(url.href, { min: 5 }) &&
validator.isInt(url.height + '', { min: 0 }) validator.isInt(url.height + '', { min: 0 })
) || ) ||

View File

@ -13,7 +13,7 @@ function isValidRSSFeed (value: string) {
'atom1' 'atom1'
] ]
return feedExtensions.indexOf(value) !== -1 return feedExtensions.includes(value)
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@ import { LogLevel } from '../../../shared/models/server/log-level.type'
const logLevels: LogLevel[] = [ 'debug', 'info', 'warn', 'error' ] const logLevels: LogLevel[] = [ 'debug', 'info', 'warn', 'error' ]
function isValidLogLevel (value: any) { function isValidLogLevel (value: any) {
return exists(value) && logLevels.indexOf(value) !== -1 return exists(value) && logLevels.includes(value)
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ function isUserEmailVerifiedValid (value: any) {
const nsfwPolicies = values(NSFW_POLICY_TYPES) const nsfwPolicies = values(NSFW_POLICY_TYPES)
function isUserNSFWPolicyValid (value: any) { function isUserNSFWPolicyValid (value: any) {
return exists(value) && nsfwPolicies.indexOf(value) !== -1 return exists(value) && nsfwPolicies.includes(value)
} }
function isUserWebTorrentEnabledValid (value: any) { function isUserWebTorrentEnabledValid (value: any) {

View File

@ -73,7 +73,7 @@ function isVideoViewsValid (value: string) {
} }
function isVideoRatingTypeValid (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) { function isVideoFileExtnameValid (value: string) {

View File

@ -257,7 +257,7 @@ function getTags (tags: any) {
function getLicence (licence: string) { function getLicence (licence: string) {
if (!licence) return undefined if (!licence) return undefined
if (licence.indexOf('Creative Commons Attribution') !== -1) return 1 if (licence.includes('Creative Commons Attribution')) return 1
return undefined return undefined
} }

View File

@ -54,7 +54,7 @@ function checkConfig () {
const defaultNSFWPolicy = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY const defaultNSFWPolicy = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY
{ {
const available = [ 'do_not_list', 'blur', 'display' ] 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 return 'NSFW policy setting should be ' + available.join(' or ') + ' instead of ' + defaultNSFWPolicy
} }
} }
@ -64,7 +64,7 @@ function checkConfig () {
if (isArray(redundancyVideos)) { if (isArray(redundancyVideos)) {
const available = [ 'most-views', 'trending', 'recently-added' ] const available = [ 'most-views', 'trending', 'recently-added' ]
for (const r of redundancyVideos) { 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 return 'Videos redundancy should have ' + available.join(' or ') + ' strategy instead of ' + r.strategy
} }

View File

@ -335,7 +335,7 @@ export function reloadConfig () {
function purge () { function purge () {
for (const fileName in require.cache) { for (const fileName in require.cache) {
if (fileName.indexOf(directory()) === -1) { if (fileName.includes(directory()) === false) {
continue continue
} }

View File

@ -1,5 +1,5 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
async function up (utils: { async function up (utils: {
transaction: Sequelize.Transaction transaction: Sequelize.Transaction

View File

@ -1,6 +1,6 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { WEBSERVER } from '../constants' import { WEBSERVER } from '../constants'
async function up (utils: { async function up (utils: {

View File

@ -1,8 +1,8 @@
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import { Transaction } from 'sequelize' import { Transaction } from 'sequelize'
import { URL } from 'url' import { URL } from 'url'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' import { ActivityPubActor, ActivityPubActorType, ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor' import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor'
@ -207,7 +207,7 @@ async function fetchActorTotalItems (url: string) {
} }
try { try {
const { body } = await doRequest(options) const { body } = await doRequest<ActivityPubOrderedCollection<unknown>>(options)
return body.totalItems ? body.totalItems : 0 return body.totalItems ? body.totalItems : 0
} catch (err) { } catch (err) {
logger.warn('Cannot fetch remote actor count %s.', url, { err }) logger.warn('Cannot fetch remote actor count %s.', url, { err })

View File

@ -20,7 +20,9 @@ import { MAccountDefault, MAccountId, MVideoId } from '../../typings/models'
import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist' import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist'
function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: MAccountId, to: string[]) { 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 { return {
name: playlistObject.name, name: playlistObject.name,
@ -205,7 +207,7 @@ async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusC
logger.info('Fetching remote playlist %s.', playlistUrl) 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) { if (isPlaylistObjectValid(body) === false || checkUrlsSameHost(body.id, playlistUrl) !== true) {
logger.debug('Remote video playlist JSON is not valid.', { body }) logger.debug('Remote video playlist JSON is not valid.', { body })

View File

@ -44,7 +44,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
async function forwardVideoRelatedActivity ( async function forwardVideoRelatedActivity (
activity: Activity, activity: Activity,
t: Transaction, t: Transaction,
followersException: MActorWithInboxes[] = [], followersException: MActorWithInboxes[],
video: MVideoId video: MVideoId
) { ) {
// Mastodon does not add our announces in audience, so we forward to them manually // 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 result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t)
const sharedInboxesException = await buildSharedInboxesException(actorsException) 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[] = []) { async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) {
@ -174,7 +174,7 @@ async function computeUris (toActors: MActor[], actorsException: MActorWithInbox
const sharedInboxesException = await buildSharedInboxesException(actorsException) const sharedInboxesException = await buildSharedInboxesException(actorsException)
return Array.from(toActorSharedInboxesSet) return Array.from(toActorSharedInboxesSet)
.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) .filter(sharedInbox => sharedInboxesException.includes(sharedInbox) === false)
} }
async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) { async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) {

View File

@ -111,7 +111,7 @@ async function fetchRemoteVideo (videoUrl: string): Promise<{ response: request.
logger.info('Fetching remote video %s.', videoUrl) 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) { if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) {
logger.debug('Remote video JSON is not valid.', { body }) logger.debug('Remote video JSON is not valid.', { body })
@ -129,7 +129,7 @@ async function fetchRemoteVideoDescription (video: MVideoAccountLight) {
json: true json: true
} }
const { body } = await doRequest(options) const { body } = await doRequest<any>(options)
return body.description ? body.description : '' 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 mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
const urlMediaType = url.mediaType 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 { 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[] = []) { function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) {
const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED const privacy = to.includes(ACTIVITY_PUB.PUBLIC)
const duration = videoObject.duration.replace(/[^\d]+/, '') ? VideoPrivacy.PUBLIC
: VideoPrivacy.UNLISTED
const duration = videoObject.duration.replace(/[^\d]+/, '')
const language = videoObject.language?.identifier const language = videoObject.language?.identifier
const category = videoObject.category const category = videoObject.category

View File

@ -5,7 +5,7 @@ import { updateActorAvatarInstance } from './activitypub'
import { processImage } from '../helpers/image-utils' import { processImage } from '../helpers/image-utils'
import { extname, join } from 'path' import { extname, join } from 'path'
import { retryTransactionWrapper } from '../helpers/database-utils' import { retryTransactionWrapper } from '../helpers/database-utils'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { CONFIG } from '../initializers/config' import { CONFIG } from '../initializers/config'
import { sequelizeTypescript } from '../initializers/database' import { sequelizeTypescript } from '../initializers/database'
import * as LRUCache from 'lru-cache' import * as LRUCache from 'lru-cache'

View File

@ -1,4 +1,4 @@
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { ActivityPubActorType } from '../../shared/models/activitypub' import { ActivityPubActorType } from '../../shared/models/activitypub'
import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
import { AccountModel } from '../models/account/account' import { AccountModel } from '../models/account/account'

View File

@ -1,5 +1,5 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { VideoChannelCreate } from '../../shared/models' import { VideoChannelCreate } from '../../shared/models'
import { VideoChannelModel } from '../models/video/video-channel' import { VideoChannelModel } from '../models/video/video-channel'
import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub' import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub'

View File

@ -38,7 +38,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
function executeIfActivityPub (req: Request, res: Response, next: NextFunction) { function executeIfActivityPub (req: Request, res: Response, next: NextFunction) {
const accepted = req.accepts(ACCEPT_HEADERS) 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 // Bypass this route
return next('route') return next('route')
} }

View File

@ -63,7 +63,7 @@ import { addUserSubscription, removeUserSubscription } from '../../../../shared/
import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoPrivacy } from '../../../../shared/models/videos'
import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' 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 { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist'
import { CustomConfig } from '../../../../shared/models/server' import { CustomConfig } from '../../../../shared/models/server'
import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'

View File

@ -49,7 +49,7 @@ describe('Test tracker', function () {
torrent.on('error', done) torrent.on('error', done)
torrent.on('warning', warn => { torrent.on('warning', warn => {
const message = typeof warn === 'string' ? warn : warn.message 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'))) torrent.on('done', () => done(new Error('No error on infohash')))
@ -64,7 +64,7 @@ describe('Test tracker', function () {
torrent.on('error', done) torrent.on('error', done)
torrent.on('warning', warn => { torrent.on('warning', warn => {
const message = typeof warn === 'string' ? warn : warn.message 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) torrent.on('done', done)
@ -83,7 +83,7 @@ describe('Test tracker', function () {
torrent.on('error', done) torrent.on('error', done)
torrent.on('warning', warn => { torrent.on('warning', warn => {
const message = typeof warn === 'string' ? warn : warn.message 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'))) torrent.on('done', () => done(new Error('Tracker is enabled')))

View File

@ -22,7 +22,7 @@ import {
} from '../../../shared/extra-utils' } from '../../../shared/extra-utils'
import { Account, VideoPlaylistPrivacy } from '../../../shared/models' import { Account, VideoPlaylistPrivacy } from '../../../shared/models'
import { createFile, readdir } from 'fs-extra' import { createFile, readdir } from 'fs-extra'
import * as uuidv4 from 'uuid/v4' import { v4 as uuidv4 } from 'uuid'
import { join } from 'path' import { join } from 'path'
const expect = chai.expect const expect = chai.expect

View File

@ -133,7 +133,7 @@ program
.description('set an existing entry as default') .description('set an existing entry as default')
.action(async url => { .action(async url => {
const settings = await getSettings() const settings = await getSettings()
const instanceExists = settings.remotes.indexOf(url) !== -1 const instanceExists = settings.remotes.includes(url)
if (instanceExists) { if (instanceExists) {
settings.default = settings.remotes.indexOf(url) settings.default = settings.remotes.indexOf(url)

View File

@ -274,7 +274,7 @@ async function getCategory (categories: string[], url: string) {
function getLicence (licence: string) { function getLicence (licence: string) {
if (!licence) return undefined 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 return undefined
} }

View File

@ -2,10 +2,7 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
import * as repl from 'repl' import * as repl from 'repl'
import * as path from 'path' import * as path from 'path'
import * as _ from 'lodash' import * as _ from 'lodash'
import * as uuidv1 from 'uuid/v1' import { uuidv1, uuidv3, uuidv4, uuidv5 } from 'uuid'
import * as uuidv3 from 'uuid/v3'
import * as uuidv4 from 'uuid/v4'
import * as uuidv5 from 'uuid/v5'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import * as YoutubeDL from 'youtube-dl' import * as YoutubeDL from 'youtube-dl'

View File

@ -69,11 +69,11 @@ export function peertubeTranslate (str: string, translations?: { [ id: string ]:
const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
export function is18nPath (path: string) { export function is18nPath (path: string) {
return possiblePaths.indexOf(path) !== -1 return possiblePaths.includes(path)
} }
export function is18nLocale (locale: string) { export function is18nLocale (locale: string) {
return POSSIBLE_LOCALES.indexOf(locale) !== -1 return POSSIBLE_LOCALES.includes(locale)
} }
export function getCompleteLocale (locale: string) { export function getCompleteLocale (locale: string) {
@ -85,7 +85,7 @@ export function getCompleteLocale (locale: string) {
} }
export function getShortLocale (locale: string) { export function getShortLocale (locale: string) {
if (locale.indexOf('-') === -1) return locale if (locale.includes('-') === false) return locale
return locale.split('-')[0] return locale.split('-')[0]
} }

View File

@ -38,5 +38,5 @@ const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
export function hasUserRight (userRole: UserRole, userRight: UserRight) { export function hasUserRight (userRole: UserRole, userRight: UserRight) {
const userRights = userRoleRights[userRole] const userRights = userRoleRights[userRole]
return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1 return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
} }

567
yarn.lock

File diff suppressed because it is too large Load Diff