mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Prefer using Object.values
This commit is contained in:
parent
bbd5aa7ead
commit
690bb8f9f3
@ -18,7 +18,7 @@ function sortBy (obj: any[], key1: string, key2?: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function intoArray (value: any) {
|
function splitIntoArray (value: any) {
|
||||||
if (!value) return undefined
|
if (!value) return undefined
|
||||||
if (Array.isArray(value)) return value
|
if (Array.isArray(value)) return value
|
||||||
|
|
||||||
@ -42,6 +42,6 @@ export {
|
|||||||
sortBy,
|
sortBy,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
removeElementFromArray,
|
removeElementFromArray,
|
||||||
intoArray,
|
splitIntoArray,
|
||||||
toBoolean
|
toBoolean
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { intoArray } from '@app/helpers'
|
import { splitIntoArray } from '@app/helpers'
|
||||||
import {
|
import {
|
||||||
BooleanBothQuery,
|
BooleanBothQuery,
|
||||||
BooleanQuery,
|
BooleanQuery,
|
||||||
@ -76,8 +76,8 @@ export class AdvancedSearch {
|
|||||||
this.categoryOneOf = options.categoryOneOf || undefined
|
this.categoryOneOf = options.categoryOneOf || undefined
|
||||||
this.licenceOneOf = options.licenceOneOf || undefined
|
this.licenceOneOf = options.licenceOneOf || undefined
|
||||||
this.languageOneOf = options.languageOneOf || undefined
|
this.languageOneOf = options.languageOneOf || undefined
|
||||||
this.tagsOneOf = intoArray(options.tagsOneOf)
|
this.tagsOneOf = splitIntoArray(options.tagsOneOf)
|
||||||
this.tagsAllOf = intoArray(options.tagsAllOf)
|
this.tagsAllOf = splitIntoArray(options.tagsAllOf)
|
||||||
this.durationMin = options.durationMin ? parseInt(options.durationMin, 10) : undefined
|
this.durationMin = options.durationMin ? parseInt(options.durationMin, 10) : undefined
|
||||||
this.durationMax = options.durationMax ? parseInt(options.durationMax, 10) : undefined
|
this.durationMax = options.durationMax ? parseInt(options.durationMax, 10) : undefined
|
||||||
|
|
||||||
@ -152,9 +152,9 @@ export class AdvancedSearch {
|
|||||||
originallyPublishedStartDate: this.originallyPublishedStartDate,
|
originallyPublishedStartDate: this.originallyPublishedStartDate,
|
||||||
originallyPublishedEndDate: this.originallyPublishedEndDate,
|
originallyPublishedEndDate: this.originallyPublishedEndDate,
|
||||||
nsfw: this.nsfw,
|
nsfw: this.nsfw,
|
||||||
categoryOneOf: intoArray(this.categoryOneOf),
|
categoryOneOf: splitIntoArray(this.categoryOneOf),
|
||||||
licenceOneOf: intoArray(this.licenceOneOf),
|
licenceOneOf: splitIntoArray(this.licenceOneOf),
|
||||||
languageOneOf: intoArray(this.languageOneOf),
|
languageOneOf: splitIntoArray(this.languageOneOf),
|
||||||
tagsOneOf: this.tagsOneOf,
|
tagsOneOf: this.tagsOneOf,
|
||||||
tagsAllOf: this.tagsAllOf,
|
tagsAllOf: this.tagsAllOf,
|
||||||
durationMin: this.durationMin,
|
durationMin: this.durationMin,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { intoArray, toBoolean } from '@app/helpers'
|
import { splitIntoArray, toBoolean } from '@app/helpers'
|
||||||
import { getAllPrivacies } from '@shared/core-utils'
|
import { getAllPrivacies } from '@shared/core-utils'
|
||||||
import { AttributesOnly } from '@shared/typescript-utils'
|
import { AttributesOnly } from '@shared/typescript-utils'
|
||||||
import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models'
|
import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models'
|
||||||
@ -94,8 +94,8 @@ export class VideoFilters {
|
|||||||
|
|
||||||
if (obj.nsfw !== undefined) this.nsfw = obj.nsfw
|
if (obj.nsfw !== undefined) this.nsfw = obj.nsfw
|
||||||
|
|
||||||
if (obj.languageOneOf !== undefined) this.languageOneOf = intoArray(obj.languageOneOf)
|
if (obj.languageOneOf !== undefined) this.languageOneOf = splitIntoArray(obj.languageOneOf)
|
||||||
if (obj.categoryOneOf !== undefined) this.categoryOneOf = intoArray(obj.categoryOneOf)
|
if (obj.categoryOneOf !== undefined) this.categoryOneOf = splitIntoArray(obj.categoryOneOf)
|
||||||
|
|
||||||
if (obj.scope !== undefined) this.scope = obj.scope
|
if (obj.scope !== undefined) this.scope = obj.scope
|
||||||
if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos)
|
if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { writeJSON } from 'fs-extra'
|
import { writeJSON } from 'fs-extra'
|
||||||
import { values } from 'lodash'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { root } from '@shared/core-utils'
|
import { root } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
@ -65,13 +64,13 @@ Object.assign(playerKeys, videojs)
|
|||||||
|
|
||||||
// Server keys
|
// Server keys
|
||||||
const serverKeys: any = {}
|
const serverKeys: any = {}
|
||||||
values(VIDEO_CATEGORIES)
|
Object.values(VIDEO_CATEGORIES)
|
||||||
.concat(values(VIDEO_LICENCES))
|
.concat(Object.values(VIDEO_LICENCES))
|
||||||
.concat(values(VIDEO_PRIVACIES))
|
.concat(Object.values(VIDEO_PRIVACIES))
|
||||||
.concat(values(VIDEO_STATES))
|
.concat(Object.values(VIDEO_STATES))
|
||||||
.concat(values(VIDEO_IMPORT_STATES))
|
.concat(Object.values(VIDEO_IMPORT_STATES))
|
||||||
.concat(values(VIDEO_PLAYLIST_PRIVACIES))
|
.concat(Object.values(VIDEO_PLAYLIST_PRIVACIES))
|
||||||
.concat(values(VIDEO_PLAYLIST_TYPES))
|
.concat(Object.values(VIDEO_PLAYLIST_TYPES))
|
||||||
.concat([
|
.concat([
|
||||||
'This video does not exist.',
|
'This video does not exist.',
|
||||||
'We cannot fetch the video. Please try again later.',
|
'We cannot fetch the video. Please try again later.',
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { map } from 'bluebird'
|
import { map } from 'bluebird'
|
||||||
import { readdir, remove, stat } from 'fs-extra'
|
import { readdir, remove, stat } from 'fs-extra'
|
||||||
import { uniq, values } from 'lodash'
|
|
||||||
import { basename, join } from 'path'
|
import { basename, join } from 'path'
|
||||||
import { get, start } from 'prompt'
|
import { get, start } from 'prompt'
|
||||||
import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
|
import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
|
||||||
import { VideoFileModel } from '@server/models/video/video-file'
|
import { VideoFileModel } from '@server/models/video/video-file'
|
||||||
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
|
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
|
||||||
|
import { uniqify } from '@shared/core-utils'
|
||||||
import { ThumbnailType } from '@shared/models'
|
import { ThumbnailType } from '@shared/models'
|
||||||
import { getUUIDFromFilename } from '../server/helpers/utils'
|
import { getUUIDFromFilename } from '../server/helpers/utils'
|
||||||
import { CONFIG } from '../server/initializers/config'
|
import { CONFIG } from '../server/initializers/config'
|
||||||
@ -23,9 +23,9 @@ run()
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function run () {
|
async function run () {
|
||||||
const dirs = values(CONFIG.STORAGE)
|
const dirs = Object.values(CONFIG.STORAGE)
|
||||||
|
|
||||||
if (uniq(dirs).length !== dirs.length) {
|
if (uniqify(dirs).length !== dirs.length) {
|
||||||
console.error('Cannot prune storage because you put multiple storage keys in the same directory.')
|
console.error('Cannot prune storage because you put multiple storage keys in the same directory.')
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { values } from 'lodash'
|
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
import { UserRole } from '@shared/models'
|
import { UserRole } from '@shared/models'
|
||||||
import { isEmailEnabled } from '../../initializers/config'
|
import { isEmailEnabled } from '../../initializers/config'
|
||||||
@ -44,9 +43,9 @@ function isUserEmailVerifiedValid (value: any) {
|
|||||||
return isBooleanValid(value)
|
return isBooleanValid(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsfwPolicies = values(NSFW_POLICY_TYPES)
|
const nsfwPolicies = new Set(Object.values(NSFW_POLICY_TYPES))
|
||||||
function isUserNSFWPolicyValid (value: any) {
|
function isUserNSFWPolicyValid (value: any) {
|
||||||
return exists(value) && nsfwPolicies.includes(value)
|
return exists(value) && nsfwPolicies.has(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserP2PEnabledValid (value: any) {
|
function isUserP2PEnabledValid (value: any) {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { UploadFilesForCheck } from 'express'
|
import { UploadFilesForCheck } from 'express'
|
||||||
import { values } from 'lodash'
|
|
||||||
import magnetUtil from 'magnet-uri'
|
import magnetUtil from 'magnet-uri'
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models'
|
import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models'
|
||||||
@ -78,8 +77,9 @@ function isVideoViewsValid (value: string) {
|
|||||||
return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS)
|
return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES))
|
||||||
function isVideoRatingTypeValid (value: string) {
|
function isVideoRatingTypeValid (value: string) {
|
||||||
return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType)
|
return value === 'none' || ratingTypes.has(value as VideoRateType)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVideoFileExtnameValid (value: string) {
|
function isVideoFileExtnameValid (value: string) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import config from 'config'
|
import config from 'config'
|
||||||
import { uniq } from 'lodash'
|
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { getFFmpegVersion } from '@server/helpers/ffmpeg'
|
import { getFFmpegVersion } from '@server/helpers/ffmpeg'
|
||||||
|
import { uniqify } from '@shared/core-utils'
|
||||||
import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
|
import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
|
||||||
import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
|
import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
|
||||||
import { isProdInstance, parseSemVersion } from '../helpers/core-utils'
|
import { isProdInstance, parseSemVersion } from '../helpers/core-utils'
|
||||||
@ -141,7 +141,7 @@ function checkLocalRedundancyConfig () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const filtered = uniq(redundancyVideos.map(r => r.strategy))
|
const filtered = uniqify(redundancyVideos.map(r => r.strategy))
|
||||||
if (filtered.length !== redundancyVideos.length) {
|
if (filtered.length !== redundancyVideos.length) {
|
||||||
throw new Error('Redundancy video entries should have unique strategies')
|
throw new Error('Redundancy video entries should have unique strategies')
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ import { readFileSync } from 'fs-extra'
|
|||||||
import { merge } from 'lodash'
|
import { merge } from 'lodash'
|
||||||
import { createTransport, Transporter } from 'nodemailer'
|
import { createTransport, Transporter } from 'nodemailer'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { toArray } from '@server/helpers/custom-validators/misc'
|
import { arrayify, root } from '@shared/core-utils'
|
||||||
import { root } from '@shared/core-utils'
|
|
||||||
import { EmailPayload } from '@shared/models'
|
import { EmailPayload } from '@shared/models'
|
||||||
import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model'
|
import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model'
|
||||||
import { isTestOrDevInstance } from '../helpers/core-utils'
|
import { isTestOrDevInstance } from '../helpers/core-utils'
|
||||||
@ -159,7 +158,7 @@ class Emailer {
|
|||||||
subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX
|
subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX
|
||||||
})
|
})
|
||||||
|
|
||||||
const toEmails = toArray(options.to)
|
const toEmails = arrayify(options.to)
|
||||||
|
|
||||||
for (const to of toEmails) {
|
for (const to of toEmails) {
|
||||||
const baseOptions: SendEmailDefaultOptions = {
|
const baseOptions: SendEmailDefaultOptions = {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, writeFile } from 'fs-extra'
|
import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, writeFile } from 'fs-extra'
|
||||||
import { flatten, uniq } from 'lodash'
|
import { flatten } from 'lodash'
|
||||||
import PQueue from 'p-queue'
|
import PQueue from 'p-queue'
|
||||||
import { basename, dirname, join } from 'path'
|
import { basename, dirname, join } from 'path'
|
||||||
import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models'
|
import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models'
|
||||||
|
import { uniqify } from '@shared/core-utils'
|
||||||
import { sha256 } from '@shared/extra-utils'
|
import { sha256 } from '@shared/extra-utils'
|
||||||
import { VideoStorage } from '@shared/models'
|
import { VideoStorage } from '@shared/models'
|
||||||
import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamDimensionsInfo } from '../helpers/ffmpeg'
|
import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamDimensionsInfo } from '../helpers/ffmpeg'
|
||||||
@ -182,7 +183,7 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string,
|
|||||||
const subPlaylistUrls = await fetchUniqUrls(playlistUrl)
|
const subPlaylistUrls = await fetchUniqUrls(playlistUrl)
|
||||||
|
|
||||||
const subRequests = subPlaylistUrls.map(u => fetchUniqUrls(u))
|
const subRequests = subPlaylistUrls.map(u => fetchUniqUrls(u))
|
||||||
const fileUrls = uniq(flatten(await Promise.all(subRequests)))
|
const fileUrls = uniqify(flatten(await Promise.all(subRequests)))
|
||||||
|
|
||||||
logger.debug('Will download %d HLS files.', fileUrls.length, { fileUrls })
|
logger.debug('Will download %d HLS files.', fileUrls.length, { fileUrls })
|
||||||
|
|
||||||
@ -227,7 +228,7 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string,
|
|||||||
return `${dirname(playlistUrl)}/${url}`
|
return `${dirname(playlistUrl)}/${url}`
|
||||||
})
|
})
|
||||||
|
|
||||||
return uniq(urls)
|
return uniqify(urls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { values } from 'lodash'
|
|
||||||
import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize'
|
import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize'
|
||||||
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
||||||
import {
|
import {
|
||||||
@ -45,7 +44,7 @@ import { AccountModel } from './account'
|
|||||||
export class AccountVideoRateModel extends Model<Partial<AttributesOnly<AccountVideoRateModel>>> {
|
export class AccountVideoRateModel extends Model<Partial<AttributesOnly<AccountVideoRateModel>>> {
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
@Column(DataType.ENUM(...values(VIDEO_RATE_TYPES)))
|
@Column(DataType.ENUM(...Object.values(VIDEO_RATE_TYPES)))
|
||||||
type: VideoRateType
|
type: VideoRateType
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { difference, values } from 'lodash'
|
import { difference } from 'lodash'
|
||||||
import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize'
|
import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AfterCreate,
|
AfterCreate,
|
||||||
@ -69,7 +69,7 @@ import { InstanceListFollowingQueryBuilder, ListFollowingOptions } from './sql/i
|
|||||||
export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowModel>>> {
|
export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowModel>>> {
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
@Column(DataType.ENUM(...values(FOLLOW_STATES)))
|
@Column(DataType.ENUM(...Object.values(FOLLOW_STATES)))
|
||||||
state: FollowState
|
state: FollowState
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { values } from 'lodash'
|
|
||||||
import { literal, Op, QueryTypes, Transaction } from 'sequelize'
|
import { literal, Op, QueryTypes, Transaction } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AllowNull,
|
AllowNull,
|
||||||
@ -163,7 +162,7 @@ export const unusedActorAttributesForAPI = [
|
|||||||
export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
|
export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
@Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES)))
|
@Column(DataType.ENUM(...Object.values(ACTIVITY_PUB_ACTOR_TYPES)))
|
||||||
type: ActivityPubActorType
|
type: ActivityPubActorType
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { values } from 'lodash'
|
|
||||||
import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize'
|
import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AfterDestroy,
|
AfterDestroy,
|
||||||
@ -283,7 +282,7 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> {
|
|||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
@Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy'))
|
@Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy'))
|
||||||
@Column(DataType.ENUM(...values(NSFW_POLICY_TYPES)))
|
@Column(DataType.ENUM(...Object.values(NSFW_POLICY_TYPES)))
|
||||||
nsfwPolicy: NSFWPolicyType
|
nsfwPolicy: NSFWPolicyType
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { uniq } from 'lodash'
|
|
||||||
import { FindOptions, Op, Order, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize'
|
import { FindOptions, Op, Order, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize'
|
||||||
import {
|
import {
|
||||||
AllowNull,
|
AllowNull,
|
||||||
@ -17,6 +16,7 @@ import {
|
|||||||
import { exists } from '@server/helpers/custom-validators/misc'
|
import { exists } from '@server/helpers/custom-validators/misc'
|
||||||
import { getServerActor } from '@server/models/application/application'
|
import { getServerActor } from '@server/models/application/application'
|
||||||
import { MAccount, MAccountId, MUserAccountId } from '@server/types/models'
|
import { MAccount, MAccountId, MUserAccountId } from '@server/types/models'
|
||||||
|
import { uniqify } from '@shared/core-utils'
|
||||||
import { VideoPrivacy } from '@shared/models'
|
import { VideoPrivacy } from '@shared/models'
|
||||||
import { AttributesOnly } from '@shared/typescript-utils'
|
import { AttributesOnly } from '@shared/typescript-utils'
|
||||||
import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects'
|
import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects'
|
||||||
@ -802,7 +802,7 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uniq(result)
|
return uniqify(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
toFormattedJSON (this: MCommentFormattable) {
|
toFormattedJSON (this: MCommentFormattable) {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import CliTable3 from 'cli-table3'
|
import CliTable3 from 'cli-table3'
|
||||||
import { Command, program } from 'commander'
|
import { Command, program } from 'commander'
|
||||||
import { uniq } from 'lodash'
|
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
|
import { uniqify } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, VideoRedundanciesTarget } from '@shared/models'
|
import { HttpStatusCode, VideoRedundanciesTarget } from '@shared/models'
|
||||||
import { assignToken, buildServer, getServerCredentials } from './cli'
|
import { assignToken, buildServer, getServerCredentials } from './cli'
|
||||||
|
|
||||||
import bytes = require('bytes')
|
import bytes = require('bytes')
|
||||||
|
|
||||||
program
|
program
|
||||||
.name('redundancy')
|
.name('redundancy')
|
||||||
.usage('[command] [options]')
|
.usage('[command] [options]')
|
||||||
@ -77,7 +76,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) {
|
|||||||
totalSize = bytes(tmp)
|
totalSize = bytes(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
const instances = uniq(
|
const instances = uniqify(
|
||||||
webtorrentFiles.concat(streamingPlaylists)
|
webtorrentFiles.concat(streamingPlaylists)
|
||||||
.map(r => r.fileUrl)
|
.map(r => r.fileUrl)
|
||||||
.map(u => new URL(u).host)
|
.map(u => new URL(u).host)
|
||||||
|
@ -15,7 +15,13 @@ function arrayify <T> (element: T | T[]) {
|
|||||||
return [ element ]
|
return [ element ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid conflict with other uniq() functions
|
||||||
|
function uniqify <T> (elements: T[]) {
|
||||||
|
return Array.from(new Set(elements))
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
uniqify,
|
||||||
findCommonElement,
|
findCommonElement,
|
||||||
arrayify
|
arrayify
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user