From 0628157fe9662fdb2b6fa658b8b53fe684c013ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Dec 2021 14:44:58 +0100 Subject: Move uuid stuff in extra utils Since it requires an external dependency --- 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 +- server/lib/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 ++- 22 files changed, 32 insertions(+), 23 deletions(-) (limited to 'server') diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts index 5ada4a805..258b50fe9 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.ts index dc1947764..795e14e73 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.ts index 80ecbfef1..8b8cacff9 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts @@ -9,7 +9,7 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } fro import { 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.ts index e8f400cff..89787f20b 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.ts index 65578c143..81a60ee66 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 !== null diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index c4704b189..b174ae436 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.ts index 221475bb1..ef3e15968 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.ts index fb27c9301..4bf3100e4 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.ts index 4ed4d9681..4c85b04f7 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.Transaction diff --git a/server/lib/activitypub/actors/shared/object-to-model-attributes.ts b/server/lib/activitypub/actors/shared/object-to-model-attributes.ts index 38d93c108..23bc972e5 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/activit import { 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.ts index 04ad98f3e..c6826759b 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.ts index bf0c3a86b..5a85bea42 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.ts index 3ba0c0ca4..0d292ac90 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.ts index 4027f885d..c3f55fd95 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.ts index 8450ad49e..edad10a55 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.ts index 99a4818ab..7456f37c5 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.ts index 20741ea64..6b240f116 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.ts index 07bb64810..0d43c795e 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.ts index 1f103f930..e5077487a 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.ts index e6e1d5f7b..9e330bd61 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.ts index 0bd474c09..f9f3e0e0e 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.ts index 8e8fc7e20..a723ed8b4 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, -- cgit v1.2.3