From 0628157fe9662fdb2b6fa658b8b53fe684c013ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Dec 2021 14:44:58 +0100 Subject: [PATCH] Move uuid stuff in extra utils Since it requires an external dependency --- client/src/app/core/plugins/plugin.service.ts | 3 ++- .../shared/shared-forms/dynamic-form-field.component.html | 2 +- server/controllers/api/users/token.ts | 2 +- server/controllers/api/video-playlist.ts | 2 +- server/controllers/api/videos/live.ts | 2 +- server/controllers/api/videos/upload.ts | 4 ++-- server/helpers/custom-validators/misc.ts | 2 +- server/helpers/image-utils.ts | 3 ++- server/initializers/migrations/0080-video-channels.ts | 2 +- server/initializers/migrations/0345-video-playlists.ts | 2 +- server/initializers/migrations/0560-user-feed-token.ts | 2 +- .../activitypub/actors/shared/object-to-model-attributes.ts | 3 ++- server/lib/local-actor.ts | 3 ++- server/lib/paths.ts | 3 ++- server/lib/user.ts | 2 +- server/lib/video-path-manager.ts | 2 +- server/models/user/user-notification.ts | 2 +- server/models/video/formatter/video-format-utils.ts | 2 +- server/models/video/video-caption.ts | 2 +- server/models/video/video-playlist.ts | 3 ++- server/models/video/video.ts | 3 ++- server/tests/api/notifications/moderation-notifications.ts | 3 ++- server/tests/api/notifications/user-notifications.ts | 3 ++- server/tests/cli/prune-storage.ts | 3 ++- shared/core-utils/common/object.ts | 5 +++++ shared/core-utils/videos/bitrate.ts | 2 +- shared/core-utils/videos/index.ts | 1 - shared/extra-utils/index.ts | 1 + shared/{core-utils/videos => extra-utils}/uuid.ts | 0 shared/server-commands/videos/videos-command.ts | 3 ++- 30 files changed, 44 insertions(+), 28 deletions(-) rename shared/{core-utils/videos => extra-utils}/uuid.ts (100%) diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index bb9125fe1..dadc2a41d 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -11,6 +11,7 @@ import { ServerService } from '@app/core/server/server.service' import { getDevLocale, isOnDevLocale } from '@app/helpers' import { CustomModalComponent } from '@app/modal/custom-modal.component' import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' +import { getKeys } from '@shared/core-utils' import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' import { ClientHook, @@ -134,7 +135,7 @@ export class PluginService implements ClientHook { } async translateSetting (npmName: string, setting: RegisterClientFormFieldOptions) { - for (const key of [ 'label', 'html', 'descriptionHTML' ]) { + for (const key of getKeys(setting, [ 'label', 'html', 'descriptionHTML' ])) { if (setting[key]) setting[key] = await this.translateBy(npmName, setting[key]) } diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html index c228069b5..2ef61ecfc 100644 --- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html @@ -1,4 +1,4 @@ -
+
(object: O, keys: K[]): Pick return result } +function getKeys (object: O, keys: K[]): K[] { + return (Object.keys(object) as K[]).filter(k => keys.includes(k)) +} + function sortObjectComparator (key: string, order: 'asc' | 'desc') { return (a: any, b: any) => { if (a[key] < b[key]) { @@ -26,5 +30,6 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') { export { pick, + getKeys, sortObjectComparator } diff --git a/shared/core-utils/videos/bitrate.ts b/shared/core-utils/videos/bitrate.ts index c1891188f..30d22df09 100644 --- a/shared/core-utils/videos/bitrate.ts +++ b/shared/core-utils/videos/bitrate.ts @@ -1,4 +1,4 @@ -import { VideoResolution } from "@shared/models" +import { VideoResolution } from '@shared/models' type BitPerPixel = { [ id in VideoResolution ]: number } diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts index 8f6736d39..620e3a716 100644 --- a/shared/core-utils/videos/index.ts +++ b/shared/core-utils/videos/index.ts @@ -1,3 +1,2 @@ export * from './bitrate' export * from './privacy' -export * from './uuid' diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 373d27cb4..e2e161a7b 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts @@ -1,3 +1,4 @@ export * from './crypto' export * from './ffprobe' export * from './file' +export * from './uuid' diff --git a/shared/core-utils/videos/uuid.ts b/shared/extra-utils/uuid.ts similarity index 100% rename from shared/core-utils/videos/uuid.ts rename to shared/extra-utils/uuid.ts diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index ead57b9aa..21753ddc4 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts @@ -5,7 +5,8 @@ import { createReadStream, stat } from 'fs-extra' import got, { Response as GotResponse } from 'got' import { omit } from 'lodash' import validator from 'validator' -import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils' +import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils' +import { buildUUID } from '@shared/extra-utils' import { HttpStatusCode, ResultList,