From 7d9ba5c08999c6482f0bc5e0c09c6f55b7724090 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 May 2021 11:15:29 +0200 Subject: [PATCH] Cleanup models directory organization --- scripts/prune-storage.ts | 2 +- scripts/reset-password.ts | 2 +- scripts/update-host.ts | 4 ++-- server/controllers/activitypub/client.ts | 2 +- server/controllers/api/server/follows.ts | 18 ++++++++--------- .../api/server/server-blocklist.ts | 2 +- server/controllers/api/users/index.ts | 2 +- server/controllers/api/users/me.ts | 2 +- server/controllers/api/users/my-blocklist.ts | 2 +- server/controllers/api/users/my-history.ts | 2 +- .../controllers/api/users/my-notifications.ts | 14 ++++++------- .../controllers/api/users/my-subscriptions.ts | 2 +- server/controllers/api/videos/watching.ts | 2 +- server/controllers/lazy-static.ts | 2 +- server/controllers/static.ts | 2 +- server/helpers/actor.ts | 2 +- server/helpers/middlewares/accounts.ts | 2 +- server/helpers/signup.ts | 2 +- server/helpers/webfinger.ts | 6 +++--- server/initializers/checker-after-init.ts | 2 +- server/initializers/database.ts | 14 ++++++------- server/initializers/installer.ts | 2 +- server/lib/activitypub/actor.ts | 4 ++-- server/lib/activitypub/audience.ts | 2 +- .../lib/activitypub/process/process-accept.ts | 4 ++-- .../lib/activitypub/process/process-delete.ts | 2 +- .../lib/activitypub/process/process-follow.ts | 14 ++++++------- .../lib/activitypub/process/process-reject.ts | 2 +- .../lib/activitypub/process/process-undo.ts | 4 ++-- .../lib/activitypub/process/process-update.ts | 20 +++++++++---------- server/lib/activitypub/send/send-delete.ts | 2 +- server/lib/activitypub/send/send-view.ts | 2 +- server/lib/activitypub/send/utils.ts | 12 +++++------ server/lib/auth/oauth-model.ts | 4 ++-- .../job-queue/handlers/activitypub-follow.ts | 20 +++++++++---------- .../handlers/activitypub-refresher.ts | 8 ++++---- server/lib/job-queue/handlers/actor-keys.ts | 2 +- .../handlers/utils/activitypub-http-utils.ts | 8 ++++---- .../job-queue/handlers/video-file-import.ts | 2 +- .../job-queue/handlers/video-transcoding.ts | 2 +- server/lib/live-manager.ts | 2 +- server/lib/moderation.ts | 4 ++-- server/lib/notifier.ts | 4 ++-- server/lib/plugins/plugin-helpers-builder.ts | 2 +- server/lib/redundancy.ts | 12 +++++------ .../lib/schedulers/actor-follow-scheduler.ts | 4 ++-- .../schedulers/auto-follow-index-instances.ts | 2 +- .../remove-old-history-scheduler.ts | 2 +- server/lib/stat-manager.ts | 4 ++-- server/lib/user.ts | 9 +++++---- server/middlewares/validators/follows.ts | 16 +++++++-------- .../validators/user-subscriptions.ts | 8 ++++---- server/middlewares/validators/users.ts | 4 ++-- .../validators/videos/video-channels.ts | 4 ++-- server/middlewares/validators/webfinger.ts | 6 +++--- server/models/account/account-blocklist.ts | 2 +- server/models/account/account-video-rate.ts | 2 +- server/models/account/account.ts | 8 ++++---- .../{activitypub => actor}/actor-follow.ts | 0 .../models/{account => actor}/actor-image.ts | 0 server/models/{activitypub => actor}/actor.ts | 2 +- server/models/oauth/oauth-token.ts | 4 ++-- server/models/redundancy/video-redundancy.ts | 2 +- server/models/server/server.ts | 2 +- .../user-notification-setting.ts | 0 .../{account => user}/user-notification.ts | 8 ++++---- .../{account => user}/user-video-history.ts | 0 server/models/{account => user}/user.ts | 8 ++++---- server/models/video/video-channel.ts | 6 +++--- server/models/video/video-comment.ts | 2 +- server/models/video/video-import.ts | 4 ++-- server/models/video/video-playlist.ts | 2 +- server/models/video/video-share.ts | 2 +- server/models/video/video.ts | 8 ++++---- .../{moderation => abuse}/abuse-message.ts | 0 .../models/{moderation => abuse}/abuse.ts | 0 .../models/{moderation => abuse}/index.ts | 0 server/types/models/account/account.ts | 6 +++--- server/types/models/account/index.ts | 3 --- .../models/{account => actor}/actor-follow.ts | 2 +- .../models/{account => actor}/actor-image.ts | 2 +- .../types/models/{account => actor}/actor.ts | 5 ++--- server/types/models/actor/index.ts | 3 +++ server/types/models/index.ts | 3 ++- .../models/user/user-notification-setting.ts | 2 +- server/types/models/user/user-notification.ts | 8 ++++---- .../types/models/user/user-video-history.ts | 2 +- server/types/models/user/user.ts | 2 +- server/types/models/video/video-channels.ts | 6 ++++-- server/types/models/video/video-share.ts | 4 ++-- .../plugins/register-server-option.model.ts | 4 ++-- 91 files changed, 202 insertions(+), 199 deletions(-) rename server/models/{activitypub => actor}/actor-follow.ts (100%) rename server/models/{account => actor}/actor-image.ts (100%) rename server/models/{activitypub => actor}/actor.ts (99%) rename server/models/{account => user}/user-notification-setting.ts (100%) rename server/models/{account => user}/user-notification.ts (98%) rename server/models/{account => user}/user-video-history.ts (100%) rename server/models/{account => user}/user.ts (99%) rename server/types/models/{moderation => abuse}/abuse-message.ts (100%) rename server/types/models/{moderation => abuse}/abuse.ts (100%) rename server/types/models/{moderation => abuse}/index.ts (100%) rename server/types/models/{account => actor}/actor-follow.ts (96%) rename server/types/models/{account => actor}/actor-image.ts (83%) rename server/types/models/{account => actor}/actor.ts (98%) create mode 100644 server/types/models/actor/index.ts diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 32314b0b7..0f2d1320e 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -11,7 +11,7 @@ import { VideoRedundancyModel } from '../server/models/redundancy/video-redundan import * as Bluebird from 'bluebird' import { getUUIDFromFilename } from '../server/helpers/utils' import { ThumbnailModel } from '../server/models/video/thumbnail' -import { ActorImageModel } from '../server/models/account/actor-image' +import { ActorImageModel } from '../server/models/actor/actor-image' import { uniq, values } from 'lodash' import { ThumbnailType } from '@shared/models' diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 7e7de6b8a..7c1a64a3f 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts @@ -3,7 +3,7 @@ registerTSPaths() import * as program from 'commander' import { initDatabaseModels } from '../server/initializers/database' -import { UserModel } from '../server/models/account/user' +import { UserModel } from '../server/models/user/user' import { isUserPasswordValid } from '../server/helpers/custom-validators/users' program diff --git a/scripts/update-host.ts b/scripts/update-host.ts index e497be4e2..592684225 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -2,9 +2,9 @@ import { registerTSPaths } from '../server/helpers/register-ts-paths' registerTSPaths() import { WEBSERVER } from '../server/initializers/constants' -import { ActorFollowModel } from '../server/models/activitypub/actor-follow' +import { ActorFollowModel } from '../server/models/actor/actor-follow' import { VideoModel } from '../server/models/video/video' -import { ActorModel } from '../server/models/activitypub/actor' +import { ActorModel } from '../server/models/actor/actor' import { getLocalAccountActivityPubUrl, getLocalVideoActivityPubUrl, diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 1b4acc234..1982e171d 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -30,7 +30,7 @@ import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' import { AccountModel } from '../../models/account/account' import { AccountVideoRateModel } from '../../models/account/account-video-rate' -import { ActorFollowModel } from '../../models/activitypub/actor-follow' +import { ActorFollowModel } from '../../models/actor/actor-follow' import { VideoModel } from '../../models/video/video' import { VideoCaptionModel } from '../../models/video/video-caption' import { VideoCommentModel } from '../../models/video/video-comment' diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 80025bc5b..daeef22de 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -1,9 +1,15 @@ import * as express from 'express' +import { getServerActor } from '@server/models/application/application' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { UserRight } from '../../../../shared/models/users' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' import { SERVER_ACTOR_NAME } from '../../../initializers/constants' +import { sequelizeTypescript } from '../../../initializers/database' +import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' +import { JobQueue } from '../../../lib/job-queue' +import { removeRedundanciesOfServer } from '../../../lib/redundancy' import { asyncMiddleware, authenticate, @@ -19,16 +25,10 @@ import { followingSortValidator, followValidator, getFollowerValidator, - removeFollowingValidator, - listFollowsValidator + listFollowsValidator, + removeFollowingValidator } from '../../../middlewares/validators' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { JobQueue } from '../../../lib/job-queue' -import { removeRedundanciesOfServer } from '../../../lib/redundancy' -import { sequelizeTypescript } from '../../../initializers/database' -import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' -import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { ActorFollowModel } from '../../../models/actor/actor-follow' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts index 6e341c0fb..a86bc7d19 100644 --- a/server/controllers/api/server/server-blocklist.ts +++ b/server/controllers/api/server/server-blocklist.ts @@ -1,7 +1,7 @@ import 'multer' import * as express from 'express' import { logger } from '@server/helpers/logger' -import { UserNotificationModel } from '@server/models/account/user-notification' +import { UserNotificationModel } from '@server/models/user/user-notification' import { getServerActor } from '@server/models/application/application' import { UserRight } from '../../../../shared/models/users' import { getFormattedObjects } from '../../../helpers/utils' diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index e2b1ea7cd..c655d1648 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts @@ -45,7 +45,7 @@ import { usersResetPasswordValidator, usersVerifyEmailValidator } from '../../../middlewares/validators' -import { UserModel } from '../../../models/account/user' +import { UserModel } from '../../../models/user/user' import { meRouter } from './me' import { myAbusesRouter } from './my-abuses' import { myBlocklistRouter } from './my-blocklist' diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 0763d1900..d97652840 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -28,7 +28,7 @@ import { deleteMeValidator, videoImportsSortValidator, videosSortValidator } fro import { updateAvatarValidator } from '../../../middlewares/validators/actor-image' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { UserModel } from '../../../models/account/user' +import { UserModel } from '../../../models/user/user' import { VideoModel } from '../../../models/video/video' import { VideoImportModel } from '../../../models/video/video-import' diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index faaef3ac0..a1561b751 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -20,7 +20,7 @@ import { import { AccountBlocklistModel } from '../../../models/account/account-blocklist' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { ServerBlocklistModel } from '../../../models/server/server-blocklist' -import { UserNotificationModel } from '@server/models/account/user-notification' +import { UserNotificationModel } from '@server/models/user/user-notification' import { logger } from '@server/helpers/logger' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index 72c7da373..cff1697ab 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts @@ -9,7 +9,7 @@ import { userHistoryRemoveValidator } from '../../../middlewares' import { getFormattedObjects } from '../../../helpers/utils' -import { UserVideoHistoryModel } from '../../../models/account/user-video-history' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history' import { sequelizeTypescript } from '../../../initializers/database' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts index 0a9101a46..2909770da 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/controllers/api/users/my-notifications.ts @@ -1,5 +1,9 @@ -import * as express from 'express' import 'multer' +import * as express from 'express' +import { UserNotificationModel } from '@server/models/user/user-notification' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { UserNotificationSetting } from '../../../../shared/models/users' +import { getFormattedObjects } from '../../../helpers/utils' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -9,17 +13,13 @@ import { setDefaultSort, userNotificationsSortValidator } from '../../../middlewares' -import { getFormattedObjects } from '../../../helpers/utils' -import { UserNotificationModel } from '../../../models/account/user-notification' -import { meRouter } from './me' import { listUserNotificationsValidator, markAsReadUserNotificationsValidator, updateNotificationSettingsValidator } from '../../../middlewares/validators/user-notifications' -import { UserNotificationSetting } from '../../../../shared/models/users' -import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting' +import { meRouter } from './me' const myNotificationsRouter = express.Router() diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 56b93276f..46a73d49e 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts @@ -27,7 +27,7 @@ import { userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { VideoModel } from '../../../models/video/video' const mySubscriptionsRouter = express.Router() diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 627f12aa9..08190e583 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { UserWatchingVideo } from '../../../../shared' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoWatchingValidator } from '../../../middlewares' -import { UserVideoHistoryModel } from '../../../models/account/user-video-history' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const watchingRouter = express.Router() diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts index 6f71fdb16..25d3b49b4 100644 --- a/server/controllers/lazy-static.ts +++ b/server/controllers/lazy-static.ts @@ -7,7 +7,7 @@ import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants' import { actorImagePathUnsafeCache, pushActorImageProcessInQueue } from '../lib/actor-image' import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' import { asyncMiddleware } from '../middlewares' -import { ActorImageModel } from '../models/account/actor-image' +import { ActorImageModel } from '../models/actor/actor-image' const lazyStaticRouter = express.Router() diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 5cf4e9575..97c48b1d7 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -20,7 +20,7 @@ import { import { getThemeOrDefault } from '../lib/plugins/theme-utils' import { asyncMiddleware } from '../middlewares' import { cacheRoute } from '../middlewares/cache' -import { UserModel } from '../models/account/user' +import { UserModel } from '../models/user/user' import { VideoModel } from '../models/video/video' import { VideoCommentModel } from '../models/video/video-comment' diff --git a/server/helpers/actor.ts b/server/helpers/actor.ts index a60d3ed5d..5f742505b 100644 --- a/server/helpers/actor.ts +++ b/server/helpers/actor.ts @@ -1,5 +1,5 @@ -import { ActorModel } from '../models/activitypub/actor' +import { ActorModel } from '../models/actor/actor' import { MActorAccountChannelId, MActorFull } from '../types/models' type ActorFetchByUrlType = 'all' | 'association-ids' diff --git a/server/helpers/middlewares/accounts.ts b/server/helpers/middlewares/accounts.ts index 13ae6cdf4..5addd3e1a 100644 --- a/server/helpers/middlewares/accounts.ts +++ b/server/helpers/middlewares/accounts.ts @@ -1,5 +1,5 @@ import { Response } from 'express' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { AccountModel } from '../../models/account/account' import { MAccountDefault } from '../../types/models' diff --git a/server/helpers/signup.ts b/server/helpers/signup.ts index ed872539b..8fa81e601 100644 --- a/server/helpers/signup.ts +++ b/server/helpers/signup.ts @@ -1,4 +1,4 @@ -import { UserModel } from '../models/account/user' +import { UserModel } from '../models/user/user' import * as ipaddr from 'ipaddr.js' import { CONFIG } from '../initializers/config' diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index da7e88077..33367f651 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts @@ -1,10 +1,10 @@ import * as WebFinger from 'webfinger.js' import { WebFingerData } from '../../shared' -import { ActorModel } from '../models/activitypub/actor' -import { isTestInstance } from './core-utils' -import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' import { WEBSERVER } from '../initializers/constants' +import { ActorModel } from '../models/actor/actor' import { MActorFull } from '../types/models' +import { isTestInstance } from './core-utils' +import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' const webfinger = new WebFinger({ webfist_fallback: false, diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index a93c8b7fd..911734fa0 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -7,7 +7,7 @@ import { RecentlyAddedStrategy } from '../../shared/models/redundancy' import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils' import { isArray } from '../helpers/custom-validators/misc' import { logger } from '../helpers/logger' -import { UserModel } from '../models/account/user' +import { UserModel } from '../models/user/user' import { ApplicationModel, getServerActor } from '../models/application/application' import { OAuthClientModel } from '../models/oauth/oauth-client' import { CONFIG, isEmailEnabled } from './config' diff --git a/server/initializers/database.ts b/server/initializers/database.ts index edf12bc41..75a13ec8b 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -2,6 +2,9 @@ import { QueryTypes, Transaction } from 'sequelize' import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' import { TrackerModel } from '@server/models/server/tracker' import { VideoTrackerModel } from '@server/models/server/video-tracker' +import { UserModel } from '@server/models/user/user' +import { UserNotificationModel } from '@server/models/user/user-notification' +import { UserVideoHistoryModel } from '@server/models/user/user-video-history' import { isTestInstance } from '../helpers/core-utils' import { logger } from '../helpers/logger' import { AbuseModel } from '../models/abuse/abuse' @@ -11,13 +14,9 @@ import { VideoCommentAbuseModel } from '../models/abuse/video-comment-abuse' import { AccountModel } from '../models/account/account' import { AccountBlocklistModel } from '../models/account/account-blocklist' import { AccountVideoRateModel } from '../models/account/account-video-rate' -import { ActorImageModel } from '../models/account/actor-image' -import { UserModel } from '../models/account/user' -import { UserNotificationModel } from '../models/account/user-notification' -import { UserNotificationSettingModel } from '../models/account/user-notification-setting' -import { UserVideoHistoryModel } from '../models/account/user-video-history' -import { ActorModel } from '../models/activitypub/actor' -import { ActorFollowModel } from '../models/activitypub/actor-follow' +import { ActorModel } from '../models/actor/actor' +import { ActorFollowModel } from '../models/actor/actor-follow' +import { ActorImageModel } from '../models/actor/actor-image' import { ApplicationModel } from '../models/application/application' import { OAuthClientModel } from '../models/oauth/oauth-client' import { OAuthTokenModel } from '../models/oauth/oauth-token' @@ -25,6 +24,7 @@ import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' import { PluginModel } from '../models/server/plugin' import { ServerModel } from '../models/server/server' import { ServerBlocklistModel } from '../models/server/server-blocklist' +import { UserNotificationSettingModel } from '../models/user/user-notification-setting' import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' import { TagModel } from '../models/video/tag' import { ThumbnailModel } from '../models/video/thumbnail' diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 8dcff64e2..676f88653 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts @@ -2,7 +2,7 @@ import * as passwordGenerator from 'password-generator' import { UserRole } from '../../shared' import { logger } from '../helpers/logger' import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' -import { UserModel } from '../models/account/user' +import { UserModel } from '../models/user/user' import { ApplicationModel } from '../models/application/application' import { OAuthClientModel } from '../models/oauth/oauth-client' import { applicationExist, clientsExist, usersExist } from './checker-after-init' diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 5fe7381c9..8865b6277 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -20,8 +20,8 @@ import { getUrlFromWebfinger } from '../../helpers/webfinger' import { MIMETYPES, WEBSERVER } from '../../initializers/constants' import { sequelizeTypescript } from '../../initializers/database' import { AccountModel } from '../../models/account/account' -import { ActorImageModel } from '../../models/account/actor-image' -import { ActorModel } from '../../models/activitypub/actor' +import { ActorModel } from '../../models/actor/actor' +import { ActorImageModel } from '../../models/actor/actor-image' import { ServerModel } from '../../models/server/server' import { VideoChannelModel } from '../../models/video/video-channel' import { diff --git a/server/lib/activitypub/audience.ts b/server/lib/activitypub/audience.ts index 2986714d3..d0558f191 100644 --- a/server/lib/activitypub/audience.ts +++ b/server/lib/activitypub/audience.ts @@ -1,7 +1,7 @@ import { Transaction } from 'sequelize' import { ActivityAudience } from '../../../shared/models/activitypub' import { ACTIVITY_PUB } from '../../initializers/constants' -import { ActorModel } from '../../models/activitypub/actor' +import { ActorModel } from '../../models/actor/actor' import { VideoModel } from '../../models/video/video' import { VideoShareModel } from '../../models/video/video-share' import { MActorFollowersUrl, MActorLight, MActorUrl, MCommentOwner, MCommentOwnerVideo, MVideoId } from '../../types/models' diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts index 1799829f8..8ad470cf4 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/lib/activitypub/process/process-accept.ts @@ -1,8 +1,8 @@ import { ActivityAccept } from '../../../../shared/models/activitypub' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { addFetchOutboxJob } from '../actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { APProcessorOptions } from '../../../types/activitypub-processor.model' import { MActorDefault, MActorSignature } from '../../../types/models' +import { addFetchOutboxJob } from '../actor' async function processAcceptActivity (options: APProcessorOptions) { const { byActor: targetActor, inboxActor } = options diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 88a968318..20214246c 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts @@ -2,7 +2,7 @@ import { ActivityDelete } from '../../../../shared/models/activitypub' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { sequelizeTypescript } from '../../../initializers/database' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' import { VideoModel } from '../../../models/video/video' import { VideoCommentModel } from '../../../models/video/video-comment' import { VideoPlaylistModel } from '../../../models/video/video-playlist' diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 38d684512..9009c6469 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -1,17 +1,17 @@ +import { getServerActor } from '@server/models/application/application' import { ActivityFollow } from '../../../../shared/models/activitypub' +import { getAPId } from '../../../helpers/activitypub' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' -import { sequelizeTypescript } from '../../../initializers/database' -import { ActorModel } from '../../../models/activitypub/actor' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { sendAccept, sendReject } from '../send' -import { Notifier } from '../../notifier' -import { getAPId } from '../../../helpers/activitypub' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' +import { ActorModel } from '../../../models/actor/actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { APProcessorOptions } from '../../../types/activitypub-processor.model' import { MActorFollowActors, MActorSignature } from '../../../types/models' +import { Notifier } from '../../notifier' import { autoFollowBackIfNeeded } from '../follow' -import { getServerActor } from '@server/models/application/application' +import { sendAccept, sendReject } from '../send' async function processFollowActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/process/process-reject.ts b/server/lib/activitypub/process/process-reject.ts index 03b669fd9..7f7ab305f 100644 --- a/server/lib/activitypub/process/process-reject.ts +++ b/server/lib/activitypub/process/process-reject.ts @@ -1,6 +1,6 @@ import { ActivityReject } from '../../../../shared/models/activitypub/activity' import { sequelizeTypescript } from '../../../initializers/database' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { APProcessorOptions } from '../../../types/activitypub-processor.model' import { MActor } from '../../../types/models' diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts index e520c2f0d..9f031b528 100644 --- a/server/lib/activitypub/process/process-undo.ts +++ b/server/lib/activitypub/process/process-undo.ts @@ -4,8 +4,8 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { sequelizeTypescript } from '../../../initializers/database' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { ActorModel } from '../../../models/activitypub/actor' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorModel } from '../../../models/actor/actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' import { VideoShareModel } from '../../../models/video/video-share' import { APProcessorOptions } from '../../../types/activitypub-processor.model' diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 6df9b93b2..6cd9d0fba 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts @@ -1,23 +1,23 @@ +import { isRedundancyAccepted } from '@server/lib/redundancy' +import { ActorImageType } from '@shared/models' import { ActivityUpdate, CacheFileObject, VideoObject } from '../../../../shared/models/activitypub' import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' +import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' +import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file' +import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { sequelizeTypescript } from '../../../initializers/database' import { AccountModel } from '../../../models/account/account' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' import { VideoChannelModel } from '../../../models/video/video-channel' +import { APProcessorOptions } from '../../../types/activitypub-processor.model' +import { MAccountIdActor, MActorSignature } from '../../../types/models' import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor' -import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos' -import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' -import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file' import { createOrUpdateCacheFile } from '../cache-file' -import { forwardVideoRelatedActivity } from '../send/utils' -import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' import { createOrUpdateVideoPlaylist } from '../playlist' -import { APProcessorOptions } from '../../../types/activitypub-processor.model' -import { MActorSignature, MAccountIdActor } from '../../../types/models' -import { isRedundancyAccepted } from '@server/lib/redundancy' -import { ActorImageType } from '@shared/models' +import { forwardVideoRelatedActivity } from '../send/utils' +import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos' async function processUpdateActivity (options: APProcessorOptions) { const { activity, byActor } = options diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index e0acced18..d31f8c10b 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts @@ -2,7 +2,7 @@ import { Transaction } from 'sequelize' import { getServerActor } from '@server/models/application/application' import { ActivityAudience, ActivityDelete } from '../../../../shared/models/activitypub' import { logger } from '../../../helpers/logger' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' import { VideoCommentModel } from '../../../models/video/video-comment' import { VideoShareModel } from '../../../models/video/video-share' import { MActorUrl } from '../../../types/models' diff --git a/server/lib/activitypub/send/send-view.ts b/server/lib/activitypub/send/send-view.ts index 9254dc7c5..153e94295 100644 --- a/server/lib/activitypub/send/send-view.ts +++ b/server/lib/activitypub/send/send-view.ts @@ -2,7 +2,7 @@ import { Transaction } from 'sequelize' import { MActorAudience, MVideoImmutable, MVideoUrl } from '@server/types/models' import { ActivityAudience, ActivityView } from '../../../../shared/models/activitypub' import { logger } from '../../../helpers/logger' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' import { audiencify, getAudience } from '../audience' import { getLocalVideoViewActivityPubUrl } from '../url' import { sendVideoRelatedActivity } from './utils' diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts index 85a9f009d..db0e91b71 100644 --- a/server/lib/activitypub/send/utils.ts +++ b/server/lib/activitypub/send/utils.ts @@ -1,14 +1,14 @@ import { Transaction } from 'sequelize' +import { getServerActor } from '@server/models/application/application' +import { ContextType } from '@shared/models/activitypub/context' import { Activity, ActivityAudience } from '../../../../shared/models/activitypub' +import { afterCommitIfTransaction } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' -import { ActorModel } from '../../../models/activitypub/actor' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorModel } from '../../../models/actor/actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' +import { MActor, MActorId, MActorLight, MActorWithInboxes, MVideoAccountLight, MVideoId, MVideoImmutable } from '../../../types/models' import { JobQueue } from '../../job-queue' import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience' -import { afterCommitIfTransaction } from '../../../helpers/database-utils' -import { MActor, MActorId, MActorLight, MActorWithInboxes, MVideoAccountLight, MVideoId, MVideoImmutable } from '../../../types/models' -import { getServerActor } from '@server/models/application/application' -import { ContextType } from '@shared/models/activitypub/context' async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { byActor: MActorLight diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index b9c69eb2d..ae728d080 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { AccessDeniedError } from 'oauth2-server' import { PluginManager } from '@server/lib/plugins/plugin-manager' -import { ActorModel } from '@server/models/activitypub/actor' +import { ActorModel } from '@server/models/actor/actor' import { MOAuthClient } from '@server/types/models' import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' import { MUser } from '@server/types/models/user/user' @@ -9,7 +9,7 @@ import { UserAdminFlag } from '@shared/models/users/user-flag.model' import { UserRole } from '@shared/models/users/user-role' import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' -import { UserModel } from '../../models/account/user' +import { UserModel } from '../../models/user/user' import { OAuthClientModel } from '../../models/oauth/oauth-client' import { OAuthTokenModel } from '../../models/oauth/oauth-token' import { createUserAccountAndChannelAndPlaylist } from '../user' diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 82c95be80..ec8df8969 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -1,18 +1,18 @@ import * as Bull from 'bull' -import { logger } from '../../../helpers/logger' -import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants' -import { sendFollow } from '../../activitypub/send' +import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' +import { ActivitypubFollowPayload } from '@shared/models' import { sanitizeHost } from '../../../helpers/core-utils' -import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' -import { getOrCreateActorAndServerAndModel } from '../../activitypub/actor' import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { ActorModel } from '../../../models/activitypub/actor' -import { Notifier } from '../../notifier' +import { logger } from '../../../helpers/logger' +import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' +import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants' import { sequelizeTypescript } from '../../../initializers/database' +import { ActorModel } from '../../../models/actor/actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { MActor, MActorFollowActors, MActorFull } from '../../../types/models' -import { ActivitypubFollowPayload } from '@shared/models' -import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' +import { getOrCreateActorAndServerAndModel } from '../../activitypub/actor' +import { sendFollow } from '../../activitypub/send' +import { Notifier } from '../../notifier' async function processActivityPubFollow (job: Bull.Job) { const payload = job.data as ActivitypubFollowPayload diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts index 666e56868..c09b1bcc8 100644 --- a/server/lib/job-queue/handlers/activitypub-refresher.ts +++ b/server/lib/job-queue/handlers/activitypub-refresher.ts @@ -1,12 +1,12 @@ import * as Bull from 'bull' +import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlist' +import { RefreshPayload } from '@shared/models' import { logger } from '../../../helpers/logger' import { fetchVideoByUrl } from '../../../helpers/video' +import { ActorModel } from '../../../models/actor/actor' +import { VideoPlaylistModel } from '../../../models/video/video-playlist' import { refreshActorIfNeeded } from '../../activitypub/actor' import { refreshVideoIfNeeded } from '../../activitypub/videos' -import { ActorModel } from '../../../models/activitypub/actor' -import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { RefreshPayload } from '@shared/models' -import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlist' async function refreshAPObject (job: Bull.Job) { const payload = job.data as RefreshPayload diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts index 125307843..3eef565d0 100644 --- a/server/lib/job-queue/handlers/actor-keys.ts +++ b/server/lib/job-queue/handlers/actor-keys.ts @@ -1,6 +1,6 @@ import * as Bull from 'bull' import { generateAndSaveActorKeys } from '@server/lib/activitypub/actor' -import { ActorModel } from '@server/models/activitypub/actor' +import { ActorModel } from '@server/models/actor/actor' import { ActorKeysPayload } from '@shared/models' import { logger } from '../../../helpers/logger' diff --git a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts index e8a91450d..37e7c1fad 100644 --- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts +++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts @@ -1,10 +1,10 @@ +import { buildDigest } from '@server/helpers/peertube-crypto' +import { getServerActor } from '@server/models/application/application' +import { ContextType } from '@shared/models/activitypub/context' import { buildSignedActivity } from '../../../../helpers/activitypub' -import { ActorModel } from '../../../../models/activitypub/actor' import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants' +import { ActorModel } from '../../../../models/actor/actor' import { MActor } from '../../../../types/models' -import { getServerActor } from '@server/models/application/application' -import { buildDigest } from '@server/helpers/peertube-crypto' -import { ContextType } from '@shared/models/activitypub/context' type Payload = { body: T, contextType?: ContextType, signatureActorId?: number } diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index 71f2cafcd..8297a1571 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts @@ -3,7 +3,7 @@ import { copy, stat } from 'fs-extra' import { extname } from 'path' import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' import { MVideoFullLight } from '@server/types/models' import { VideoFileImportPayload } from '@shared/models' import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index e31bc82f5..8d659daa6 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -2,7 +2,7 @@ import * as Bull from 'bull' import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' import { getTranscodingJobPriority, publishAndFederateIfNeeded } from '@server/lib/video' import { getVideoFilePath } from '@server/lib/video-paths' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' import { MUser, MUserId, MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' import { HLSTranscodingPayload, diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index fe2a43f61..8e7fd5511 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts @@ -11,7 +11,7 @@ import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution import { logger } from '@server/helpers/logger' import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, VIEW_LIFETIME, WEBSERVER } from '@server/initializers/constants' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' import { VideoModel } from '@server/models/video/video' import { VideoFileModel } from '@server/models/video/video-file' import { VideoLiveModel } from '@server/models/video/video-live' diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts index 925d64902..d83086005 100644 --- a/server/lib/moderation.ts +++ b/server/lib/moderation.ts @@ -24,8 +24,8 @@ import { VideoObject } from '../../shared/models/activitypub/objects' import { VideoCommentObject } from '../../shared/models/activitypub/objects/video-comment-object' import { LiveVideoCreate, VideoCreate, VideoImportCreate } from '../../shared/models/videos' import { VideoCommentCreate } from '../../shared/models/videos/video-comment.model' -import { UserModel } from '../models/account/user' -import { ActorModel } from '../models/activitypub/actor' +import { UserModel } from '../models/user/user' +import { ActorModel } from '../models/actor/actor' import { VideoModel } from '../models/video/video' import { VideoCommentModel } from '../models/video/video-comment' import { sendAbuse } from './activitypub/send/send-flag' diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index da7f7cc05..1f9ff16df 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts @@ -17,8 +17,8 @@ import { VideoPrivacy, VideoState } from '../../shared/models/videos' import { logger } from '../helpers/logger' import { CONFIG } from '../initializers/config' import { AccountBlocklistModel } from '../models/account/account-blocklist' -import { UserModel } from '../models/account/user' -import { UserNotificationModel } from '../models/account/user-notification' +import { UserModel } from '../models/user/user' +import { UserNotificationModel } from '../models/user/user-notification' import { MAbuseFull, MAbuseMessage, MAccountServer, MActorFollowFull, MApplication, MPlugin } from '../types/models' import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../types/models/video' import { isBlockedByServerOrAccount } from './blocklist' diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index f1bc24d8b..cb1cd4d9a 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts @@ -17,7 +17,7 @@ import { VideoBlacklistCreate } from '@shared/models' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' import { getServerConfig } from '../config' import { blacklistVideo, unblacklistVideo } from '../video-blacklist' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { const logger = buildPluginLogger(npmName) diff --git a/server/lib/redundancy.ts b/server/lib/redundancy.ts index da620b607..2a9241249 100644 --- a/server/lib/redundancy.ts +++ b/server/lib/redundancy.ts @@ -1,12 +1,12 @@ -import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' -import { sendUndoCacheFile } from './activitypub/send' import { Transaction } from 'sequelize' -import { MActorSignature, MVideoRedundancyVideo } from '@server/types/models' -import { CONFIG } from '@server/initializers/config' import { logger } from '@server/helpers/logger' -import { ActorFollowModel } from '@server/models/activitypub/actor-follow' -import { Activity } from '@shared/models' +import { CONFIG } from '@server/initializers/config' +import { ActorFollowModel } from '@server/models/actor/actor-follow' import { getServerActor } from '@server/models/application/application' +import { MActorSignature, MVideoRedundancyVideo } from '@server/types/models' +import { Activity } from '@shared/models' +import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' +import { sendUndoCacheFile } from './activitypub/send' async function removeVideoRedundancy (videoRedundancy: MVideoRedundancyVideo, t?: Transaction) { const serverActor = await getServerActor() diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/lib/schedulers/actor-follow-scheduler.ts index 598c0211f..1b80316e9 100644 --- a/server/lib/schedulers/actor-follow-scheduler.ts +++ b/server/lib/schedulers/actor-follow-scheduler.ts @@ -1,9 +1,9 @@ import { isTestInstance } from '../../helpers/core-utils' import { logger } from '../../helpers/logger' -import { ActorFollowModel } from '../../models/activitypub/actor-follow' -import { AbstractScheduler } from './abstract-scheduler' import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' +import { ActorFollowModel } from '../../models/actor/actor-follow' import { ActorFollowScoreCache } from '../files-cache' +import { AbstractScheduler } from './abstract-scheduler' export class ActorFollowScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index 0b8cd1389..aaa5feed5 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts @@ -1,7 +1,7 @@ import { chunk } from 'lodash' import { doJSONRequest } from '@server/helpers/requests' import { JobQueue } from '@server/lib/job-queue' -import { ActorFollowModel } from '@server/models/activitypub/actor-follow' +import { ActorFollowModel } from '@server/models/actor/actor-follow' import { getServerActor } from '@server/models/application/application' import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' diff --git a/server/lib/schedulers/remove-old-history-scheduler.ts b/server/lib/schedulers/remove-old-history-scheduler.ts index 17a42b2c4..225669ea2 100644 --- a/server/lib/schedulers/remove-old-history-scheduler.ts +++ b/server/lib/schedulers/remove-old-history-scheduler.ts @@ -1,7 +1,7 @@ import { logger } from '../../helpers/logger' import { AbstractScheduler } from './abstract-scheduler' import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' -import { UserVideoHistoryModel } from '../../models/account/user-video-history' +import { UserVideoHistoryModel } from '../../models/user/user-video-history' import { CONFIG } from '../../initializers/config' export class RemoveOldHistoryScheduler extends AbstractScheduler { diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts index 09ba208bd..25ed21927 100644 --- a/server/lib/stat-manager.ts +++ b/server/lib/stat-manager.ts @@ -1,6 +1,6 @@ import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/account/user' -import { ActorFollowModel } from '@server/models/activitypub/actor-follow' +import { UserModel } from '@server/models/user/user' +import { ActorFollowModel } from '@server/models/actor/actor-follow' import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' import { VideoModel } from '@server/models/video/video' import { VideoChannelModel } from '@server/models/video/video-channel' diff --git a/server/lib/user.ts b/server/lib/user.ts index 9b0a0a2f1..8a6fcebc7 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts @@ -1,14 +1,15 @@ import { Transaction } from 'sequelize/types' import { v4 as uuidv4 } from 'uuid' -import { UserModel } from '@server/models/account/user' +import { UserModel } from '@server/models/user/user' +import { MActorDefault } from '@server/types/models/actor' import { ActivityPubActorType } from '../../shared/models/activitypub' import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' import { sequelizeTypescript } from '../initializers/database' import { AccountModel } from '../models/account/account' -import { UserNotificationSettingModel } from '../models/account/user-notification-setting' -import { ActorModel } from '../models/activitypub/actor' -import { MAccountDefault, MActorDefault, MChannelActor } from '../types/models' +import { ActorModel } from '../models/actor/actor' +import { UserNotificationSettingModel } from '../models/user/user-notification-setting' +import { MAccountDefault, MChannelActor } from '../types/models' import { MUser, MUserDefault, MUserId } from '../types/models/user' import { buildActorInstance, generateAndSaveActorKeys } from './activitypub/actor' import { getLocalAccountActivityPubUrl } from './activitypub/url' diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index bb849dc72..1d18de8cd 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts @@ -1,18 +1,18 @@ import * as express from 'express' import { body, param, query } from 'express-validator' +import { isFollowStateValid } from '@server/helpers/custom-validators/follows' +import { getServerActor } from '@server/models/application/application' +import { MActorFollowActorsDefault } from '@server/types/models' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { isTestInstance } from '../../helpers/core-utils' +import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' +import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' -import { ActorFollowModel } from '../../models/activitypub/actor-follow' +import { ActorModel } from '../../models/actor/actor' +import { ActorFollowModel } from '../../models/actor/actor-follow' import { areValidationErrors } from './utils' -import { ActorModel } from '../../models/activitypub/actor' -import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' -import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' -import { MActorFollowActorsDefault } from '@server/types/models' -import { isFollowStateValid } from '@server/helpers/custom-validators/follows' -import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const listFollowsValidator = [ query('state') diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts index 0d0c8ccbf..1823892b6 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/middlewares/validators/user-subscriptions.ts @@ -1,12 +1,12 @@ import * as express from 'express' import { body, param, query } from 'express-validator' -import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' -import { ActorFollowModel } from '../../models/activitypub/actor-follow' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' import { toArray } from '../../helpers/custom-validators/misc' +import { logger } from '../../helpers/logger' import { WEBSERVER } from '../../initializers/constants' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { ActorFollowModel } from '../../models/actor/actor-follow' +import { areValidationErrors } from './utils' const userSubscriptionListValidator = [ query('search').optional().not().isEmpty().withMessage('Should have a valid search'), diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 37119e279..548d5df4d 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -34,8 +34,8 @@ import { doesVideoExist } from '../../helpers/middlewares' import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' import { isThemeRegistered } from '../../lib/plugins/theme-utils' import { Redis } from '../../lib/redis' -import { UserModel } from '../../models/account/user' -import { ActorModel } from '../../models/activitypub/actor' +import { UserModel } from '../../models/user/user' +import { ActorModel } from '../../models/actor/actor' import { areValidationErrors } from './utils' const usersListValidator = [ diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index 2463d281c..e881f0d3e 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts @@ -3,6 +3,7 @@ import { body, param, query } from 'express-validator' import { VIDEO_CHANNELS } from '@server/initializers/constants' import { MChannelAccountDefault, MUser } from '@server/types/models' import { UserRight } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' import { @@ -12,10 +13,9 @@ import { } from '../../../helpers/custom-validators/video-channels' import { logger } from '../../../helpers/logger' import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' import { VideoChannelModel } from '../../../models/video/video-channel' import { areValidationErrors } from '../utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const videoChannelsAddValidator = [ body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts index a71422ed8..c2dfccc96 100644 --- a/server/middlewares/validators/webfinger.ts +++ b/server/middlewares/validators/webfinger.ts @@ -1,11 +1,11 @@ import * as express from 'express' import { query } from 'express-validator' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' +import { getHostWithPort } from '../../helpers/express-utils' import { logger } from '../../helpers/logger' -import { ActorModel } from '../../models/activitypub/actor' +import { ActorModel } from '../../models/actor/actor' import { areValidationErrors } from './utils' -import { getHostWithPort } from '../../helpers/express-utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const webfingerValidator = [ query('resource').custom(isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'), diff --git a/server/models/account/account-blocklist.ts b/server/models/account/account-blocklist.ts index fe9168ab8..9f3be22bd 100644 --- a/server/models/account/account-blocklist.ts +++ b/server/models/account/account-blocklist.ts @@ -2,7 +2,7 @@ import { Op } from 'sequelize' import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' import { MAccountBlocklist, MAccountBlocklistAccounts, MAccountBlocklistFormattable } from '@server/types/models' import { AccountBlock } from '../../../shared/models' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' import { ServerModel } from '../server/server' import { getSort, searchAttribute } from '../utils' import { AccountModel } from './account' diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 801f76bba..576a44576 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -11,7 +11,7 @@ import { AccountVideoRate } from '../../../shared' import { VideoRateType } from '../../../shared/models/videos' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' import { buildLocalAccountIdsIn, getSort, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel' diff --git a/server/models/account/account.ts b/server/models/account/account.ts index d33353af7..7b2af706d 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -30,19 +30,19 @@ import { MAccountSummaryFormattable, MChannelActor } from '../../types/models' -import { ActorModel } from '../activitypub/actor' -import { ActorFollowModel } from '../activitypub/actor-follow' +import { ActorModel } from '../actor/actor' +import { ActorFollowModel } from '../actor/actor-follow' +import { ActorImageModel } from '../actor/actor-image' import { ApplicationModel } from '../application/application' -import { ActorImageModel } from './actor-image' import { ServerModel } from '../server/server' import { ServerBlocklistModel } from '../server/server-blocklist' +import { UserModel } from '../user/user' import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { VideoCommentModel } from '../video/video-comment' import { VideoPlaylistModel } from '../video/video-playlist' import { AccountBlocklistModel } from './account-blocklist' -import { UserModel } from './user' export enum ScopeNames { SUMMARY = 'SUMMARY' diff --git a/server/models/activitypub/actor-follow.ts b/server/models/actor/actor-follow.ts similarity index 100% rename from server/models/activitypub/actor-follow.ts rename to server/models/actor/actor-follow.ts diff --git a/server/models/account/actor-image.ts b/server/models/actor/actor-image.ts similarity index 100% rename from server/models/account/actor-image.ts rename to server/models/actor/actor-image.ts diff --git a/server/models/activitypub/actor.ts b/server/models/actor/actor.ts similarity index 99% rename from server/models/activitypub/actor.ts rename to server/models/actor/actor.ts index 1af9efac2..5cf6fb8f1 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/actor/actor.ts @@ -51,12 +51,12 @@ import { MActorWithInboxes } from '../../types/models' import { AccountModel } from '../account/account' -import { ActorImageModel } from '../account/actor-image' import { ServerModel } from '../server/server' import { isOutdated, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { ActorFollowModel } from './actor-follow' +import { ActorImageModel } from './actor-image' enum ScopeNames { FULL = 'FULL' diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts index 27e643aa7..aa512a985 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts @@ -17,8 +17,8 @@ import { MUserAccountId } from '@server/types/models' import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' import { logger } from '../../helpers/logger' import { AccountModel } from '../account/account' -import { UserModel } from '../account/user' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' +import { UserModel } from '../user/user' import { OAuthClientModel } from './oauth-client' export type OAuthTokenInfo = { diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 53ebadeaf..b6538c8fd 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -29,7 +29,7 @@ import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validato import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' import { ServerModel } from '../server/server' import { getSort, getVideoSort, parseAggregateResult, throwIfNotValid } from '../utils' import { ScheduleVideoUpdateModel } from '../video/schedule-video-update' diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 0e58beeaf..fb4c15d97 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts @@ -1,7 +1,7 @@ import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { MServer, MServerFormattable } from '@server/types/models/server' import { isHostValid } from '../../helpers/custom-validators/servers' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' import { throwIfNotValid } from '../utils' import { ServerBlocklistModel } from './server-blocklist' diff --git a/server/models/account/user-notification-setting.ts b/server/models/user/user-notification-setting.ts similarity index 100% rename from server/models/account/user-notification-setting.ts rename to server/models/user/user-notification-setting.ts diff --git a/server/models/account/user-notification.ts b/server/models/user/user-notification.ts similarity index 98% rename from server/models/account/user-notification.ts rename to server/models/user/user-notification.ts index 805095002..f7f9ac867 100644 --- a/server/models/account/user-notification.ts +++ b/server/models/user/user-notification.ts @@ -7,8 +7,10 @@ import { isUserNotificationTypeValid } from '../../helpers/custom-validators/use import { AbuseModel } from '../abuse/abuse' import { VideoAbuseModel } from '../abuse/video-abuse' import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' -import { ActorModel } from '../activitypub/actor' -import { ActorFollowModel } from '../activitypub/actor-follow' +import { AccountModel } from '../account/account' +import { ActorModel } from '../actor/actor' +import { ActorFollowModel } from '../actor/actor-follow' +import { ActorImageModel } from '../actor/actor-image' import { ApplicationModel } from '../application/application' import { PluginModel } from '../server/plugin' import { ServerModel } from '../server/server' @@ -18,8 +20,6 @@ import { VideoBlacklistModel } from '../video/video-blacklist' import { VideoChannelModel } from '../video/video-channel' import { VideoCommentModel } from '../video/video-comment' import { VideoImportModel } from '../video/video-import' -import { AccountModel } from './account' -import { ActorImageModel } from './actor-image' import { UserModel } from './user' enum ScopeNames { diff --git a/server/models/account/user-video-history.ts b/server/models/user/user-video-history.ts similarity index 100% rename from server/models/account/user-video-history.ts rename to server/models/user/user-video-history.ts diff --git a/server/models/account/user.ts b/server/models/user/user.ts similarity index 99% rename from server/models/account/user.ts rename to server/models/user/user.ts index 513455773..8d2564e54 100644 --- a/server/models/account/user.ts +++ b/server/models/user/user.ts @@ -60,8 +60,10 @@ import { import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' import { getThemeOrDefault } from '../../lib/plugins/theme-utils' -import { ActorModel } from '../activitypub/actor' -import { ActorFollowModel } from '../activitypub/actor-follow' +import { AccountModel } from '../account/account' +import { ActorModel } from '../actor/actor' +import { ActorFollowModel } from '../actor/actor-follow' +import { ActorImageModel } from '../actor/actor-image' import { OAuthTokenModel } from '../oauth/oauth-token' import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' @@ -69,9 +71,7 @@ import { VideoChannelModel } from '../video/video-channel' import { VideoImportModel } from '../video/video-import' import { VideoLiveModel } from '../video/video-live' import { VideoPlaylistModel } from '../video/video-playlist' -import { AccountModel } from './account' import { UserNotificationSettingModel } from './user-notification-setting' -import { ActorImageModel } from './actor-image' enum ScopeNames { FOR_ME_API = 'FOR_ME_API', diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 081b21f2d..8e4b78723 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -36,9 +36,9 @@ import { MChannelSummaryFormattable } from '../../types/models/video' import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' -import { ActorImageModel } from '../account/actor-image' -import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' -import { ActorFollowModel } from '../activitypub/actor-follow' +import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor' +import { ActorFollowModel } from '../actor/actor-follow' +import { ActorImageModel } from '../actor/actor-image' import { ServerModel } from '../server/server' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 151c2bc81..87c66dc9f 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -39,7 +39,7 @@ import { } from '../../types/models/video' import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' import { AccountModel } from '../account/account' -import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' +import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor' import { buildBlockedAccountSQL, buildBlockedAccountSQLOptimized, diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index 8324166cc..d8f09e1e5 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts @@ -13,15 +13,15 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { afterCommitIfTransaction } from '@server/helpers/database-utils' import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import' import { VideoImport, VideoImportState } from '../../../shared' import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos' import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' -import { UserModel } from '../account/user' +import { UserModel } from '../user/user' import { getSort, throwIfNotValid } from '../utils' import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' @DefaultScope(() => ({ include: [ diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index efe5be36d..b48dd2945 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts @@ -50,11 +50,11 @@ import { MVideoPlaylistIdWithElements } from '../../types/models/video/video-playlist' import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account' +import { ActorModel } from '../actor/actor' import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getPlaylistSort, isOutdated, throwIfNotValid } from '../utils' import { ThumbnailModel } from './thumbnail' import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' import { VideoPlaylistElementModel } from './video-playlist-element' -import { ActorModel } from '../activitypub/actor' enum ScopeNames { AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 5059c1fa6..99a24dbdf 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -4,7 +4,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { MActorDefault } from '../../types/models' import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' import { VideoModel } from './video' diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 8c316e00c..f8a099d9c 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -100,14 +100,14 @@ import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models import { VideoAbuseModel } from '../abuse/video-abuse' import { AccountModel } from '../account/account' import { AccountVideoRateModel } from '../account/account-video-rate' -import { ActorImageModel } from '../account/actor-image' -import { UserModel } from '../account/user' -import { UserVideoHistoryModel } from '../account/user-video-history' -import { ActorModel } from '../activitypub/actor' +import { ActorModel } from '../actor/actor' +import { ActorImageModel } from '../actor/actor-image' import { VideoRedundancyModel } from '../redundancy/video-redundancy' import { ServerModel } from '../server/server' import { TrackerModel } from '../server/tracker' import { VideoTrackerModel } from '../server/video-tracker' +import { UserModel } from '../user/user' +import { UserVideoHistoryModel } from '../user/user-video-history' import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' import { ScheduleVideoUpdateModel } from './schedule-video-update' import { TagModel } from './tag' diff --git a/server/types/models/moderation/abuse-message.ts b/server/types/models/abuse/abuse-message.ts similarity index 100% rename from server/types/models/moderation/abuse-message.ts rename to server/types/models/abuse/abuse-message.ts diff --git a/server/types/models/moderation/abuse.ts b/server/types/models/abuse/abuse.ts similarity index 100% rename from server/types/models/moderation/abuse.ts rename to server/types/models/abuse/abuse.ts diff --git a/server/types/models/moderation/index.ts b/server/types/models/abuse/index.ts similarity index 100% rename from server/types/models/moderation/index.ts rename to server/types/models/abuse/index.ts diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts index 9513acad8..984841291 100644 --- a/server/types/models/account/account.ts +++ b/server/types/models/account/account.ts @@ -1,7 +1,5 @@ import { FunctionProperties, PickWith } from '@shared/core-utils' import { AccountModel } from '../../../models/account/account' -import { MChannelDefault } from '../video/video-channels' -import { MAccountBlocklistId } from './account-blocklist' import { MActor, MActorAPAccount, @@ -15,7 +13,9 @@ import { MActorSummary, MActorSummaryFormattable, MActorUrl -} from './actor' +} from '../actor' +import { MChannelDefault } from '../video/video-channels' +import { MAccountBlocklistId } from './account-blocklist' type Use = PickWith diff --git a/server/types/models/account/index.ts b/server/types/models/account/index.ts index e3fc00f94..dab2eea7e 100644 --- a/server/types/models/account/index.ts +++ b/server/types/models/account/index.ts @@ -1,5 +1,2 @@ export * from './account' export * from './account-blocklist' -export * from './actor-follow' -export * from './actor-image' -export * from './actor' diff --git a/server/types/models/account/actor-follow.ts b/server/types/models/actor/actor-follow.ts similarity index 96% rename from server/types/models/account/actor-follow.ts rename to server/types/models/actor/actor-follow.ts index 8e19c6140..98a6ca8a5 100644 --- a/server/types/models/account/actor-follow.ts +++ b/server/types/models/actor/actor-follow.ts @@ -1,5 +1,5 @@ import { PickWith } from '@shared/core-utils' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorFollowModel } from '../../../models/actor/actor-follow' import { MActor, MActorChannelAccountActor, diff --git a/server/types/models/account/actor-image.ts b/server/types/models/actor/actor-image.ts similarity index 83% rename from server/types/models/account/actor-image.ts rename to server/types/models/actor/actor-image.ts index e59f8b141..89adb01ae 100644 --- a/server/types/models/account/actor-image.ts +++ b/server/types/models/actor/actor-image.ts @@ -1,5 +1,5 @@ -import { ActorImageModel } from '../../../models/account/actor-image' import { FunctionProperties } from '@shared/core-utils' +import { ActorImageModel } from '../../../models/actor/actor-image' export type MActorImage = ActorImageModel diff --git a/server/types/models/account/actor.ts b/server/types/models/actor/actor.ts similarity index 98% rename from server/types/models/account/actor.ts rename to server/types/models/actor/actor.ts index 0b620872e..b3a70cbce 100644 --- a/server/types/models/account/actor.ts +++ b/server/types/models/actor/actor.ts @@ -1,9 +1,8 @@ - import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils' -import { ActorModel } from '../../../models/activitypub/actor' +import { ActorModel } from '../../../models/actor/actor' +import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from '../account' import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' -import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' import { MActorImage, MActorImageFormattable } from './actor-image' type Use = PickWith diff --git a/server/types/models/actor/index.ts b/server/types/models/actor/index.ts new file mode 100644 index 000000000..b27815255 --- /dev/null +++ b/server/types/models/actor/index.ts @@ -0,0 +1,3 @@ +export * from './actor-follow' +export * from './actor-image' +export * from './actor' diff --git a/server/types/models/index.ts b/server/types/models/index.ts index b4fdb1ff3..704cb9844 100644 --- a/server/types/models/index.ts +++ b/server/types/models/index.ts @@ -1,6 +1,7 @@ +export * from './abuse' export * from './account' +export * from './actor' export * from './application' -export * from './moderation' export * from './oauth' export * from './server' export * from './user' diff --git a/server/types/models/user/user-notification-setting.ts b/server/types/models/user/user-notification-setting.ts index c674add1b..d1db645e7 100644 --- a/server/types/models/user/user-notification-setting.ts +++ b/server/types/models/user/user-notification-setting.ts @@ -1,4 +1,4 @@ -import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' +import { UserNotificationSettingModel } from '@server/models/user/user-notification-setting' export type MNotificationSetting = Omit diff --git a/server/types/models/user/user-notification.ts b/server/types/models/user/user-notification.ts index 7ebb0485d..918614dd1 100644 --- a/server/types/models/user/user-notification.ts +++ b/server/types/models/user/user-notification.ts @@ -2,13 +2,13 @@ import { VideoAbuseModel } from '@server/models/abuse/video-abuse' import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' import { ApplicationModel } from '@server/models/application/application' import { PluginModel } from '@server/models/server/plugin' +import { UserNotificationModel } from '@server/models/user/user-notification' import { PickWith, PickWithOpt } from '@shared/core-utils' import { AbuseModel } from '../../../models/abuse/abuse' import { AccountModel } from '../../../models/account/account' -import { ActorImageModel } from '../../../models/account/actor-image' -import { UserNotificationModel } from '../../../models/account/user-notification' -import { ActorModel } from '../../../models/activitypub/actor' -import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +import { ActorModel } from '../../../models/actor/actor' +import { ActorFollowModel } from '../../../models/actor/actor-follow' +import { ActorImageModel } from '../../../models/actor/actor-image' import { ServerModel } from '../../../models/server/server' import { VideoModel } from '../../../models/video/video' import { VideoBlacklistModel } from '../../../models/video/video-blacklist' diff --git a/server/types/models/user/user-video-history.ts b/server/types/models/user/user-video-history.ts index 62673ab1b..34e2930e7 100644 --- a/server/types/models/user/user-video-history.ts +++ b/server/types/models/user/user-video-history.ts @@ -1,4 +1,4 @@ -import { UserVideoHistoryModel } from '../../../models/account/user-video-history' +import { UserVideoHistoryModel } from '../../../models/user/user-video-history' export type MUserVideoHistory = Omit diff --git a/server/types/models/user/user.ts b/server/types/models/user/user.ts index fa7de9c52..f79220e11 100644 --- a/server/types/models/user/user.ts +++ b/server/types/models/user/user.ts @@ -1,7 +1,7 @@ import { AccountModel } from '@server/models/account/account' +import { UserModel } from '@server/models/user/user' import { MVideoPlaylist } from '@server/types/models' import { PickWith, PickWithOpt } from '@shared/core-utils' -import { UserModel } from '../../../models/account/user' import { MAccount, MAccountDefault, diff --git a/server/types/models/video/video-channels.ts b/server/types/models/video/video-channels.ts index f577807ca..c147567d9 100644 --- a/server/types/models/video/video-channels.ts +++ b/server/types/models/video/video-channels.ts @@ -9,7 +9,9 @@ import { MAccountSummaryBlocks, MAccountSummaryFormattable, MAccountUrl, - MAccountUserId, + MAccountUserId +} from '../account' +import { MActor, MActorAccountChannelId, MActorAPChannel, @@ -23,7 +25,7 @@ import { MActorSummary, MActorSummaryFormattable, MActorUrl -} from '../account' +} from '../actor' import { MVideo } from './video' type Use = PickWith diff --git a/server/types/models/video/video-share.ts b/server/types/models/video/video-share.ts index b7a783bb6..78f44e58c 100644 --- a/server/types/models/video/video-share.ts +++ b/server/types/models/video/video-share.ts @@ -1,6 +1,6 @@ -import { VideoShareModel } from '../../../models/video/video-share' import { PickWith } from '@shared/core-utils' -import { MActorDefault } from '../account' +import { VideoShareModel } from '../../../models/video/video-share' +import { MActorDefault } from '../actor' import { MVideo } from './video' type Use = PickWith diff --git a/server/types/plugins/register-server-option.model.ts b/server/types/plugins/register-server-option.model.ts index 2432b7ac4..8774bcd8c 100644 --- a/server/types/plugins/register-server-option.model.ts +++ b/server/types/plugins/register-server-option.model.ts @@ -1,6 +1,6 @@ -import { Router, Response } from 'express' +import { Response, Router } from 'express' import { Logger } from 'winston' -import { ActorModel } from '@server/models/activitypub/actor' +import { ActorModel } from '@server/models/actor/actor' import { PluginPlaylistPrivacyManager, PluginSettingsManager, -- 2.41.0