ActivityPub-federated video streaming platform using P2P directly in your web browser
Move uuid stuff in extra utils
Chocobozzz0628157fe966
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.tsindex bb9125fe1f..dadc2a41d3 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.htmlindex c228069b50..2ef61ecfcd 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 @@-<div [formGroup]="form">+<div *ngIf="form" [formGroup]="form"><label *ngIf="setting.label && setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label><my-peertube-checkboxdiff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.tsindex 5ada4a8052..258b50fe92 100644--- a/server/controllers/api/users/token.ts+++ b/server/controllers/api/users/token.ts@@ -7,7 +7,7 @@ import { handleOAuthToken } from '@server/lib/auth/oauth'import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'import { Hooks } from '@server/lib/plugins/hooks'import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { ScopedToken } from '@shared/models/users/user-scoped-token'const tokensRouter = express.Router()diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.tsindex dc19477643..795e14e738 100644--- a/server/controllers/api/video-playlist.ts+++ b/server/controllers/api/video-playlist.ts@@ -4,7 +4,7 @@ import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'import { Hooks } from '@server/lib/plugins/hooks'import { getServerActor } from '@server/models/application/application'import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'-import { uuidToShort } from '@shared/core-utils'+import { uuidToShort } from '@shared/extra-utils'import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.tsindex 80ecbfef1b..8b8cacff99 100644--- a/server/controllers/api/videos/live.ts+++ b/server/controllers/api/videos/live.ts@@ -9,7 +9,7 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } froimport { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live'import { VideoLiveModel } from '@server/models/video/video-live'import { MVideoDetails, MVideoFullLight } from '@server/types/models'-import { buildUUID, uuidToShort } from '@shared/core-utils'+import { buildUUID, uuidToShort } from '@shared/extra-utils'import { HttpStatusCode, LiveVideoCreate, LiveVideoUpdate, VideoState } from '@shared/models'import { logger } from '../../../helpers/logger'import { sequelizeTypescript } from '../../../initializers/database'diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.tsindex e8f400cffd..89787f20b3 100644--- a/server/controllers/api/videos/upload.ts+++ b/server/controllers/api/videos/upload.ts@@ -18,8 +18,8 @@ import { VideoPathManager } from '@server/lib/video-path-manager'import { buildNextVideoState } from '@server/lib/video-state'import { openapiOperationDoc } from '@server/middlewares/doc'import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'-import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'-import { isAudioFile } from '@shared/extra-utils'+import { getLowercaseExtension } from '@shared/core-utils'+import { isAudioFile, uuidToShort } from '@shared/extra-utils'import { HttpStatusCode, VideoCreate, VideoResolution, VideoState } from '@shared/models'import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'import { retryTransactionWrapper } from '../../../helpers/database-utils'diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.tsindex 65578c1438..81a60ee660 100644--- a/server/helpers/custom-validators/misc.ts+++ b/server/helpers/custom-validators/misc.ts@@ -2,7 +2,7 @@ import 'multer'import { UploadFilesForCheck } from 'express'import { sep } from 'path'import validator from 'validator'-import { isShortUUID, shortToUUID } from '@shared/core-utils'+import { isShortUUID, shortToUUID } from '@shared/extra-utils'function exists (value: any) {return value !== undefined && value !== nulldiff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.tsindex c4704b189f..b174ae4369 100644--- a/server/helpers/image-utils.ts+++ b/server/helpers/image-utils.ts@@ -1,6 +1,7 @@import { copy, readFile, remove, rename } from 'fs-extra'import Jimp, { read } from 'jimp'-import { buildUUID, getLowercaseExtension } from '@shared/core-utils'+import { getLowercaseExtension } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { convertWebPToJPG, processGIF } from './ffmpeg-utils'import { logger } from './logger'diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.tsindex 221475bb14..ef3e15968c 100644--- a/server/initializers/migrations/0080-video-channels.ts+++ b/server/initializers/migrations/0080-video-channels.ts@@ -1,4 +1,4 @@-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import * as Sequelize from 'sequelize'async function up (utils: {diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.tsindex fb27c93012..4bf3100e41 100644--- a/server/initializers/migrations/0345-video-playlists.ts+++ b/server/initializers/migrations/0345-video-playlists.ts@@ -1,5 +1,5 @@import * as Sequelize from 'sequelize'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'import { WEBSERVER } from '../constants'diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/initializers/migrations/0560-user-feed-token.tsindex 4ed4d96817..4c85b04f79 100644--- a/server/initializers/migrations/0560-user-feed-token.ts+++ b/server/initializers/migrations/0560-user-feed-token.ts@@ -1,5 +1,5 @@import * as Sequelize from 'sequelize'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'async function up (utils: {transaction: Sequelize.Transactiondiff --git a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts b/server/lib/activitypub/actors/shared/object-to-model-attributes.tsindex 38d93c1085..23bc972e56 100644--- a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts+++ b/server/lib/activitypub/actors/shared/object-to-model-attributes.ts@@ -2,7 +2,8 @@ import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitimport { MIMETYPES } from '@server/initializers/constants'import { ActorModel } from '@server/models/actor/actor'import { FilteredModelAttributes } from '@server/types'-import { buildUUID, getLowercaseExtension } from '@shared/core-utils'+import { getLowercaseExtension } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { ActivityPubActor, ActorImageType } from '@shared/models'function getActorAttributesFromObject (diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.tsindex 04ad98f3e4..c6826759bd 100644--- a/server/lib/local-actor.ts+++ b/server/lib/local-actor.ts@@ -3,7 +3,8 @@ import { queue } from 'async'import LRUCache from 'lru-cache'import { join } from 'path'import { ActorModel } from '@server/models/actor/actor'-import { buildUUID, getLowercaseExtension } from '@shared/core-utils'+import { getLowercaseExtension } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { ActivityPubActorType, ActorImageType } from '@shared/models'import { retryTransactionWrapper } from '../helpers/database-utils'import { processImage } from '../helpers/image-utils'diff --git a/server/lib/paths.ts b/server/lib/paths.tsindex bf0c3a86b7..5a85bea428 100644--- a/server/lib/paths.ts+++ b/server/lib/paths.ts@@ -2,7 +2,8 @@ import { join } from 'path'import { CONFIG } from '@server/initializers/config'import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'-import { buildUUID, removeFragmentedMP4Ext } from '@shared/core-utils'+import { removeFragmentedMP4Ext } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'// ################## Video file name ##################diff --git a/server/lib/user.ts b/server/lib/user.tsindex 3ba0c0ca4b..0d292ac90a 100644--- a/server/lib/user.ts+++ b/server/lib/user.ts@@ -1,7 +1,7 @@import { Transaction } from 'sequelize/types'import { UserModel } from '@server/models/user/user'import { MActorDefault } from '@server/types/models/actor'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { ActivityPubActorType } from '../../shared/models/activitypub'import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'diff --git a/server/lib/video-path-manager.ts b/server/lib/video-path-manager.tsindex 4027f885d1..c3f55fd954 100644--- a/server/lib/video-path-manager.ts+++ b/server/lib/video-path-manager.ts@@ -10,7 +10,7 @@ import {MVideoFileVideo,MVideoUUID} from '@server/types/models'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { VideoStorage } from '@shared/models'import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage'import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths'diff --git a/server/models/user/user-notification.ts b/server/models/user/user-notification.tsindex 8450ad49ec..edad10a558 100644--- a/server/models/user/user-notification.ts+++ b/server/models/user/user-notification.ts@@ -1,7 +1,7 @@import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize'import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user'-import { uuidToShort } from '@shared/core-utils'+import { uuidToShort } from '@shared/extra-utils'import { UserNotification, UserNotificationType } from '@shared/models'import { AttributesOnly } from '@shared/typescript-utils'import { isBooleanValid } from '../../helpers/custom-validators/misc'diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.tsindex 99a4818ab0..7456f37c52 100644--- a/server/models/video/formatter/video-format-utils.ts+++ b/server/models/video/formatter/video-format-utils.ts@@ -1,7 +1,7 @@import { generateMagnetUri } from '@server/helpers/webtorrent'import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls'import { VideoViews } from '@server/lib/video-views'-import { uuidToShort } from '@shared/core-utils'+import { uuidToShort } from '@shared/extra-utils'import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models'import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects'import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos'diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.tsindex 20741ea64b..6b240f1168 100644--- a/server/models/video/video-caption.ts+++ b/server/models/video/video-caption.ts@@ -16,7 +16,7 @@ import {UpdatedAt} from 'sequelize-typescript'import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'-import { buildUUID } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { AttributesOnly } from '@shared/typescript-utils'import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.tsindex 07bb648107..0d43c795e3 100644--- a/server/models/video/video-playlist.ts+++ b/server/models/video/video-playlist.ts@@ -18,7 +18,8 @@ import {UpdatedAt} from 'sequelize-typescript'import { MAccountId, MChannelId } from '@server/types/models'-import { buildPlaylistEmbedPath, buildPlaylistWatchPath, buildUUID, pick, uuidToShort } from '@shared/core-utils'+import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'+import { buildUUID, uuidToShort } from '@shared/extra-utils'import { AttributesOnly } from '@shared/typescript-utils'import { ActivityIconObject } from '../../../shared/models/activitypub/objects'import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 1f103f930a..e5077487a9 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -32,7 +32,8 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths'import { VideoPathManager } from '@server/lib/video-path-manager'import { getServerActor } from '@server/models/application/application'import { ModelCache } from '@server/models/model-cache'-import { buildVideoEmbedPath, buildVideoWatchPath, pick, uuidToShort } from '@shared/core-utils'+import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'+import { uuidToShort } from '@shared/extra-utils'import {ResultList,ThumbnailType,diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.tsindex e6e1d5f7b4..9e330bd616 100644--- a/server/tests/api/notifications/moderation-notifications.ts+++ b/server/tests/api/notifications/moderation-notifications.ts@@ -19,7 +19,8 @@ import {MockSmtpServer,prepareNotificationsTest} from '@server/tests/shared'-import { buildUUID, wait } from '@shared/core-utils'+import { wait } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.tsindex 0bd474c09d..f9f3e0e0ea 100644--- a/server/tests/api/notifications/user-notifications.ts+++ b/server/tests/api/notifications/user-notifications.ts@@ -13,7 +13,8 @@ import {prepareNotificationsTest,uploadRandomVideoOnServers} from '@server/tests/shared'-import { buildUUID, wait } from '@shared/core-utils'+import { wait } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.tsindex 8e8fc7e20c..a723ed8b4f 100644--- a/server/tests/cli/prune-storage.ts+++ b/server/tests/cli/prune-storage.ts@@ -4,7 +4,8 @@ import 'mocha'import * as chai from 'chai'import { createFile, readdir } from 'fs-extra'import { join } from 'path'-import { buildUUID, wait } from '@shared/core-utils'+import { wait } from '@shared/core-utils'+import { buildUUID } from '@shared/extra-utils'import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'import {cleanupTests,diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.tsindex 88d6b7514d..49d209819a 100644--- a/shared/core-utils/common/object.ts+++ b/shared/core-utils/common/object.ts@@ -10,6 +10,10 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pickreturn result}+function getKeys <O extends object, K extends keyof O> (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.tsindex c1891188f1..30d22df095 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.tsindex 8f6736d39d..620e3a716f 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.tsindex 373d27cb49..e2e161a7b8 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.tssimilarity index 100%rename from shared/core-utils/videos/uuid.tsrename to shared/extra-utils/uuid.tsdiff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.tsindex ead57b9aa6..21753ddc46 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,