From 883a9019085ff9013079d6b1539b86f2f519175a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 16:02:11 +0200 Subject: Introduce debug command --- server/controllers/api/server/debug.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts index a6e9147f3..31888e963 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/controllers/api/server/debug.ts @@ -1,8 +1,8 @@ +import * as express from 'express' import { InboxManager } from '@server/lib/activitypub/inbox-manager' import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' +import { Debug, SendDebugCommand } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' -import { SendDebugCommand } from '@shared/models' -import * as express from 'express' import { UserRight } from '../../../../shared/models/users' import { authenticate, ensureUserHasRight } from '../../../middlewares' @@ -32,7 +32,7 @@ function getDebug (req: express.Request, res: express.Response) { return res.json({ ip: req.ip, activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting() - }) + } as Debug) } async function runCommand (req: express.Request, res: express.Response) { -- cgit v1.2.3 From e6346d59e63135cf012ed18c102d3b0179ef565f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 15:54:39 +0200 Subject: Introduce playlist command --- server/controllers/api/video-playlist.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 87a6f6bbe..78cbd9cff 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -5,6 +5,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 { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' @@ -202,7 +203,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) { id: videoPlaylistCreated.id, shortUUID: uuidToShort(videoPlaylistCreated.uuid), uuid: videoPlaylistCreated.uuid - } + } as VideoPlaylistCreateResult }) } @@ -338,8 +339,8 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response) return res.json({ videoPlaylistElement: { id: playlistElement.id - } - }).end() + } as VideoPlaylistElementCreateResult + }) } async function updateVideoPlaylistElement (req: express.Request, res: express.Response) { -- cgit v1.2.3 From 12edc1495a36b2199f1bf1ba37f50c7b694be382 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 14:15:11 +0200 Subject: Introduce comments command --- server/controllers/api/videos/comment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index e6f28c1cb..6a25511e5 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' -import { ResultList, ThreadsResultList, UserRight } from '../../../../shared/models' -import { VideoCommentCreate } from '../../../../shared/models/videos/comment/video-comment.model' +import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' +import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' @@ -136,7 +136,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) { return res.json({ ...getFormattedObjects(resultList.data, resultList.total), totalNotDeletedComments: resultList.totalNotDeletedComments - }) + } as VideoCommentThreads) } async function listVideoThreadComments (req: express.Request, res: express.Response) { -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/controllers/api/users/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index d907b49bf..b86fc94ef 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts @@ -4,7 +4,7 @@ import { tokensRouter } from '@server/controllers/api/users/token' import { Hooks } from '@server/lib/plugins/hooks' import { OAuthTokenModel } from '@server/models/oauth/oauth-token' import { MUser, MUserAccountDefault } from '@server/types/models' -import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' +import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' import { UserRegister } from '../../../../shared/models/users/user-register.model' @@ -220,7 +220,7 @@ async function createUser (req: express.Request, res: express.Response) { account: { id: account.id } - } + } as UserCreateResult }) } -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/controllers/api/abuse.ts | 2 +- server/controllers/api/bulk.ts | 2 +- server/controllers/api/custom-page.ts | 2 +- server/controllers/api/index.ts | 2 +- server/controllers/api/oauth-clients.ts | 2 +- server/controllers/api/plugins.ts | 2 +- server/controllers/api/search/search-video-channels.ts | 2 +- server/controllers/api/search/search-video-playlists.ts | 2 +- server/controllers/api/search/search-videos.ts | 2 +- server/controllers/api/server/contact.ts | 4 ++-- server/controllers/api/server/debug.ts | 2 +- server/controllers/api/server/follows.ts | 2 +- server/controllers/api/server/redundancy.ts | 16 ++++++++-------- server/controllers/api/server/server-blocklist.ts | 4 ++-- 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 +- server/controllers/api/users/my-notifications.ts | 2 +- server/controllers/api/users/my-subscriptions.ts | 2 +- server/controllers/api/video-channel.ts | 2 +- server/controllers/api/video-playlist.ts | 2 +- server/controllers/api/videos/blacklist.ts | 2 +- server/controllers/api/videos/captions.ts | 2 +- server/controllers/api/videos/comment.ts | 2 +- server/controllers/api/videos/index.ts | 2 +- server/controllers/api/videos/live.ts | 2 +- server/controllers/api/videos/ownership.ts | 2 +- server/controllers/api/videos/rate.ts | 2 +- server/controllers/api/videos/update.ts | 4 ++-- server/controllers/api/videos/upload.ts | 2 +- server/controllers/api/videos/watching.ts | 2 +- 32 files changed, 42 insertions(+), 42 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts index ba5b94840..e851365e9 100644 --- a/server/controllers/api/abuse.ts +++ b/server/controllers/api/abuse.ts @@ -6,7 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse' import { AbuseMessageModel } from '@server/models/abuse/abuse-message' import { getServerActor } from '@server/models/application/application' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' -import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/models' import { AbuseCreate, AbuseState, UserRight } from '../../../shared' import { getFormattedObjects } from '../../helpers/utils' import { sequelizeTypescript } from '../../initializers/database' diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts index 192daccde..10d83571d 100644 --- a/server/controllers/api/bulk.ts +++ b/server/controllers/api/bulk.ts @@ -4,7 +4,7 @@ import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bu import { VideoCommentModel } from '@server/models/video/video-comment' import { removeComment } from '@server/lib/video-comment' import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' -import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/models' const bulkRouter = express.Router() diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index c19f03c56..cc1aa8427 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { ServerConfigManager } from '@server/lib/server-config-manager' import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { UserRight } from '@shared/models' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 28378654a..93b14dadb 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts @@ -1,7 +1,7 @@ import * as cors from 'cors' import * as express from 'express' import * as RateLimit from 'express-rate-limit' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../shared/models' import { badRequest } from '../../helpers/express-utils' import { CONFIG } from '../../initializers/config' import { abuseRouter } from './abuse' diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts index 15bbf5c4d..f95f06864 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/controllers/api/oauth-clients.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { OAuthClientLocal } from '../../../shared' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { logger } from '../../helpers/logger' import { CONFIG } from '../../initializers/config' import { asyncMiddleware, openapiOperationDoc } from '../../middlewares' diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 1e6a02c49..4b213c246 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts @@ -23,7 +23,7 @@ import { updatePluginSettingsValidator } from '@server/middlewares/validators/plugins' import { PluginModel } from '@server/models/server/plugin' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { InstallOrUpdatePlugin, ManagePlugin, diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts index 16beeed60..fe9178e69 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/controllers/api/search/search-video-channels.ts @@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/models' import { ResultList, VideoChannel } from '@shared/models' import { VideoChannelsSearchQuery } from '../../../../shared/models/search' import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts index b231ff1e2..a0e2c1747 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/controllers/api/search/search-video-playlists.ts @@ -11,7 +11,7 @@ import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@ser import { getServerActor } from '@server/models/application/application' import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { MVideoPlaylistFullSummary } from '@server/types/models' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' import { asyncMiddleware, diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts index b626baa28..0e6fd9c72 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/controllers/api/search/search-videos.ts @@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/models' import { ResultList, Video } from '@shared/models' import { VideosSearchQuery } from '../../../../shared/models/search' import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts index caddc0909..ae36dd599 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/controllers/api/server/contact.ts @@ -3,7 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew import { Redis } from '../../../lib/redis' import { Emailer } from '../../../lib/emailer' import { ContactForm } from '../../../../shared/models/server' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const contactRouter = express.Router() @@ -15,7 +15,7 @@ contactRouter.post('/contact', async function contactAdministrator (req: express.Request, res: express.Response) { const data = req.body as ContactForm - await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) + Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) await Redis.Instance.setContactFormIp(req.ip) diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts index 31888e963..0601b89ce 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/controllers/api/server/debug.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { InboxManager } from '@server/lib/activitypub/inbox-manager' import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' import { Debug, SendDebugCommand } from '@shared/models' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserRight } from '../../../../shared/models/users' import { authenticate, ensureUserHasRight } from '../../../middlewares' diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 12357a2ca..e6f4f6b92 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserRight } from '../../../../shared/models/users' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts index bc593ad43..99d1c762b 100644 --- a/server/controllers/api/server/redundancy.ts +++ b/server/controllers/api/server/redundancy.ts @@ -1,5 +1,10 @@ import * as express from 'express' +import { JobQueue } from '@server/lib/job-queue' +import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserRight } from '../../../../shared/models/users' +import { logger } from '../../../helpers/logger' +import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy' import { asyncMiddleware, authenticate, @@ -10,16 +15,11 @@ import { videoRedundanciesSortValidator } from '../../../middlewares' import { - listVideoRedundanciesValidator, - updateServerRedundancyValidator, addVideoRedundancyValidator, - removeVideoRedundancyValidator + listVideoRedundanciesValidator, + removeVideoRedundancyValidator, + updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy' -import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy' -import { logger } from '../../../helpers/logger' -import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' -import { JobQueue } from '@server/lib/job-queue' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const serverRedundancyRouter = express.Router() diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts index a86bc7d19..b3ee50d85 100644 --- a/server/controllers/api/server/server-blocklist.ts +++ b/server/controllers/api/server/server-blocklist.ts @@ -1,8 +1,9 @@ import 'multer' import * as express from 'express' import { logger } from '@server/helpers/logger' -import { UserNotificationModel } from '@server/models/user/user-notification' import { getServerActor } from '@server/models/application/application' +import { UserNotificationModel } from '@server/models/user/user-notification' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserRight } from '../../../../shared/models/users' import { getFormattedObjects } from '../../../helpers/utils' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' @@ -25,7 +26,6 @@ import { } from '../../../middlewares/validators' import { AccountBlocklistModel } from '../../../models/account/account-blocklist' import { ServerBlocklistModel } from '../../../models/server/server-blocklist' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const serverBlocklistRouter = express.Router() diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index b86fc94ef..be800e8b5 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts @@ -5,7 +5,7 @@ import { Hooks } from '@server/lib/plugins/hooks' import { OAuthTokenModel } from '@server/models/oauth/oauth-token' import { MUser, MUserAccountDefault } from '@server/types/models' import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' import { UserRegister } from '../../../../shared/models/users/user-register.model' import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 1f2b2f9dd..c9610c59f 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -3,7 +3,7 @@ import * as express from 'express' import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' import { Hooks } from '@server/lib/plugins/hooks' import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' import { createReqFiles } from '../../../helpers/express-utils' import { getFormattedObjects } from '../../../helpers/utils' diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index a1561b751..fe11b6e77 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -22,7 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist import { ServerBlocklistModel } from '../../../models/server/server-blocklist' import { UserNotificationModel } from '@server/models/user/user-notification' import { logger } from '@server/helpers/logger' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myBlocklistRouter = express.Router() diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index cff1697ab..85e04925e 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts @@ -11,7 +11,7 @@ import { import { getFormattedObjects } from '../../../helpers/utils' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myVideosHistoryRouter = express.Router() diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts index 2909770da..3beee07c0 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/controllers/api/users/my-notifications.ts @@ -1,7 +1,7 @@ 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 { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserNotificationSetting } from '../../../../shared/models/users' import { getFormattedObjects } from '../../../helpers/utils' import { diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 46a73d49e..84f519926 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts @@ -3,7 +3,7 @@ import * as express from 'express' import { sendUndoFollow } from '@server/lib/activitypub/send' import { VideoChannelModel } from '@server/models/video/video-channel' import { VideosCommonQuery } from '@shared/models' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' import { getFormattedObjects } from '../../../helpers/utils' import { WEBSERVER } from '../../../initializers/constants' diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index bc8d203b0..784f97b1e 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -3,7 +3,7 @@ import { Hooks } from '@server/lib/plugins/hooks' import { getServerActor } from '@server/models/application/application' import { MChannelBannerAccountDefault } from '@server/types/models' import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' import { resetSequelizeInstance } from '../../helpers/database-utils' import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 78cbd9cff..4971d0a77 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -6,7 +6,7 @@ import { Hooks } from '@server/lib/plugins/hooks' import { getServerActor } from '@server/models/application/application' import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 530e17965..a7f5f53d8 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -19,7 +19,7 @@ import { videosBlacklistUpdateValidator } from '../../../middlewares' import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const blacklistRouter = express.Router() diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index ad7423a31..4008de60f 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { MVideoCaption } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' import { createReqFiles } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 6a25511e5..90b633bb5 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,5 +1,5 @@ import * as express from 'express' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 74b100e59..5a2ff81dc 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -6,7 +6,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc' import { getServerActor } from '@server/models/application/application' import { MVideoAccountLight } from '@server/types/models' import { VideosCommonQuery } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs' +import { HttpStatusCode } from '../../../../shared/models' import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index d8c51c2d4..ed4da8f47 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts @@ -11,7 +11,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator import { VideoLiveModel } from '@server/models/video/video-live' import { MVideoDetails, MVideoFullLight } from '@server/types/models' import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { logger } from '../../../helpers/logger' import { sequelizeTypescript } from '../../../initializers/database' import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index 1bb96e046..e6c94a45a 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts @@ -19,7 +19,7 @@ import { changeVideoChannelShare } from '../../../lib/activitypub/share' import { sendUpdateVideo } from '../../../lib/activitypub/send' import { VideoModel } from '../../../models/video/video' import { MVideoFullLight } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const ownershipVideoRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 84f42633e..134c9e5ca 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -7,7 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const rateVideoRouter = express.Router() diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index 8affe71c6..49639060b 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts @@ -2,10 +2,11 @@ import * as express from 'express' import { Transaction } from 'sequelize/types' import { changeVideoChannelShare } from '@server/lib/activitypub/share' import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' +import { openapiOperationDoc } from '@server/middlewares/doc' import { FilteredModelAttributes } from '@server/types' import { MVideoFullLight } from '@server/types/models' import { VideoUpdate } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs' +import { HttpStatusCode } from '../../../../shared/models' import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' import { resetSequelizeInstance } from '../../../helpers/database-utils' import { createReqFiles } from '../../../helpers/express-utils' @@ -20,7 +21,6 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' import { VideoModel } from '../../../models/video/video' -import { openapiOperationDoc } from '@server/middlewares/doc' const lTags = loggerTagsFactory('api', 'video') const auditLogger = auditLoggerFactory('videos') diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index bcd21ac99..1603ef127 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts @@ -11,7 +11,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc' import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' import { uploadx } from '@uploadx/core' import { VideoCreate, VideoState } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs' +import { HttpStatusCode } from '../../../../shared/models' import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { createReqFiles } from '../../../helpers/express-utils' diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 8b15525aa..2899dbd9c 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts @@ -8,7 +8,7 @@ import { videoWatchingValidator } from '../../../middlewares' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const watchingRouter = express.Router() -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/controllers/api/bulk.ts | 6 +++--- server/controllers/api/config.ts | 2 +- server/controllers/api/custom-page.ts | 3 +-- server/controllers/api/overviews.ts | 10 +++++----- server/controllers/api/plugins.ts | 2 +- server/controllers/api/search/search-video-channels.ts | 3 +-- server/controllers/api/search/search-video-playlists.ts | 5 ++--- server/controllers/api/search/search-videos.ts | 3 +-- server/controllers/api/server/contact.ts | 8 ++++---- server/controllers/api/server/index.ts | 8 ++++---- server/controllers/api/server/logs.ts | 12 ++++++------ server/controllers/api/users/me.ts | 2 +- server/controllers/api/users/my-blocklist.ts | 10 +++++----- server/controllers/api/users/my-history.ts | 6 +++--- server/controllers/api/users/my-video-playlists.ts | 2 +- server/controllers/api/videos/blacklist.ts | 2 +- server/controllers/api/videos/comment.ts | 2 +- server/controllers/api/videos/ownership.ts | 14 +++++++------- server/controllers/api/videos/rate.ts | 4 ++-- server/controllers/api/videos/watching.ts | 2 +- 20 files changed, 51 insertions(+), 55 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts index 10d83571d..62121ece5 100644 --- a/server/controllers/api/bulk.ts +++ b/server/controllers/api/bulk.ts @@ -1,10 +1,10 @@ import * as express from 'express' -import { asyncMiddleware, authenticate } from '../../middlewares' +import { removeComment } from '@server/lib/video-comment' import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' import { VideoCommentModel } from '@server/models/video/video-comment' -import { removeComment } from '@server/lib/video-comment' -import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' import { HttpStatusCode } from '@shared/models' +import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' +import { asyncMiddleware, authenticate } from '../../middlewares' const bulkRouter = express.Router() diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 9bd8c21c5..ee733a38c 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,8 +1,8 @@ -import { ServerConfigManager } from '@server/lib/server-config-manager' import * as express from 'express' import { remove, writeJSON } from 'fs-extra' import { snakeCase } from 'lodash' import validator from 'validator' +import { ServerConfigManager } from '@server/lib/server-config-manager' import { UserRight } from '../../../shared' import { About } from '../../../shared/models/server/about.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model' diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index cc1aa8427..68d8c2ea4 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts @@ -1,8 +1,7 @@ import * as express from 'express' import { ServerConfigManager } from '@server/lib/server-config-manager' import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { HttpStatusCode } from '@shared/models' -import { UserRight } from '@shared/models' +import { HttpStatusCode, UserRight } from '@shared/models' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' const customPageRouter = express.Router() diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts index ad879aad6..aaa341d54 100644 --- a/server/controllers/api/overviews.ts +++ b/server/controllers/api/overviews.ts @@ -1,12 +1,12 @@ import * as express from 'express' +import * as memoizee from 'memoizee' +import { logger } from '@server/helpers/logger' +import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' import { buildNSFWFilter } from '../../helpers/express-utils' -import { VideoModel } from '../../models/video/video' +import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' import { TagModel } from '../../models/video/tag' -import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' -import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' -import * as memoizee from 'memoizee' -import { logger } from '@server/helpers/logger' +import { VideoModel } from '../../models/video/video' const overviewsRouter = express.Router() diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 4b213c246..3a9ef34e8 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts @@ -23,8 +23,8 @@ import { updatePluginSettingsValidator } from '@server/middlewares/validators/plugins' import { PluginModel } from '@server/models/server/plugin' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, InstallOrUpdatePlugin, ManagePlugin, PeertubePluginIndexList, diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts index fe9178e69..c8f0a0a0b 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/controllers/api/search/search-video-channels.ts @@ -6,8 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoChannel } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' import { VideoChannelsSearchQuery } from '../../../../shared/models/search' import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts index a0e2c1747..f55b1fba3 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/controllers/api/search/search-video-playlists.ts @@ -5,14 +5,14 @@ import { logger } from '@server/helpers/logger' import { doJSONRequest } from '@server/helpers/requests' import { getFormattedObjects } from '@server/helpers/utils' import { CONFIG } from '@server/initializers/config' +import { WEBSERVER } from '@server/initializers/constants' import { getOrCreateAPVideoPlaylist } from '@server/lib/activitypub/playlists/get' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' import { getServerActor } from '@server/models/application/application' import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { MVideoPlaylistFullSummary } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' +import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' import { asyncMiddleware, openapiOperationDoc, @@ -23,7 +23,6 @@ import { videoPlaylistsListSearchValidator, videoPlaylistsSearchSortValidator } from '../../../middlewares' -import { WEBSERVER } from '@server/initializers/constants' const searchPlaylistsRouter = express.Router() diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts index 0e6fd9c72..a4153f3f8 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/controllers/api/search/search-videos.ts @@ -6,8 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { HttpStatusCode } from '@shared/models' -import { ResultList, Video } from '@shared/models' +import { HttpStatusCode, ResultList, Video } from '@shared/models' import { VideosSearchQuery } from '../../../../shared/models/search' import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts index ae36dd599..b315e99cf 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/controllers/api/server/contact.ts @@ -1,9 +1,9 @@ import * as express from 'express' -import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' -import { Redis } from '../../../lib/redis' -import { Emailer } from '../../../lib/emailer' -import { ContactForm } from '../../../../shared/models/server' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { ContactForm } from '../../../../shared/models/server' +import { Emailer } from '../../../lib/emailer' +import { Redis } from '../../../lib/redis' +import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' const contactRouter = express.Router() diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts index 6b8793a19..32fefefc0 100644 --- a/server/controllers/api/server/index.ts +++ b/server/controllers/api/server/index.ts @@ -1,11 +1,11 @@ import * as express from 'express' +import { contactRouter } from './contact' +import { debugRouter } from './debug' import { serverFollowsRouter } from './follows' -import { statsRouter } from './stats' +import { logsRouter } from './logs' import { serverRedundancyRouter } from './redundancy' import { serverBlocklistRouter } from './server-blocklist' -import { contactRouter } from './contact' -import { logsRouter } from './logs' -import { debugRouter } from './debug' +import { statsRouter } from './stats' const serverRouter = express.Router() diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts index 4b543d686..f78607d35 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/controllers/api/server/logs.ts @@ -1,14 +1,14 @@ import * as express from 'express' -import { UserRight } from '../../../../shared/models/users' -import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' -import { mtimeSortFilesDesc } from '../../../../shared/core-utils/logs/logs' import { readdir, readFile } from 'fs-extra' -import { AUDIT_LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS, LOG_FILENAME } from '../../../initializers/constants' import { join } from 'path' -import { getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs' +import { logger } from '@server/helpers/logger' +import { mtimeSortFilesDesc } from '../../../../shared/core-utils/logs/logs' import { LogLevel } from '../../../../shared/models/server/log-level.type' +import { UserRight } from '../../../../shared/models/users' import { CONFIG } from '../../../initializers/config' -import { logger } from '@server/helpers/logger' +import { AUDIT_LOG_FILENAME, LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants' +import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' +import { getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs' const logsRouter = express.Router() diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index c9610c59f..ac6faca9c 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -2,6 +2,7 @@ import 'multer' import * as express from 'express' import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' import { Hooks } from '@server/lib/plugins/hooks' +import { AttributesOnly } from '@shared/core-utils' import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' @@ -31,7 +32,6 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat import { UserModel } from '../../../models/user/user' import { VideoModel } from '../../../models/video/video' import { VideoImportModel } from '../../../models/video/video-import' -import { AttributesOnly } from '@shared/core-utils' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index fe11b6e77..24fff83e3 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -1,6 +1,10 @@ -import * as express from 'express' import 'multer' +import * as express from 'express' +import { logger } from '@server/helpers/logger' +import { UserNotificationModel } from '@server/models/user/user-notification' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { getFormattedObjects } from '../../../helpers/utils' +import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -18,11 +22,7 @@ import { unblockServerByAccountValidator } from '../../../middlewares/validators' 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/user/user-notification' -import { logger } from '@server/helpers/logger' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myBlocklistRouter = express.Router() diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index 85e04925e..a6e723103 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts @@ -1,4 +1,7 @@ import * as express from 'express' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { getFormattedObjects } from '../../../helpers/utils' +import { sequelizeTypescript } from '../../../initializers/database' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -8,10 +11,7 @@ import { userHistoryListValidator, userHistoryRemoveValidator } from '../../../middlewares' -import { getFormattedObjects } from '../../../helpers/utils' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' -import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myVideosHistoryRouter = express.Router() diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts index d0bd99463..76e741ba5 100644 --- a/server/controllers/api/users/my-video-playlists.ts +++ b/server/controllers/api/users/my-video-playlists.ts @@ -1,8 +1,8 @@ import * as express from 'express' +import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' import { asyncMiddleware, authenticate } from '../../../middlewares' import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' const myVideoPlaylistsRouter = express.Router() diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index a7f5f53d8..6bc768471 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -1,6 +1,7 @@ import * as express from 'express' import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' import { UserRight, VideoBlacklistCreate } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' @@ -19,7 +20,6 @@ import { videosBlacklistUpdateValidator } from '../../../middlewares' import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const blacklistRouter = express.Router() diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 90b633bb5..cb696f652 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,6 +1,6 @@ import * as express from 'express' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' import { getFormattedObjects } from '../../../helpers/utils' diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index e6c94a45a..f48acbc68 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts @@ -1,6 +1,12 @@ import * as express from 'express' +import { MVideoFullLight } from '@server/types/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' import { logger } from '../../../helpers/logger' +import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' +import { sendUpdateVideo } from '../../../lib/activitypub/send' +import { changeVideoChannelShare } from '../../../lib/activitypub/share' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -11,15 +17,9 @@ import { videosChangeOwnershipValidator, videosTerminateChangeOwnershipValidator } from '../../../middlewares' +import { VideoModel } from '../../../models/video/video' import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' -import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' import { VideoChannelModel } from '../../../models/video/video-channel' -import { getFormattedObjects } from '../../../helpers/utils' -import { changeVideoChannelShare } from '../../../lib/activitypub/share' -import { sendUpdateVideo } from '../../../lib/activitypub/send' -import { VideoModel } from '../../../models/video/video' -import { MVideoFullLight } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const ownershipVideoRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 134c9e5ca..96f6cd886 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,13 +1,13 @@ import * as express from 'express' import { UserVideoRateUpdate } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { logger } from '../../../helpers/logger' import { VIDEO_RATE_TYPES } from '../../../initializers/constants' +import { sequelizeTypescript } from '../../../initializers/database' import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const rateVideoRouter = express.Router() diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 2899dbd9c..05c75e543 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts @@ -1,5 +1,6 @@ import * as express from 'express' import { UserWatchingVideo } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -8,7 +9,6 @@ import { videoWatchingValidator } from '../../../middlewares' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const watchingRouter = express.Router() -- cgit v1.2.3 From 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Jul 2021 14:15:15 +0200 Subject: Add ability for instances to follow any actor --- server/controllers/api/server/follows.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index e6f4f6b92..cbe6b7e4f 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -29,6 +29,7 @@ import { removeFollowingValidator } from '../../../middlewares/validators' import { ActorFollowModel } from '../../../models/actor/actor-follow' +import { ServerFollowCreate } from '@shared/models' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', @@ -45,10 +46,10 @@ serverFollowsRouter.post('/following', ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW), followValidator, setBodyHostsPort, - asyncMiddleware(followInstance) + asyncMiddleware(addFollow) ) -serverFollowsRouter.delete('/following/:host', +serverFollowsRouter.delete('/following/:hostOrHandle', authenticate, ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW), asyncMiddleware(removeFollowingValidator), @@ -125,8 +126,8 @@ async function listFollowers (req: express.Request, res: express.Response) { return res.json(getFormattedObjects(resultList.data, resultList.total)) } -async function followInstance (req: express.Request, res: express.Response) { - const hosts = req.body.hosts as string[] +async function addFollow (req: express.Request, res: express.Response) { + const { hosts, handles } = req.body as ServerFollowCreate const follower = await getServerActor() for (const host of hosts) { @@ -139,6 +140,18 @@ async function followInstance (req: express.Request, res: express.Response) { JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) } + for (const handle of handles) { + const [ name, host ] = handle.split('@') + + const payload = { + host, + name, + followerActorId: follower.id + } + + JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) + } + return res.status(HttpStatusCode.NO_CONTENT_204).end() } -- cgit v1.2.3