diff options
-rw-r--r-- | client/src/app/helpers/utils/object.ts | 4 | ||||
-rw-r--r-- | client/src/app/shared/shared-search/advanced-search.model.ts | 12 | ||||
-rw-r--r-- | client/src/app/shared/shared-video-miniature/video-filters.model.ts | 6 | ||||
-rwxr-xr-x | scripts/i18n/create-custom-files.ts | 15 | ||||
-rwxr-xr-x | scripts/prune-storage.ts | 6 | ||||
-rw-r--r-- | server/helpers/custom-validators/users.ts | 5 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 4 | ||||
-rw-r--r-- | server/initializers/checker-after-init.ts | 4 | ||||
-rw-r--r-- | server/lib/emailer.ts | 5 | ||||
-rw-r--r-- | server/lib/hls.ts | 7 | ||||
-rw-r--r-- | server/models/account/account-video-rate.ts | 3 | ||||
-rw-r--r-- | server/models/actor/actor-follow.ts | 4 | ||||
-rw-r--r-- | server/models/actor/actor.ts | 3 | ||||
-rw-r--r-- | server/models/user/user.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 4 | ||||
-rw-r--r-- | server/tools/peertube-redundancy.ts | 5 | ||||
-rw-r--r-- | shared/core-utils/common/array.ts | 6 |
17 files changed, 48 insertions, 48 deletions
diff --git a/client/src/app/helpers/utils/object.ts b/client/src/app/helpers/utils/object.ts index 1ca4a23ac..69b2b18c0 100644 --- a/client/src/app/helpers/utils/object.ts +++ b/client/src/app/helpers/utils/object.ts | |||
@@ -18,7 +18,7 @@ function sortBy (obj: any[], key1: string, key2?: string) { | |||
18 | }) | 18 | }) |
19 | } | 19 | } |
20 | 20 | ||
21 | function intoArray (value: any) { | 21 | function splitIntoArray (value: any) { |
22 | if (!value) return undefined | 22 | if (!value) return undefined |
23 | if (Array.isArray(value)) return value | 23 | if (Array.isArray(value)) return value |
24 | 24 | ||
@@ -42,6 +42,6 @@ export { | |||
42 | sortBy, | 42 | sortBy, |
43 | immutableAssign, | 43 | immutableAssign, |
44 | removeElementFromArray, | 44 | removeElementFromArray, |
45 | intoArray, | 45 | splitIntoArray, |
46 | toBoolean | 46 | toBoolean |
47 | } | 47 | } |
diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts index ea9baa27f..e8bb00fd3 100644 --- a/client/src/app/shared/shared-search/advanced-search.model.ts +++ b/client/src/app/shared/shared-search/advanced-search.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { intoArray } from '@app/helpers' | 1 | import { splitIntoArray } from '@app/helpers' |
2 | import { | 2 | import { |
3 | BooleanBothQuery, | 3 | BooleanBothQuery, |
4 | BooleanQuery, | 4 | BooleanQuery, |
@@ -76,8 +76,8 @@ export class AdvancedSearch { | |||
76 | this.categoryOneOf = options.categoryOneOf || undefined | 76 | this.categoryOneOf = options.categoryOneOf || undefined |
77 | this.licenceOneOf = options.licenceOneOf || undefined | 77 | this.licenceOneOf = options.licenceOneOf || undefined |
78 | this.languageOneOf = options.languageOneOf || undefined | 78 | this.languageOneOf = options.languageOneOf || undefined |
79 | this.tagsOneOf = intoArray(options.tagsOneOf) | 79 | this.tagsOneOf = splitIntoArray(options.tagsOneOf) |
80 | this.tagsAllOf = intoArray(options.tagsAllOf) | 80 | this.tagsAllOf = splitIntoArray(options.tagsAllOf) |
81 | this.durationMin = options.durationMin ? parseInt(options.durationMin, 10) : undefined | 81 | this.durationMin = options.durationMin ? parseInt(options.durationMin, 10) : undefined |
82 | this.durationMax = options.durationMax ? parseInt(options.durationMax, 10) : undefined | 82 | this.durationMax = options.durationMax ? parseInt(options.durationMax, 10) : undefined |
83 | 83 | ||
@@ -152,9 +152,9 @@ export class AdvancedSearch { | |||
152 | originallyPublishedStartDate: this.originallyPublishedStartDate, | 152 | originallyPublishedStartDate: this.originallyPublishedStartDate, |
153 | originallyPublishedEndDate: this.originallyPublishedEndDate, | 153 | originallyPublishedEndDate: this.originallyPublishedEndDate, |
154 | nsfw: this.nsfw, | 154 | nsfw: this.nsfw, |
155 | categoryOneOf: intoArray(this.categoryOneOf), | 155 | categoryOneOf: splitIntoArray(this.categoryOneOf), |
156 | licenceOneOf: intoArray(this.licenceOneOf), | 156 | licenceOneOf: splitIntoArray(this.licenceOneOf), |
157 | languageOneOf: intoArray(this.languageOneOf), | 157 | languageOneOf: splitIntoArray(this.languageOneOf), |
158 | tagsOneOf: this.tagsOneOf, | 158 | tagsOneOf: this.tagsOneOf, |
159 | tagsAllOf: this.tagsAllOf, | 159 | tagsAllOf: this.tagsAllOf, |
160 | durationMin: this.durationMin, | 160 | durationMin: this.durationMin, |
diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts index 8ad2fcd5d..73a30ca08 100644 --- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts +++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { intoArray, toBoolean } from '@app/helpers' | 1 | import { splitIntoArray, toBoolean } from '@app/helpers' |
2 | import { getAllPrivacies } from '@shared/core-utils' | 2 | import { getAllPrivacies } from '@shared/core-utils' |
3 | import { AttributesOnly } from '@shared/typescript-utils' | 3 | import { AttributesOnly } from '@shared/typescript-utils' |
4 | import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models' | 4 | import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models' |
@@ -94,8 +94,8 @@ export class VideoFilters { | |||
94 | 94 | ||
95 | if (obj.nsfw !== undefined) this.nsfw = obj.nsfw | 95 | if (obj.nsfw !== undefined) this.nsfw = obj.nsfw |
96 | 96 | ||
97 | if (obj.languageOneOf !== undefined) this.languageOneOf = intoArray(obj.languageOneOf) | 97 | if (obj.languageOneOf !== undefined) this.languageOneOf = splitIntoArray(obj.languageOneOf) |
98 | if (obj.categoryOneOf !== undefined) this.categoryOneOf = intoArray(obj.categoryOneOf) | 98 | if (obj.categoryOneOf !== undefined) this.categoryOneOf = splitIntoArray(obj.categoryOneOf) |
99 | 99 | ||
100 | if (obj.scope !== undefined) this.scope = obj.scope | 100 | if (obj.scope !== undefined) this.scope = obj.scope |
101 | if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos) | 101 | if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos) |
diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts index e52909c43..8179cb43f 100755 --- a/scripts/i18n/create-custom-files.ts +++ b/scripts/i18n/create-custom-files.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { writeJSON } from 'fs-extra' | 1 | import { writeJSON } from 'fs-extra' |
2 | import { values } from 'lodash' | ||
3 | import { join } from 'path' | 2 | import { join } from 'path' |
4 | import { root } from '@shared/core-utils' | 3 | import { root } from '@shared/core-utils' |
5 | import { | 4 | import { |
@@ -65,13 +64,13 @@ Object.assign(playerKeys, videojs) | |||
65 | 64 | ||
66 | // Server keys | 65 | // Server keys |
67 | const serverKeys: any = {} | 66 | const serverKeys: any = {} |
68 | values(VIDEO_CATEGORIES) | 67 | Object.values(VIDEO_CATEGORIES) |
69 | .concat(values(VIDEO_LICENCES)) | 68 | .concat(Object.values(VIDEO_LICENCES)) |
70 | .concat(values(VIDEO_PRIVACIES)) | 69 | .concat(Object.values(VIDEO_PRIVACIES)) |
71 | .concat(values(VIDEO_STATES)) | 70 | .concat(Object.values(VIDEO_STATES)) |
72 | .concat(values(VIDEO_IMPORT_STATES)) | 71 | .concat(Object.values(VIDEO_IMPORT_STATES)) |
73 | .concat(values(VIDEO_PLAYLIST_PRIVACIES)) | 72 | .concat(Object.values(VIDEO_PLAYLIST_PRIVACIES)) |
74 | .concat(values(VIDEO_PLAYLIST_TYPES)) | 73 | .concat(Object.values(VIDEO_PLAYLIST_TYPES)) |
75 | .concat([ | 74 | .concat([ |
76 | 'This video does not exist.', | 75 | 'This video does not exist.', |
77 | 'We cannot fetch the video. Please try again later.', | 76 | 'We cannot fetch the video. Please try again later.', |
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index bb1e8e024..3012bdb94 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import { map } from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { readdir, remove, stat } from 'fs-extra' | 2 | import { readdir, remove, stat } from 'fs-extra' |
3 | import { uniq, values } from 'lodash' | ||
4 | import { basename, join } from 'path' | 3 | import { basename, join } from 'path' |
5 | import { get, start } from 'prompt' | 4 | import { get, start } from 'prompt' |
6 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' | 5 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' |
7 | import { VideoFileModel } from '@server/models/video/video-file' | 6 | import { VideoFileModel } from '@server/models/video/video-file' |
8 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 7 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
8 | import { uniqify } from '@shared/core-utils' | ||
9 | import { ThumbnailType } from '@shared/models' | 9 | import { ThumbnailType } from '@shared/models' |
10 | import { getUUIDFromFilename } from '../server/helpers/utils' | 10 | import { getUUIDFromFilename } from '../server/helpers/utils' |
11 | import { CONFIG } from '../server/initializers/config' | 11 | import { CONFIG } from '../server/initializers/config' |
@@ -23,9 +23,9 @@ run() | |||
23 | }) | 23 | }) |
24 | 24 | ||
25 | async function run () { | 25 | async function run () { |
26 | const dirs = values(CONFIG.STORAGE) | 26 | const dirs = Object.values(CONFIG.STORAGE) |
27 | 27 | ||
28 | if (uniq(dirs).length !== dirs.length) { | 28 | if (uniqify(dirs).length !== dirs.length) { |
29 | console.error('Cannot prune storage because you put multiple storage keys in the same directory.') | 29 | console.error('Cannot prune storage because you put multiple storage keys in the same directory.') |
30 | process.exit(0) | 30 | process.exit(0) |
31 | } | 31 | } |
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 8a6f6fca1..9df550fc2 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { values } from 'lodash' | ||
2 | import validator from 'validator' | 1 | import validator from 'validator' |
3 | import { UserRole } from '@shared/models' | 2 | import { UserRole } from '@shared/models' |
4 | import { isEmailEnabled } from '../../initializers/config' | 3 | import { isEmailEnabled } from '../../initializers/config' |
@@ -44,9 +43,9 @@ function isUserEmailVerifiedValid (value: any) { | |||
44 | return isBooleanValid(value) | 43 | return isBooleanValid(value) |
45 | } | 44 | } |
46 | 45 | ||
47 | const nsfwPolicies = values(NSFW_POLICY_TYPES) | 46 | const nsfwPolicies = new Set(Object.values(NSFW_POLICY_TYPES)) |
48 | function isUserNSFWPolicyValid (value: any) { | 47 | function isUserNSFWPolicyValid (value: any) { |
49 | return exists(value) && nsfwPolicies.includes(value) | 48 | return exists(value) && nsfwPolicies.has(value) |
50 | } | 49 | } |
51 | 50 | ||
52 | function isUserP2PEnabledValid (value: any) { | 51 | function isUserP2PEnabledValid (value: any) { |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index ca5f70fdc..3ebfe2937 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { UploadFilesForCheck } from 'express' | 1 | import { UploadFilesForCheck } from 'express' |
2 | import { values } from 'lodash' | ||
3 | import magnetUtil from 'magnet-uri' | 2 | import magnetUtil from 'magnet-uri' |
4 | import validator from 'validator' | 3 | import validator from 'validator' |
5 | import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' | 4 | import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' |
@@ -78,8 +77,9 @@ function isVideoViewsValid (value: string) { | |||
78 | return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) | 77 | return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) |
79 | } | 78 | } |
80 | 79 | ||
80 | const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES)) | ||
81 | function isVideoRatingTypeValid (value: string) { | 81 | function isVideoRatingTypeValid (value: string) { |
82 | return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType) | 82 | return value === 'none' || ratingTypes.has(value as VideoRateType) |
83 | } | 83 | } |
84 | 84 | ||
85 | function isVideoFileExtnameValid (value: string) { | 85 | function isVideoFileExtnameValid (value: string) { |
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 74c82541e..42839d1c9 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import config from 'config' | 1 | import config from 'config' |
2 | import { uniq } from 'lodash' | ||
3 | import { URL } from 'url' | 2 | import { URL } from 'url' |
4 | import { getFFmpegVersion } from '@server/helpers/ffmpeg' | 3 | import { getFFmpegVersion } from '@server/helpers/ffmpeg' |
4 | import { uniqify } from '@shared/core-utils' | ||
5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | 5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' |
6 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' | 6 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' |
7 | import { isProdInstance, parseSemVersion } from '../helpers/core-utils' | 7 | import { isProdInstance, parseSemVersion } from '../helpers/core-utils' |
@@ -141,7 +141,7 @@ function checkLocalRedundancyConfig () { | |||
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | const filtered = uniq(redundancyVideos.map(r => r.strategy)) | 144 | const filtered = uniqify(redundancyVideos.map(r => r.strategy)) |
145 | if (filtered.length !== redundancyVideos.length) { | 145 | if (filtered.length !== redundancyVideos.length) { |
146 | throw new Error('Redundancy video entries should have unique strategies') | 146 | throw new Error('Redundancy video entries should have unique strategies') |
147 | } | 147 | } |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 3cdba5c76..39b662eb2 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -2,8 +2,7 @@ import { readFileSync } from 'fs-extra' | |||
2 | import { merge } from 'lodash' | 2 | import { merge } from 'lodash' |
3 | import { createTransport, Transporter } from 'nodemailer' | 3 | import { createTransport, Transporter } from 'nodemailer' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { toArray } from '@server/helpers/custom-validators/misc' | 5 | import { arrayify, root } from '@shared/core-utils' |
6 | import { root } from '@shared/core-utils' | ||
7 | import { EmailPayload } from '@shared/models' | 6 | import { EmailPayload } from '@shared/models' |
8 | import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' | 7 | import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' |
9 | import { isTestOrDevInstance } from '../helpers/core-utils' | 8 | import { isTestOrDevInstance } from '../helpers/core-utils' |
@@ -159,7 +158,7 @@ class Emailer { | |||
159 | subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX | 158 | subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX |
160 | }) | 159 | }) |
161 | 160 | ||
162 | const toEmails = toArray(options.to) | 161 | const toEmails = arrayify(options.to) |
163 | 162 | ||
164 | for (const to of toEmails) { | 163 | for (const to of toEmails) { |
165 | const baseOptions: SendEmailDefaultOptions = { | 164 | const baseOptions: SendEmailDefaultOptions = { |
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index 9ec931b4f..a0a5afc0f 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, writeFile } from 'fs-extra' | 1 | import { close, ensureDir, move, open, outputJSON, read, readFile, remove, stat, writeFile } from 'fs-extra' |
2 | import { flatten, uniq } from 'lodash' | 2 | import { flatten } from 'lodash' |
3 | import PQueue from 'p-queue' | 3 | import PQueue from 'p-queue' |
4 | import { basename, dirname, join } from 'path' | 4 | import { basename, dirname, join } from 'path' |
5 | import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' | 5 | import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' |
6 | import { uniqify } from '@shared/core-utils' | ||
6 | import { sha256 } from '@shared/extra-utils' | 7 | import { sha256 } from '@shared/extra-utils' |
7 | import { VideoStorage } from '@shared/models' | 8 | import { VideoStorage } from '@shared/models' |
8 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamDimensionsInfo } from '../helpers/ffmpeg' | 9 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamDimensionsInfo } from '../helpers/ffmpeg' |
@@ -182,7 +183,7 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, | |||
182 | const subPlaylistUrls = await fetchUniqUrls(playlistUrl) | 183 | const subPlaylistUrls = await fetchUniqUrls(playlistUrl) |
183 | 184 | ||
184 | const subRequests = subPlaylistUrls.map(u => fetchUniqUrls(u)) | 185 | const subRequests = subPlaylistUrls.map(u => fetchUniqUrls(u)) |
185 | const fileUrls = uniq(flatten(await Promise.all(subRequests))) | 186 | const fileUrls = uniqify(flatten(await Promise.all(subRequests))) |
186 | 187 | ||
187 | logger.debug('Will download %d HLS files.', fileUrls.length, { fileUrls }) | 188 | logger.debug('Will download %d HLS files.', fileUrls.length, { fileUrls }) |
188 | 189 | ||
@@ -227,7 +228,7 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, | |||
227 | return `${dirname(playlistUrl)}/${url}` | 228 | return `${dirname(playlistUrl)}/${url}` |
228 | }) | 229 | }) |
229 | 230 | ||
230 | return uniq(urls) | 231 | return uniqify(urls) |
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 5c7d9cfc0..7afc907da 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { values } from 'lodash' | ||
2 | import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize' | 1 | import { FindOptions, Op, QueryTypes, Transaction } from 'sequelize' |
3 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' |
4 | import { | 3 | import { |
@@ -45,7 +44,7 @@ import { AccountModel } from './account' | |||
45 | export class AccountVideoRateModel extends Model<Partial<AttributesOnly<AccountVideoRateModel>>> { | 44 | export class AccountVideoRateModel extends Model<Partial<AttributesOnly<AccountVideoRateModel>>> { |
46 | 45 | ||
47 | @AllowNull(false) | 46 | @AllowNull(false) |
48 | @Column(DataType.ENUM(...values(VIDEO_RATE_TYPES))) | 47 | @Column(DataType.ENUM(...Object.values(VIDEO_RATE_TYPES))) |
49 | type: VideoRateType | 48 | type: VideoRateType |
50 | 49 | ||
51 | @AllowNull(false) | 50 | @AllowNull(false) |
diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts index 127b29ad7..9615229dd 100644 --- a/server/models/actor/actor-follow.ts +++ b/server/models/actor/actor-follow.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { difference, values } from 'lodash' | 1 | import { difference } from 'lodash' |
2 | import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize' | 2 | import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize' |
3 | import { | 3 | import { |
4 | AfterCreate, | 4 | AfterCreate, |
@@ -69,7 +69,7 @@ import { InstanceListFollowingQueryBuilder, ListFollowingOptions } from './sql/i | |||
69 | export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowModel>>> { | 69 | export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowModel>>> { |
70 | 70 | ||
71 | @AllowNull(false) | 71 | @AllowNull(false) |
72 | @Column(DataType.ENUM(...values(FOLLOW_STATES))) | 72 | @Column(DataType.ENUM(...Object.values(FOLLOW_STATES))) |
73 | state: FollowState | 73 | state: FollowState |
74 | 74 | ||
75 | @AllowNull(false) | 75 | @AllowNull(false) |
diff --git a/server/models/actor/actor.ts b/server/models/actor/actor.ts index 7be5a140c..88db241dc 100644 --- a/server/models/actor/actor.ts +++ b/server/models/actor/actor.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { values } from 'lodash' | ||
2 | import { literal, Op, QueryTypes, Transaction } from 'sequelize' | 1 | import { literal, Op, QueryTypes, Transaction } from 'sequelize' |
3 | import { | 2 | import { |
4 | AllowNull, | 3 | AllowNull, |
@@ -163,7 +162,7 @@ export const unusedActorAttributesForAPI = [ | |||
163 | export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> { | 162 | export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> { |
164 | 163 | ||
165 | @AllowNull(false) | 164 | @AllowNull(false) |
166 | @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES))) | 165 | @Column(DataType.ENUM(...Object.values(ACTIVITY_PUB_ACTOR_TYPES))) |
167 | type: ActivityPubActorType | 166 | type: ActivityPubActorType |
168 | 167 | ||
169 | @AllowNull(false) | 168 | @AllowNull(false) |
diff --git a/server/models/user/user.ts b/server/models/user/user.ts index 3fd359359..a2c2497fd 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { values } from 'lodash' | ||
2 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' | 1 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' |
3 | import { | 2 | import { |
4 | AfterDestroy, | 3 | AfterDestroy, |
@@ -283,7 +282,7 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> { | |||
283 | 282 | ||
284 | @AllowNull(false) | 283 | @AllowNull(false) |
285 | @Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy')) | 284 | @Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy')) |
286 | @Column(DataType.ENUM(...values(NSFW_POLICY_TYPES))) | 285 | @Column(DataType.ENUM(...Object.values(NSFW_POLICY_TYPES))) |
287 | nsfwPolicy: NSFWPolicyType | 286 | nsfwPolicy: NSFWPolicyType |
288 | 287 | ||
289 | @AllowNull(false) | 288 | @AllowNull(false) |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 1195e47e9..af9614d30 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { uniq } from 'lodash' | ||
2 | import { FindOptions, Op, Order, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' | 1 | import { FindOptions, Op, Order, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' |
3 | import { | 2 | import { |
4 | AllowNull, | 3 | AllowNull, |
@@ -17,6 +16,7 @@ import { | |||
17 | import { exists } from '@server/helpers/custom-validators/misc' | 16 | import { exists } from '@server/helpers/custom-validators/misc' |
18 | import { getServerActor } from '@server/models/application/application' | 17 | import { getServerActor } from '@server/models/application/application' |
19 | import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' | 18 | import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' |
19 | import { uniqify } from '@shared/core-utils' | ||
20 | import { VideoPrivacy } from '@shared/models' | 20 | import { VideoPrivacy } from '@shared/models' |
21 | import { AttributesOnly } from '@shared/typescript-utils' | 21 | import { AttributesOnly } from '@shared/typescript-utils' |
22 | import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects' | 22 | import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects' |
@@ -802,7 +802,7 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment | |||
802 | ) | 802 | ) |
803 | } | 803 | } |
804 | 804 | ||
805 | return uniq(result) | 805 | return uniqify(result) |
806 | } | 806 | } |
807 | 807 | ||
808 | toFormattedJSON (this: MCommentFormattable) { | 808 | toFormattedJSON (this: MCommentFormattable) { |
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 2c62a3c19..4bb9fbc5a 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts | |||
@@ -1,13 +1,12 @@ | |||
1 | import CliTable3 from 'cli-table3' | 1 | import CliTable3 from 'cli-table3' |
2 | import { Command, program } from 'commander' | 2 | import { Command, program } from 'commander' |
3 | import { uniq } from 'lodash' | ||
4 | import { URL } from 'url' | 3 | import { URL } from 'url' |
5 | import validator from 'validator' | 4 | import validator from 'validator' |
5 | import { uniqify } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, VideoRedundanciesTarget } from '@shared/models' | 6 | import { HttpStatusCode, VideoRedundanciesTarget } from '@shared/models' |
7 | import { assignToken, buildServer, getServerCredentials } from './cli' | 7 | import { assignToken, buildServer, getServerCredentials } from './cli' |
8 | 8 | ||
9 | import bytes = require('bytes') | 9 | import bytes = require('bytes') |
10 | |||
11 | program | 10 | program |
12 | .name('redundancy') | 11 | .name('redundancy') |
13 | .usage('[command] [options]') | 12 | .usage('[command] [options]') |
@@ -77,7 +76,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) { | |||
77 | totalSize = bytes(tmp) | 76 | totalSize = bytes(tmp) |
78 | } | 77 | } |
79 | 78 | ||
80 | const instances = uniq( | 79 | const instances = uniqify( |
81 | webtorrentFiles.concat(streamingPlaylists) | 80 | webtorrentFiles.concat(streamingPlaylists) |
82 | .map(r => r.fileUrl) | 81 | .map(r => r.fileUrl) |
83 | .map(u => new URL(u).host) | 82 | .map(u => new URL(u).host) |
diff --git a/shared/core-utils/common/array.ts b/shared/core-utils/common/array.ts index 95393c731..e1b422165 100644 --- a/shared/core-utils/common/array.ts +++ b/shared/core-utils/common/array.ts | |||
@@ -15,7 +15,13 @@ function arrayify <T> (element: T | T[]) { | |||
15 | return [ element ] | 15 | return [ element ] |
16 | } | 16 | } |
17 | 17 | ||
18 | // Avoid conflict with other uniq() functions | ||
19 | function uniqify <T> (elements: T[]) { | ||
20 | return Array.from(new Set(elements)) | ||
21 | } | ||
22 | |||
18 | export { | 23 | export { |
24 | uniqify, | ||
19 | findCommonElement, | 25 | findCommonElement, |
20 | arrayify | 26 | arrayify |
21 | } | 27 | } |