diff --git a/apps/meteor/.mocharc.js b/apps/meteor/.mocharc.js index 944f72eebe297..cf66605275df6 100644 --- a/apps/meteor/.mocharc.js +++ b/apps/meteor/.mocharc.js @@ -29,14 +29,16 @@ module.exports = { 'tests/unit/lib/**/*.tests.ts', 'server/routes/avatar/**/*.spec.ts', 'tests/unit/lib/**/*.spec.ts', + 'tests/unit/server/**/*.tests.js', 'tests/unit/server/**/*.tests.ts', 'tests/unit/server/**/*.spec.ts', - 'app/2fa/server/**/*.spec.ts', + 'server/lib/2fa/**/*.spec.ts', 'server/api/lib/**/*.spec.ts', - 'app/file-upload/server/**/*.spec.ts', - 'app/statistics/server/**/*.spec.ts', + 'server/lib/media/**/*.spec.ts', + 'server/lib/statistics/**/*.spec.ts', + 'server/meteor-methods/**/*.spec.ts', 'app/livechat/server/lib/**/*.spec.ts', - 'app/push/server/**/*.spec.ts', + 'server/lib/notifications/push/**/*.spec.ts', 'app/utils/server/**/*.spec.ts', ], }; diff --git a/apps/meteor/app/2fa/server/index.ts b/apps/meteor/app/2fa/server/index.ts deleted file mode 100644 index 548c151ac1859..0000000000000 --- a/apps/meteor/app/2fa/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './MethodInvocationOverride'; -import './loginHandler'; diff --git a/apps/meteor/app/apple/server/index.ts b/apps/meteor/app/apple/server/index.ts deleted file mode 100644 index 7dd8c1845d894..0000000000000 --- a/apps/meteor/app/apple/server/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './appleOauthRegisterService'; -import './loginHandler'; -import './applePassportOAuth'; diff --git a/apps/meteor/app/apps/server/bridges/cloud.ts b/apps/meteor/app/apps/server/bridges/cloud.ts index 83d9f98311c1b..e3f108e0c7e8c 100644 --- a/apps/meteor/app/apps/server/bridges/cloud.ts +++ b/apps/meteor/app/apps/server/bridges/cloud.ts @@ -2,7 +2,7 @@ import type { IAppServerOrchestrator } from '@rocket.chat/apps'; import { CloudWorkspaceBridge } from '@rocket.chat/apps/dist/server/bridges/CloudWorkspaceBridge'; import type { IWorkspaceToken } from '@rocket.chat/apps-engine/definition/cloud/IWorkspaceToken'; -import { getWorkspaceAccessTokenWithScope } from '../../../cloud/server'; +import { getWorkspaceAccessTokenWithScope } from '../../../../server/lib/cloud'; export class AppCloudBridge extends CloudWorkspaceBridge { constructor(private readonly orch: IAppServerOrchestrator) { diff --git a/apps/meteor/app/apps/server/bridges/email.ts b/apps/meteor/app/apps/server/bridges/email.ts index 8f984b7bb6ce2..d45b94ae419cd 100644 --- a/apps/meteor/app/apps/server/bridges/email.ts +++ b/apps/meteor/app/apps/server/bridges/email.ts @@ -2,7 +2,7 @@ import type { IAppServerOrchestrator } from '@rocket.chat/apps'; import { EmailBridge } from '@rocket.chat/apps/dist/server/bridges/EmailBridge'; import type { IEmail } from '@rocket.chat/apps-engine/definition/email'; -import * as Mailer from '../../../mailer/server/api'; +import * as Mailer from '../../../../server/lib/notifications/email/api'; import { settings } from '../../../settings/server'; export class AppEmailBridge extends EmailBridge { diff --git a/apps/meteor/app/apps/server/bridges/messages.ts b/apps/meteor/app/apps/server/bridges/messages.ts index ab45094722b2c..61d23f1542b6c 100644 --- a/apps/meteor/app/apps/server/bridges/messages.ts +++ b/apps/meteor/app/apps/server/bridges/messages.ts @@ -9,9 +9,9 @@ import { Users, Subscriptions } from '@rocket.chat/models'; import { deleteMessage } from '../../../../server/lib/messages/deleteMessage'; import { updateMessage } from '../../../../server/lib/messages/updateMessage'; +import { executeSetReaction } from '../../../../server/lib/messaging/reactions/setReaction'; +import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; import { executeSendMessage } from '../../../../server/meteor-methods/messages/sendMessage'; -import notifications from '../../../notifications/server/lib/Notifications'; -import { executeSetReaction } from '../../../reactions/server/setReaction'; export class AppMessageBridge extends MessageBridge { constructor(private readonly orch: IAppServerOrchestrator) { diff --git a/apps/meteor/app/apps/server/bridges/uploads.ts b/apps/meteor/app/apps/server/bridges/uploads.ts index 3947996a7eb78..0637e29e74a36 100644 --- a/apps/meteor/app/apps/server/bridges/uploads.ts +++ b/apps/meteor/app/apps/server/bridges/uploads.ts @@ -4,9 +4,9 @@ import type { IUpload } from '@rocket.chat/apps-engine/definition/uploads'; import type { IUploadDetails } from '@rocket.chat/apps-engine/definition/uploads/IUploadDetails'; import { determineFileType } from '../../../../ee/lib/misc/determineFileType'; +import { FileUpload } from '../../../../server/lib/media/file-upload'; +import { sendFileMessage } from '../../../../server/meteor-methods/messages/sendFileMessage'; import { sendFileLivechatMessage } from '../../../../server/meteor-methods/omnichannel/sendFileLivechatMessage'; -import { FileUpload } from '../../../file-upload/server'; -import { sendFileMessage } from '../../../file-upload/server/methods/sendFileMessage'; const getUploadDetails = (details: IUploadDetails): Partial => { if (details.visitorToken) { diff --git a/apps/meteor/app/authentication/server/index.ts b/apps/meteor/app/authentication/server/index.ts deleted file mode 100644 index 5ff4af4eef118..0000000000000 --- a/apps/meteor/app/authentication/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './hooks/login'; -import './startup'; diff --git a/apps/meteor/app/crowd/server/index.ts b/apps/meteor/app/crowd/server/index.ts deleted file mode 100644 index a90aba7f9556c..0000000000000 --- a/apps/meteor/app/crowd/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './crowd'; -import './methods'; diff --git a/apps/meteor/app/custom-sounds/server/index.ts b/apps/meteor/app/custom-sounds/server/index.ts deleted file mode 100644 index 6a14ccff15656..0000000000000 --- a/apps/meteor/app/custom-sounds/server/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import './startup/custom-sounds'; -import './methods/deleteCustomSound'; -import './methods/insertOrUpdateSound'; -import './methods/listCustomSounds'; -import './methods/uploadCustomSound'; diff --git a/apps/meteor/app/discussion/server/index.ts b/apps/meteor/app/discussion/server/index.ts deleted file mode 100644 index f55b1d737379f..0000000000000 --- a/apps/meteor/app/discussion/server/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './permissions'; - -import './hooks/propagateDiscussionMetadata'; diff --git a/apps/meteor/app/dolphin/server/index.ts b/apps/meteor/app/dolphin/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/dolphin/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/drupal/server/index.ts b/apps/meteor/app/drupal/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/drupal/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/emoji-custom/server/index.ts b/apps/meteor/app/emoji-custom/server/index.ts deleted file mode 100644 index 3ec2051f8fffb..0000000000000 --- a/apps/meteor/app/emoji-custom/server/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import './startup/emoji-custom'; -import './methods/deleteEmojiCustom'; -import './methods/insertOrUpdateEmoji'; -import './methods/uploadEmojiCustom'; diff --git a/apps/meteor/app/emoji-native/server/index.ts b/apps/meteor/app/emoji-native/server/index.ts deleted file mode 100644 index 723d879892f7d..0000000000000 --- a/apps/meteor/app/emoji-native/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './lib'; -import './callbacks'; diff --git a/apps/meteor/app/emoji/server/index.ts b/apps/meteor/app/emoji/server/index.ts deleted file mode 100644 index 525aac9589067..0000000000000 --- a/apps/meteor/app/emoji/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { emoji } from './lib'; diff --git a/apps/meteor/app/github-enterprise/server/index.ts b/apps/meteor/app/github-enterprise/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/github-enterprise/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/github/server/index.ts b/apps/meteor/app/github/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/github/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/gitlab/server/index.ts b/apps/meteor/app/gitlab/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/gitlab/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/iframe-login/server/index.ts b/apps/meteor/app/iframe-login/server/index.ts deleted file mode 100644 index 6dbf8cb373253..0000000000000 --- a/apps/meteor/app/iframe-login/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './iframe_server'; diff --git a/apps/meteor/app/integrations/server/index.ts b/apps/meteor/app/integrations/server/index.ts deleted file mode 100644 index f645d275e022f..0000000000000 --- a/apps/meteor/app/integrations/server/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import './logger'; -import './lib/validateOutgoingIntegration'; -import './api/api'; -import './lib/triggerHandler'; -import './triggers'; -import './startup'; diff --git a/apps/meteor/app/invites/server/functions/sendInvitationEmail.ts b/apps/meteor/app/invites/server/functions/sendInvitationEmail.ts index 7ce86d37bd31c..a63ebfab32a2c 100644 --- a/apps/meteor/app/invites/server/functions/sendInvitationEmail.ts +++ b/apps/meteor/app/invites/server/functions/sendInvitationEmail.ts @@ -3,8 +3,8 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; +import * as Mailer from '../../../../server/lib/notifications/email/api'; import { notifyOnSettingChanged } from '../../../lib/server/lib/notifyListener'; -import * as Mailer from '../../../mailer/server/api'; import { settings } from '../../../settings/server'; let html = ''; diff --git a/apps/meteor/app/lib/server/functions/notifications/desktop.ts b/apps/meteor/app/lib/server/functions/notifications/desktop.ts index 4554656d408b6..f215981bfe10e 100644 --- a/apps/meteor/app/lib/server/functions/notifications/desktop.ts +++ b/apps/meteor/app/lib/server/functions/notifications/desktop.ts @@ -1,8 +1,8 @@ import { api } from '@rocket.chat/core-services'; import type { IMessage, IRoom, IUser, AtLeast } from '@rocket.chat/core-typings'; +import { metrics } from '../../../../../server/lib/metrics'; import { roomCoordinator } from '../../../../../server/lib/rooms/roomCoordinator'; -import { metrics } from '../../../../metrics/server'; import { settings } from '../../../../settings/server'; /** diff --git a/apps/meteor/app/lib/server/functions/notifications/email.js b/apps/meteor/app/lib/server/functions/notifications/email.js index c41445fcf55b2..5a5a72b2a4659 100644 --- a/apps/meteor/app/lib/server/functions/notifications/email.js +++ b/apps/meteor/app/lib/server/functions/notifications/email.js @@ -4,9 +4,9 @@ import { Meteor } from 'meteor/meteor'; import { ltrim } from '../../../../../lib/utils/stringUtils'; import { callbacks } from '../../../../../server/lib/callbacks'; import { i18n } from '../../../../../server/lib/i18n'; +import { metrics } from '../../../../../server/lib/metrics'; +import * as Mailer from '../../../../../server/lib/notifications/email/api'; import { roomCoordinator } from '../../../../../server/lib/rooms/roomCoordinator'; -import * as Mailer from '../../../../mailer/server/api'; -import { metrics } from '../../../../metrics/server'; import { settings } from '../../../../settings/server'; import { getURL } from '../../../../utils/server/getURL'; diff --git a/apps/meteor/app/lib/server/index.ts b/apps/meteor/app/lib/server/index.ts index 9a9c1e8d085fe..087e329910cfc 100644 --- a/apps/meteor/app/lib/server/index.ts +++ b/apps/meteor/app/lib/server/index.ts @@ -2,11 +2,11 @@ import '../lib/MessageTypes'; import './lib/bugsnag'; import './lib/debug'; import './lib/loginErrorMessageOverride'; -import './oauth/oauth'; -import './oauth/facebook'; -import './oauth/google'; -import './oauth/proxy'; -import './oauth/twitter'; +import '../../../server/lib/auth-providers/oauth/oauth'; +import '../../../server/lib/auth-providers/oauth/facebook'; +import '../../../server/lib/auth-providers/oauth/google'; +import '../../../server/lib/auth-providers/oauth/proxy'; +import '../../../server/lib/auth-providers/oauth/twitter'; import './startup/mentionUserNotInChannel'; export * from './lib'; diff --git a/apps/meteor/app/lib/server/lib/debug.js b/apps/meteor/app/lib/server/lib/debug.js index 579e2b6bad0bc..4977ea0dd731e 100644 --- a/apps/meteor/app/lib/server/lib/debug.js +++ b/apps/meteor/app/lib/server/lib/debug.js @@ -6,8 +6,8 @@ import { WebApp } from 'meteor/webapp'; import _ from 'underscore'; import { getMethodArgs } from '../../../../server/lib/logger/logPayloads'; +import { metrics } from '../../../../server/lib/metrics'; import { getModifiedHttpHeaders } from '../../../../server/lib/shared/getModifiedHttpHeaders'; -import { metrics } from '../../../metrics/server'; import { settings } from '../../../settings/server'; const logger = new Logger('Meteor'); diff --git a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts index 9a1b46374c49a..940bc9b2523c3 100644 --- a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts +++ b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts @@ -2,7 +2,7 @@ import { Logger } from '@rocket.chat/logger'; import type { PathPattern } from '@rocket.chat/rest-typings'; import semver from 'semver'; -import { metrics } from '../../../metrics/server/lib/metrics'; +import { metrics } from '../../../../server/lib/metrics/lib/metrics'; const deprecationLogger = new Logger('DeprecationWarning'); diff --git a/apps/meteor/app/lib/server/lib/index.ts b/apps/meteor/app/lib/server/lib/index.ts index be0fad1f89f41..94e0daf97fdc1 100644 --- a/apps/meteor/app/lib/server/lib/index.ts +++ b/apps/meteor/app/lib/server/lib/index.ts @@ -6,9 +6,9 @@ library files. */ import './afterUserActions'; -import './notifyUsersOnMessage'; +import '../../../../server/hooks/messages/notifyUsersOnMessage'; -export { sendNotification } from './sendNotificationsOnMessage'; +export { sendNotification } from '../../../../server/hooks/messages/sendNotificationsOnMessage'; export { passwordPolicy } from './passwordPolicy'; export { validateEmailDomain } from './validateEmailDomain'; export { RateLimiterClass as RateLimiter } from './RateLimiter'; diff --git a/apps/meteor/app/lib/server/lib/msgStream.ts b/apps/meteor/app/lib/server/lib/msgStream.ts index 208c3ab14f549..3db2b02dad3f7 100644 --- a/apps/meteor/app/lib/server/lib/msgStream.ts +++ b/apps/meteor/app/lib/server/lib/msgStream.ts @@ -1,3 +1,3 @@ -import notifications from '../../../notifications/server/lib/Notifications'; +import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; export const msgStream = notifications.streamRoomMessage; diff --git a/apps/meteor/app/lib/server/lib/processDirectEmail.ts b/apps/meteor/app/lib/server/lib/processDirectEmail.ts index 75ff7f8863812..507939e2d1e4e 100644 --- a/apps/meteor/app/lib/server/lib/processDirectEmail.ts +++ b/apps/meteor/app/lib/server/lib/processDirectEmail.ts @@ -5,8 +5,8 @@ import moment from 'moment'; import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; import { sendMessage } from '../../../../server/lib/messages/sendMessage'; +import { metrics } from '../../../../server/lib/metrics'; import { canAccessRoomAsync } from '../../../authorization/server'; -import { metrics } from '../../../metrics/server'; import { settings } from '../../../settings/server'; const isParsedEmail = (email: ParsedMail): email is Required => 'date' in email && 'html' in email; diff --git a/apps/meteor/app/lib/server/startup/rateLimiter.js b/apps/meteor/app/lib/server/startup/rateLimiter.js index d493eccfb4b39..ee2da4faba73f 100644 --- a/apps/meteor/app/lib/server/startup/rateLimiter.js +++ b/apps/meteor/app/lib/server/startup/rateLimiter.js @@ -5,7 +5,7 @@ import { RateLimiter } from 'meteor/rate-limit'; import _ from 'underscore'; import { sleep } from '../../../../lib/utils/sleep'; -import { metrics } from '../../../metrics/server'; +import { metrics } from '../../../../server/lib/metrics'; import { settings } from '../../../settings/server'; const logger = new Logger('RateLimiter'); diff --git a/apps/meteor/app/linkedin/server/index.ts b/apps/meteor/app/linkedin/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/linkedin/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index b30aeb8aabe17..d956247de2bd0 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -1,19 +1,19 @@ import './livechat'; import './startup'; -import './hooks/leadCapture'; -import './hooks/markRoomResponded'; -import './hooks/offlineMessage'; -import './hooks/offlineMessageToChannel'; -import './hooks/saveAnalyticsData'; -import './hooks/sendToCRM'; -import './hooks/processRoomAbandonment'; -import './hooks/saveLastVisitorMessageTs'; -import './hooks/markRoomNotResponded'; -import './hooks/sendEmailTranscriptOnClose'; -import './hooks/saveLastMessageToInquiry'; -import './hooks/afterUserActions'; -import './hooks/afterAgentRemoved'; -import './hooks/afterSaveOmnichannelMessage'; +import '../../../server/hooks/omnichannel/leadCapture'; +import '../../../server/hooks/omnichannel/markRoomResponded'; +import '../../../server/hooks/omnichannel/offlineMessage'; +import '../../../server/hooks/omnichannel/offlineMessageToChannel'; +import '../../../server/hooks/omnichannel/saveAnalyticsData'; +import '../../../server/hooks/omnichannel/sendToCRM'; +import '../../../server/hooks/omnichannel/processRoomAbandonment'; +import '../../../server/hooks/omnichannel/saveLastVisitorMessageTs'; +import '../../../server/hooks/omnichannel/markRoomNotResponded'; +import '../../../server/hooks/omnichannel/sendEmailTranscriptOnClose'; +import '../../../server/hooks/omnichannel/saveLastMessageToInquiry'; +import '../../../server/hooks/omnichannel/afterUserActions'; +import '../../../server/hooks/omnichannel/afterAgentRemoved'; +import '../../../server/hooks/omnichannel/afterSaveOmnichannelMessage'; import './lib/QueueManager'; import './lib/RoutingManager'; import './lib/routing/External'; diff --git a/apps/meteor/app/livechat/server/lib/guests.ts b/apps/meteor/app/livechat/server/lib/guests.ts index 11051e1e7a228..a9727e4017e41 100644 --- a/apps/meteor/app/livechat/server/lib/guests.ts +++ b/apps/meteor/app/livechat/server/lib/guests.ts @@ -20,7 +20,7 @@ import { livechatLogger } from './logger'; import { trim } from '../../../../lib/utils/stringUtils'; import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; import { i18n } from '../../../../server/lib/i18n'; -import { FileUpload } from '../../../file-upload/server'; +import { FileUpload } from '../../../../server/lib/media/file-upload'; import { notifyOnSubscriptionChanged, notifyOnLivechatInquiryChanged, diff --git a/apps/meteor/app/livechat/server/lib/hooks.ts b/apps/meteor/app/livechat/server/lib/hooks.ts index baaf226f21d8c..f58cd9c638335 100644 --- a/apps/meteor/app/livechat/server/lib/hooks.ts +++ b/apps/meteor/app/livechat/server/lib/hooks.ts @@ -15,10 +15,10 @@ import { LivechatContacts, LivechatDepartmentAgents, LivechatVisitors, Users } f import { makeFunction } from '@rocket.chat/patch-injection'; import { setUserStatusLivechat } from './utils'; +import { sendToCRM } from '../../../../server/hooks/omnichannel/sendToCRM'; import { callbacks } from '../../../../server/lib/callbacks'; import { notifyOnLivechatDepartmentAgentChangedByDepartmentId } from '../../../lib/server/lib/notifyListener'; import { settings } from '../../../settings/server'; -import { sendToCRM } from '../hooks/sendToCRM'; export async function afterAgentUserActivated(user: IUser) { if (!user.roles.includes('livechat-agent')) { diff --git a/apps/meteor/app/livechat/server/lib/messages.ts b/apps/meteor/app/livechat/server/lib/messages.ts index 599b81d251a51..ec03f872777e5 100644 --- a/apps/meteor/app/livechat/server/lib/messages.ts +++ b/apps/meteor/app/livechat/server/lib/messages.ts @@ -13,7 +13,7 @@ import { callbacks } from '../../../../server/lib/callbacks'; import { deleteMessage as deleteMessageFunc } from '../../../../server/lib/messages/deleteMessage'; import { sendMessage as sendMessageFunc } from '../../../../server/lib/messages/sendMessage'; import { updateMessage as updateMessageFunc } from '../../../../server/lib/messages/updateMessage'; -import * as Mailer from '../../../mailer/server/api'; +import * as Mailer from '../../../../server/lib/notifications/email/api'; import { settings } from '../../../settings/server'; const dnsResolveMx = util.promisify(dns.resolveMx); diff --git a/apps/meteor/app/livechat/server/lib/sendTranscript.ts b/apps/meteor/app/livechat/server/lib/sendTranscript.ts index 199275f6a516b..c837ee4fc1c0a 100644 --- a/apps/meteor/app/livechat/server/lib/sendTranscript.ts +++ b/apps/meteor/app/livechat/server/lib/sendTranscript.ts @@ -20,8 +20,8 @@ import moment from 'moment-timezone'; import { callbacks } from '../../../../server/lib/callbacks'; import { i18n } from '../../../../server/lib/i18n'; -import { FileUpload } from '../../../file-upload/server'; -import * as Mailer from '../../../mailer/server/api'; +import { FileUpload } from '../../../../server/lib/media/file-upload'; +import * as Mailer from '../../../../server/lib/notifications/email/api'; import { settings } from '../../../settings/server'; import { getTimezone } from '../../../utils/server/lib/getTimezone'; diff --git a/apps/meteor/app/livechat/server/lib/webhooks.ts b/apps/meteor/app/livechat/server/lib/webhooks.ts index de49a6bb0cae7..a4621bbecf957 100644 --- a/apps/meteor/app/livechat/server/lib/webhooks.ts +++ b/apps/meteor/app/livechat/server/lib/webhooks.ts @@ -2,7 +2,7 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import type { Response } from '@rocket.chat/server-fetch'; import { webhooksLogger } from './logger'; -import { metrics } from '../../../metrics/server'; +import { metrics } from '../../../../server/lib/metrics'; import { settings } from '../../../settings/server'; const isRetryable = (status: number): boolean => status >= 500 || status === 429; diff --git a/apps/meteor/app/mentions/server/index.ts b/apps/meteor/app/mentions/server/index.ts deleted file mode 100644 index b16d62185a64e..0000000000000 --- a/apps/meteor/app/mentions/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './getMentionedTeamMembers'; -import './methods/getUserMentionsByChannel'; diff --git a/apps/meteor/app/message-mark-as-unread/server/index.ts b/apps/meteor/app/message-mark-as-unread/server/index.ts deleted file mode 100644 index d9ad8ff7357a0..0000000000000 --- a/apps/meteor/app/message-mark-as-unread/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './unreadMessages'; diff --git a/apps/meteor/app/message-pin/server/index.ts b/apps/meteor/app/message-pin/server/index.ts deleted file mode 100644 index 19a4497a35322..0000000000000 --- a/apps/meteor/app/message-pin/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './pinMessage'; diff --git a/apps/meteor/app/message-star/server/index.ts b/apps/meteor/app/message-star/server/index.ts deleted file mode 100644 index cff8c3818b0e4..0000000000000 --- a/apps/meteor/app/message-star/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './starMessage'; diff --git a/apps/meteor/app/meteor-accounts-saml/server/index.ts b/apps/meteor/app/meteor-accounts-saml/server/index.ts deleted file mode 100644 index 8da4b6cc9c9b9..0000000000000 --- a/apps/meteor/app/meteor-accounts-saml/server/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import './startup'; -import './loginHandler'; -import './listener'; -import './methods/samlLogout'; -import './methods/addSamlService'; diff --git a/apps/meteor/app/meteor-developer/server/index.ts b/apps/meteor/app/meteor-developer/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/meteor-developer/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/app/reactions/server/index.ts b/apps/meteor/app/reactions/server/index.ts deleted file mode 100644 index 8c5644023dbc8..0000000000000 --- a/apps/meteor/app/reactions/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './setReaction'; diff --git a/apps/meteor/app/search/server/index.ts b/apps/meteor/app/search/server/index.ts deleted file mode 100644 index 762dc8ab112b2..0000000000000 --- a/apps/meteor/app/search/server/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import './model/SearchProvider'; -import './events'; -import './search.internalService'; -import './register'; -import './startup'; -import './service'; -import './methods'; diff --git a/apps/meteor/app/threads/server/hooks/index.ts b/apps/meteor/app/threads/server/hooks/index.ts deleted file mode 100644 index b1be2eb6f38af..0000000000000 --- a/apps/meteor/app/threads/server/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './aftersavemessage'; diff --git a/apps/meteor/app/threads/server/index.ts b/apps/meteor/app/threads/server/index.ts deleted file mode 100644 index 015ef46fd3598..0000000000000 --- a/apps/meteor/app/threads/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './hooks'; diff --git a/apps/meteor/app/token-login/server/index.ts b/apps/meteor/app/token-login/server/index.ts deleted file mode 100644 index 3cb9f1aac0b55..0000000000000 --- a/apps/meteor/app/token-login/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './login_token_server'; diff --git a/apps/meteor/app/utils/server/functions/normalizeMessageFileUpload.ts b/apps/meteor/app/utils/server/functions/normalizeMessageFileUpload.ts index 173592a982766..086e29f60e3e6 100644 --- a/apps/meteor/app/utils/server/functions/normalizeMessageFileUpload.ts +++ b/apps/meteor/app/utils/server/functions/normalizeMessageFileUpload.ts @@ -1,7 +1,7 @@ import type { IMessage } from '@rocket.chat/core-typings'; import { Uploads } from '@rocket.chat/models'; -import { FileUpload } from '../../../file-upload/server'; +import { FileUpload } from '../../../../server/lib/media/file-upload'; import { getURL } from '../getURL'; export const normalizeMessageFileUpload = async (message: Omit): Promise> => { diff --git a/apps/meteor/app/wordpress/server/index.ts b/apps/meteor/app/wordpress/server/index.ts deleted file mode 100644 index cf327e4971bb2..0000000000000 --- a/apps/meteor/app/wordpress/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -import './lib'; diff --git a/apps/meteor/ee/app/authorization/lib/addRoleRestrictions.ts b/apps/meteor/ee/app/authorization/lib/addRoleRestrictions.ts deleted file mode 100644 index 15f8525394cfd..0000000000000 --- a/apps/meteor/ee/app/authorization/lib/addRoleRestrictions.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { guestPermissions } from './guestPermissions'; -import { AuthorizationUtils } from '../../../../app/authorization/lib/AuthorizationUtils'; - -export const addRoleRestrictions = function () { - AuthorizationUtils.addRolePermissionWhiteList('guest', guestPermissions); -}; diff --git a/apps/meteor/ee/app/authorization/server/index.ts b/apps/meteor/ee/app/authorization/server/index.ts deleted file mode 100644 index a904bc84a9ef2..0000000000000 --- a/apps/meteor/ee/app/authorization/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import '../lib/addRoleRestrictions'; -import './callback'; diff --git a/apps/meteor/ee/app/canned-responses/server/index.ts b/apps/meteor/ee/app/canned-responses/server/index.ts deleted file mode 100644 index 7a4e7f6ce49c9..0000000000000 --- a/apps/meteor/ee/app/canned-responses/server/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { License } from '@rocket.chat/license'; - -await License.onLicense('canned-responses', async () => { - const { createSettings } = await import('./settings'); - await import('./permissions'); - await import('./hooks/onRemoveAgentDepartment'); - await import('./hooks/onSaveAgentDepartment'); - await import('./hooks/cannedResponses'); - await import('../../../server/meteor-methods/saveCannedResponse'); - await import('../../../server/meteor-methods/removeCannedResponse'); - - await createSettings(); -}); diff --git a/apps/meteor/ee/app/license/server/index.ts b/apps/meteor/ee/app/license/server/index.ts deleted file mode 100644 index 23f769f016a1f..0000000000000 --- a/apps/meteor/ee/app/license/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './settings'; -import '../../../server/meteor-methods/license'; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/index.ts b/apps/meteor/ee/app/livechat-enterprise/server/index.ts index 97e1bf0a76eb5..3ab49a09fc428 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/index.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/index.ts @@ -2,19 +2,19 @@ import { License } from '@rocket.chat/license'; import { patchOmniCore } from '@rocket.chat/omni-core-ee'; import { Meteor } from 'meteor/meteor'; -import './hooks/afterTakeInquiry'; -import './hooks/beforeNewInquiry'; -import './hooks/beforeNewRoom'; -import './hooks/beforeRoutingChat'; -import './hooks/checkAgentBeforeTakeInquiry'; -import './hooks/handleNextAgentPreferredEvents'; -import './hooks/onCheckRoomParamsApi'; -import './hooks/onLoadConfigApi'; -import './hooks/onSaveVisitorInfo'; -import './hooks/scheduleAutoTransfer'; -import './hooks/resumeOnHold'; -import './hooks/afterOnHold'; -import './hooks/onTransferFailure'; +import '../../../server/hooks/omnichannel/afterTakeInquiry'; +import '../../../server/hooks/omnichannel/beforeNewInquiry'; +import '../../../server/hooks/omnichannel/beforeNewRoom'; +import '../../../server/hooks/omnichannel/beforeRoutingChat'; +import '../../../server/hooks/omnichannel/checkAgentBeforeTakeInquiry'; +import '../../../server/hooks/omnichannel/handleNextAgentPreferredEvents'; +import '../../../server/hooks/omnichannel/onCheckRoomParamsApi'; +import '../../../server/hooks/omnichannel/onLoadConfigApi'; +import '../../../server/hooks/omnichannel/onSaveVisitorInfo'; +import '../../../server/hooks/omnichannel/scheduleAutoTransfer'; +import '../../../server/hooks/omnichannel/resumeOnHold'; +import '../../../server/hooks/omnichannel/afterOnHold'; +import '../../../server/hooks/omnichannel/onTransferFailure'; import './lib/routing/LoadBalancing'; import './lib/routing/LoadRotation'; import './lib/AutoCloseOnHoldScheduler'; @@ -25,7 +25,7 @@ import { createDefaultPriorities } from './priorities'; patchOmniCore(); await License.onLicense('livechat-enterprise', async () => { - require('./hooks'); + require('../../../server/hooks/omnichannel'); await import('./startup'); const { createPermissions } = await import('./permissions'); const { createSettings } = await import('./settings'); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadBalancing.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadBalancing.ts index 3974f96067dab..9d1fd9fcfda91 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadBalancing.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadBalancing.ts @@ -3,7 +3,7 @@ import { Users } from '@rocket.chat/models'; import { RoutingManager } from '../../../../../../app/livechat/server/lib/RoutingManager'; import { settings } from '../../../../../../app/settings/server'; import type { IRoutingManagerConfig } from '../../../../../../definition/IRoutingManagerConfig'; -import { getChatLimitsQuery } from '../../hooks/applySimultaneousChatsRestrictions'; +import { getChatLimitsQuery } from '../../../../../server/hooks/omnichannel/applySimultaneousChatsRestrictions'; import { logger } from '../logger'; /* Load Balancing Queuing method: diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadRotation.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadRotation.ts index 3e4fab5f94da5..a46e58ed24c8c 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadRotation.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/routing/LoadRotation.ts @@ -4,7 +4,7 @@ import { Users } from '@rocket.chat/models'; import { RoutingManager } from '../../../../../../app/livechat/server/lib/RoutingManager'; import { settings } from '../../../../../../app/settings/server'; import type { IRoutingManagerConfig } from '../../../../../../definition/IRoutingManagerConfig'; -import { getChatLimitsQuery } from '../../hooks/applySimultaneousChatsRestrictions'; +import { getChatLimitsQuery } from '../../../../../server/hooks/omnichannel/applySimultaneousChatsRestrictions'; import { logger } from '../logger'; /* Load Rotation Queuing method: diff --git a/apps/meteor/ee/app/message-read-receipt/server/hooks/index.ts b/apps/meteor/ee/app/message-read-receipt/server/hooks/index.ts deleted file mode 100644 index 5995d9fd5b764..0000000000000 --- a/apps/meteor/ee/app/message-read-receipt/server/hooks/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './afterReadMessages'; -import './afterSaveMessage'; -import './afterDeleteRoom'; diff --git a/apps/meteor/ee/app/message-read-receipt/server/index.ts b/apps/meteor/ee/app/message-read-receipt/server/index.ts deleted file mode 100644 index bb405c0eaffdf..0000000000000 --- a/apps/meteor/ee/app/message-read-receipt/server/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { License } from '@rocket.chat/license'; - -await License.onLicense('message-read-receipt', async () => { - await import('./hooks'); -}); diff --git a/apps/meteor/ee/server/apps/appRequestsCron.ts b/apps/meteor/ee/server/apps/appRequestsCron.ts index 4e32b8b9d49c1..50c509a6468fd 100644 --- a/apps/meteor/ee/server/apps/appRequestsCron.ts +++ b/apps/meteor/ee/server/apps/appRequestsCron.ts @@ -3,8 +3,8 @@ import type { ExtendedFetchOptions } from '@rocket.chat/server-fetch'; import { appRequestNotififyForUsers } from './marketplace/appRequestNotifyUsers'; import { Apps } from './orchestrator'; -import { getWorkspaceAccessToken } from '../../../app/cloud/server'; import { settings } from '../../../app/settings/server'; +import { getWorkspaceAccessToken } from '../../../server/lib/cloud'; const appsNotifyAppRequests = async function _appsNotifyAppRequests() { try { diff --git a/apps/meteor/ee/server/apps/communication/rest.ts b/apps/meteor/ee/server/apps/communication/rest.ts index 13e1715a1f9fc..a69e3e0b2ddd1 100644 --- a/apps/meteor/ee/server/apps/communication/rest.ts +++ b/apps/meteor/ee/server/apps/communication/rest.ts @@ -16,8 +16,6 @@ import { registerAppLogsDistinctInstanceHandler } from './endpoints/appLogsDisti import { registerAppLogsExportHandler } from './endpoints/appLogsExportHandler'; import { registerAppLogsHandler } from './endpoints/appLogsHandler'; import { registerAppsCountHandler } from './endpoints/appsCountHandler'; -import { getWorkspaceAccessToken, getWorkspaceAccessTokenWithScope } from '../../../../app/cloud/server'; -import { metrics } from '../../../../app/metrics/server'; import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; import { API } from '../../../../server/api'; @@ -26,12 +24,14 @@ import { getUploadFormData } from '../../../../server/api/lib/getUploadFormData' import { loggerMiddleware } from '../../../../server/api/v1/middlewares/logger'; import { metricsMiddleware } from '../../../../server/api/v1/middlewares/metrics'; import { tracerSpanMiddleware } from '../../../../server/api/v1/middlewares/tracer'; +import { getWorkspaceAccessToken, getWorkspaceAccessTokenWithScope } from '../../../../server/lib/cloud'; import { i18n } from '../../../../server/lib/i18n'; +import { metrics } from '../../../../server/lib/metrics'; import { sendMessagesToAdmins } from '../../../../server/lib/sendMessagesToAdmins'; import { AppsEngineNoNodesFoundError } from '../../../../server/services/apps-engine/service'; -import { canEnableApp } from '../../../app/license/server/canEnableApp'; import { fetchAppsStatusFromCluster } from '../../../lib/misc/fetchAppsStatusFromCluster'; import { formatAppInstanceForRest } from '../../../lib/misc/formatAppInstanceForRest'; +import { canEnableApp } from '../../lib/license/canEnableApp'; import { notifyMarketplace } from '../marketplace/appInstall'; import { fetchMarketplaceApps } from '../marketplace/fetchMarketplaceApps'; import { fetchMarketplaceCategories } from '../marketplace/fetchMarketplaceCategories'; diff --git a/apps/meteor/ee/server/apps/communication/websockets.ts b/apps/meteor/ee/server/apps/communication/websockets.ts index 81581363af490..32310add15d94 100644 --- a/apps/meteor/ee/server/apps/communication/websockets.ts +++ b/apps/meteor/ee/server/apps/communication/websockets.ts @@ -5,8 +5,8 @@ import { api } from '@rocket.chat/core-services'; import { InstanceStatus } from '@rocket.chat/instance-status'; import { AppEvents } from './events'; -import notifications from '../../../../app/notifications/server/lib/Notifications'; import { SystemLogger } from '../../../../server/lib/logger/system'; +import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; import type { IStreamer } from '../../../../server/modules/streamer/types'; import type { AppServerOrchestrator } from '../orchestrator'; diff --git a/apps/meteor/ee/server/apps/cron.ts b/apps/meteor/ee/server/apps/cron.ts index 9a09a1b457d18..fc655f087dbd3 100644 --- a/apps/meteor/ee/server/apps/cron.ts +++ b/apps/meteor/ee/server/apps/cron.ts @@ -4,7 +4,7 @@ import { cronJobs } from '@rocket.chat/cron'; import { Settings, Users } from '@rocket.chat/models'; import { Apps } from './orchestrator'; -import { getWorkspaceAccessToken } from '../../../app/cloud/server'; +import { getWorkspaceAccessToken } from '../../../server/lib/cloud'; import { i18n } from '../../../server/lib/i18n'; import { sendMessagesToAdmins } from '../../../server/lib/sendMessagesToAdmins'; diff --git a/apps/meteor/ee/server/apps/marketplace/appInstall.ts b/apps/meteor/ee/server/apps/marketplace/appInstall.ts index 70a0c68625b02..ef5f666632bf8 100644 --- a/apps/meteor/ee/server/apps/marketplace/appInstall.ts +++ b/apps/meteor/ee/server/apps/marketplace/appInstall.ts @@ -1,8 +1,8 @@ import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; -import { getWorkspaceAccessToken } from '../../../../app/cloud/server'; import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; +import { getWorkspaceAccessToken } from '../../../../server/lib/cloud'; import { Apps } from '../orchestrator'; type MarketplaceNotificationType = 'install' | 'update' | 'uninstall'; diff --git a/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts b/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts index 54e7b9e66f846..5c6ec5f3cf585 100644 --- a/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts +++ b/apps/meteor/ee/server/apps/marketplace/appRequestNotifyUsers.ts @@ -1,7 +1,7 @@ import type { AppRequest, IUser } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; -import { getWorkspaceAccessToken } from '../../../../app/cloud/server'; +import { getWorkspaceAccessToken } from '../../../../server/lib/cloud'; import { i18n } from '../../../../server/lib/i18n'; import { sendDirectMessageToUsers } from '../../../../server/lib/sendDirectMessageToUsers'; diff --git a/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceApps.ts b/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceApps.ts index eaead32e1ba78..9556316c27d75 100644 --- a/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceApps.ts +++ b/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceApps.ts @@ -3,8 +3,8 @@ import * as z from 'zod'; import { getMarketplaceHeaders } from './getMarketplaceHeaders'; import { MarketplaceAppsError, MarketplaceConnectionError, MarketplaceUnsupportedVersionError } from './marketplaceErrors'; -import { getWorkspaceAccessToken } from '../../../../app/cloud/server'; import { settings } from '../../../../app/settings/server'; +import { getWorkspaceAccessToken } from '../../../../server/lib/cloud'; import { Apps } from '../orchestrator'; type FetchMarketplaceAppsParams = { diff --git a/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceCategories.ts b/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceCategories.ts index 0ec5bb2baf1e9..cc2d4cbbd283d 100644 --- a/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceCategories.ts +++ b/apps/meteor/ee/server/apps/marketplace/fetchMarketplaceCategories.ts @@ -3,8 +3,8 @@ import * as z from 'zod'; import { getMarketplaceHeaders } from './getMarketplaceHeaders'; import { MarketplaceAppsError, MarketplaceConnectionError, MarketplaceUnsupportedVersionError } from './marketplaceErrors'; -import { getWorkspaceAccessToken } from '../../../../app/cloud/server'; import { settings } from '../../../../app/settings/server'; +import { getWorkspaceAccessToken } from '../../../../server/lib/cloud'; import { Apps } from '../orchestrator'; const fetchMarketplaceCategoriesSchema = z.array( diff --git a/apps/meteor/ee/server/apps/orchestrator.js b/apps/meteor/ee/server/apps/orchestrator.js index 879f4a6160784..2be26538d246b 100644 --- a/apps/meteor/ee/server/apps/orchestrator.js +++ b/apps/meteor/ee/server/apps/orchestrator.js @@ -29,7 +29,7 @@ import { } from '../../../app/apps/server/converters'; import { AppThreadsConverter } from '../../../app/apps/server/converters/threads'; import { settings } from '../../../app/settings/server'; -import { canEnableApp } from '../../app/license/server/canEnableApp'; +import { canEnableApp } from '../lib/license/canEnableApp'; const DISABLED_PRIVATE_APP_INSTALLATION = ['yes', 'true'].includes(String(process.env.DISABLE_PRIVATE_APP_INSTALLATION).toLowerCase()); diff --git a/apps/meteor/ee/server/configuration/saml.ts b/apps/meteor/ee/server/configuration/saml.ts index 6ab5f10926233..c6ab761fe5967 100644 --- a/apps/meteor/ee/server/configuration/saml.ts +++ b/apps/meteor/ee/server/configuration/saml.ts @@ -1,10 +1,10 @@ import { License } from '@rocket.chat/license'; import { Roles, Users } from '@rocket.chat/models'; -import type { ISAMLUser } from '../../../app/meteor-accounts-saml/server/definition/ISAMLUser'; -import { SAMLUtils } from '../../../app/meteor-accounts-saml/server/lib/Utils'; import { settings } from '../../../app/settings/server'; import { ensureArray } from '../../../lib/utils/arrayUtils'; +import type { ISAMLUser } from '../../../server/lib/saml/definition/ISAMLUser'; +import { SAMLUtils } from '../../../server/lib/saml/lib/Utils'; import { addSettings } from '../settings/saml'; await License.onLicense('saml-enterprise', () => { diff --git a/apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts b/apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts index 4260161d1435b..017023bcfa561 100644 --- a/apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts +++ b/apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts @@ -1,8 +1,8 @@ import { Abac } from '@rocket.chat/core-services'; import { License } from '@rocket.chat/license'; -import { beforeAddUserToRoom } from '../../../../app/lib/server/lib/beforeAddUserToRoom'; import { settings } from '../../../../app/settings/server'; +import { beforeAddUserToRoom } from '../../../../server/hooks/rooms/beforeAddUserToRoom'; beforeAddUserToRoom.patch(async (prev, users, room, actor) => { await prev(users, room, actor); diff --git a/apps/meteor/ee/app/authorization/server/callback.ts b/apps/meteor/ee/server/hooks/auth/callback.ts similarity index 94% rename from apps/meteor/ee/app/authorization/server/callback.ts rename to apps/meteor/ee/server/hooks/auth/callback.ts index 6f1dcae77a018..b03f561600df2 100644 --- a/apps/meteor/ee/app/authorization/server/callback.ts +++ b/apps/meteor/ee/server/hooks/auth/callback.ts @@ -3,7 +3,7 @@ import { License } from '@rocket.chat/license'; import { callbacks } from '../../../../server/lib/callbacks'; import { i18n } from '../../../../server/lib/i18n'; -import { validateUserRoles } from '../../../server/lib/authorization/validateUserRoles'; +import { validateUserRoles } from '../../lib/authorization/validateUserRoles'; License.onInstall(() => { callbacks.add( diff --git a/apps/meteor/ee/app/canned-responses/server/hooks/cannedResponses.ts b/apps/meteor/ee/server/hooks/canned-responses/cannedResponses.ts similarity index 79% rename from apps/meteor/ee/app/canned-responses/server/hooks/cannedResponses.ts rename to apps/meteor/ee/server/hooks/canned-responses/cannedResponses.ts index 20b94619eb5c9..95601020923c2 100644 --- a/apps/meteor/ee/app/canned-responses/server/hooks/cannedResponses.ts +++ b/apps/meteor/ee/server/hooks/canned-responses/cannedResponses.ts @@ -1,7 +1,7 @@ import { License } from '@rocket.chat/license'; -import { settings } from '../../../../../app/settings/server'; -import { BeforeSaveCannedResponse } from '../../../../server/hooks/messages/BeforeSaveCannedResponse'; +import { settings } from '../../../../app/settings/server'; +import { BeforeSaveCannedResponse } from '../messages/BeforeSaveCannedResponse'; void License.onToggledFeature('canned-responses', { up: () => { diff --git a/apps/meteor/ee/app/canned-responses/server/hooks/onRemoveAgentDepartment.ts b/apps/meteor/ee/server/hooks/canned-responses/onRemoveAgentDepartment.ts similarity index 78% rename from apps/meteor/ee/app/canned-responses/server/hooks/onRemoveAgentDepartment.ts rename to apps/meteor/ee/server/hooks/canned-responses/onRemoveAgentDepartment.ts index a05917dcf3fd8..3cb2dd3456f4e 100644 --- a/apps/meteor/ee/app/canned-responses/server/hooks/onRemoveAgentDepartment.ts +++ b/apps/meteor/ee/server/hooks/canned-responses/onRemoveAgentDepartment.ts @@ -1,7 +1,7 @@ import { CannedResponse } from '@rocket.chat/models'; -import notifications from '../../../../../app/notifications/server/lib/Notifications'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; +import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; callbacks.add( 'livechat.removeAgentDepartment', diff --git a/apps/meteor/ee/app/canned-responses/server/hooks/onSaveAgentDepartment.ts b/apps/meteor/ee/server/hooks/canned-responses/onSaveAgentDepartment.ts similarity index 76% rename from apps/meteor/ee/app/canned-responses/server/hooks/onSaveAgentDepartment.ts rename to apps/meteor/ee/server/hooks/canned-responses/onSaveAgentDepartment.ts index 348fe23a674d5..c64eab12a392a 100644 --- a/apps/meteor/ee/app/canned-responses/server/hooks/onSaveAgentDepartment.ts +++ b/apps/meteor/ee/server/hooks/canned-responses/onSaveAgentDepartment.ts @@ -1,7 +1,7 @@ import { CannedResponse } from '@rocket.chat/models'; -import notifications from '../../../../../app/notifications/server/lib/Notifications'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; +import notifications from '../../../../server/lib/notifications/core/lib/Notifications'; callbacks.add( 'livechat.saveAgentDepartment', diff --git a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterDeleteRoom.ts b/apps/meteor/ee/server/hooks/messages/afterDeleteRoom.ts similarity index 81% rename from apps/meteor/ee/app/message-read-receipt/server/hooks/afterDeleteRoom.ts rename to apps/meteor/ee/server/hooks/messages/afterDeleteRoom.ts index e0f3af49b2d69..9689764a2d2c3 100644 --- a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterDeleteRoom.ts +++ b/apps/meteor/ee/server/hooks/messages/afterDeleteRoom.ts @@ -1,6 +1,6 @@ import { ReadReceipts, ReadReceiptsArchive } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'afterDeleteRoom', diff --git a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterReadMessages.ts b/apps/meteor/ee/server/hooks/messages/afterReadMessages.ts similarity index 74% rename from apps/meteor/ee/app/message-read-receipt/server/hooks/afterReadMessages.ts rename to apps/meteor/ee/server/hooks/messages/afterReadMessages.ts index b2add51b3ed4f..b97a0ad5ad221 100644 --- a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterReadMessages.ts +++ b/apps/meteor/ee/server/hooks/messages/afterReadMessages.ts @@ -1,9 +1,9 @@ import { MessageReads } from '@rocket.chat/core-services'; import { type IUser, type IRoom, type IMessage } from '@rocket.chat/core-typings'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { ReadReceipt } from '../../../../server/lib/message-read-receipt/ReadReceipt'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { ReadReceipt } from '../../lib/message-read-receipt/ReadReceipt'; callbacks.add( 'afterReadMessages', diff --git a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterSaveMessage.ts b/apps/meteor/ee/server/hooks/messages/afterSaveMessage.ts similarity index 74% rename from apps/meteor/ee/app/message-read-receipt/server/hooks/afterSaveMessage.ts rename to apps/meteor/ee/server/hooks/messages/afterSaveMessage.ts index 1323f324bc8ba..3723976655b3d 100644 --- a/apps/meteor/ee/app/message-read-receipt/server/hooks/afterSaveMessage.ts +++ b/apps/meteor/ee/server/hooks/messages/afterSaveMessage.ts @@ -1,7 +1,7 @@ import { isEditedMessage } from '@rocket.chat/core-typings'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { ReadReceipt } from '../../../../server/lib/message-read-receipt/ReadReceipt'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { ReadReceipt } from '../../lib/message-read-receipt/ReadReceipt'; callbacks.add( 'afterSaveMessage', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/addDepartmentAncestors.ts b/apps/meteor/ee/server/hooks/omnichannel/addDepartmentAncestors.ts similarity index 88% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/addDepartmentAncestors.ts rename to apps/meteor/ee/server/hooks/omnichannel/addDepartmentAncestors.ts index 47d5e02ff662a..b0d93b2b3d2dd 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/addDepartmentAncestors.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/addDepartmentAncestors.ts @@ -1,7 +1,7 @@ import type { ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatRooms, LivechatDepartment } from '@rocket.chat/models'; -import { onNewRoom } from '../../../../../app/livechat/server/lib/hooks'; +import { onNewRoom } from '../../../../app/livechat/server/lib/hooks'; onNewRoom.patch(async (originalFn, room) => { await originalFn(room); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts b/apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToAgent.ts similarity index 85% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToAgent.ts index 8316251403f8d..1de4ee226e9b0 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToAgent.ts @@ -1,6 +1,6 @@ import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.afterForwardChatToAgent', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts b/apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToDepartment.ts similarity index 89% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToDepartment.ts index 3bb16a6a033fe..a4b6413d3e772 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterForwardChatToDepartment.ts @@ -1,8 +1,8 @@ import type { ILivechatDepartment, IOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms, LivechatDepartment } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { cbLogger } from '../lib/logger'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; callbacks.add( 'livechat.afterForwardChatToDepartment', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterInquiryQueued.ts b/apps/meteor/ee/server/hooks/omnichannel/afterInquiryQueued.ts similarity index 73% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterInquiryQueued.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterInquiryQueued.ts index e422808d19e6e..bf660edab61fd 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterInquiryQueued.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterInquiryQueued.ts @@ -1,9 +1,9 @@ import type { ILivechatInquiryRecord } from '@rocket.chat/core-typings'; import moment from 'moment'; -import { afterInquiryQueued } from '../../../../../app/livechat/server/lib/hooks'; -import { settings } from '../../../../../app/settings/server'; -import { OmnichannelQueueInactivityMonitor } from '../lib/QueueInactivityMonitor'; +import { afterInquiryQueued } from '../../../../app/livechat/server/lib/hooks'; +import { settings } from '../../../../app/settings/server'; +import { OmnichannelQueueInactivityMonitor } from '../../../app/livechat-enterprise/server/lib/QueueInactivityMonitor'; export const afterInquiryQueuedFunc = async (inquiry: ILivechatInquiryRecord) => { const timer = settings.get('Livechat_max_queue_wait_time'); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts b/apps/meteor/ee/server/hooks/omnichannel/afterOnHold.ts similarity index 74% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterOnHold.ts index 89a28af413420..c808e3527355b 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterOnHold.ts @@ -1,10 +1,10 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { i18n } from '../../../../../server/lib/i18n'; -import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; -import { cbLogger } from '../lib/logger'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { i18n } from '../../../../server/lib/i18n'; +import { AutoCloseOnHoldScheduler } from '../../../app/livechat-enterprise/server/lib/AutoCloseOnHoldScheduler'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; let autoCloseOnHoldChatTimeout = 0; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts b/apps/meteor/ee/server/hooks/omnichannel/afterOnHoldChatResumed.ts similarity index 69% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterOnHoldChatResumed.ts index e114fd89ec435..1688ff91781ba 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterOnHoldChatResumed.ts @@ -1,8 +1,8 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; -import { cbLogger } from '../lib/logger'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { AutoCloseOnHoldScheduler } from '../../../app/livechat-enterprise/server/lib/AutoCloseOnHoldScheduler'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; type IRoom = Pick; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterRemoveDepartment.ts b/apps/meteor/ee/server/hooks/omnichannel/afterRemoveDepartment.ts similarity index 87% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterRemoveDepartment.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterRemoveDepartment.ts index 9e7589ddce7c0..d4841825653f5 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterRemoveDepartment.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterRemoveDepartment.ts @@ -1,8 +1,8 @@ import type { AtLeast, ILivechatAgent, ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatDepartment, LivechatUnit } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { cbLogger } from '../lib/logger'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; const afterRemoveDepartment = async (options: { department: AtLeast; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterReturnRoomAsInquiry.ts b/apps/meteor/ee/server/hooks/omnichannel/afterReturnRoomAsInquiry.ts similarity index 84% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterReturnRoomAsInquiry.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterReturnRoomAsInquiry.ts index 7b64957bbfa00..1514365de0039 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterReturnRoomAsInquiry.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterReturnRoomAsInquiry.ts @@ -1,8 +1,8 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; settings.watch('Livechat_abandoned_rooms_action', (value) => { if (!value || value === 'none') { diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTagRemoved.ts b/apps/meteor/ee/server/hooks/omnichannel/afterTagRemoved.ts similarity index 80% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTagRemoved.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterTagRemoved.ts index cff97b5cfac0b..13c15cae21bf9 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTagRemoved.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterTagRemoved.ts @@ -1,6 +1,6 @@ import { CannedResponse } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.afterTagRemoved', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTakeInquiry.ts b/apps/meteor/ee/server/hooks/omnichannel/afterTakeInquiry.ts similarity index 70% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTakeInquiry.ts rename to apps/meteor/ee/server/hooks/omnichannel/afterTakeInquiry.ts index 7a0d02775e408..14a8bb2175380 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterTakeInquiry.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/afterTakeInquiry.ts @@ -1,13 +1,13 @@ import type { InquiryWithAgentInfo, IOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatVisitors } from '@rocket.chat/models'; -import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager'; -import { afterTakeInquiry } from '../../../../../app/livechat/server/lib/hooks'; -import { settings } from '../../../../../app/settings/server'; -import { AutoTransferChatScheduler } from '../lib/AutoTransferChatScheduler'; -import { debouncedDispatchWaitingQueueStatus } from '../lib/Helper'; -import { OmnichannelQueueInactivityMonitor } from '../lib/QueueInactivityMonitor'; -import { cbLogger } from '../lib/logger'; +import { RoutingManager } from '../../../../app/livechat/server/lib/RoutingManager'; +import { afterTakeInquiry } from '../../../../app/livechat/server/lib/hooks'; +import { settings } from '../../../../app/settings/server'; +import { AutoTransferChatScheduler } from '../../../app/livechat-enterprise/server/lib/AutoTransferChatScheduler'; +import { debouncedDispatchWaitingQueueStatus } from '../../../app/livechat-enterprise/server/lib/Helper'; +import { OmnichannelQueueInactivityMonitor } from '../../../app/livechat-enterprise/server/lib/QueueInactivityMonitor'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; afterTakeInquiry.patch( async ( diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/applyRoomRestrictions.ts b/apps/meteor/ee/server/hooks/omnichannel/applyRoomRestrictions.ts similarity index 75% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/applyRoomRestrictions.ts rename to apps/meteor/ee/server/hooks/omnichannel/applyRoomRestrictions.ts index 92cf49e763402..3f701f37c1af2 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/applyRoomRestrictions.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/applyRoomRestrictions.ts @@ -1,8 +1,8 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import type { FilterOperators } from 'mongodb'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { restrictQuery } from '../lib/restrictQuery'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { restrictQuery } from '../../../app/livechat-enterprise/server/lib/restrictQuery'; callbacks.add( 'livechat.applyRoomRestrictions', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/applySimultaneousChatsRestrictions.ts b/apps/meteor/ee/server/hooks/omnichannel/applySimultaneousChatsRestrictions.ts similarity index 91% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/applySimultaneousChatsRestrictions.ts rename to apps/meteor/ee/server/hooks/omnichannel/applySimultaneousChatsRestrictions.ts index bc8bf4a595ec4..9f6ca9bbd14fc 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/applySimultaneousChatsRestrictions.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/applySimultaneousChatsRestrictions.ts @@ -2,8 +2,8 @@ import type { ILivechatDepartment, AvailableAgentsAggregation } from '@rocket.ch import { LivechatDepartment } from '@rocket.chat/models'; import type { Filter } from 'mongodb'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; export async function getChatLimitsQuery(departmentId?: string): Promise> { const limitFilter: Filter = []; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeForwardRoomToDepartment.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeForwardRoomToDepartment.ts similarity index 95% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeForwardRoomToDepartment.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeForwardRoomToDepartment.ts index 8f0f31b7b1489..7e4d6cf8fcc57 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeForwardRoomToDepartment.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeForwardRoomToDepartment.ts @@ -2,7 +2,7 @@ import type { ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatDepartment } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.beforeForwardRoomToDepartment', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeJoinRoom.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeJoinRoom.ts similarity index 80% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeJoinRoom.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeJoinRoom.ts index 4e6f7b6303d3e..300439849b7c6 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeJoinRoom.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeJoinRoom.ts @@ -2,9 +2,9 @@ import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import type { IUser, IRoom } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { isAgentWithinChatLimits } from '../lib/Helper'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { isAgentWithinChatLimits } from '../../../app/livechat-enterprise/server/lib/Helper'; callbacks.add( 'beforeJoinRoom', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeListTags.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeListTags.ts similarity index 78% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeListTags.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeListTags.ts index f6fbdac43e6ad..9f9029dfa28c5 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeListTags.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeListTags.ts @@ -1,6 +1,6 @@ import { LivechatTag } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.beforeListTags', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewInquiry.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeNewInquiry.ts similarity index 96% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewInquiry.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeNewInquiry.ts index 92a3fe31c591b..f7910755b33d8 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewInquiry.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeNewInquiry.ts @@ -2,7 +2,7 @@ import type { ILivechatInquiryRecord, ILivechatPriority, IOmnichannelServiceLeve import { LivechatPriority, OmnichannelServiceLevelAgreements } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.beforeInquiry', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewRoom.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeNewRoom.ts similarity index 86% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewRoom.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeNewRoom.ts index dd48cd79f0bc8..cefa5b96fa93d 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeNewRoom.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeNewRoom.ts @@ -2,8 +2,8 @@ import type { IOmnichannelRoomInfo, IOmnichannelRoomExtraData, IOmnichannelRoom import { OmnichannelServiceLevelAgreements } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { beforeNewRoom } from '../../../../../app/livechat/server/lib/hooks'; -import { isPlainObject } from '../../../../../lib/utils/isPlainObject'; +import { beforeNewRoom } from '../../../../app/livechat/server/lib/hooks'; +import { isPlainObject } from '../../../../lib/utils/isPlainObject'; export const beforeNewRoomPatched = async ( _next: any, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeRoutingChat.ts b/apps/meteor/ee/server/hooks/omnichannel/beforeRoutingChat.ts similarity index 77% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeRoutingChat.ts rename to apps/meteor/ee/server/hooks/omnichannel/beforeRoutingChat.ts index 53690f0b5279e..6c54f607c8250 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeRoutingChat.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/beforeRoutingChat.ts @@ -1,14 +1,14 @@ import type { ILivechatInquiryRecord, SelectedAgent, ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatDepartment, LivechatInquiry, LivechatRooms } from '@rocket.chat/models'; -import { notifyOnLivechatInquiryChanged, notifyOnRoomChangedById } from '../../../../../app/lib/server/lib/notifyListener'; -import { allowAgentSkipQueue } from '../../../../../app/livechat/server/lib/Helper'; -import { saveQueueInquiry } from '../../../../../app/livechat/server/lib/QueueManager'; -import { setDepartmentForGuest } from '../../../../../app/livechat/server/lib/departmentsLib'; -import { beforeRouteChat } from '../../../../../app/livechat/server/lib/hooks'; -import { online } from '../../../../../app/livechat/server/lib/service-status'; -import { settings } from '../../../../../app/settings/server'; -import { cbLogger } from '../lib/logger'; +import { notifyOnLivechatInquiryChanged, notifyOnRoomChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { allowAgentSkipQueue } from '../../../../app/livechat/server/lib/Helper'; +import { saveQueueInquiry } from '../../../../app/livechat/server/lib/QueueManager'; +import { setDepartmentForGuest } from '../../../../app/livechat/server/lib/departmentsLib'; +import { beforeRouteChat } from '../../../../app/livechat/server/lib/hooks'; +import { online } from '../../../../app/livechat/server/lib/service-status'; +import { settings } from '../../../../app/settings/server'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; beforeRouteChat.patch( async ( diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts b/apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts similarity index 77% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts rename to apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts index 349ad44652bf1..539bcbd03132c 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/checkAgentBeforeTakeInquiry.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts @@ -1,11 +1,11 @@ import { Users } from '@rocket.chat/models'; -import { allowAgentSkipQueue } from '../../../../../app/livechat/server/lib/Helper'; -import { checkOnlineAgents } from '../../../../../app/livechat/server/lib/service-status'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { isAgentWithinChatLimits } from '../lib/Helper'; -import { cbLogger } from '../lib/logger'; +import { allowAgentSkipQueue } from '../../../../app/livechat/server/lib/Helper'; +import { checkOnlineAgents } from '../../../../app/livechat/server/lib/service-status'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { isAgentWithinChatLimits } from '../../../app/livechat-enterprise/server/lib/Helper'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; const validateMaxChats = async ({ agent, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts b/apps/meteor/ee/server/hooks/omnichannel/handleNextAgentPreferredEvents.ts similarity index 88% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts rename to apps/meteor/ee/server/hooks/omnichannel/handleNextAgentPreferredEvents.ts index 054110339c78c..fd934e5ea8d47 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/handleNextAgentPreferredEvents.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/handleNextAgentPreferredEvents.ts @@ -1,12 +1,12 @@ import type { IUser, SelectedAgent } from '@rocket.chat/core-typings'; import { LivechatVisitors, LivechatContacts, LivechatInquiry, LivechatRooms, Users } from '@rocket.chat/models'; -import { notifyOnLivechatInquiryChanged } from '../../../../../app/lib/server/lib/notifyListener'; -import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager'; -import { migrateVisitorIfMissingContact } from '../../../../../app/livechat/server/lib/contacts/migrateVisitorIfMissingContact'; -import { checkDefaultAgentOnNewRoom } from '../../../../../app/livechat/server/lib/hooks'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { notifyOnLivechatInquiryChanged } from '../../../../app/lib/server/lib/notifyListener'; +import { RoutingManager } from '../../../../app/livechat/server/lib/RoutingManager'; +import { migrateVisitorIfMissingContact } from '../../../../app/livechat/server/lib/contacts/migrateVisitorIfMissingContact'; +import { checkDefaultAgentOnNewRoom } from '../../../../app/livechat/server/lib/hooks'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; const normalizeDefaultAgent = (agent?: Pick | null): SelectedAgent | undefined => { if (!agent) { diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts b/apps/meteor/ee/server/hooks/omnichannel/index.ts similarity index 100% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts rename to apps/meteor/ee/server/hooks/omnichannel/index.ts diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts b/apps/meteor/ee/server/hooks/omnichannel/manageDepartmentUnit.ts similarity index 93% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts rename to apps/meteor/ee/server/hooks/omnichannel/manageDepartmentUnit.ts index 365b183691ae0..417da726593fd 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/manageDepartmentUnit.ts @@ -2,8 +2,8 @@ import type { ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatDepartment, LivechatUnit } from '@rocket.chat/models'; import { getUnitsFromUser } from '@rocket.chat/omni-core-ee'; -import { hasAnyRoleAsync } from '../../../../../server/lib/authorization/hasRole'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { hasAnyRoleAsync } from '../../../../server/lib/authorization/hasRole'; +import { callbacks } from '../../../../server/lib/callbacks'; export const manageDepartmentUnit = async ({ userId, departmentId, unitId }: { userId: string; departmentId: string; unitId: string }) => { const accessibleUnits = await getUnitsFromUser(userId); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onAgentAssignmentFailed.ts b/apps/meteor/ee/server/hooks/omnichannel/onAgentAssignmentFailed.ts similarity index 88% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onAgentAssignmentFailed.ts rename to apps/meteor/ee/server/hooks/omnichannel/onAgentAssignmentFailed.ts index c2be90593b852..64af8d2071f98 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onAgentAssignmentFailed.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onAgentAssignmentFailed.ts @@ -1,7 +1,7 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; const handleOnAgentAssignmentFailed = async ( room: IOmnichannelRoom, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onBusinessHourStart.ts b/apps/meteor/ee/server/hooks/omnichannel/onBusinessHourStart.ts similarity index 68% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onBusinessHourStart.ts rename to apps/meteor/ee/server/hooks/omnichannel/onBusinessHourStart.ts index 3dcdc77f7da45..88be598051080 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onBusinessHourStart.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onBusinessHourStart.ts @@ -1,8 +1,8 @@ import { LivechatBusinessHourBehaviors } from '@rocket.chat/core-typings'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { MultipleBusinessHoursBehavior } from '../business-hour/Multiple'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { MultipleBusinessHoursBehavior } from '../../../app/livechat-enterprise/server/business-hour/Multiple'; callbacks.add( 'on-business-hour-start', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCheckRoomParamsApi.ts b/apps/meteor/ee/server/hooks/omnichannel/onCheckRoomParamsApi.ts similarity index 63% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onCheckRoomParamsApi.ts rename to apps/meteor/ee/server/hooks/omnichannel/onCheckRoomParamsApi.ts index 92f75dc8a7d72..300a5a4a049aa 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCheckRoomParamsApi.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onCheckRoomParamsApi.ts @@ -1,5 +1,5 @@ import { Match } from 'meteor/check'; -import { onCheckRoomParams } from '../../../../../server/api/v1/omnichannel/lib/livechat'; +import { onCheckRoomParams } from '../../../../server/api/v1/omnichannel/lib/livechat'; onCheckRoomParams.patch((_: any, params) => ({ ...params, sla: Match.Maybe(String), priority: Match.Maybe(String) })); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts b/apps/meteor/ee/server/hooks/omnichannel/onCloseLivechat.ts similarity index 72% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts rename to apps/meteor/ee/server/hooks/omnichannel/onCloseLivechat.ts index ada48cd8701d4..b1466ef572cef 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onCloseLivechat.ts @@ -1,10 +1,10 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; -import { debouncedDispatchWaitingQueueStatus } from '../lib/Helper'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { AutoCloseOnHoldScheduler } from '../../../app/livechat-enterprise/server/lib/AutoCloseOnHoldScheduler'; +import { debouncedDispatchWaitingQueueStatus } from '../../../app/livechat-enterprise/server/lib/Helper'; type LivechatCloseCallbackParams = { room: IOmnichannelRoom; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts b/apps/meteor/ee/server/hooks/omnichannel/onLoadConfigApi.ts similarity index 84% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts rename to apps/meteor/ee/server/hooks/omnichannel/onLoadConfigApi.ts index bbd9f9a089938..56fe5ff110168 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onLoadConfigApi.ts @@ -1,7 +1,7 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; -import { getExtraConfigInfo } from '../../../../../server/api/v1/omnichannel/lib/livechat'; -import { getLivechatQueueInfo, getLivechatCustomFields } from '../lib/Helper'; +import { getExtraConfigInfo } from '../../../../server/api/v1/omnichannel/lib/livechat'; +import { getLivechatQueueInfo, getLivechatCustomFields } from '../../../app/livechat-enterprise/server/lib/Helper'; getExtraConfigInfo.patch( async ( diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.ts b/apps/meteor/ee/server/hooks/omnichannel/onLoadForwardDepartmentRestrictions.ts similarity index 92% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.ts rename to apps/meteor/ee/server/hooks/omnichannel/onLoadForwardDepartmentRestrictions.ts index 167ee89ec50e7..fa4f5fdb85d4e 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onLoadForwardDepartmentRestrictions.ts @@ -1,7 +1,7 @@ import type { ILivechatDepartment } from '@rocket.chat/core-typings'; import { LivechatDepartment } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; +import { callbacks } from '../../../../server/lib/callbacks'; callbacks.add( 'livechat.onLoadForwardDepartmentRestrictions', diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onSaveVisitorInfo.ts b/apps/meteor/ee/server/hooks/omnichannel/onSaveVisitorInfo.ts similarity index 89% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onSaveVisitorInfo.ts rename to apps/meteor/ee/server/hooks/omnichannel/onSaveVisitorInfo.ts index e435e1fc505c0..b89755c69dff6 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onSaveVisitorInfo.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onSaveVisitorInfo.ts @@ -1,9 +1,9 @@ import type { IOmnichannelRoom, IOmnichannelServiceLevelAgreements, IUser } from '@rocket.chat/core-typings'; import { OmnichannelServiceLevelAgreements } from '@rocket.chat/models'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { removePriorityFromRoom, updateRoomPriority } from '../../../../server/api/v1/omnichannel/lib/priorities'; -import { removeRoomSLA, updateRoomSLA } from '../../../../server/api/v1/omnichannel/lib/sla'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { removePriorityFromRoom, updateRoomPriority } from '../../api/v1/omnichannel/lib/priorities'; +import { removeRoomSLA, updateRoomSLA } from '../../api/v1/omnichannel/lib/sla'; const updateSLA = async (room: IOmnichannelRoom, user: Required>, slaId?: string) => { if (!slaId) { diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onTransferFailure.ts b/apps/meteor/ee/server/hooks/omnichannel/onTransferFailure.ts similarity index 87% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/onTransferFailure.ts rename to apps/meteor/ee/server/hooks/omnichannel/onTransferFailure.ts index 17fc7e6503c4a..1d6a546780ad5 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onTransferFailure.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/onTransferFailure.ts @@ -2,10 +2,10 @@ import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import type { IRoom, ILivechatVisitor, ILivechatDepartment, TransferData, AtLeast } from '@rocket.chat/core-typings'; import { LivechatDepartment } from '@rocket.chat/models'; -import { forwardRoomToDepartment } from '../../../../../app/livechat/server/lib/Helper'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { cbLogger } from '../lib/logger'; +import { forwardRoomToDepartment } from '../../../../app/livechat/server/lib/Helper'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { cbLogger } from '../../../app/livechat-enterprise/server/lib/logger'; const onTransferFailure = async ( room: IRoom, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts b/apps/meteor/ee/server/hooks/omnichannel/resumeOnHold.ts similarity index 92% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts rename to apps/meteor/ee/server/hooks/omnichannel/resumeOnHold.ts index b35b9e8acce5f..227051b139626 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/resumeOnHold.ts @@ -3,9 +3,9 @@ import type { ILivechatVisitor, IMessage, IOmnichannelRoom, IUser } from '@rocke import { isMessageFromVisitor, isEditedMessage } from '@rocket.chat/core-typings'; import { LivechatRooms, LivechatVisitors, Users } from '@rocket.chat/models'; -import { callbackLogger } from '../../../../../app/livechat/server/lib/logger'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { i18n } from '../../../../../server/lib/i18n'; +import { callbackLogger } from '../../../../app/livechat/server/lib/logger'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { i18n } from '../../../../server/lib/i18n'; const resumeOnHoldCommentAndUser = async (room: IOmnichannelRoom): Promise<{ comment: string; resumedBy: IUser }> => { const { diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/scheduleAutoTransfer.ts b/apps/meteor/ee/server/hooks/omnichannel/scheduleAutoTransfer.ts similarity index 85% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/scheduleAutoTransfer.ts rename to apps/meteor/ee/server/hooks/omnichannel/scheduleAutoTransfer.ts index 3e6efc71e330f..08f27130f62f4 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/scheduleAutoTransfer.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/scheduleAutoTransfer.ts @@ -1,9 +1,9 @@ import type { IMessage, IOmnichannelRoom } from '@rocket.chat/core-typings'; -import type { CloseRoomParams } from '../../../../../app/livechat/server/lib/localTypes'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { AutoTransferChatScheduler } from '../lib/AutoTransferChatScheduler'; +import type { CloseRoomParams } from '../../../../app/livechat/server/lib/localTypes'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { AutoTransferChatScheduler } from '../../../app/livechat-enterprise/server/lib/AutoTransferChatScheduler'; type LivechatCloseCallbackParams = { room: IOmnichannelRoom; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/sendPdfTranscriptOnClose.ts b/apps/meteor/ee/server/hooks/omnichannel/sendPdfTranscriptOnClose.ts similarity index 75% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/sendPdfTranscriptOnClose.ts rename to apps/meteor/ee/server/hooks/omnichannel/sendPdfTranscriptOnClose.ts index 9a043d59133da..67f5a1fa4c610 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/sendPdfTranscriptOnClose.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/sendPdfTranscriptOnClose.ts @@ -1,9 +1,9 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import { isOmnichannelRoom } from '@rocket.chat/core-typings'; -import type { CloseRoomParams } from '../../../../../app/livechat/server/lib/localTypes'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { requestPdfTranscript } from '../lib/requestPdfTranscript'; +import type { CloseRoomParams } from '../../../../app/livechat/server/lib/localTypes'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { requestPdfTranscript } from '../../../app/livechat-enterprise/server/lib/requestPdfTranscript'; type LivechatCloseCallbackParams = { room: IOmnichannelRoom; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/setPredictedVisitorAbandonmentTime.ts b/apps/meteor/ee/server/hooks/omnichannel/setPredictedVisitorAbandonmentTime.ts similarity index 79% rename from apps/meteor/ee/app/livechat-enterprise/server/hooks/setPredictedVisitorAbandonmentTime.ts rename to apps/meteor/ee/server/hooks/omnichannel/setPredictedVisitorAbandonmentTime.ts index 93ee3a28bb2fb..82eff84bb042a 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/setPredictedVisitorAbandonmentTime.ts +++ b/apps/meteor/ee/server/hooks/omnichannel/setPredictedVisitorAbandonmentTime.ts @@ -2,10 +2,10 @@ import type { IMessage } from '@rocket.chat/core-typings'; import { isEditedMessage, isMessageFromVisitor } from '@rocket.chat/core-typings'; import moment from 'moment'; -import { markRoomResponded } from '../../../../../app/livechat/server/hooks/markRoomResponded'; -import { settings } from '../../../../../app/settings/server'; -import { callbacks } from '../../../../../server/lib/callbacks'; -import { setPredictedVisitorAbandonmentTime } from '../lib/Helper'; +import { settings } from '../../../../app/settings/server'; +import { markRoomResponded } from '../../../../server/hooks/omnichannel/markRoomResponded'; +import { callbacks } from '../../../../server/lib/callbacks'; +import { setPredictedVisitorAbandonmentTime } from '../../../app/livechat-enterprise/server/lib/Helper'; function shouldSaveInactivity(message: IMessage): boolean { if (message.t || isEditedMessage(message) || isMessageFromVisitor(message)) { diff --git a/apps/meteor/ee/server/index.ts b/apps/meteor/ee/server/index.ts index e6b0cd350d530..db95640b08d83 100644 --- a/apps/meteor/ee/server/index.ts +++ b/apps/meteor/ee/server/index.ts @@ -1,10 +1,10 @@ import './models/startup'; -import '../app/license/server'; +import './lib/license/settings'; +import './meteor-methods/license'; import './api/v1/canned-responses'; -import '../app/authorization/server/index'; -import '../app/canned-responses/server/index'; +import './lib/canned-responses'; import '../app/livechat-enterprise/server/index'; -import '../app/message-read-receipt/server/index'; +import './lib/message-read-receipt'; import './api'; import '../app/settings/server/index'; import './requestSeatsRoute'; diff --git a/apps/meteor/ee/server/lib/audit/methods.ts b/apps/meteor/ee/server/lib/audit/methods.ts index e76ba1005004e..3073002120f4d 100644 --- a/apps/meteor/ee/server/lib/audit/methods.ts +++ b/apps/meteor/ee/server/lib/audit/methods.ts @@ -8,10 +8,10 @@ import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Meteor } from 'meteor/meteor'; import type { Filter } from 'mongodb'; -import { updateCounter } from '../../../../app/statistics/server'; import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; import { callbacks } from '../../../../server/lib/callbacks'; import { i18n } from '../../../../server/lib/i18n'; +import { updateCounter } from '../../../../server/lib/statistics'; const getValue = (room: IRoom | null) => room && { rids: [room._id], name: room.name }; diff --git a/apps/meteor/ee/server/lib/canned-responses/index.ts b/apps/meteor/ee/server/lib/canned-responses/index.ts new file mode 100644 index 0000000000000..bd224850372b9 --- /dev/null +++ b/apps/meteor/ee/server/lib/canned-responses/index.ts @@ -0,0 +1,13 @@ +import { License } from '@rocket.chat/license'; + +await License.onLicense('canned-responses', async () => { + const { createSettings } = await import('./settings'); + await import('./permissions'); + await import('../../hooks/canned-responses/onRemoveAgentDepartment'); + await import('../../hooks/canned-responses/onSaveAgentDepartment'); + await import('../../hooks/canned-responses/cannedResponses'); + await import('../../meteor-methods/saveCannedResponse'); + await import('../../meteor-methods/removeCannedResponse'); + + await createSettings(); +}); diff --git a/apps/meteor/ee/app/canned-responses/server/permissions.ts b/apps/meteor/ee/server/lib/canned-responses/permissions.ts similarity index 100% rename from apps/meteor/ee/app/canned-responses/server/permissions.ts rename to apps/meteor/ee/server/lib/canned-responses/permissions.ts diff --git a/apps/meteor/ee/app/canned-responses/server/settings.ts b/apps/meteor/ee/server/lib/canned-responses/settings.ts similarity index 100% rename from apps/meteor/ee/app/canned-responses/server/settings.ts rename to apps/meteor/ee/server/lib/canned-responses/settings.ts diff --git a/apps/meteor/ee/server/lib/deviceManagement/session.ts b/apps/meteor/ee/server/lib/deviceManagement/session.ts index a613fbb0a11d0..564be1b8ef90e 100644 --- a/apps/meteor/ee/server/lib/deviceManagement/session.ts +++ b/apps/meteor/ee/server/lib/deviceManagement/session.ts @@ -5,11 +5,11 @@ import { Meteor } from 'meteor/meteor'; import moment from 'moment'; import { UAParser } from 'ua-parser-js'; -import * as Mailer from '../../../../app/mailer/server/api'; import { settings } from '../../../../app/settings/server'; -import { UAParserDesktop, UAParserMobile } from '../../../../app/statistics/server/lib/UAParserCustom'; import { t } from '../../../../app/utils/lib/i18n'; import { getUserPreference } from '../../../../app/utils/server/lib/getUserPreference'; +import * as Mailer from '../../../../server/lib/notifications/email/api'; +import { UAParserDesktop, UAParserMobile } from '../../../../server/lib/statistics/lib/UAParserCustom'; import { deviceManagementEvents } from '../../../../server/services/device-management/events'; let mailTemplates: string; diff --git a/apps/meteor/ee/server/lib/ldap/Manager.spec.ts b/apps/meteor/ee/server/lib/ldap/Manager.spec.ts index 692a74dee3fe8..3ebff2f9858e7 100644 --- a/apps/meteor/ee/server/lib/ldap/Manager.spec.ts +++ b/apps/meteor/ee/server/lib/ldap/Manager.spec.ts @@ -14,7 +14,7 @@ const { LDAPEEManager } = proxyquire.noCallThru().load('./Manager', { '@rocket.chat/core-services': { Abac: {}, Team: {} }, '@rocket.chat/license': { License: { hasModule: () => false } }, '@rocket.chat/models': { Users: {}, Roles: {}, Subscriptions: subscriptionsStub, Rooms: roomsStub }, - '../../../../app/importer/server/definitions/IConversionCallbacks': {}, + '../../../../server/lib/import/definitions/IConversionCallbacks': {}, '../../../../app/settings/server': { settings: settingsStub }, '../../../../app/utils/server/lib/getValidRoomName': { getValidRoomName: (name: string) => Promise.resolve(name) }, '../../../../lib/utils/arrayUtils': { ensureArray: (value: unknown) => (Array.isArray(value) ? value : [value]) }, diff --git a/apps/meteor/ee/server/lib/ldap/Manager.ts b/apps/meteor/ee/server/lib/ldap/Manager.ts index d25b15c78baf3..c78eba154c57b 100644 --- a/apps/meteor/ee/server/lib/ldap/Manager.ts +++ b/apps/meteor/ee/server/lib/ldap/Manager.ts @@ -6,13 +6,13 @@ import type ldapjs from 'ldapjs'; import type { FindCursor } from 'mongodb'; import { copyCustomFieldsLDAP } from './copyCustomFieldsLDAP'; -import type { - ImporterAfterImportCallback, - ImporterBeforeImportCallback, -} from '../../../../app/importer/server/definitions/IConversionCallbacks'; import { settings } from '../../../../app/settings/server'; import { getValidRoomName } from '../../../../app/utils/server/lib/getValidRoomName'; import { ensureArray } from '../../../../lib/utils/arrayUtils'; +import type { + ImporterAfterImportCallback, + ImporterBeforeImportCallback, +} from '../../../../server/lib/import/definitions/IConversionCallbacks'; import { LDAPConnection } from '../../../../server/lib/ldap/Connection'; import { logger, searchLogger, mapLogger } from '../../../../server/lib/ldap/Logger'; import { LDAPManager } from '../../../../server/lib/ldap/Manager'; diff --git a/apps/meteor/ee/app/license/server/airGappedRestrictions.ts b/apps/meteor/ee/server/lib/license/airGappedRestrictions.ts similarity index 100% rename from apps/meteor/ee/app/license/server/airGappedRestrictions.ts rename to apps/meteor/ee/server/lib/license/airGappedRestrictions.ts diff --git a/apps/meteor/ee/app/license/server/canEnableApp.ts b/apps/meteor/ee/server/lib/license/canEnableApp.ts similarity index 100% rename from apps/meteor/ee/app/license/server/canEnableApp.ts rename to apps/meteor/ee/server/lib/license/canEnableApp.ts diff --git a/apps/meteor/ee/app/license/server/getSeatsRequestLink.ts b/apps/meteor/ee/server/lib/license/getSeatsRequestLink.ts similarity index 100% rename from apps/meteor/ee/app/license/server/getSeatsRequestLink.ts rename to apps/meteor/ee/server/lib/license/getSeatsRequestLink.ts diff --git a/apps/meteor/ee/app/license/server/lib/getAppCount.ts b/apps/meteor/ee/server/lib/license/lib/getAppCount.ts similarity index 100% rename from apps/meteor/ee/app/license/server/lib/getAppCount.ts rename to apps/meteor/ee/server/lib/license/lib/getAppCount.ts diff --git a/apps/meteor/ee/app/license/server/license.internalService.ts b/apps/meteor/ee/server/lib/license/license.internalService.ts similarity index 88% rename from apps/meteor/ee/app/license/server/license.internalService.ts rename to apps/meteor/ee/server/lib/license/license.internalService.ts index c38c4ecfe26f3..6600353afee2d 100644 --- a/apps/meteor/ee/app/license/server/license.internalService.ts +++ b/apps/meteor/ee/server/lib/license/license.internalService.ts @@ -3,8 +3,8 @@ import { api, ServiceClassInternal } from '@rocket.chat/core-services'; import type { LicenseModule } from '@rocket.chat/core-typings'; import { License } from '@rocket.chat/license'; -import { resetEnterprisePermissions } from '../../../server/lib/authorization/resetEnterprisePermissions'; -import { guestPermissions } from '../../authorization/lib/guestPermissions'; +import { guestPermissions } from '../../../app/authorization/lib/guestPermissions'; +import { resetEnterprisePermissions } from '../authorization/resetEnterprisePermissions'; export class LicenseService extends ServiceClassInternal implements ILicense { protected name = 'license'; diff --git a/apps/meteor/ee/app/license/server/settings.ts b/apps/meteor/ee/server/lib/license/settings.ts similarity index 100% rename from apps/meteor/ee/app/license/server/settings.ts rename to apps/meteor/ee/server/lib/license/settings.ts diff --git a/apps/meteor/ee/app/license/server/startup.ts b/apps/meteor/ee/server/lib/license/startup.ts similarity index 100% rename from apps/meteor/ee/app/license/server/startup.ts rename to apps/meteor/ee/server/lib/license/startup.ts diff --git a/apps/meteor/ee/server/lib/message-read-receipt/index.ts b/apps/meteor/ee/server/lib/message-read-receipt/index.ts new file mode 100644 index 0000000000000..f89fb1c91cf09 --- /dev/null +++ b/apps/meteor/ee/server/lib/message-read-receipt/index.ts @@ -0,0 +1,7 @@ +import { License } from '@rocket.chat/license'; + +await License.onLicense('message-read-receipt', async () => { + await import('../../hooks/messages/afterReadMessages'); + await import('../../hooks/messages/afterSaveMessage'); + await import('../../hooks/messages/afterDeleteRoom'); +}); diff --git a/apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts b/apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts index 1acd19c291ea1..b83c2963433d1 100644 --- a/apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts +++ b/apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts @@ -2,8 +2,8 @@ import { CannedResponse } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import notifications from '../../../app/notifications/server/lib/Notifications'; import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; +import notifications from '../../../server/lib/notifications/core/lib/Notifications'; export const removeCannedResponse = async (uid: string, _id: string): Promise => { if (!(await hasPermissionAsync(uid, 'remove-canned-responses'))) { diff --git a/apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts b/apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts index 4f26b9bf6740f..9f5b87a88ee5b 100644 --- a/apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts +++ b/apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts @@ -3,8 +3,8 @@ import { LivechatDepartment, CannedResponse, Users } from '@rocket.chat/models'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import notifications from '../../../app/notifications/server/lib/Notifications'; import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; +import notifications from '../../../server/lib/notifications/core/lib/Notifications'; type ResponseData = { shortcut: string; diff --git a/apps/meteor/ee/server/patches/airGappedRestrictionsWrapper.ts b/apps/meteor/ee/server/patches/airGappedRestrictionsWrapper.ts index dabafe87c9fca..172b43cb6c91d 100644 --- a/apps/meteor/ee/server/patches/airGappedRestrictionsWrapper.ts +++ b/apps/meteor/ee/server/patches/airGappedRestrictionsWrapper.ts @@ -1,6 +1,6 @@ import { AirGappedRestriction } from '@rocket.chat/license'; -import { applyAirGappedRestrictionsValidation } from '../../../app/license/server/airGappedRestrictionsWrapper'; +import { applyAirGappedRestrictionsValidation } from '../../../server/lib/cloud/license/airGappedRestrictionsWrapper'; applyAirGappedRestrictionsValidation.patch(async (_: any, fn: () => Promise): Promise => { if (AirGappedRestriction.restricted) { diff --git a/apps/meteor/ee/server/requestSeatsRoute.ts b/apps/meteor/ee/server/requestSeatsRoute.ts index ffb610b55f02b..84c18284f3767 100644 --- a/apps/meteor/ee/server/requestSeatsRoute.ts +++ b/apps/meteor/ee/server/requestSeatsRoute.ts @@ -2,9 +2,9 @@ import { Analytics } from '@rocket.chat/core-services'; import express, { type Request } from 'express'; import { WebApp } from 'meteor/webapp'; +import { getSeatsRequestLink } from './lib/license/getSeatsRequestLink'; import { authenticationMiddleware, hasPermissionMiddleware } from '../../server/api/v1/middlewares/authentication'; import { getCheckoutUrl, fallback } from '../../server/lib/cloud/getCheckoutUrl'; -import { getSeatsRequestLink } from '../app/license/server/getSeatsRequestLink'; const apiServer = express(); diff --git a/apps/meteor/ee/server/settings/saml.ts b/apps/meteor/ee/server/settings/saml.ts index 50cb499af07fd..03132c5f93835 100644 --- a/apps/meteor/ee/server/settings/saml.ts +++ b/apps/meteor/ee/server/settings/saml.ts @@ -1,3 +1,4 @@ +import { settingsRegistry } from '../../../app/settings/server'; import { defaultAuthnContextTemplate, defaultAuthRequestTemplate, @@ -8,8 +9,7 @@ import { defaultAuthnContext, defaultMetadataTemplate, defaultMetadataCertificateTemplate, -} from '../../../app/meteor-accounts-saml/server/lib/constants'; -import { settingsRegistry } from '../../../app/settings/server'; +} from '../../../server/lib/saml/lib/constants'; export const addSettings = async function (name: string): Promise { await settingsRegistry.addGroup('SAML', async function () { diff --git a/apps/meteor/ee/server/startup/index.ts b/apps/meteor/ee/server/startup/index.ts index 8aaadc847ffe8..c34d8a16fcc71 100644 --- a/apps/meteor/ee/server/startup/index.ts +++ b/apps/meteor/ee/server/startup/index.ts @@ -1,4 +1,4 @@ -import '../../app/authorization/server'; +import '../hooks/auth/callback'; import './audit'; import './deviceManagement'; import './engagementDashboard'; diff --git a/apps/meteor/ee/server/startup/services.ts b/apps/meteor/ee/server/startup/services.ts index e7790810271b7..67ed7eebfaf9d 100644 --- a/apps/meteor/ee/server/startup/services.ts +++ b/apps/meteor/ee/server/startup/services.ts @@ -2,9 +2,9 @@ import { AbacService } from '@rocket.chat/abac'; import { api } from '@rocket.chat/core-services'; import { isRunningMs } from '../../../server/lib/isRunningMs'; -import { LicenseService } from '../../app/license/server/license.internalService'; import { OmnichannelEE } from '../../app/livechat-enterprise/server/services/omnichannel.internalService'; import { EnterpriseSettings } from '../../app/settings/server/settings.internalService'; +import { LicenseService } from '../lib/license/license.internalService'; import { InstanceService } from '../local-services/instance/service'; import { LDAPEEService } from '../local-services/ldap/service'; import { MessageReadsService } from '../local-services/message-reads/service'; diff --git a/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airGappedRestrictionsWrapper.spec.ts b/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airGappedRestrictionsWrapper.spec.ts index 982efe01158e3..880106c1c0e44 100644 --- a/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airGappedRestrictionsWrapper.spec.ts +++ b/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airGappedRestrictionsWrapper.spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import proxyquire from 'proxyquire'; import sinon from 'sinon'; -import { applyAirGappedRestrictionsValidation } from '../../../../../app/license/server/airGappedRestrictionsWrapper'; +import { applyAirGappedRestrictionsValidation } from '../../../../../server/lib/cloud/license/airGappedRestrictionsWrapper'; let restrictionFlag = true; @@ -16,7 +16,7 @@ proxyquire.noCallThru().load('../../../../server/patches/airGappedRestrictionsWr '@rocket.chat/license': { AirGappedRestriction: airgappedModule, }, - '../../../app/license/server/airGappedRestrictionsWrapper': { + '../../../server/lib/cloud/license/airGappedRestrictionsWrapper': { applyAirGappedRestrictionsValidation, }, }); diff --git a/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airgappedRestrictions.spec.ts b/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airgappedRestrictions.spec.ts index 66b812910a89f..ff222daafc6c7 100644 --- a/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airgappedRestrictions.spec.ts +++ b/apps/meteor/ee/tests/unit/server/airgappedRestrictions/airgappedRestrictions.spec.ts @@ -47,7 +47,7 @@ registerModel('IServerEventsModel', { createAuditServerEvent: () => undefined, } as any); -proxyquire.noCallThru().load('../../../../app/license/server/airGappedRestrictions.ts', { +proxyquire.noCallThru().load('../../../../server/lib/license/airGappedRestrictions.ts', { '@rocket.chat/license': { AirGappedRestriction: airgappedRestrictionObj, License: licenseMock, diff --git a/apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/afterInquiryQueued.spec.ts b/apps/meteor/ee/tests/unit/server/hooks/omnichannel/afterInquiryQueued.spec.ts similarity index 91% rename from apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/afterInquiryQueued.spec.ts rename to apps/meteor/ee/tests/unit/server/hooks/omnichannel/afterInquiryQueued.spec.ts index 192038229bc69..a65a07962ec87 100644 --- a/apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/afterInquiryQueued.spec.ts +++ b/apps/meteor/ee/tests/unit/server/hooks/omnichannel/afterInquiryQueued.spec.ts @@ -15,14 +15,14 @@ const queueMonitorStub = { const { afterInquiryQueuedFunc: afterInquiryQueued } = proxyquire .noCallThru() - .load('../../../../../../app/livechat-enterprise/server/hooks/afterInquiryQueued.ts', { - '../../../../../app/settings/server': { + .load('../../../../../server/hooks/omnichannel/afterInquiryQueued.ts', { + '../../../../app/settings/server': { settings: settingStub, }, - '../lib/QueueInactivityMonitor': { + '../../../app/livechat-enterprise/server/lib/QueueInactivityMonitor': { OmnichannelQueueInactivityMonitor: queueMonitorStub, }, - '../../../../../app/livechat/server/lib/hooks': { + '../../../../app/livechat/server/lib/hooks': { afterInquiryQueued: { patch: sinon.stub() }, }, }); diff --git a/apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/manageDepartmentUnit.spec.ts b/apps/meteor/ee/tests/unit/server/hooks/omnichannel/manageDepartmentUnit.spec.ts similarity index 95% rename from apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/manageDepartmentUnit.spec.ts rename to apps/meteor/ee/tests/unit/server/hooks/omnichannel/manageDepartmentUnit.spec.ts index e925b640fc671..5a35992a55ba4 100644 --- a/apps/meteor/ee/tests/unit/apps/livechat-enterprise/server/hooks/manageDepartmentUnit.spec.ts +++ b/apps/meteor/ee/tests/unit/server/hooks/omnichannel/manageDepartmentUnit.spec.ts @@ -18,20 +18,18 @@ const livechatUnitStub = { const hasAnyRoleStub = sinon.stub(); const getUnitsFromUserStub = sinon.stub(); -const { manageDepartmentUnit } = proxyquire - .noCallThru() - .load('../../../../../../app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts', { - '@rocket.chat/omni-core-ee': { - getUnitsFromUser: getUnitsFromUserStub, - }, - '../../../../../server/lib/authorization/hasRole': { - hasAnyRoleAsync: hasAnyRoleStub, - }, - '@rocket.chat/models': { - LivechatDepartment: livechatDepartmentStub, - LivechatUnit: livechatUnitStub, - }, - }); +const { manageDepartmentUnit } = proxyquire.noCallThru().load('../../../../../server/hooks/omnichannel/manageDepartmentUnit.ts', { + '@rocket.chat/omni-core-ee': { + getUnitsFromUser: getUnitsFromUserStub, + }, + '../../../../server/lib/authorization/hasRole': { + hasAnyRoleAsync: hasAnyRoleStub, + }, + '@rocket.chat/models': { + LivechatDepartment: livechatDepartmentStub, + LivechatUnit: livechatUnitStub, + }, +}); describe('hooks/manageDepartmentUnit', () => { beforeEach(() => { diff --git a/apps/meteor/imports/personal-access-tokens/server/api/methods/generateToken.ts b/apps/meteor/imports/personal-access-tokens/server/api/methods/generateToken.ts index 18880c5cd58fe..a3655adceec3d 100644 --- a/apps/meteor/imports/personal-access-tokens/server/api/methods/generateToken.ts +++ b/apps/meteor/imports/personal-access-tokens/server/api/methods/generateToken.ts @@ -5,7 +5,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { hasPermissionAsync } from '../../../../../server/lib/authorization/hasPermission'; -import { twoFactorRequired } from '../../../../../app/2fa/server/twoFactorRequired'; +import { twoFactorRequired } from '../../../../../server/lib/2fa/twoFactorRequired'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { diff --git a/apps/meteor/imports/personal-access-tokens/server/api/methods/regenerateToken.ts b/apps/meteor/imports/personal-access-tokens/server/api/methods/regenerateToken.ts index c6a9df5745ef0..4862b45f91279 100644 --- a/apps/meteor/imports/personal-access-tokens/server/api/methods/regenerateToken.ts +++ b/apps/meteor/imports/personal-access-tokens/server/api/methods/regenerateToken.ts @@ -4,7 +4,7 @@ import { Users } from '@rocket.chat/models'; import { isPersonalAccessToken } from '@rocket.chat/core-typings'; import { hasPermissionAsync } from '../../../../../server/lib/authorization/hasPermission'; -import { twoFactorRequired } from '../../../../../app/2fa/server/twoFactorRequired'; +import { twoFactorRequired } from '../../../../../server/lib/2fa/twoFactorRequired'; import { removePersonalAccessTokenOfUser } from './removeToken'; import { generatePersonalAccessTokenOfUser } from './generateToken'; declare module '@rocket.chat/ddp-client' { diff --git a/apps/meteor/imports/personal-access-tokens/server/api/methods/removeToken.ts b/apps/meteor/imports/personal-access-tokens/server/api/methods/removeToken.ts index 9f1ab6f1c32c7..302344cf0604f 100644 --- a/apps/meteor/imports/personal-access-tokens/server/api/methods/removeToken.ts +++ b/apps/meteor/imports/personal-access-tokens/server/api/methods/removeToken.ts @@ -3,7 +3,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { hasPermissionAsync } from '../../../../../server/lib/authorization/hasPermission'; -import { twoFactorRequired } from '../../../../../app/2fa/server/twoFactorRequired'; +import { twoFactorRequired } from '../../../../../server/lib/2fa/twoFactorRequired'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { diff --git a/apps/meteor/jest.config.ts b/apps/meteor/jest.config.ts index 2af5ffbb8286e..dc25c7e5d01bd 100644 --- a/apps/meteor/jest.config.ts +++ b/apps/meteor/jest.config.ts @@ -37,7 +37,7 @@ export default { '/app/livechat/server/business-hour/**/*.spec.ts?(x)', '/app/livechat/server/api/**/*.spec.ts', '/ee/server/lib/authorization/validateUserRoles.spec.ts', - '/ee/app/license/server/**/*.spec.ts', + '/ee/server/lib/license/**/*.spec.ts', '/ee/server/patches/**/*.spec.ts', '/ee/server/cron/**/*.spec.ts', '/server/lib/cloud/supportedVersionsToken/**.spec.ts', @@ -52,9 +52,9 @@ export default { '/server/api/*.spec.ts', '/server/api/lib/getUserInfo.spec.ts', '/server/api/v1/middlewares/*.spec.ts', - '/app/version-check/server/**/*.spec.ts', + '/server/lib/cloud/version-check/**/*.spec.ts', '/app/apple/lib/**.spec.ts', - '/app/apple/server/**.spec.ts', + '/server/lib/auth-providers/apple/**.spec.ts', ], coveragePathIgnorePatterns: ['/node_modules/'], }, diff --git a/apps/meteor/scripts/migration/check-broken-imports.mjs b/apps/meteor/scripts/migration/check-broken-imports.mjs new file mode 100644 index 0000000000000..33b09c4f96827 --- /dev/null +++ b/apps/meteor/scripts/migration/check-broken-imports.mjs @@ -0,0 +1,72 @@ +#!/usr/bin/env node + +/** + * Disposable migration helper: finds relative imports that do not resolve to a + * file on disk. Catches the directories ESLint ignores (its known blind spot + * during this migration — see MIGRATION_PLAN.md). + */ + +import fs from 'node:fs'; +import path from 'node:path'; + +const ROOT = path.resolve(import.meta.dirname, '../..'); +const dirs = process.argv.slice(2).length + ? process.argv.slice(2) + : ['app', 'server', 'ee', 'lib', 'imports', 'client', 'definition', 'tests']; + +const IMPORT_RE = /(?:from\s+|import\s+|(?:import|require)\s*\(\s*)(['"])(\.[^'"]+)\1/g; +const EXT = ['.ts', '.tsx', '.js', '.jsx']; + +function getAllFiles(dir) { + const results = []; + if (!fs.existsSync(dir)) return results; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) results.push(...getAllFiles(full)); + else if (EXT.some((e) => entry.name.endsWith(e))) results.push(full); + } + return results; +} + +function resolves(fromFile, spec) { + const resolved = path.resolve(path.dirname(fromFile), spec); + const noJsExt = resolved.replace(/\.js$/, ''); + const candidates = [ + resolved, + ...EXT.map((e) => `${resolved}${e}`), + `${noJsExt}.ts`, + `${noJsExt}.tsx`, + ...EXT.map((e) => path.join(resolved, `index${e}`)), + `${resolved}.d.ts`, + `${resolved}.json`, + `${resolved}.css`, + `${resolved}.info`, + ]; + return candidates.some((c) => fs.existsSync(c) && fs.statSync(c).isFile()); +} + +let problems = 0; +for (const dir of dirs) { + for (const file of getAllFiles(path.join(ROOT, dir))) { + const content = fs.readFileSync(file, 'utf8'); + for (const m of content.matchAll(IMPORT_RE)) { + if (!resolves(file, m[2])) { + console.log(`${path.relative(ROOT, file)}: unresolved import ${m[2]}`); + problems++; + } + } + } +} +for (const entry of fs.readdirSync(ROOT, { withFileTypes: true })) { + if (!entry.isFile() || !EXT.some((e) => entry.name.endsWith(e))) continue; + const file = path.join(ROOT, entry.name); + const content = fs.readFileSync(file, 'utf8'); + for (const m of content.matchAll(IMPORT_RE)) { + if (!resolves(file, m[2])) { + console.log(`${entry.name}: unresolved import ${m[2]}`); + problems++; + } + } +} +console.log(problems ? `\n${problems} unresolved import(s).` : 'All relative imports resolve.'); +process.exit(problems ? 1 : 0); diff --git a/apps/meteor/scripts/migration/check-mock-keys.mjs b/apps/meteor/scripts/migration/check-mock-keys.mjs new file mode 100644 index 0000000000000..c5639e92c1d14 --- /dev/null +++ b/apps/meteor/scripts/migration/check-mock-keys.mjs @@ -0,0 +1,106 @@ +#!/usr/bin/env node + +/** + * Disposable migration helper: verifies proxyquire/jest.mock string literals. + * + * - proxyquire `.load('', { '': ... })`: the target must resolve to + * a real file, and every relative key must literally match an import specifier + * used by the loaded module (proxyquire matches keys literally). + * - `jest.mock('')`: a relative key must resolve to a real file from the + * spec's directory. + * + * Scans all *.spec.ts / *.tests.{ts,js} under the given dirs (default: app, + * server, ee, tests, imports). + */ + +import fs from 'node:fs'; +import path from 'node:path'; + +const ROOT = path.resolve(import.meta.dirname, '../..'); +const dirs = process.argv.slice(2).length ? process.argv.slice(2) : ['app', 'server', 'ee', 'tests', 'imports']; + +function getAllFiles(dir) { + const results = []; + if (!fs.existsSync(dir)) return results; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) results.push(...getAllFiles(full)); + else if (/\.(spec|tests)\.(ts|js)$/.test(entry.name)) results.push(full); + } + return results; +} + +function resolveModule(fromDir, spec) { + const resolved = path.resolve(fromDir, spec); + const noJsExt = resolved.replace(/\.js$/, ''); + for (const c of [ + resolved, + `${resolved}.ts`, + `${resolved}.tsx`, + `${resolved}.js`, + `${noJsExt}.ts`, + path.join(resolved, 'index.ts'), + path.join(resolved, 'index.js'), + ]) { + if (fs.existsSync(c) && fs.statSync(c).isFile()) return c; + } + return null; +} + +let problems = 0; +for (const dir of dirs) { + for (const specFile of getAllFiles(path.join(ROOT, dir))) { + const content = fs.readFileSync(specFile, 'utf8'); + const rel = path.relative(ROOT, specFile); + + // jest.mock relative keys must resolve from the spec's dir + for (const m of content.matchAll(/jest\.mock\(\s*(['"])(\.[^'"]+)\1/g)) { + if (!resolveModule(path.dirname(specFile), m[2])) { + console.log(`${rel}: jest.mock key does not resolve: ${m[2]}`); + problems++; + } + } + + // proxyquire targets + literal keys + for (const m of content.matchAll(/\.load\(\s*(['"])(\.[^'"]+)\1\s*,/g)) { + const target = m[2]; + const targetFile = resolveModule(path.dirname(specFile), target); + if (!targetFile) { + console.log(`${rel}: proxyquire target does not resolve: ${target}`); + problems++; + continue; + } + const modContent = fs.readFileSync(targetFile, 'utf8'); + const modSpecifiers = new Set( + [...modContent.matchAll(/(?:from\s+|import\s+|(?:import|require)\s*\(\s*)(['"])([^'"]+)\1/g)].map((x) => x[2]), + ); + // keys of the stub object immediately following this .load( target, + // only when the second argument is an inline object literal + const after = content.slice(m.index + m[0].length); + if (!/^\s*\{/.test(after)) continue; + const open = after.indexOf('{'); + // naive brace matching to find the stubs object end + let depth = 0; + let end = open; + for (let i = open; i < after.length; i++) { + if (after[i] === '{') depth++; + else if (after[i] === '}') { + depth--; + if (depth === 0) { + end = i; + break; + } + } + } + const stubs = after.slice(open, end + 1); + for (const k of stubs.matchAll(/(['"])(\.[^'"]+)\1\s*:/g)) { + if (!modSpecifiers.has(k[2])) { + console.log(`${rel}: stale proxyquire key for ${path.relative(ROOT, targetFile)}: ${k[2]}`); + problems++; + } + } + } + } +} +console.log(problems ? `\n${problems} problem(s) found.` : 'All mock keys OK.'); +process.exit(problems ? 1 : 0); diff --git a/apps/meteor/scripts/migration/phase6a-auth-providers.tsv b/apps/meteor/scripts/migration/phase6a-auth-providers.tsv new file mode 100644 index 0000000000000..67f84fe282b7f --- /dev/null +++ b/apps/meteor/scripts/migration/phase6a-auth-providers.tsv @@ -0,0 +1,31 @@ +# Phase 6a: auth providers → server/lib/auth-providers/ (+ methods → server/meteor-methods/) +# Format: old-pathnew-path (relative to apps/meteor/) +app/apple/server server/lib/auth-providers/apple +app/crowd/server/crowd.ts server/lib/auth-providers/crowd/crowd.ts +app/crowd/server/logger.ts server/lib/auth-providers/crowd/logger.ts +app/crowd/server/methods.ts server/meteor-methods/auth/crowd.ts +app/custom-oauth/server server/lib/auth-providers/custom-oauth +app/dolphin/server/lib.ts server/lib/auth-providers/dolphin.ts +app/drupal/server/lib.ts server/lib/auth-providers/drupal.ts +app/github/server/lib.ts server/lib/auth-providers/github.ts +app/github-enterprise/server/lib.ts server/lib/auth-providers/github-enterprise.ts +app/gitlab/server/lib.ts server/lib/auth-providers/gitlab.ts +app/google-oauth/server/index.js server/lib/auth-providers/google.js +app/iframe-login/server/iframe_server.ts server/lib/auth-providers/iframe.ts +app/wordpress/server/lib.ts server/lib/auth-providers/wordpress.ts +app/lib/server/oauth/facebook.js server/lib/auth-providers/oauth/facebook.js +app/lib/server/oauth/google.js server/lib/auth-providers/oauth/google.js +app/lib/server/oauth/oauth.js server/lib/auth-providers/oauth/oauth.js +app/lib/server/oauth/proxy.js server/lib/auth-providers/oauth/proxy.js +app/lib/server/oauth/twitter.js server/lib/auth-providers/oauth/twitter.js +app/meteor-accounts-saml/server/methods/addSamlService.ts server/meteor-methods/auth/addSamlService.ts +app/meteor-accounts-saml/server/methods/samlLogout.ts server/meteor-methods/auth/samlLogout.ts +app/meteor-accounts-saml/server server/lib/saml +app/2fa/server server/lib/2fa +app/token-login/server/login_token_server.js server/lib/auth/token-login.js +app/authentication/server/ILoginAttempt.ts server/lib/auth/ILoginAttempt.ts +app/authentication/server/lib/logLoginAttempts.ts server/lib/auth/logLoginAttempts.ts +app/authentication/server/lib/restrictLoginAttempts.ts server/lib/auth/restrictLoginAttempts.ts +app/authentication/server/startup/index.js server/lib/auth/startup.js +tests/unit/app/custom-oauth/server/transform_helpers.tests.js tests/unit/server/lib/auth-providers/custom-oauth/transform_helpers.tests.js +tests/unit/app/meteor-accounts-saml tests/unit/server/lib/saml diff --git a/apps/meteor/scripts/migration/phase6a-followup-oauth.tsv b/apps/meteor/scripts/migration/phase6a-followup-oauth.tsv new file mode 100644 index 0000000000000..1c777c9a797ef --- /dev/null +++ b/apps/meteor/scripts/migration/phase6a-followup-oauth.tsv @@ -0,0 +1,3 @@ +# Phase 6a follow-up: OAuth providers missed by the plan table +app/linkedin/server/lib.ts server/lib/auth-providers/linkedin.ts +app/meteor-developer/server/lib.ts server/lib/auth-providers/meteor-developer.ts diff --git a/apps/meteor/scripts/migration/phase6b-ee-hooks.tsv b/apps/meteor/scripts/migration/phase6b-ee-hooks.tsv new file mode 100644 index 0000000000000..46c17cd0f91bc --- /dev/null +++ b/apps/meteor/scripts/migration/phase6b-ee-hooks.tsv @@ -0,0 +1,8 @@ +# Phase 6b (EE mirror): hooks → ee/server/hooks// +# Format: old-pathnew-path (relative to apps/meteor/) +ee/app/livechat-enterprise/server/hooks ee/server/hooks/omnichannel +ee/app/canned-responses/server/hooks ee/server/hooks/canned-responses +ee/app/message-read-receipt/server/hooks/afterDeleteRoom.ts ee/server/hooks/messages/afterDeleteRoom.ts +ee/app/message-read-receipt/server/hooks/afterReadMessages.ts ee/server/hooks/messages/afterReadMessages.ts +ee/app/message-read-receipt/server/hooks/afterSaveMessage.ts ee/server/hooks/messages/afterSaveMessage.ts +ee/app/authorization/server/callback.ts ee/server/hooks/auth/callback.ts diff --git a/apps/meteor/scripts/migration/phase6b-hooks.tsv b/apps/meteor/scripts/migration/phase6b-hooks.tsv new file mode 100644 index 0000000000000..51ff83c593247 --- /dev/null +++ b/apps/meteor/scripts/migration/phase6b-hooks.tsv @@ -0,0 +1,13 @@ +# Phase 6b: hooks → server/hooks// +# Format: old-pathnew-path (relative to apps/meteor/) +app/authentication/server/hooks/login.ts server/hooks/auth/login.ts +app/discussion/server/hooks/propagateDiscussionMetadata.ts server/hooks/messages/propagateDiscussionMetadata.ts +app/threads/server/hooks/aftersavemessage.ts server/hooks/messages/processThreads.ts +app/lib/server/lib/afterSaveMessage.ts server/hooks/messages/afterSaveMessage.ts +app/lib/server/lib/notifyUsersOnMessage.ts server/hooks/messages/notifyUsersOnMessage.ts +app/lib/server/lib/sendNotificationsOnMessage.ts server/hooks/messages/sendNotificationsOnMessage.ts +app/lib/server/lib/beforeAddUserToRoom.ts server/hooks/rooms/beforeAddUserToRoom.ts +app/livechat/server/hooks server/hooks/omnichannel +tests/unit/app/livechat/server/hooks tests/unit/server/hooks/omnichannel +tests/unit/server/livechat/hooks/markRoomResponded.spec.ts tests/unit/server/hooks/omnichannel/markRoomResponded.spec.ts +tests/unit/server/livechat/hooks/beforeNewRoom.spec.ts tests/unit/server/hooks/omnichannel/beforeNewRoom.spec.ts diff --git a/apps/meteor/scripts/migration/phase6c-notifications.tsv b/apps/meteor/scripts/migration/phase6c-notifications.tsv new file mode 100644 index 0000000000000..8eca072a826c4 --- /dev/null +++ b/apps/meteor/scripts/migration/phase6c-notifications.tsv @@ -0,0 +1,10 @@ +# Phase 6c: notification libraries → server/lib/notifications/ +# Format: old-pathnew-path (relative to apps/meteor/) +app/push/server/methods.ts server/meteor-methods/platform/push.ts +app/push/server server/lib/notifications/push +app/push-notifications/server/methods/saveNotificationSettings.ts server/meteor-methods/users/saveNotificationSettings.ts +app/push-notifications/server server/lib/notifications/push-config +app/mailer/server server/lib/notifications/email +app/mail-messages/server server/lib/notifications/mail-messages +app/notification-queue/server/NotificationQueue.ts server/lib/notifications/queue/NotificationQueue.ts +app/notifications/server server/lib/notifications/core diff --git a/apps/meteor/scripts/migration/phase6d-messaging.tsv b/apps/meteor/scripts/migration/phase6d-messaging.tsv new file mode 100644 index 0000000000000..1908582e38ebd --- /dev/null +++ b/apps/meteor/scripts/migration/phase6d-messaging.tsv @@ -0,0 +1,14 @@ +# Phase 6d: messaging libraries → server/lib/messaging/ +# Format: old-pathnew-path (relative to apps/meteor/) +app/mentions/server/methods/getUserMentionsByChannel.ts server/meteor-methods/messages/getUserMentionsByChannel.ts +app/mentions/server server/lib/messaging/mentions +app/threads/server/functions.ts server/lib/messaging/threads/functions.ts +app/discussion/server/permissions.ts server/lib/messaging/discussions/permissions.ts +app/reactions/server/setReaction.ts server/lib/messaging/reactions/setReaction.ts +app/message-pin/server/pinMessage.ts server/lib/messaging/pins/pinMessage.ts +app/message-star/server/starMessage.ts server/lib/messaging/stars/starMessage.ts +app/message-mark-as-unread/server/logger.ts server/lib/messaging/unread/logger.ts +app/message-mark-as-unread/server/unreadMessages.ts server/lib/messaging/unread/unreadMessages.ts +app/markdown/server/index.ts server/lib/messaging/markdown.ts +app/emoji/server/lib.ts server/lib/messaging/emoji.ts +tests/unit/app/mentions/server.tests.js tests/unit/server/lib/messaging/mentions/server.tests.js diff --git a/apps/meteor/scripts/migration/phase6e-media-import-libs.tsv b/apps/meteor/scripts/migration/phase6e-media-import-libs.tsv new file mode 100644 index 0000000000000..157dfe02b63f7 --- /dev/null +++ b/apps/meteor/scripts/migration/phase6e-media-import-libs.tsv @@ -0,0 +1,49 @@ +# Phase 6e: media, import, search, and remaining libraries +# Format: old-pathnew-path (relative to apps/meteor/) +# -- method split-outs first (order matters: files out before their parent dir moves) -- +app/file-upload/server/methods/sendFileMessage.spec.ts server/meteor-methods/messages/sendFileMessage.spec.ts +app/file-upload/server/methods/sendFileMessage.ts server/meteor-methods/messages/sendFileMessage.ts +app/file-upload/server/methods/getS3FileUrl.ts server/meteor-methods/media/getS3FileUrl.ts +app/file-upload/server/methods/isImagePreviewSupported.ts server/lib/media/file-upload/isImagePreviewSupported.ts +app/emoji-custom/server/methods/deleteEmojiCustom.ts server/meteor-methods/media/deleteEmojiCustom.ts +app/emoji-custom/server/methods/insertOrUpdateEmoji.ts server/meteor-methods/media/insertOrUpdateEmoji.ts +app/emoji-custom/server/methods/uploadEmojiCustom.ts server/meteor-methods/media/uploadEmojiCustom.ts +app/custom-sounds/server/methods/deleteCustomSound.ts server/meteor-methods/media/deleteCustomSound.ts +app/custom-sounds/server/methods/insertOrUpdateSound.ts server/meteor-methods/media/insertOrUpdateSound.ts +app/custom-sounds/server/methods/listCustomSounds.ts server/meteor-methods/media/listCustomSounds.ts +app/custom-sounds/server/methods/uploadCustomSound.ts server/meteor-methods/media/uploadCustomSound.ts +app/search/server/methods.ts server/meteor-methods/platform/search.ts +app/cloud/server/methods.ts server/meteor-methods/platform/cloud.ts +app/statistics/server/methods/getStatistics.ts server/meteor-methods/platform/getStatistics.ts +app/version-check/server/methods/banner_dismiss.ts server/meteor-methods/platform/banner_dismiss.ts +# -- integrations webhook API belongs to server/api -- +app/integrations/server/api/api.ts server/api/webhooks.ts +# -- media -- +app/file-upload/server server/lib/media/file-upload +app/file/server server/lib/media/file +app/emoji-custom/server server/lib/media/emoji-custom +app/emoji-native/server server/lib/media/emoji-native +app/custom-sounds/server server/lib/media/custom-sounds +app/assets/server server/lib/media/assets +# -- import -- +app/importer/server server/lib/import +app/importer-csv/server server/lib/import/csv +app/importer-slack/server server/lib/import/slack +app/importer-slack-users/server server/lib/import/slack-users +app/importer-omnichannel-contacts/server server/lib/import/omnichannel-contacts +app/importer-pending-avatars/server server/lib/import/pending-avatars +app/importer-pending-files/server server/lib/import/pending-files +# -- remaining libraries -- +app/search/server server/lib/search +app/autotranslate/server server/lib/autotranslate +app/e2e/server server/lib/e2e +app/integrations/server server/lib/integrations +app/statistics/server server/lib/statistics +app/metrics/server server/lib/metrics +app/cloud/server server/lib/cloud +app/version-check/server server/lib/cloud/version-check +app/license/server/airGappedRestrictionsWrapper.ts server/lib/cloud/license/airGappedRestrictionsWrapper.ts +# -- test mirrors -- +tests/unit/app/importer/server tests/unit/server/lib/import +tests/unit/app/statistics/server tests/unit/server/lib/statistics +tests/unit/app/e2e/server tests/unit/server/lib/e2e diff --git a/apps/meteor/server/api/ApiClass.ts b/apps/meteor/server/api/ApiClass.ts index 6ab935e0a3c7b..e9994cb09d271 100644 --- a/apps/meteor/server/api/ApiClass.ts +++ b/apps/meteor/server/api/ApiClass.ts @@ -48,10 +48,10 @@ import { settings } from '../../app/settings/server'; import { getNestedProp } from '../lib/getNestedProp'; import { authenticationMiddlewareForHono } from './v1/middlewares/authenticationHono'; import { permissionsMiddleware } from './v1/middlewares/permissions'; -import { checkCodeForUser } from '../../app/2fa/server/code'; import { getDefaultUserFields } from '../../app/utils/server/functions/getDefaultUserFields'; import { license } from '../../ee/server/api/v1/middlewares/license'; import { isObject } from '../../lib/utils/isObject'; +import { checkCodeForUser } from '../lib/2fa/code'; import { hasPermissionAsync } from '../lib/authorization/hasPermission'; import { shouldBreakInVersion } from '../lib/shouldBreakInVersion'; diff --git a/apps/meteor/server/api/api.ts b/apps/meteor/server/api/api.ts index 87387c579a4b4..2207e7647e145 100644 --- a/apps/meteor/server/api/api.ts +++ b/apps/meteor/server/api/api.ts @@ -6,12 +6,12 @@ import { WebApp } from 'meteor/webapp'; import { APIClass } from './ApiClass'; import { type APIActionHandler, RocketChatAPIRouter } from './router'; +import { metrics } from '../lib/metrics'; import { cors } from './v1/middlewares/cors'; import { loggerMiddleware } from './v1/middlewares/logger'; import { metricsMiddleware } from './v1/middlewares/metrics'; import { remoteAddressMiddleware } from './v1/middlewares/remoteAddressMiddleware'; import { tracerSpanMiddleware } from './v1/middlewares/tracer'; -import { metrics } from '../../app/metrics/server'; import { settings } from '../../app/settings/server'; const logger = new Logger('API'); diff --git a/apps/meteor/server/api/definition.ts b/apps/meteor/server/api/definition.ts index e465139fd66d3..7f795fac25f74 100644 --- a/apps/meteor/server/api/definition.ts +++ b/apps/meteor/server/api/definition.ts @@ -5,8 +5,8 @@ import type { Logger } from '@rocket.chat/logger'; import type { Method, MethodOf, OperationParams, OperationResult, PathPattern, UrlParams } from '@rocket.chat/rest-typings'; import type { ValidateFunction } from 'ajv'; -import type { ITwoFactorOptions } from '../../app/2fa/server/code'; import type { DeprecationLoggerNextPlannedVersion } from '../../app/lib/server/lib/deprecationWarningLogger'; +import type { ITwoFactorOptions } from '../lib/2fa/code'; export type SuccessStatusCodes = Exclude, Range<200>>; diff --git a/apps/meteor/server/api/v1/assets.ts b/apps/meteor/server/api/v1/assets.ts index 333b02cff1e86..9a29c409a2e23 100644 --- a/apps/meteor/server/api/v1/assets.ts +++ b/apps/meteor/server/api/v1/assets.ts @@ -7,9 +7,9 @@ import { validateBadRequestErrorResponse, } from '@rocket.chat/rest-typings'; -import { RocketChatAssets, refreshClients } from '../../../app/assets/server'; import { notifyOnSettingChangedById } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; +import { RocketChatAssets, refreshClients } from '../../lib/media/assets'; import { updateAuditedByUser } from '../../settings/lib/auditedSettingUpdates'; import { API } from '../api'; import { getUploadFormData } from '../lib/getUploadFormData'; diff --git a/apps/meteor/server/api/v1/autotranslate.ts b/apps/meteor/server/api/v1/autotranslate.ts index 313ac66b831c6..8e174b3f9039f 100644 --- a/apps/meteor/server/api/v1/autotranslate.ts +++ b/apps/meteor/server/api/v1/autotranslate.ts @@ -10,10 +10,10 @@ import { } from '@rocket.chat/rest-typings'; import { canAccessRoomAsync } from '../../../app/authorization/server'; -import { getSupportedLanguages } from '../../../app/autotranslate/server/functions/getSupportedLanguages'; -import { saveAutoTranslateSettings } from '../../../app/autotranslate/server/functions/saveSettings'; -import { translateMessage } from '../../../app/autotranslate/server/functions/translateMessage'; import { settings } from '../../../app/settings/server'; +import { getSupportedLanguages } from '../../lib/autotranslate/functions/getSupportedLanguages'; +import { saveAutoTranslateSettings } from '../../lib/autotranslate/functions/saveSettings'; +import { translateMessage } from '../../lib/autotranslate/functions/translateMessage'; import type { ExtractRoutesFromAPI } from '../ApiClass'; import { API } from '../api'; diff --git a/apps/meteor/server/api/v1/channels.ts b/apps/meteor/server/api/v1/channels.ts index bb20a86d62e67..f8c8072c60b15 100644 --- a/apps/meteor/server/api/v1/channels.ts +++ b/apps/meteor/server/api/v1/channels.ts @@ -35,15 +35,15 @@ import { check, Match } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { canAccessRoomAsync } from '../../../app/authorization/server'; -import { mountIntegrationQueryBasedOnPermissions } from '../../../app/integrations/server/lib/mountQueriesBasedOnPermission'; -import { getUserMentionsByChannel } from '../../../app/mentions/server/methods/getUserMentionsByChannel'; import { settings } from '../../../app/settings/server'; import { normalizeMessagesForUser } from '../../../app/utils/server/lib/normalizeMessagesForUser'; import { hasAllPermissionAsync, hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { eraseRoom } from '../../lib/eraseRoom'; import { findUsersOfRoom } from '../../lib/findUsersOfRoom'; +import { mountIntegrationQueryBasedOnPermissions } from '../../lib/integrations/lib/mountQueriesBasedOnPermission'; import { openRoom } from '../../lib/openRoom'; import { getChannelHistory } from '../../meteor-methods/messages/getChannelHistory'; +import { getUserMentionsByChannel } from '../../meteor-methods/messages/getUserMentionsByChannel'; import { addAllUserToRoomFn } from '../../meteor-methods/rooms/addAllUserToRoom'; import { addRoomLeader } from '../../meteor-methods/rooms/addRoomLeader'; import { addRoomModerator } from '../../meteor-methods/rooms/addRoomModerator'; diff --git a/apps/meteor/server/api/v1/chat.ts b/apps/meteor/server/api/v1/chat.ts index 46024299b7b34..0fb4d345ceea8 100644 --- a/apps/meteor/server/api/v1/chat.ts +++ b/apps/meteor/server/api/v1/chat.ts @@ -31,16 +31,16 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { Meteor } from 'meteor/meteor'; import { roomAccessAttributes } from '../../../app/authorization/server'; -import { applyAirGappedRestrictionsValidation } from '../../../app/license/server/airGappedRestrictionsWrapper'; -import { pinMessage, unpinMessage } from '../../../app/message-pin/server/pinMessage'; -import { starMessage } from '../../../app/message-star/server/starMessage'; -import { executeSetReaction } from '../../../app/reactions/server/setReaction'; import { settings } from '../../../app/settings/server'; import { normalizeMessagesForUser } from '../../../app/utils/server/lib/normalizeMessagesForUser'; import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { applyAirGappedRestrictionsValidation } from '../../lib/cloud/license/airGappedRestrictionsWrapper'; import { deleteMessageValidatingPermission } from '../../lib/messages/deleteMessage'; import { processWebhookMessage } from '../../lib/messages/processWebhookMessage'; +import { pinMessage, unpinMessage } from '../../lib/messaging/pins/pinMessage'; +import { executeSetReaction } from '../../lib/messaging/reactions/setReaction'; +import { starMessage } from '../../lib/messaging/stars/starMessage'; import { reportMessage } from '../../lib/moderation/reportMessage'; import { followMessage } from '../../meteor-methods/messages/followMessage'; import { getSingleMessage } from '../../meteor-methods/messages/getSingleMessage'; diff --git a/apps/meteor/server/api/v1/custom-sounds.ts b/apps/meteor/server/api/v1/custom-sounds.ts index 12f073d0c4878..85240f181e0b8 100644 --- a/apps/meteor/server/api/v1/custom-sounds.ts +++ b/apps/meteor/server/api/v1/custom-sounds.ts @@ -17,12 +17,12 @@ import { import { escapeRegExp } from '@rocket.chat/string-helpers'; import { Meteor } from 'meteor/meteor'; -import { deleteCustomSound } from '../../../app/custom-sounds/server/lib/deleteCustomSound'; -import { insertOrUpdateSound } from '../../../app/custom-sounds/server/lib/insertOrUpdateSound'; -import { uploadCustomSound } from '../../../app/custom-sounds/server/lib/uploadCustomSound'; import { getExtension, getMimeTypeFromFileName } from '../../../app/utils/lib/mimeTypes'; import { MAX_CUSTOM_SOUND_SIZE_BYTES, CUSTOM_SOUND_ALLOWED_MIME_TYPES } from '../../../lib/constants'; import { SystemLogger } from '../../lib/logger/system'; +import { deleteCustomSound } from '../../lib/media/custom-sounds/lib/deleteCustomSound'; +import { insertOrUpdateSound } from '../../lib/media/custom-sounds/lib/insertOrUpdateSound'; +import { uploadCustomSound } from '../../lib/media/custom-sounds/lib/uploadCustomSound'; import type { ExtractRoutesFromAPI } from '../ApiClass'; import { API } from '../api'; import { getPaginationItems } from '../lib/getPaginationItems'; diff --git a/apps/meteor/server/api/v1/e2e.ts b/apps/meteor/server/api/v1/e2e.ts index 71d77ace7e768..5b7be8eeb77df 100644 --- a/apps/meteor/server/api/v1/e2e.ts +++ b/apps/meteor/server/api/v1/e2e.ts @@ -10,12 +10,12 @@ import { } from '@rocket.chat/rest-typings'; import ExpiryMap from 'expiry-map'; -import { handleSuggestedGroupKey } from '../../../app/e2e/server/functions/handleSuggestedGroupKey'; -import { provideUsersSuggestedGroupKeys } from '../../../app/e2e/server/functions/provideUsersSuggestedGroupKeys'; -import { resetRoomKey } from '../../../app/e2e/server/functions/resetRoomKey'; import { settings } from '../../../app/settings/server'; import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { handleSuggestedGroupKey } from '../../lib/e2e/functions/handleSuggestedGroupKey'; +import { provideUsersSuggestedGroupKeys } from '../../lib/e2e/functions/provideUsersSuggestedGroupKeys'; +import { resetRoomKey } from '../../lib/e2e/functions/resetRoomKey'; import { getUsersOfRoomWithoutKeyMethod } from '../../meteor-methods/platform/getUsersOfRoomWithoutKey'; import { requestSubscriptionKeysMethod } from '../../meteor-methods/platform/requestSubscriptionKeys'; import { setRoomKeyIDMethod } from '../../meteor-methods/platform/setRoomKeyID'; diff --git a/apps/meteor/server/api/v1/emoji-custom.ts b/apps/meteor/server/api/v1/emoji-custom.ts index 06545dc711bfd..7ac4540a33793 100644 --- a/apps/meteor/server/api/v1/emoji-custom.ts +++ b/apps/meteor/server/api/v1/emoji-custom.ts @@ -6,11 +6,11 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { Meteor } from 'meteor/meteor'; import type { WithId } from 'mongodb'; -import type { EmojiData } from '../../../app/emoji-custom/server/lib/insertOrUpdateEmoji'; -import { insertOrUpdateEmoji } from '../../../app/emoji-custom/server/lib/insertOrUpdateEmoji'; -import { uploadEmojiCustomWithBuffer } from '../../../app/emoji-custom/server/lib/uploadEmojiCustom'; -import { deleteEmojiCustom } from '../../../app/emoji-custom/server/methods/deleteEmojiCustom'; import { settings } from '../../../app/settings/server'; +import type { EmojiData } from '../../lib/media/emoji-custom/lib/insertOrUpdateEmoji'; +import { insertOrUpdateEmoji } from '../../lib/media/emoji-custom/lib/insertOrUpdateEmoji'; +import { uploadEmojiCustomWithBuffer } from '../../lib/media/emoji-custom/lib/uploadEmojiCustom'; +import { deleteEmojiCustom } from '../../meteor-methods/media/deleteEmojiCustom'; import type { ExtractRoutesFromAPI } from '../ApiClass'; import { API } from '../api'; import { findEmojisCustom } from '../lib/emoji-custom'; diff --git a/apps/meteor/server/api/v1/groups.ts b/apps/meteor/server/api/v1/groups.ts index d1bba764b80c3..882dc89146aa7 100644 --- a/apps/meteor/server/api/v1/groups.ts +++ b/apps/meteor/server/api/v1/groups.ts @@ -15,11 +15,11 @@ import { Meteor } from 'meteor/meteor'; import type { Filter } from 'mongodb'; import { canAccessRoomAsync, roomAccessAttributes } from '../../../app/authorization/server'; -import { mountIntegrationQueryBasedOnPermissions } from '../../../app/integrations/server/lib/mountQueriesBasedOnPermission'; import { normalizeMessagesForUser } from '../../../app/utils/server/lib/normalizeMessagesForUser'; import { hasAllPermissionAsync, hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { eraseRoom } from '../../lib/eraseRoom'; import { findUsersOfRoom } from '../../lib/findUsersOfRoom'; +import { mountIntegrationQueryBasedOnPermissions } from '../../lib/integrations/lib/mountQueriesBasedOnPermission'; import { openRoom } from '../../lib/openRoom'; import { getChannelHistory } from '../../meteor-methods/messages/getChannelHistory'; import { addAllUserToRoomFn } from '../../meteor-methods/rooms/addAllUserToRoom'; diff --git a/apps/meteor/server/api/v1/import.ts b/apps/meteor/server/api/v1/import.ts index f9a81d03a6fb7..6cb2b4d3be21f 100644 --- a/apps/meteor/server/api/v1/import.ts +++ b/apps/meteor/server/api/v1/import.ts @@ -20,9 +20,9 @@ import { } from '@rocket.chat/rest-typings'; import { Meteor } from 'meteor/meteor'; -import { Importers } from '../../../app/importer/server'; -import { PendingAvatarImporter } from '../../../app/importer-pending-avatars/server/PendingAvatarImporter'; -import { PendingFileImporter } from '../../../app/importer-pending-files/server/PendingFileImporter'; +import { Importers } from '../../lib/import'; +import { PendingAvatarImporter } from '../../lib/import/pending-avatars/PendingAvatarImporter'; +import { PendingFileImporter } from '../../lib/import/pending-files/PendingFileImporter'; import { executeDownloadPublicImportFile } from '../../meteor-methods/import/downloadPublicImportFile'; import { executeGetImportFileData } from '../../meteor-methods/import/getImportFileData'; import { executeGetImportProgress } from '../../meteor-methods/import/getImportProgress'; diff --git a/apps/meteor/server/api/v1/integrations.ts b/apps/meteor/server/api/v1/integrations.ts index 869b8c8e25676..175c98da5a3a8 100644 --- a/apps/meteor/server/api/v1/integrations.ts +++ b/apps/meteor/server/api/v1/integrations.ts @@ -18,14 +18,11 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { Match, check } from 'meteor/check'; import type { Filter } from 'mongodb'; -import { - clearIntegrationHistoryMethod, - replayOutgoingIntegrationMethod, -} from '../../../app/integrations/server/functions/clearIntegrationHistory'; +import { clearIntegrationHistoryMethod, replayOutgoingIntegrationMethod } from '../../lib/integrations/functions/clearIntegrationHistory'; import { mountIntegrationHistoryQueryBasedOnPermissions, mountIntegrationQueryBasedOnPermissions, -} from '../../../app/integrations/server/lib/mountQueriesBasedOnPermission'; +} from '../../lib/integrations/lib/mountQueriesBasedOnPermission'; import { addIncomingIntegration } from '../../meteor-methods/integrations/incoming/addIncomingIntegration'; import { deleteIncomingIntegration } from '../../meteor-methods/integrations/incoming/deleteIncomingIntegration'; import { updateIncomingIntegration } from '../../meteor-methods/integrations/incoming/updateIncomingIntegration'; diff --git a/apps/meteor/server/api/v1/mailer.ts b/apps/meteor/server/api/v1/mailer.ts index 8acd84a075c6f..226af5d761cdf 100644 --- a/apps/meteor/server/api/v1/mailer.ts +++ b/apps/meteor/server/api/v1/mailer.ts @@ -7,8 +7,8 @@ import { validateBadRequestErrorResponse, } from '@rocket.chat/rest-typings'; -import { sendMail } from '../../../app/mail-messages/server/functions/sendMail'; -import { Mailer } from '../../../app/mail-messages/server/lib/Mailer'; +import { sendMail } from '../../lib/notifications/mail-messages/functions/sendMail'; +import { Mailer } from '../../lib/notifications/mail-messages/lib/Mailer'; import { API } from '../api'; const mailerResponseSchema = ajv.compile({ diff --git a/apps/meteor/server/api/v1/omnichannel/sms.ts b/apps/meteor/server/api/v1/omnichannel/sms.ts index 1fe642508d175..e421229ebc75a 100644 --- a/apps/meteor/server/api/v1/omnichannel/sms.ts +++ b/apps/meteor/server/api/v1/omnichannel/sms.ts @@ -17,12 +17,12 @@ import { Meteor } from 'meteor/meteor'; import { API } from '../..'; import { setCustomField } from './lib/customFields'; -import { FileUpload } from '../../../../app/file-upload/server'; import type { ILivechatMessage } from '../../../../app/livechat/server/lib/localTypes'; import { sendMessage } from '../../../../app/livechat/server/lib/messages'; import { createRoom } from '../../../../app/livechat/server/lib/rooms'; import { settings } from '../../../../app/settings/server'; import { getFileExtension } from '../../../../lib/utils/getFileExtension'; +import { FileUpload } from '../../../lib/media/file-upload'; const logger = new Logger('SMS'); diff --git a/apps/meteor/server/api/v1/omnichannel/upload.ts b/apps/meteor/server/api/v1/omnichannel/upload.ts index 2f97751348a05..621c9c40f78e4 100644 --- a/apps/meteor/server/api/v1/omnichannel/upload.ts +++ b/apps/meteor/server/api/v1/omnichannel/upload.ts @@ -1,9 +1,9 @@ import { LivechatVisitors, LivechatRooms } from '@rocket.chat/models'; import { API } from '../..'; -import { FileUpload } from '../../../../app/file-upload/server'; import { settings } from '../../../../app/settings/server'; import { fileUploadIsValidContentType } from '../../../../app/utils/server/restrictions'; +import { FileUpload } from '../../../lib/media/file-upload'; import { sendFileLivechatMessage } from '../../../meteor-methods/omnichannel/sendFileLivechatMessage'; import { MultipartUploadHandler } from '../../lib/MultipartUploadHandler'; diff --git a/apps/meteor/server/api/v1/push.ts b/apps/meteor/server/api/v1/push.ts index 06f6c7d59c27e..f7eec002cc1f8 100644 --- a/apps/meteor/server/api/v1/push.ts +++ b/apps/meteor/server/api/v1/push.ts @@ -14,9 +14,9 @@ import type { JSONSchemaType } from 'ajv'; import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; -import PushNotification from '../../../app/push-notifications/server/lib/PushNotification'; import { settings } from '../../../app/settings/server'; import { canAccessRoomAsync } from '../../lib/authorization/canAccessRoom'; +import PushNotification from '../../lib/notifications/push-config/lib/PushNotification'; import { executePushTest } from '../../lib/pushConfig'; import type { ExtractRoutesFromAPI } from '../ApiClass'; import { API } from '../api'; diff --git a/apps/meteor/server/api/v1/rooms.ts b/apps/meteor/server/api/v1/rooms.ts index 98d6e162a3607..464dbf655ae97 100644 --- a/apps/meteor/server/api/v1/rooms.ts +++ b/apps/meteor/server/api/v1/rooms.ts @@ -46,26 +46,24 @@ import { isTruthy } from '@rocket.chat/tools'; import { Meteor } from 'meteor/meteor'; import { stripABACManagedFieldsForAdmin } from '../../../app/authorization/server/lib/isABACManagedRoom'; -import { FileUpload } from '../../../app/file-upload/server'; -import { sendFileMessage } from '../../../app/file-upload/server/methods/sendFileMessage'; import { notifyOnSubscriptionChanged } from '../../../app/lib/server/lib/notifyListener'; -import { applyAirGappedRestrictionsValidation } from '../../../app/license/server/airGappedRestrictionsWrapper'; -import type { NotificationFieldType } from '../../../app/push-notifications/server/methods/saveNotificationSettings'; -import { saveNotificationSettingsMethod } from '../../../app/push-notifications/server/methods/saveNotificationSettings'; import { settings } from '../../../app/settings/server'; import { adminFields } from '../../../lib/rooms/adminFields'; import { omit } from '../../../lib/utils/omit'; import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { banUserFromRoomMethod } from '../../lib/banUserFromRoom'; +import { applyAirGappedRestrictionsValidation } from '../../lib/cloud/license/airGappedRestrictionsWrapper'; import * as dataExport from '../../lib/dataExport'; import { eraseRoom } from '../../lib/eraseRoom'; import { findUsersOfRoomOrderedByRole } from '../../lib/findUsersOfRoomOrderedByRole'; +import { FileUpload } from '../../lib/media/file-upload'; import { openRoom } from '../../lib/openRoom'; import type { RoomRoles } from '../../lib/roles/getRoomRoles'; import { syncRolePrioritiesForRoomIfRequired } from '../../lib/rooms/syncRolePrioritiesForRoomIfRequired'; import { unbanUserFromRoom } from '../../lib/unbanUserFromRoom'; import { createDiscussion } from '../../meteor-methods/messages/createDiscussion'; +import { sendFileMessage } from '../../meteor-methods/messages/sendFileMessage'; import { executeArchiveRoom } from '../../meteor-methods/rooms/archiveRoom'; import { cleanRoomHistoryMethod } from '../../meteor-methods/rooms/cleanRoomHistory'; import { executeGetRoomRoles } from '../../meteor-methods/rooms/getRoomRoles'; @@ -76,6 +74,8 @@ import { saveRoomSettings } from '../../meteor-methods/rooms/saveRoomSettings'; import { toggleFavoriteMethod } from '../../meteor-methods/rooms/toggleFavorite'; import { executeUnarchiveRoom } from '../../meteor-methods/rooms/unarchiveRoom'; import { unmuteUserInRoom } from '../../meteor-methods/rooms/unmuteUserInRoom'; +import { saveNotificationSettingsMethod } from '../../meteor-methods/users/saveNotificationSettings'; +import type { NotificationFieldType } from '../../meteor-methods/users/saveNotificationSettings'; import { roomsGetMethod } from '../../publications/room'; import type { ExtractRoutesFromAPI } from '../ApiClass'; import { API } from '../api'; diff --git a/apps/meteor/server/api/v1/stats.ts b/apps/meteor/server/api/v1/stats.ts index debdf52c15a5d..54f7c62f3f74c 100644 --- a/apps/meteor/server/api/v1/stats.ts +++ b/apps/meteor/server/api/v1/stats.ts @@ -7,8 +7,8 @@ import { validateBadRequestErrorResponse, } from '@rocket.chat/rest-typings'; -import { getStatistics, getLastStatistics } from '../../../app/statistics/server'; -import telemetryEvent from '../../../app/statistics/server/lib/telemetryEvents'; +import { getStatistics, getLastStatistics } from '../../lib/statistics'; +import telemetryEvent from '../../lib/statistics/lib/telemetryEvents'; import { API } from '../api'; import { getPaginationItems } from '../lib/getPaginationItems'; diff --git a/apps/meteor/server/api/v1/subscriptions.ts b/apps/meteor/server/api/v1/subscriptions.ts index 081760fd67515..ff670abc141e2 100644 --- a/apps/meteor/server/api/v1/subscriptions.ts +++ b/apps/meteor/server/api/v1/subscriptions.ts @@ -11,7 +11,7 @@ import { } from '@rocket.chat/rest-typings'; import { Meteor } from 'meteor/meteor'; -import { unreadMessages } from '../../../app/message-mark-as-unread/server/unreadMessages'; +import { unreadMessages } from '../../lib/messaging/unread/unreadMessages'; import { readMessages } from '../../lib/readMessages'; import { getSubscriptions } from '../../publications/subscription'; import { API } from '../api'; diff --git a/apps/meteor/server/api/v1/twoFactorChallenges.ts b/apps/meteor/server/api/v1/twoFactorChallenges.ts index 866f4eeccf763..db144dce8b4b0 100644 --- a/apps/meteor/server/api/v1/twoFactorChallenges.ts +++ b/apps/meteor/server/api/v1/twoFactorChallenges.ts @@ -4,7 +4,7 @@ import { isTwoFactorChallengesSendEmailCodeParamsPOST, isTwoFactorChallengesVeri import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; -import { getUserForCheck, rememberAuthorizationByToken } from '../../../app/2fa/server/code'; +import { getUserForCheck, rememberAuthorizationByToken } from '../../lib/2fa/code'; import { emailCheckForOAuth, getTwoFAMethodForOAuth } from '../../lib/oauth/twoFactorAuth'; import { generateConnection } from '../ApiClass'; import { API } from '../api'; diff --git a/apps/meteor/server/api/v1/users.ts b/apps/meteor/server/api/v1/users.ts index e8738154e2b2d..7024b9eed3b4b 100644 --- a/apps/meteor/server/api/v1/users.ts +++ b/apps/meteor/server/api/v1/users.ts @@ -36,8 +36,6 @@ import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import type { Filter } from 'mongodb'; -import { getUserForCheck, emailCheck } from '../../../app/2fa/server/code'; -import { resetTOTP } from '../../../app/2fa/server/functions/resetTOTP'; import { notifyOnUserChange, notifyOnUserChangeAsync } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; import { isSMTPConfigured } from '../../../app/utils/server/functions/isSMTPConfigured'; @@ -46,6 +44,8 @@ import { generatePersonalAccessTokenOfUser } from '../../../imports/personal-acc import { regeneratePersonalAccessTokenOfUser } from '../../../imports/personal-access-tokens/server/api/methods/regenerateToken'; import { removePersonalAccessTokenOfUser } from '../../../imports/personal-access-tokens/server/api/methods/removeToken'; import { runUserLogoutCleanUp } from '../../hooks/userLogoutCleanUp'; +import { getUserForCheck, emailCheck } from '../../lib/2fa/code'; +import { resetTOTP } from '../../lib/2fa/functions/resetTOTP'; import { UserChangedAuditStore } from '../../lib/auditServerEvents/userChanged'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { i18n } from '../../lib/i18n'; diff --git a/apps/meteor/app/integrations/server/api/api.ts b/apps/meteor/server/api/webhooks.ts similarity index 91% rename from apps/meteor/app/integrations/server/api/api.ts rename to apps/meteor/server/api/webhooks.ts index 9265fed6161fa..7d8b1827ed5ae 100644 --- a/apps/meteor/app/integrations/server/api/api.ts +++ b/apps/meteor/server/api/webhooks.ts @@ -8,24 +8,24 @@ import type { RateLimiterOptionsToCheck } from 'meteor/rate-limit'; import { WebApp } from 'meteor/webapp'; import _ from 'underscore'; -import { isPlainObject } from '../../../../lib/utils/isPlainObject'; -import { APIClass } from '../../../../server/api/ApiClass'; -import type { RateLimiterOptions } from '../../../../server/api/api'; -import { API, defaultRateLimiterOptions } from '../../../../server/api/api'; -import type { FailureResult, GenericRouteExecutionContext, SuccessResult, UnavailableResult } from '../../../../server/api/definition'; -import type { APIActionContext } from '../../../../server/api/router'; -import { loggerMiddleware } from '../../../../server/api/v1/middlewares/logger'; -import { metricsMiddleware } from '../../../../server/api/v1/middlewares/metrics'; -import { tracerSpanMiddleware } from '../../../../server/api/v1/middlewares/tracer'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import type { WebhookResponseItem } from '../../../../server/lib/messages/processWebhookMessage'; -import { processWebhookMessage } from '../../../../server/lib/messages/processWebhookMessage'; -import { addOutgoingIntegration } from '../../../../server/meteor-methods/integrations/outgoing/addOutgoingIntegration'; -import { deleteOutgoingIntegration } from '../../../../server/meteor-methods/integrations/outgoing/deleteOutgoingIntegration'; -import { metrics } from '../../../metrics/server'; -import { settings } from '../../../settings/server'; -import { IsolatedVMScriptEngine } from '../lib/isolated-vm/isolated-vm'; -import { incomingLogger, integrationLogger } from '../logger'; +import { APIClass } from './ApiClass'; +import type { RateLimiterOptions } from './api'; +import { API, defaultRateLimiterOptions } from './api'; +import type { FailureResult, GenericRouteExecutionContext, SuccessResult, UnavailableResult } from './definition'; +import type { APIActionContext } from './router'; +import { metrics } from '../lib/metrics'; +import { loggerMiddleware } from './v1/middlewares/logger'; +import { metricsMiddleware } from './v1/middlewares/metrics'; +import { tracerSpanMiddleware } from './v1/middlewares/tracer'; +import { settings } from '../../app/settings/server'; +import { isPlainObject } from '../../lib/utils/isPlainObject'; +import { hasPermissionAsync } from '../lib/authorization/hasPermission'; +import { IsolatedVMScriptEngine } from '../lib/integrations/lib/isolated-vm/isolated-vm'; +import { incomingLogger, integrationLogger } from '../lib/integrations/logger'; +import type { WebhookResponseItem } from '../lib/messages/processWebhookMessage'; +import { processWebhookMessage } from '../lib/messages/processWebhookMessage'; +import { addOutgoingIntegration } from '../meteor-methods/integrations/outgoing/addOutgoingIntegration'; +import { deleteOutgoingIntegration } from '../meteor-methods/integrations/outgoing/deleteOutgoingIntegration'; const ivmEngine = new IsolatedVMScriptEngine(true); diff --git a/apps/meteor/server/bridges/nextcloud/lib.ts b/apps/meteor/server/bridges/nextcloud/lib.ts index 03b56ee320bea..deff356908a42 100644 --- a/apps/meteor/server/bridges/nextcloud/lib.ts +++ b/apps/meteor/server/bridges/nextcloud/lib.ts @@ -2,8 +2,8 @@ import type { OAuthConfiguration } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import passport from 'passport'; -import { CustomOAuth } from '../../../app/custom-oauth/server/custom_oauth_server'; import { settings } from '../../../app/settings/server'; +import { CustomOAuth } from '../../lib/auth-providers/custom-oauth/custom_oauth_server'; import { addPassportCustomOAuth } from '../../lib/oauth/addPassportCustomOAuth'; const NEXTCLOUD_PATHS = { diff --git a/apps/meteor/server/bridges/slack/SlackAdapter.ts b/apps/meteor/server/bridges/slack/SlackAdapter.ts index c2f1e4952c459..ddd041eb3829d 100644 --- a/apps/meteor/server/bridges/slack/SlackAdapter.ts +++ b/apps/meteor/server/bridges/slack/SlackAdapter.ts @@ -17,13 +17,13 @@ import { Meteor } from 'meteor/meteor'; import { SlackAPI } from './SlackAPI'; import { slackLogger } from './logger'; import { saveRoomName, saveRoomTopic } from '../../../app/channel-settings/server'; -import { FileUpload } from '../../../app/file-upload/server'; -import { executeSetReaction } from '../../../app/reactions/server/setReaction'; import { settings } from '../../../app/settings/server'; import { getUserAvatarURL } from '../../../app/utils/server/getUserAvatarURL'; +import { FileUpload } from '../../lib/media/file-upload'; import { deleteMessage } from '../../lib/messages/deleteMessage'; import { sendMessage } from '../../lib/messages/sendMessage'; import { updateMessage } from '../../lib/messages/updateMessage'; +import { executeSetReaction } from '../../lib/messaging/reactions/setReaction'; import { addUserToRoom } from '../../lib/rooms/addUserToRoom'; import { archiveRoom } from '../../lib/rooms/archiveRoom'; import { removeUserFromRoom } from '../../lib/rooms/removeUserFromRoom'; diff --git a/apps/meteor/server/bridges/smarsh/functions/sendEmail.ts b/apps/meteor/server/bridges/smarsh/functions/sendEmail.ts index 46ad7ed2358ac..99027839f3303 100644 --- a/apps/meteor/server/bridges/smarsh/functions/sendEmail.ts +++ b/apps/meteor/server/bridges/smarsh/functions/sendEmail.ts @@ -6,8 +6,8 @@ // } import { Uploads } from '@rocket.chat/models'; -import * as Mailer from '../../../../app/mailer/server/api'; import { settings } from '../../../../app/settings/server'; +import * as Mailer from '../../../lib/notifications/email/api'; import { UploadFS } from '../../../ufs'; export const sendEmail = async (data: { files: string[]; subject: string; body: string }) => { diff --git a/apps/meteor/server/configuration/configureAssets.ts b/apps/meteor/server/configuration/configureAssets.ts index c64dd4b5edaaf..4e2af1855d592 100644 --- a/apps/meteor/server/configuration/configureAssets.ts +++ b/apps/meteor/server/configuration/configureAssets.ts @@ -1,5 +1,5 @@ -import { RocketChatAssets } from '../../app/assets/server'; import type { ICachedSettings } from '../../app/settings/server/CachedSettings'; +import { RocketChatAssets } from '../lib/media/assets'; export async function configureAssets(settings: ICachedSettings): Promise { settings.watchByRegex(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value)); diff --git a/apps/meteor/server/configuration/pushNotification.ts b/apps/meteor/server/configuration/pushNotification.ts index 6a3dd52145cf3..96cac02539e7e 100644 --- a/apps/meteor/server/configuration/pushNotification.ts +++ b/apps/meteor/server/configuration/pushNotification.ts @@ -1,6 +1,6 @@ -import { getWorkspaceAccessToken } from '../../app/cloud/server'; -import { Push } from '../../app/push/server'; import type { ICachedSettings } from '../../app/settings/server/CachedSettings'; +import { getWorkspaceAccessToken } from '../lib/cloud'; +import { Push } from '../lib/notifications/push'; export async function configurePushNotifications(settings: ICachedSettings): Promise { settings.watch('Push_enable', async (enabled) => { diff --git a/apps/meteor/server/cron/temporaryUploadsCleanup.ts b/apps/meteor/server/cron/temporaryUploadsCleanup.ts index 351d29ffd698c..c4577f01cacfd 100644 --- a/apps/meteor/server/cron/temporaryUploadsCleanup.ts +++ b/apps/meteor/server/cron/temporaryUploadsCleanup.ts @@ -1,7 +1,7 @@ import { cronJobs } from '@rocket.chat/cron'; import { Uploads } from '@rocket.chat/models'; -import { FileUpload } from '../../app/file-upload/server'; +import { FileUpload } from '../lib/media/file-upload'; async function temporaryUploadCleanup(): Promise { const files = await Uploads.findExpiredTemporaryFiles({ projection: { _id: 1 } }).toArray(); diff --git a/apps/meteor/server/cron/usageReport.spec.ts b/apps/meteor/server/cron/usageReport.spec.ts index 1b4b464bfbbd6..21aba74188455 100644 --- a/apps/meteor/server/cron/usageReport.spec.ts +++ b/apps/meteor/server/cron/usageReport.spec.ts @@ -15,7 +15,7 @@ jest.mock('@rocket.chat/models', () => ({ }, })); -jest.mock('../../app/statistics/server/functions/sendUsageReport', () => ({ +jest.mock('../lib/statistics/functions/sendUsageReport', () => ({ sendUsageReport: () => undefined, })); diff --git a/apps/meteor/server/cron/usageReport.ts b/apps/meteor/server/cron/usageReport.ts index c4afec47de1fc..22ad61f7e4c78 100644 --- a/apps/meteor/server/cron/usageReport.ts +++ b/apps/meteor/server/cron/usageReport.ts @@ -3,7 +3,7 @@ import { AirGappedRestriction } from '@rocket.chat/license'; import type { Logger } from '@rocket.chat/logger'; import { Statistics } from '@rocket.chat/models'; -import { sendUsageReport } from '../../app/statistics/server/functions/sendUsageReport'; +import { sendUsageReport } from '../lib/statistics/functions/sendUsageReport'; export const sendUsageReportAndComputeRestriction = async (statsToken?: string) => { // If the report failed to be sent we need to get the last existing token diff --git a/apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts b/apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts index 57ca854038960..260ac3448ffa1 100644 --- a/apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts +++ b/apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts @@ -13,13 +13,13 @@ import type { ParsedMail, Attachment } from 'mailparser'; import { stripHtml } from 'string-strip-html'; import { logger } from './logger'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; import { QueueManager } from '../../../app/livechat/server/lib/QueueManager'; import { setDepartmentForGuest } from '../../../app/livechat/server/lib/departmentsLib'; import { sendMessage } from '../../../app/livechat/server/lib/messages'; import { settings } from '../../../app/settings/server'; import { i18n } from '../../lib/i18n'; +import { FileUpload } from '../../lib/media/file-upload'; type FileAttachment = VideoAttachmentProps & ImageAttachmentProps & AudioAttachmentProps; diff --git a/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts b/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts index e271d9d4293ea..222130234d80b 100644 --- a/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts +++ b/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts @@ -8,12 +8,12 @@ import type Mail from 'nodemailer/lib/mailer'; import { inboxes } from './EmailInbox'; import type { Inbox } from './EmailInbox'; import { logger } from './logger'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; import { slashCommands } from '../../../app/utils/server/slashCommand'; import { callbacks } from '../../lib/callbacks'; import { i18n } from '../../lib/i18n'; +import { FileUpload } from '../../lib/media/file-upload'; import { sendMessage } from '../../lib/messages/sendMessage'; const livechatQuoteRegExp = /^\[\s\]\(https?:\/\/.+\/live\/.+\?msg=(?.+?)\)\s(?.+)/s; diff --git a/apps/meteor/app/authentication/server/hooks/login.ts b/apps/meteor/server/hooks/auth/login.ts similarity index 71% rename from apps/meteor/app/authentication/server/hooks/login.ts rename to apps/meteor/server/hooks/auth/login.ts index 191639e208dee..e99ca5f2b8c06 100644 --- a/apps/meteor/app/authentication/server/hooks/login.ts +++ b/apps/meteor/server/hooks/auth/login.ts @@ -1,10 +1,10 @@ import { Accounts } from 'meteor/accounts-base'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import type { ILoginAttempt } from '../ILoginAttempt'; -import { logFailedLoginAttempts } from '../lib/logLoginAttempts'; -import { saveFailedLoginAttempts, saveSuccessfulLogin } from '../lib/restrictLoginAttempts'; +import { settings } from '../../../app/settings/server'; +import type { ILoginAttempt } from '../../lib/auth/ILoginAttempt'; +import { logFailedLoginAttempts } from '../../lib/auth/logLoginAttempts'; +import { saveFailedLoginAttempts, saveSuccessfulLogin } from '../../lib/auth/restrictLoginAttempts'; +import { callbacks } from '../../lib/callbacks'; const ignoredErrorTypes = ['totp-required', 'error-login-blocked-for-user']; diff --git a/apps/meteor/app/lib/server/lib/afterSaveMessage.ts b/apps/meteor/server/hooks/messages/afterSaveMessage.ts similarity index 90% rename from apps/meteor/app/lib/server/lib/afterSaveMessage.ts rename to apps/meteor/server/hooks/messages/afterSaveMessage.ts index 7325b5e9e23ec..35cd826dc4511 100644 --- a/apps/meteor/app/lib/server/lib/afterSaveMessage.ts +++ b/apps/meteor/server/hooks/messages/afterSaveMessage.ts @@ -3,8 +3,8 @@ import type { IMessage, IUser, IRoom } from '@rocket.chat/core-typings'; import type { Updater } from '@rocket.chat/models'; import { Rooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import type { SendMessageOptions } from '../../../../server/lib/messages/sendMessage'; +import { callbacks } from '../../lib/callbacks'; +import type { SendMessageOptions } from '../../lib/messages/sendMessage'; export async function afterSaveMessage( message: IMessage, diff --git a/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts b/apps/meteor/server/hooks/messages/notifyUsersOnMessage.ts similarity index 96% rename from apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts rename to apps/meteor/server/hooks/messages/notifyUsersOnMessage.ts index 80cf172c9dcb1..56211d5e679c9 100644 --- a/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts +++ b/apps/meteor/server/hooks/messages/notifyUsersOnMessage.ts @@ -4,14 +4,14 @@ import type { Updater } from '@rocket.chat/models'; import { Subscriptions, Rooms } from '@rocket.chat/models'; import moment from 'moment'; +import { messageContainsHighlight } from '../../../app/lib/server/functions/notifications/messageContainsHighlight'; import { notifyOnSubscriptionChanged, notifyOnSubscriptionChangedByRoomIdAndUserId, notifyOnSubscriptionChangedByRoomIdAndUserIds, -} from './notifyListener'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { messageContainsHighlight } from '../functions/notifications/messageContainsHighlight'; +} from '../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; export async function getMentions(message: IMessage): Promise<{ toAll: boolean; toHere: boolean; mentionIds: string[] }> { const { diff --git a/apps/meteor/app/threads/server/hooks/aftersavemessage.ts b/apps/meteor/server/hooks/messages/processThreads.ts similarity index 81% rename from apps/meteor/app/threads/server/hooks/aftersavemessage.ts rename to apps/meteor/server/hooks/messages/processThreads.ts index d75fa98215c3e..bea122acf450d 100644 --- a/apps/meteor/app/threads/server/hooks/aftersavemessage.ts +++ b/apps/meteor/server/hooks/messages/processThreads.ts @@ -3,13 +3,13 @@ import { isEditedMessage } from '@rocket.chat/core-typings'; import { Messages } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { callbacks } from '../../../../server/lib/callbacks'; -import type { SendMessageOptions } from '../../../../server/lib/messages/sendMessage'; -import { notifyOnMessageChange } from '../../../lib/server/lib/notifyListener'; -import { updateThreadUsersSubscriptions, getMentions } from '../../../lib/server/lib/notifyUsersOnMessage'; -import { sendMessageNotifications } from '../../../lib/server/lib/sendNotificationsOnMessage'; -import { settings } from '../../../settings/server'; -import { reply } from '../functions'; +import { updateThreadUsersSubscriptions, getMentions } from './notifyUsersOnMessage'; +import { sendMessageNotifications } from './sendNotificationsOnMessage'; +import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; +import type { SendMessageOptions } from '../../lib/messages/sendMessage'; +import { reply } from '../../lib/messaging/threads/functions'; async function notifyUsersOnReply(message: IMessage, replies: IUser['_id'][]) { // skips this callback if the message was edited diff --git a/apps/meteor/app/discussion/server/hooks/propagateDiscussionMetadata.ts b/apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts similarity index 91% rename from apps/meteor/app/discussion/server/hooks/propagateDiscussionMetadata.ts rename to apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts index 4ed1ab8a87e9a..5e123fe8c1ca8 100644 --- a/apps/meteor/app/discussion/server/hooks/propagateDiscussionMetadata.ts +++ b/apps/meteor/server/hooks/messages/propagateDiscussionMetadata.ts @@ -1,9 +1,9 @@ import type { IRoom } from '@rocket.chat/core-typings'; import { Messages, Rooms, VideoConference } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { deleteRoom } from '../../../../server/lib/rooms/deleteRoom'; -import { notifyOnMessageChange } from '../../../lib/server/lib/notifyListener'; +import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; +import { callbacks } from '../../lib/callbacks'; +import { deleteRoom } from '../../lib/rooms/deleteRoom'; const updateAndNotifyParentRoomWithParentMessage = async (room: IRoom): Promise => { const parentMessage = await Messages.refreshDiscussionMetadata(room); diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts b/apps/meteor/server/hooks/messages/sendNotificationsOnMessage.ts similarity index 92% rename from apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts rename to apps/meteor/server/hooks/messages/sendNotificationsOnMessage.ts index f42e25d67d0ab..ebf901dca8d62 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts +++ b/apps/meteor/server/hooks/messages/sendNotificationsOnMessage.ts @@ -12,17 +12,17 @@ import moment from 'moment'; import type { RootFilterOperators } from 'mongodb'; import { getMentions } from './notifyUsersOnMessage'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator'; -import { shortnameToUnicode } from '../../../emoji-native/lib/shortnameToUnicode'; -import { Notification } from '../../../notification-queue/server/NotificationQueue'; -import { settings } from '../../../settings/server'; -import { parseMessageTextPerUser, replaceMentionedUsernamesWithFullNames } from '../functions/notifications'; -import { notifyDesktopUser, shouldNotifyDesktop } from '../functions/notifications/desktop'; -import { getEmailData, shouldNotifyEmail } from '../functions/notifications/email'; -import { messageContainsHighlight } from '../functions/notifications/messageContainsHighlight'; -import { getPushData, shouldNotifyMobile } from '../functions/notifications/mobile'; +import { shortnameToUnicode } from '../../../app/emoji-native/lib/shortnameToUnicode'; +import { parseMessageTextPerUser, replaceMentionedUsernamesWithFullNames } from '../../../app/lib/server/functions/notifications'; +import { notifyDesktopUser, shouldNotifyDesktop } from '../../../app/lib/server/functions/notifications/desktop'; +import { getEmailData, shouldNotifyEmail } from '../../../app/lib/server/functions/notifications/email'; +import { messageContainsHighlight } from '../../../app/lib/server/functions/notifications/messageContainsHighlight'; +import { getPushData, shouldNotifyMobile } from '../../../app/lib/server/functions/notifications/mobile'; +import { settings } from '../../../app/settings/server'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { callbacks } from '../../lib/callbacks'; +import { Notification } from '../../lib/notifications/queue/NotificationQueue'; +import { roomCoordinator } from '../../lib/rooms/roomCoordinator'; type SubscriptionAggregation = { receiver: [Pick | null]; diff --git a/apps/meteor/app/livechat/server/hooks/afterAgentRemoved.ts b/apps/meteor/server/hooks/omnichannel/afterAgentRemoved.ts similarity index 91% rename from apps/meteor/app/livechat/server/hooks/afterAgentRemoved.ts rename to apps/meteor/server/hooks/omnichannel/afterAgentRemoved.ts index 4687d8ef47dfa..873d044c2a536 100644 --- a/apps/meteor/app/livechat/server/hooks/afterAgentRemoved.ts +++ b/apps/meteor/server/hooks/omnichannel/afterAgentRemoved.ts @@ -1,7 +1,7 @@ import { LivechatDepartment, Users, LivechatDepartmentAgents, LivechatVisitors } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { notifyOnLivechatDepartmentAgentChanged, notifyOnUserChange } from '../../../lib/server/lib/notifyListener'; +import { notifyOnLivechatDepartmentAgentChanged, notifyOnUserChange } from '../../../app/lib/server/lib/notifyListener'; +import { callbacks } from '../../lib/callbacks'; callbacks.add('livechat.afterAgentRemoved', async ({ agent }) => { const departments = await LivechatDepartmentAgents.findByAgentId(agent._id).toArray(); diff --git a/apps/meteor/app/livechat/server/hooks/afterSaveOmnichannelMessage.ts b/apps/meteor/server/hooks/omnichannel/afterSaveOmnichannelMessage.ts similarity index 90% rename from apps/meteor/app/livechat/server/hooks/afterSaveOmnichannelMessage.ts rename to apps/meteor/server/hooks/omnichannel/afterSaveOmnichannelMessage.ts index 8e5a17725cef2..633ede3eda689 100644 --- a/apps/meteor/app/livechat/server/hooks/afterSaveOmnichannelMessage.ts +++ b/apps/meteor/server/hooks/omnichannel/afterSaveOmnichannelMessage.ts @@ -1,7 +1,7 @@ import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; +import { callbacks } from '../../lib/callbacks'; callbacks.add( 'afterSaveMessage', diff --git a/apps/meteor/app/livechat/server/hooks/afterUserActions.ts b/apps/meteor/server/hooks/omnichannel/afterUserActions.ts similarity index 94% rename from apps/meteor/app/livechat/server/hooks/afterUserActions.ts rename to apps/meteor/server/hooks/omnichannel/afterUserActions.ts index 3b70b836d7ea6..e4ca70ddb42b2 100644 --- a/apps/meteor/app/livechat/server/hooks/afterUserActions.ts +++ b/apps/meteor/server/hooks/omnichannel/afterUserActions.ts @@ -1,8 +1,8 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { afterAgentUserActivated, afterAgentAdded, afterRemoveAgent } from '../lib/hooks'; +import { afterAgentUserActivated, afterAgentAdded, afterRemoveAgent } from '../../../app/livechat/server/lib/hooks'; +import { callbacks } from '../../lib/callbacks'; type IAfterSaveUserProps = { user: IUser; diff --git a/apps/meteor/app/livechat/server/hooks/leadCapture.ts b/apps/meteor/server/hooks/omnichannel/leadCapture.ts similarity index 94% rename from apps/meteor/app/livechat/server/hooks/leadCapture.ts rename to apps/meteor/server/hooks/omnichannel/leadCapture.ts index 84689cecaabfb..189d750d36cba 100644 --- a/apps/meteor/app/livechat/server/hooks/leadCapture.ts +++ b/apps/meteor/server/hooks/omnichannel/leadCapture.ts @@ -3,8 +3,8 @@ import { isEditedMessage } from '@rocket.chat/core-typings'; import { LivechatVisitors } from '@rocket.chat/models'; import { isTruthy } from '@rocket.chat/tools'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; function validateMessage(message: IMessage, room: IOmnichannelRoom) { // skips this callback if the message was edited diff --git a/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts b/apps/meteor/server/hooks/omnichannel/markRoomNotResponded.ts similarity index 91% rename from apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts rename to apps/meteor/server/hooks/omnichannel/markRoomNotResponded.ts index d3422ef33bb43..84419ac5e7437 100644 --- a/apps/meteor/app/livechat/server/hooks/markRoomNotResponded.ts +++ b/apps/meteor/server/hooks/omnichannel/markRoomNotResponded.ts @@ -1,7 +1,7 @@ import { isEditedMessage } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; +import { callbacks } from '../../lib/callbacks'; callbacks.add( 'afterOmnichannelSaveMessage', diff --git a/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts b/apps/meteor/server/hooks/omnichannel/markRoomResponded.ts similarity index 90% rename from apps/meteor/app/livechat/server/hooks/markRoomResponded.ts rename to apps/meteor/server/hooks/omnichannel/markRoomResponded.ts index fbda30475d5c2..b42f6dfe68a92 100644 --- a/apps/meteor/app/livechat/server/hooks/markRoomResponded.ts +++ b/apps/meteor/server/hooks/omnichannel/markRoomResponded.ts @@ -4,10 +4,10 @@ import type { Updater } from '@rocket.chat/models'; import { LivechatRooms, LivechatContacts, LivechatInquiry } from '@rocket.chat/models'; import moment from 'moment'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { notifyOnLivechatInquiryChanged } from '../../../lib/server/lib/notifyListener'; -import { settings } from '../../../settings/server'; -import { isMessageFromBot } from '../lib/isMessageFromBot'; +import { notifyOnLivechatInquiryChanged } from '../../../app/lib/server/lib/notifyListener'; +import { isMessageFromBot } from '../../../app/livechat/server/lib/isMessageFromBot'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; export async function markRoomResponded( message: IMessage, diff --git a/apps/meteor/app/livechat/server/hooks/offlineMessage.ts b/apps/meteor/server/hooks/omnichannel/offlineMessage.ts similarity index 70% rename from apps/meteor/app/livechat/server/hooks/offlineMessage.ts rename to apps/meteor/server/hooks/omnichannel/offlineMessage.ts index 0496d7da1a9e4..d09df28446fb4 100644 --- a/apps/meteor/app/livechat/server/hooks/offlineMessage.ts +++ b/apps/meteor/server/hooks/omnichannel/offlineMessage.ts @@ -1,6 +1,6 @@ -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { sendRequest } from '../lib/webhooks'; +import { sendRequest } from '../../../app/livechat/server/lib/webhooks'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; callbacks.add( 'livechat.offlineMessage', diff --git a/apps/meteor/app/livechat/server/hooks/offlineMessageToChannel.ts b/apps/meteor/server/hooks/omnichannel/offlineMessageToChannel.ts similarity index 89% rename from apps/meteor/app/livechat/server/hooks/offlineMessageToChannel.ts rename to apps/meteor/server/hooks/omnichannel/offlineMessageToChannel.ts index 1574162190276..14e42b46724cf 100644 --- a/apps/meteor/app/livechat/server/hooks/offlineMessageToChannel.ts +++ b/apps/meteor/server/hooks/omnichannel/offlineMessageToChannel.ts @@ -2,10 +2,10 @@ import type { ILivechatDepartment } from '@rocket.chat/core-typings'; import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatDepartment, Users, Rooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { i18n } from '../../../../server/lib/i18n'; -import { sendMessage } from '../../../../server/lib/messages/sendMessage'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; +import { i18n } from '../../lib/i18n'; +import { sendMessage } from '../../lib/messages/sendMessage'; callbacks.add( 'livechat.offlineMessage', diff --git a/apps/meteor/app/livechat/server/hooks/processRoomAbandonment.ts b/apps/meteor/server/hooks/omnichannel/processRoomAbandonment.ts similarity index 95% rename from apps/meteor/app/livechat/server/hooks/processRoomAbandonment.ts rename to apps/meteor/server/hooks/omnichannel/processRoomAbandonment.ts index ffe339adec77b..23b8e7e949d6d 100644 --- a/apps/meteor/app/livechat/server/hooks/processRoomAbandonment.ts +++ b/apps/meteor/server/hooks/omnichannel/processRoomAbandonment.ts @@ -3,10 +3,10 @@ import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatBusinessHours, LivechatDepartment, Messages, LivechatRooms } from '@rocket.chat/models'; import moment from 'moment'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { businessHourManager } from '../business-hour'; -import type { CloseRoomParams } from '../lib/localTypes'; +import { businessHourManager } from '../../../app/livechat/server/business-hour'; +import type { CloseRoomParams } from '../../../app/livechat/server/lib/localTypes'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; export const getSecondsWhenOfficeHoursIsDisabled = (room: IOmnichannelRoom, agentLastMessage: IMessage) => moment(new Date(room.closedAt || new Date())).diff(moment(new Date(agentLastMessage.ts)), 'seconds'); diff --git a/apps/meteor/app/livechat/server/hooks/saveAnalyticsData.ts b/apps/meteor/server/hooks/omnichannel/saveAnalyticsData.ts similarity index 91% rename from apps/meteor/app/livechat/server/hooks/saveAnalyticsData.ts rename to apps/meteor/server/hooks/omnichannel/saveAnalyticsData.ts index eff6229b57552..bdc87aaf4deb0 100644 --- a/apps/meteor/app/livechat/server/hooks/saveAnalyticsData.ts +++ b/apps/meteor/server/hooks/omnichannel/saveAnalyticsData.ts @@ -2,10 +2,10 @@ import { isEditedMessage, isMessageFromVisitor, isSystemMessage } from '@rocket. import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { normalizeMessageFileUpload } from '../../../utils/server/functions/normalizeMessageFileUpload'; -import { isMessageFromBot } from '../lib/isMessageFromBot'; +import { isMessageFromBot } from '../../../app/livechat/server/lib/isMessageFromBot'; +import { settings } from '../../../app/settings/server'; +import { normalizeMessageFileUpload } from '../../../app/utils/server/functions/normalizeMessageFileUpload'; +import { callbacks } from '../../lib/callbacks'; const getMetricValue = (metric: T | undefined, defaultValue: T): T => metric ?? defaultValue; const calculateTimeDifference = (startTime: T, now: Date): number => diff --git a/apps/meteor/app/livechat/server/hooks/saveLastMessageToInquiry.ts b/apps/meteor/server/hooks/omnichannel/saveLastMessageToInquiry.ts similarity index 74% rename from apps/meteor/app/livechat/server/hooks/saveLastMessageToInquiry.ts rename to apps/meteor/server/hooks/omnichannel/saveLastMessageToInquiry.ts index acb4c53927c8d..9f5f61e033d7b 100644 --- a/apps/meteor/app/livechat/server/hooks/saveLastMessageToInquiry.ts +++ b/apps/meteor/server/hooks/omnichannel/saveLastMessageToInquiry.ts @@ -1,10 +1,10 @@ import { isEditedMessage } from '@rocket.chat/core-typings'; import { LivechatInquiry } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { notifyOnLivechatInquiryChanged } from '../../../lib/server/lib/notifyListener'; -import { settings } from '../../../settings/server'; -import { RoutingManager } from '../lib/RoutingManager'; +import { notifyOnLivechatInquiryChanged } from '../../../app/lib/server/lib/notifyListener'; +import { RoutingManager } from '../../../app/livechat/server/lib/RoutingManager'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../../lib/callbacks'; callbacks.add( 'afterOmnichannelSaveMessage', diff --git a/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts b/apps/meteor/server/hooks/omnichannel/saveLastVisitorMessageTs.ts similarity index 88% rename from apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts rename to apps/meteor/server/hooks/omnichannel/saveLastVisitorMessageTs.ts index 3b0649b7eb5b3..2917b0424d655 100644 --- a/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts +++ b/apps/meteor/server/hooks/omnichannel/saveLastVisitorMessageTs.ts @@ -1,7 +1,7 @@ import { isMessageFromVisitor } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; +import { callbacks } from '../../lib/callbacks'; callbacks.add( 'afterOmnichannelSaveMessage', diff --git a/apps/meteor/app/livechat/server/hooks/sendEmailTranscriptOnClose.ts b/apps/meteor/server/hooks/omnichannel/sendEmailTranscriptOnClose.ts similarity index 89% rename from apps/meteor/app/livechat/server/hooks/sendEmailTranscriptOnClose.ts rename to apps/meteor/server/hooks/omnichannel/sendEmailTranscriptOnClose.ts index 16fa7b239fea3..9dd569c7952c4 100644 --- a/apps/meteor/app/livechat/server/hooks/sendEmailTranscriptOnClose.ts +++ b/apps/meteor/server/hooks/omnichannel/sendEmailTranscriptOnClose.ts @@ -2,9 +2,9 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; import { isOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms } from '@rocket.chat/models'; -import { callbacks } from '../../../../server/lib/callbacks'; -import type { CloseRoomParams } from '../lib/localTypes'; -import { sendTranscript } from '../lib/sendTranscript'; +import type { CloseRoomParams } from '../../../app/livechat/server/lib/localTypes'; +import { sendTranscript } from '../../../app/livechat/server/lib/sendTranscript'; +import { callbacks } from '../../lib/callbacks'; type LivechatCloseCallbackParams = { room: IOmnichannelRoom; diff --git a/apps/meteor/app/livechat/server/hooks/sendToCRM.ts b/apps/meteor/server/hooks/omnichannel/sendToCRM.ts similarity index 95% rename from apps/meteor/app/livechat/server/hooks/sendToCRM.ts rename to apps/meteor/server/hooks/omnichannel/sendToCRM.ts index d4c11fba6a582..90d60be860c05 100644 --- a/apps/meteor/app/livechat/server/hooks/sendToCRM.ts +++ b/apps/meteor/server/hooks/omnichannel/sendToCRM.ts @@ -3,11 +3,11 @@ import { isEditedMessage, isOmnichannelRoom } from '@rocket.chat/core-typings'; import { LivechatRooms, Messages } from '@rocket.chat/models'; import type { Response } from '@rocket.chat/server-fetch'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { normalizeMessageFileUpload } from '../../../utils/server/functions/normalizeMessageFileUpload'; -import { getLivechatRoomGuestInfo } from '../lib/guests'; -import { sendRequest } from '../lib/webhooks'; +import { getLivechatRoomGuestInfo } from '../../../app/livechat/server/lib/guests'; +import { sendRequest } from '../../../app/livechat/server/lib/webhooks'; +import { settings } from '../../../app/settings/server'; +import { normalizeMessageFileUpload } from '../../../app/utils/server/functions/normalizeMessageFileUpload'; +import { callbacks } from '../../lib/callbacks'; type AdditionalFields = | Record diff --git a/apps/meteor/app/lib/server/lib/beforeAddUserToRoom.ts b/apps/meteor/server/hooks/rooms/beforeAddUserToRoom.ts similarity index 100% rename from apps/meteor/app/lib/server/lib/beforeAddUserToRoom.ts rename to apps/meteor/server/hooks/rooms/beforeAddUserToRoom.ts diff --git a/apps/meteor/server/hooks/sauMonitorHooks.ts b/apps/meteor/server/hooks/sauMonitorHooks.ts index ca985869af877..adf252a5cf50f 100644 --- a/apps/meteor/server/hooks/sauMonitorHooks.ts +++ b/apps/meteor/server/hooks/sauMonitorHooks.ts @@ -4,7 +4,7 @@ import { getHeader } from '@rocket.chat/tools'; import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; -import type { ILoginAttempt } from '../../app/authentication/server/ILoginAttempt'; +import type { ILoginAttempt } from '../lib/auth/ILoginAttempt'; import { deviceManagementEvents } from '../services/device-management/events'; import { sauEvents } from '../services/sauMonitor/events'; diff --git a/apps/meteor/server/importPackages.ts b/apps/meteor/server/importPackages.ts index 9069341261b1b..faafa042d2f41 100644 --- a/apps/meteor/server/importPackages.ts +++ b/apps/meteor/server/importPackages.ts @@ -1,50 +1,59 @@ import '../app/cors/server'; -import '../app/2fa/server'; +import './lib/2fa/MethodInvocationOverride'; +import './lib/2fa/loginHandler'; import './api'; -import '../app/apple/server'; -import '../app/assets/server'; +import './lib/auth-providers/apple/appleOauthRegisterService'; +import './lib/auth-providers/apple/loginHandler'; +import './lib/auth-providers/apple/applePassportOAuth'; +import './lib/media/assets'; import '../app/authorization/server'; -import '../app/autotranslate/server'; +import './lib/autotranslate'; import './lib/bot-helpers'; import '../app/channel-settings/server'; -import '../app/cloud/server'; -import '../app/crowd/server'; -import '../app/custom-oauth/server/custom_oauth_server'; -import '../app/custom-sounds/server'; -import '../app/dolphin/server'; -import '../app/drupal/server'; -import '../app/emoji/server'; -import '../app/emoji-custom/server'; -import '../app/emoji-native/server'; +import './lib/cloud'; +import './lib/auth-providers/crowd/crowd'; +import './lib/auth-providers/custom-oauth/custom_oauth_server'; +import './lib/media/custom-sounds/startup/custom-sounds'; +import './lib/auth-providers/dolphin'; +import './lib/auth-providers/drupal'; +import './lib/messaging/emoji'; +import './lib/media/emoji-custom/startup/emoji-custom'; +import './lib/media/emoji-native/lib'; +import './lib/media/emoji-native/callbacks'; import '../app/error-handler/server'; -import '../app/file/server'; -import '../app/file-upload/server'; -import '../app/github-enterprise/server'; -import '../app/gitlab/server'; -import '../app/google-oauth/server'; -import '../app/iframe-login/server'; -import '../app/importer/server'; -import '../app/importer-csv/server'; -import '../app/importer-omnichannel-contacts/server'; -import '../app/importer-pending-files/server'; -import '../app/importer-pending-avatars/server'; -import '../app/importer-slack/server'; -import '../app/importer-slack-users/server'; -import '../app/integrations/server'; +import './lib/media/file'; +import './lib/media/file-upload'; +import './lib/auth-providers/github-enterprise'; +import './lib/auth-providers/gitlab'; +import './lib/auth-providers/google'; +import './lib/auth-providers/iframe'; +import './lib/import'; +import './lib/import/csv'; +import './lib/import/omnichannel-contacts'; +import './lib/import/pending-files'; +import './lib/import/pending-avatars'; +import './lib/import/slack'; +import './lib/import/slack-users'; +import './lib/integrations/logger'; +import './lib/integrations/lib/validateOutgoingIntegration'; +import './api/webhooks'; +import './lib/integrations/lib/triggerHandler'; +import './lib/integrations/triggers'; +import './lib/integrations/startup'; import './bridges/irc'; import '../app/lib/server'; -import '../app/meteor-developer/server'; -import '../app/linkedin/server'; -import '../app/token-login/server'; -import '../app/mailer/server/api'; -import '../app/markdown/server'; -import '../app/mentions/server'; -import '../app/message-mark-as-unread/server'; -import '../app/message-pin/server'; -import '../app/message-star/server'; +import './lib/auth-providers/meteor-developer'; +import './lib/auth-providers/linkedin'; +import './lib/auth/token-login'; +import './lib/notifications/email/api'; +import './lib/messaging/markdown'; +import './lib/messaging/mentions/getMentionedTeamMembers'; +import './lib/messaging/unread/unreadMessages'; +import './lib/messaging/pins/pinMessage'; +import './lib/messaging/stars/starMessage'; import './bridges/nextcloud'; import '../app/oauth2-server-config/server'; -import '../app/push-notifications/server'; +import './lib/notifications/push-config'; import '../app/retention-policy/server'; import './bridges/slack'; import './slashcommands/archiveroom'; @@ -66,20 +75,29 @@ import './slashcommands/topic'; import './slashcommands/unarchiveroom'; import './bridges/smarsh'; import '../app/theme/server'; -import '../app/threads/server'; +import './hooks/messages/processThreads'; import '../app/ui-master/server'; import './bridges/webdav'; -import '../app/wordpress/server'; -import '../app/meteor-accounts-saml/server'; -import '../app/e2e/server'; -import '../app/version-check/server'; -import '../app/search/server'; -import '../app/discussion/server'; +import './lib/auth-providers/wordpress'; +import './lib/saml/startup'; +import './lib/saml/loginHandler'; +import './lib/saml/listener'; +import './lib/e2e'; +import './lib/cloud/version-check'; +import './lib/search/model/SearchProvider'; +import './lib/search/events'; +import './lib/search/search.internalService'; +import './lib/search/register'; +import './lib/search/startup'; +import './lib/search/service'; +import './lib/messaging/discussions/permissions'; +import './hooks/messages/propagateDiscussionMetadata'; import '../app/user-status/server'; -import '../app/metrics/server'; -import '../app/notifications/server'; +import './lib/metrics'; +import './lib/notifications/core'; import '../app/ui-utils/server'; -import '../app/reactions/server'; +import './lib/messaging/reactions/setReaction'; import '../app/livechat/server'; -import '../app/authentication/server'; -import '../app/github/server'; +import './hooks/auth/login'; +import './lib/auth/startup'; +import './lib/auth-providers/github'; diff --git a/apps/meteor/app/2fa/server/MethodInvocationOverride.js b/apps/meteor/server/lib/2fa/MethodInvocationOverride.js similarity index 100% rename from apps/meteor/app/2fa/server/MethodInvocationOverride.js rename to apps/meteor/server/lib/2fa/MethodInvocationOverride.js diff --git a/apps/meteor/app/2fa/server/code/EmailCheck.spec.ts b/apps/meteor/server/lib/2fa/code/EmailCheck.spec.ts similarity index 94% rename from apps/meteor/app/2fa/server/code/EmailCheck.spec.ts rename to apps/meteor/server/lib/2fa/code/EmailCheck.spec.ts index 5c3574f0b395b..e89ab1db75a45 100644 --- a/apps/meteor/app/2fa/server/code/EmailCheck.spec.ts +++ b/apps/meteor/server/lib/2fa/code/EmailCheck.spec.ts @@ -14,15 +14,15 @@ const { EmailCheck } = proxyquire.noCallThru().load('./EmailCheck', { _bcryptRounds: () => '123', }, }, - '../../../../server/lib/i18n': { + '../../i18n': { i18n: { t: (key: string) => key, }, }, - '../../../mailer/server/api': { + '../../notifications/email/api': { send: () => undefined, }, - '../../../settings/server': { + '../../../../app/settings/server': { settings: { get: settingsMock, }, diff --git a/apps/meteor/app/2fa/server/code/EmailCheck.ts b/apps/meteor/server/lib/2fa/code/EmailCheck.ts similarity index 96% rename from apps/meteor/app/2fa/server/code/EmailCheck.ts rename to apps/meteor/server/lib/2fa/code/EmailCheck.ts index c52531eaac781..1713bf3b706e4 100644 --- a/apps/meteor/app/2fa/server/code/EmailCheck.ts +++ b/apps/meteor/server/lib/2fa/code/EmailCheck.ts @@ -5,9 +5,9 @@ import bcrypt from 'bcrypt'; import { Accounts } from 'meteor/accounts-base'; import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck'; -import { i18n } from '../../../../server/lib/i18n'; -import * as Mailer from '../../../mailer/server/api'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { i18n } from '../../i18n'; +import * as Mailer from '../../notifications/email/api'; export class EmailCheck implements ICodeCheck { public readonly name: string = 'email'; diff --git a/apps/meteor/app/2fa/server/code/EmailCheckForOAuth.ts b/apps/meteor/server/lib/2fa/code/EmailCheckForOAuth.ts similarity index 100% rename from apps/meteor/app/2fa/server/code/EmailCheckForOAuth.ts rename to apps/meteor/server/lib/2fa/code/EmailCheckForOAuth.ts diff --git a/apps/meteor/app/2fa/server/code/ICodeCheck.ts b/apps/meteor/server/lib/2fa/code/ICodeCheck.ts similarity index 100% rename from apps/meteor/app/2fa/server/code/ICodeCheck.ts rename to apps/meteor/server/lib/2fa/code/ICodeCheck.ts diff --git a/apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts b/apps/meteor/server/lib/2fa/code/PasswordCheckFallback.ts similarity index 95% rename from apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts rename to apps/meteor/server/lib/2fa/code/PasswordCheckFallback.ts index d0b3661677249..fa2bbb8feac9d 100644 --- a/apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts +++ b/apps/meteor/server/lib/2fa/code/PasswordCheckFallback.ts @@ -3,7 +3,7 @@ import { Accounts } from 'meteor/accounts-base'; import type { Meteor } from 'meteor/meteor'; import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; export class PasswordCheckFallback implements ICodeCheck { public readonly name = 'password'; diff --git a/apps/meteor/app/2fa/server/code/TOTPCheck.ts b/apps/meteor/server/lib/2fa/code/TOTPCheck.ts similarity index 94% rename from apps/meteor/app/2fa/server/code/TOTPCheck.ts rename to apps/meteor/server/lib/2fa/code/TOTPCheck.ts index ae9502569457f..fe6f6366f51fd 100644 --- a/apps/meteor/app/2fa/server/code/TOTPCheck.ts +++ b/apps/meteor/server/lib/2fa/code/TOTPCheck.ts @@ -1,7 +1,7 @@ import type { IUser } from '@rocket.chat/core-typings'; import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; import { TOTP } from '../lib/totp'; export class TOTPCheck implements ICodeCheck { diff --git a/apps/meteor/app/2fa/server/code/TOTPCheckForOAuth.ts b/apps/meteor/server/lib/2fa/code/TOTPCheckForOAuth.ts similarity index 100% rename from apps/meteor/app/2fa/server/code/TOTPCheckForOAuth.ts rename to apps/meteor/server/lib/2fa/code/TOTPCheckForOAuth.ts diff --git a/apps/meteor/app/2fa/server/code/checkCodeForUser.spec.ts b/apps/meteor/server/lib/2fa/code/checkCodeForUser.spec.ts similarity index 98% rename from apps/meteor/app/2fa/server/code/checkCodeForUser.spec.ts rename to apps/meteor/server/lib/2fa/code/checkCodeForUser.spec.ts index ba925da82f919..fe46863149fd8 100644 --- a/apps/meteor/app/2fa/server/code/checkCodeForUser.spec.ts +++ b/apps/meteor/server/lib/2fa/code/checkCodeForUser.spec.ts @@ -77,10 +77,10 @@ const { checkCodeForUser, getFingerprintFromConnection } = proxyquire.noCallThru './TOTPCheck': { TOTPCheck }, './EmailCheck': { EmailCheck }, './PasswordCheckFallback': { PasswordCheckFallback }, - '../../../../server/lib/shared/getModifiedHttpHeaders': { + '../../shared/getModifiedHttpHeaders': { normalizeHeaders: (headers: unknown) => headers, }, - '../../../settings/server': { + '../../../../app/settings/server': { settings: { get: settingsGet }, }, }); diff --git a/apps/meteor/app/2fa/server/code/index.spec.ts b/apps/meteor/server/lib/2fa/code/index.spec.ts similarity index 95% rename from apps/meteor/app/2fa/server/code/index.spec.ts rename to apps/meteor/server/lib/2fa/code/index.spec.ts index b1bc937bf7a94..455c5f9689b1f 100644 --- a/apps/meteor/app/2fa/server/code/index.spec.ts +++ b/apps/meteor/server/lib/2fa/code/index.spec.ts @@ -50,8 +50,8 @@ const { checkCodeForUser } = proxyquire.noCallThru().load('./index', { './TOTPCheck': { TOTPCheck: TOTPCheckMock }, './EmailCheck': { EmailCheck: DisabledCheckMock }, './PasswordCheckFallback': { PasswordCheckFallback: class extends DisabledCheckMock {} }, - '../../../../server/lib/shared/getModifiedHttpHeaders': { normalizeHeaders: (headers: unknown) => headers }, - '../../../settings/server': { settings: { get: settingsMock } }, + '../../shared/getModifiedHttpHeaders': { normalizeHeaders: (headers: unknown) => headers }, + '../../../../app/settings/server': { settings: { get: settingsMock } }, '@rocket.chat/models': { Users: { findOneById: async () => null, diff --git a/apps/meteor/app/2fa/server/code/index.ts b/apps/meteor/server/lib/2fa/code/index.ts similarity index 98% rename from apps/meteor/app/2fa/server/code/index.ts rename to apps/meteor/server/lib/2fa/code/index.ts index 956688e617566..2544142ada820 100644 --- a/apps/meteor/app/2fa/server/code/index.ts +++ b/apps/meteor/server/lib/2fa/code/index.ts @@ -9,8 +9,8 @@ import { EmailCheck } from './EmailCheck'; import type { ICodeCheck } from './ICodeCheck'; import { PasswordCheckFallback } from './PasswordCheckFallback'; import { TOTPCheck } from './TOTPCheck'; -import { normalizeHeaders } from '../../../../server/lib/shared/getModifiedHttpHeaders'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { normalizeHeaders } from '../../shared/getModifiedHttpHeaders'; export interface ITwoFactorOptions { disablePasswordFallback?: boolean; diff --git a/apps/meteor/app/2fa/server/definitions/MeteorUser.d.ts b/apps/meteor/server/lib/2fa/definitions/MeteorUser.d.ts similarity index 100% rename from apps/meteor/app/2fa/server/definitions/MeteorUser.d.ts rename to apps/meteor/server/lib/2fa/definitions/MeteorUser.d.ts diff --git a/apps/meteor/app/2fa/server/functions/resetTOTP.ts b/apps/meteor/server/lib/2fa/functions/resetTOTP.ts similarity index 86% rename from apps/meteor/app/2fa/server/functions/resetTOTP.ts rename to apps/meteor/server/lib/2fa/functions/resetTOTP.ts index bbffd70e6e8d8..76b48c5550c72 100644 --- a/apps/meteor/app/2fa/server/functions/resetTOTP.ts +++ b/apps/meteor/server/lib/2fa/functions/resetTOTP.ts @@ -2,11 +2,11 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { i18n } from '../../../../server/lib/i18n'; -import { isUserIdFederated } from '../../../../server/lib/isUserIdFederated'; -import { notifyOnUserChange } from '../../../lib/server/lib/notifyListener'; -import * as Mailer from '../../../mailer/server/api'; -import { settings } from '../../../settings/server'; +import { notifyOnUserChange } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { i18n } from '../../i18n'; +import { isUserIdFederated } from '../../isUserIdFederated'; +import * as Mailer from '../../notifications/email/api'; const sendResetNotification = async function (uid: string): Promise { const user = await Users.findOneById>(uid, { diff --git a/apps/meteor/app/2fa/server/lib/totp.ts b/apps/meteor/server/lib/2fa/lib/totp.ts similarity index 96% rename from apps/meteor/app/2fa/server/lib/totp.ts rename to apps/meteor/server/lib/2fa/lib/totp.ts index 87a4c39ac2518..d4cd2a9ab0b36 100644 --- a/apps/meteor/app/2fa/server/lib/totp.ts +++ b/apps/meteor/server/lib/2fa/lib/totp.ts @@ -3,7 +3,7 @@ import { Random } from '@rocket.chat/random'; import { SHA256 } from '@rocket.chat/sha256'; import speakeasy from 'speakeasy'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; export const TOTP = { generateSecret(): speakeasy.GeneratedSecret { diff --git a/apps/meteor/app/2fa/server/loginHandler.ts b/apps/meteor/server/lib/2fa/loginHandler.ts similarity index 95% rename from apps/meteor/app/2fa/server/loginHandler.ts rename to apps/meteor/server/lib/2fa/loginHandler.ts index 772e3cff93696..4b1742e208b1a 100644 --- a/apps/meteor/app/2fa/server/loginHandler.ts +++ b/apps/meteor/server/lib/2fa/loginHandler.ts @@ -3,8 +3,8 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { OAuth } from 'meteor/oauth'; -import { checkCodeForUser } from './code/index'; -import { callbacks } from '../../../server/lib/callbacks'; +import { checkCodeForUser } from './code'; +import { callbacks } from '../callbacks'; const isMeteorError = (error: any): error is Meteor.Error => { return error?.meteorError !== undefined; diff --git a/apps/meteor/app/2fa/server/twoFactorRequired.ts b/apps/meteor/server/lib/2fa/twoFactorRequired.ts similarity index 93% rename from apps/meteor/app/2fa/server/twoFactorRequired.ts rename to apps/meteor/server/lib/2fa/twoFactorRequired.ts index c89c21ff47b31..007de8ae50fd2 100644 --- a/apps/meteor/app/2fa/server/twoFactorRequired.ts +++ b/apps/meteor/server/lib/2fa/twoFactorRequired.ts @@ -1,7 +1,7 @@ import { Meteor } from 'meteor/meteor'; -import type { ITwoFactorOptions } from './code/index'; -import { checkCodeForUser } from './code/index'; +import type { ITwoFactorOptions } from './code'; +import { checkCodeForUser } from './code'; export type AuthenticatedContext = { userId: string; diff --git a/apps/meteor/app/apple/server/AppleCustomOAuth.ts b/apps/meteor/server/lib/auth-providers/apple/AppleCustomOAuth.ts similarity index 82% rename from apps/meteor/app/apple/server/AppleCustomOAuth.ts rename to apps/meteor/server/lib/auth-providers/apple/AppleCustomOAuth.ts index ac43edf1e3254..2ea47ca7544be 100644 --- a/apps/meteor/app/apple/server/AppleCustomOAuth.ts +++ b/apps/meteor/server/lib/auth-providers/apple/AppleCustomOAuth.ts @@ -1,9 +1,9 @@ import { MeteorError } from '@rocket.chat/core-services'; import { Accounts } from 'meteor/accounts-base'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; -import { handleIdentityToken } from '../lib/handleIdentityToken'; +import { handleIdentityToken } from '../../../../app/apple/lib/handleIdentityToken'; +import { settings } from '../../../../app/settings/server'; +import { CustomOAuth } from '../custom-oauth/custom_oauth_server'; export class AppleCustomOAuth extends CustomOAuth { override async getIdentity(_accessToken: string, query: Record): Promise { diff --git a/apps/meteor/app/apple/server/appleOauthRegisterService.ts b/apps/meteor/server/lib/auth-providers/apple/appleOauthRegisterService.ts similarity index 96% rename from apps/meteor/app/apple/server/appleOauthRegisterService.ts rename to apps/meteor/server/lib/auth-providers/apple/appleOauthRegisterService.ts index f236b9598b23f..026aa1f4556f0 100644 --- a/apps/meteor/app/apple/server/appleOauthRegisterService.ts +++ b/apps/meteor/server/lib/auth-providers/apple/appleOauthRegisterService.ts @@ -3,8 +3,8 @@ import { createPrivateKey, sign } from 'node:crypto'; import { ServiceConfiguration } from 'meteor/service-configuration'; import { AppleCustomOAuth } from './AppleCustomOAuth'; -import { settings } from '../../settings/server'; -import { config } from '../lib/config'; +import { config } from '../../../../app/apple/lib/config'; +import { settings } from '../../../../app/settings/server'; new AppleCustomOAuth('apple', config); diff --git a/apps/meteor/app/apple/server/applePassportOAuth.ts b/apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.ts similarity index 91% rename from apps/meteor/app/apple/server/applePassportOAuth.ts rename to apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.ts index 483062ba379d8..f8a4cce3386da 100644 --- a/apps/meteor/app/apple/server/applePassportOAuth.ts +++ b/apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.ts @@ -8,12 +8,12 @@ import { Strategy as AppleStrategy } from 'passport-apple'; import type { Profile } from 'passport-apple'; import { AppleCustomOAuth } from './AppleCustomOAuth'; -import { oAuthRouter } from '../../../server/configuration/configurePassport'; -import { allowPassportOAuthMiddleware } from '../../../server/lib/oauth/allowPassportOAuthMiddleware'; -import { passportOAuthCallback } from '../../../server/lib/oauth/passportOAuthCallback'; -import { settings } from '../../settings/server'; -import { config } from '../lib/config'; -import { handleIdentityToken } from '../lib/handleIdentityToken'; +import { config } from '../../../../app/apple/lib/config'; +import { handleIdentityToken } from '../../../../app/apple/lib/handleIdentityToken'; +import { settings } from '../../../../app/settings/server'; +import { oAuthRouter } from '../../../configuration/configurePassport'; +import { allowPassportOAuthMiddleware } from '../../oauth/allowPassportOAuthMiddleware'; +import { passportOAuthCallback } from '../../oauth/passportOAuthCallback'; new AppleCustomOAuth('apple', config); diff --git a/apps/meteor/app/apple/server/loginHandler.spec.ts b/apps/meteor/server/lib/auth-providers/apple/loginHandler.spec.ts similarity index 92% rename from apps/meteor/app/apple/server/loginHandler.spec.ts rename to apps/meteor/server/lib/auth-providers/apple/loginHandler.spec.ts index ffa50a952d4cf..1f5f507ecf3f0 100644 --- a/apps/meteor/app/apple/server/loginHandler.spec.ts +++ b/apps/meteor/server/lib/auth-providers/apple/loginHandler.spec.ts @@ -1,7 +1,7 @@ import { Accounts } from 'meteor/accounts-base'; -import { settings } from '../../settings/server'; -import { handleIdentityToken } from '../lib/handleIdentityToken'; +import { handleIdentityToken } from '../../../../app/apple/lib/handleIdentityToken'; +import { settings } from '../../../../app/settings/server'; jest.mock( 'meteor/accounts-base', @@ -32,13 +32,13 @@ jest.mock( { virtual: true }, ); -jest.mock('../../settings/server', () => ({ +jest.mock('../../../../app/settings/server', () => ({ settings: { get: jest.fn(), }, })); -jest.mock('../lib/handleIdentityToken', () => ({ +jest.mock('../../../../app/apple/lib/handleIdentityToken', () => ({ handleIdentityToken: jest.fn(), })); diff --git a/apps/meteor/app/apple/server/loginHandler.ts b/apps/meteor/server/lib/auth-providers/apple/loginHandler.ts similarity index 88% rename from apps/meteor/app/apple/server/loginHandler.ts rename to apps/meteor/server/lib/auth-providers/apple/loginHandler.ts index 96ccd53323b32..0a370b4be814a 100644 --- a/apps/meteor/app/apple/server/loginHandler.ts +++ b/apps/meteor/server/lib/auth-providers/apple/loginHandler.ts @@ -1,8 +1,8 @@ import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; -import { settings } from '../../settings/server'; -import { handleIdentityToken } from '../lib/handleIdentityToken'; +import { handleIdentityToken } from '../../../../app/apple/lib/handleIdentityToken'; +import { settings } from '../../../../app/settings/server'; Accounts.registerLoginHandler('apple', async (loginRequest) => { if (!loginRequest.identityToken) { diff --git a/apps/meteor/app/crowd/server/crowd.ts b/apps/meteor/server/lib/auth-providers/crowd/crowd.ts similarity index 96% rename from apps/meteor/app/crowd/server/crowd.ts rename to apps/meteor/server/lib/auth-providers/crowd/crowd.ts index a28053bf00d4b..0b6d6c340a86e 100644 --- a/apps/meteor/app/crowd/server/crowd.ts +++ b/apps/meteor/server/lib/auth-providers/crowd/crowd.ts @@ -7,12 +7,12 @@ import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; import { logger } from './logger'; -import { deleteUser } from '../../../server/lib/users/deleteUser'; -import { setRealName } from '../../../server/lib/users/setRealName'; -import { setUserActiveStatus } from '../../../server/lib/users/setUserActiveStatus'; -import { crowdIntervalValuesToCronMap } from '../../../server/settings/crowd'; -import { notifyOnUserChange, notifyOnUserChangeById, notifyOnUserChangeAsync } from '../../lib/server/lib/notifyListener'; -import { settings } from '../../settings/server'; +import { notifyOnUserChange, notifyOnUserChangeById, notifyOnUserChangeAsync } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { crowdIntervalValuesToCronMap } from '../../../settings/crowd'; +import { deleteUser } from '../../users/deleteUser'; +import { setRealName } from '../../users/setRealName'; +import { setUserActiveStatus } from '../../users/setUserActiveStatus'; type CrowdUser = Pick & { crowd: Record; crowd_username: string }; diff --git a/apps/meteor/app/crowd/server/logger.ts b/apps/meteor/server/lib/auth-providers/crowd/logger.ts similarity index 100% rename from apps/meteor/app/crowd/server/logger.ts rename to apps/meteor/server/lib/auth-providers/crowd/logger.ts diff --git a/apps/meteor/app/custom-oauth/server/customOAuth.ts b/apps/meteor/server/lib/auth-providers/custom-oauth/customOAuth.ts similarity index 97% rename from apps/meteor/app/custom-oauth/server/customOAuth.ts rename to apps/meteor/server/lib/auth-providers/custom-oauth/customOAuth.ts index 988018518cfdf..f540de50a0c49 100644 --- a/apps/meteor/app/custom-oauth/server/customOAuth.ts +++ b/apps/meteor/server/lib/auth-providers/custom-oauth/customOAuth.ts @@ -10,11 +10,11 @@ import type { VerifyFunction, StrategyOptions } from 'passport-oauth2'; import { Strategy } from 'passport-oauth2'; import { normalizers, fromTemplate, renameInvalidProperties } from './transform_helpers'; -import { client } from '../../../server/database/utils'; -import { callbacks } from '../../../server/lib/callbacks'; -import { saveUserIdentity } from '../../../server/lib/users/saveUserIdentity'; -import { notifyOnUserChange } from '../../lib/server/lib/notifyListener'; -import { settings } from '../../settings/server/cached'; +import { notifyOnUserChange } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server/cached'; +import { client } from '../../../database/utils'; +import { callbacks } from '../../callbacks'; +import { saveUserIdentity } from '../../users/saveUserIdentity'; const logger = new Logger('CustomOAuth'); const BeforeUpdateOrCreateUserFromExternalService = new Map< diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.d.ts b/apps/meteor/server/lib/auth-providers/custom-oauth/custom_oauth_server.d.ts similarity index 100% rename from apps/meteor/app/custom-oauth/server/custom_oauth_server.d.ts rename to apps/meteor/server/lib/auth-providers/custom-oauth/custom_oauth_server.d.ts diff --git a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js b/apps/meteor/server/lib/auth-providers/custom-oauth/custom_oauth_server.js similarity index 97% rename from apps/meteor/app/custom-oauth/server/custom_oauth_server.js rename to apps/meteor/server/lib/auth-providers/custom-oauth/custom_oauth_server.js index bade47d8cc1b3..12d7a85e32486 100644 --- a/apps/meteor/app/custom-oauth/server/custom_oauth_server.js +++ b/apps/meteor/server/lib/auth-providers/custom-oauth/custom_oauth_server.js @@ -11,12 +11,12 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import _ from 'underscore'; import { normalizers, fromTemplate, renameInvalidProperties } from './transform_helpers'; -import { client } from '../../../server/database/utils'; -import { callbacks } from '../../../server/lib/callbacks'; -import { saveUserIdentity } from '../../../server/lib/users/saveUserIdentity'; -import { notifyOnUserChange } from '../../lib/server/lib/notifyListener'; -import { registerAccessTokenService } from '../../lib/server/oauth/oauth'; -import { settings } from '../../settings/server'; +import { notifyOnUserChange } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { client } from '../../../database/utils'; +import { callbacks } from '../../callbacks'; +import { saveUserIdentity } from '../../users/saveUserIdentity'; +import { registerAccessTokenService } from '../oauth/oauth'; const logger = new Logger('CustomOAuth'); diff --git a/apps/meteor/app/custom-oauth/server/transform_helpers.js b/apps/meteor/server/lib/auth-providers/custom-oauth/transform_helpers.js similarity index 98% rename from apps/meteor/app/custom-oauth/server/transform_helpers.js rename to apps/meteor/server/lib/auth-providers/custom-oauth/transform_helpers.js index ded142bf1e241..7f794bf5e8a2c 100644 --- a/apps/meteor/app/custom-oauth/server/transform_helpers.js +++ b/apps/meteor/server/lib/auth-providers/custom-oauth/transform_helpers.js @@ -1,4 +1,4 @@ -import { isObject } from '../../../lib/utils/isObject'; +import { isObject } from '../../../../lib/utils/isObject'; export const normalizers = { // Set 'id' to '_id' for any sources that provide it diff --git a/apps/meteor/app/dolphin/server/lib.ts b/apps/meteor/server/lib/auth-providers/dolphin.ts similarity index 87% rename from apps/meteor/app/dolphin/server/lib.ts rename to apps/meteor/server/lib/auth-providers/dolphin.ts index 04f2f76782e1e..8b3d41168daf0 100644 --- a/apps/meteor/app/dolphin/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/dolphin.ts @@ -4,11 +4,11 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import passport from 'passport'; import _ from 'underscore'; -import { callbacks } from '../../../server/lib/callbacks'; -import { beforeCreateUserCallback } from '../../../server/lib/callbacks/beforeCreateUserCallback'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; +import { callbacks } from '../callbacks'; +import { beforeCreateUserCallback } from '../callbacks/beforeCreateUserCallback'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; +import { settings } from '../../../app/settings/server'; const config: Partial = { serverURL: '', diff --git a/apps/meteor/app/drupal/server/lib.ts b/apps/meteor/server/lib/auth-providers/drupal.ts similarity index 88% rename from apps/meteor/app/drupal/server/lib.ts rename to apps/meteor/server/lib/auth-providers/drupal.ts index dffa2ac41638b..f781fbe7b9d0a 100644 --- a/apps/meteor/app/drupal/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/drupal.ts @@ -3,9 +3,9 @@ import { Meteor } from 'meteor/meteor'; import passport from 'passport'; import _ from 'underscore'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; +import { settings } from '../../../app/settings/server'; const config: Partial = { serverURL: '', diff --git a/apps/meteor/app/github-enterprise/server/lib.ts b/apps/meteor/server/lib/auth-providers/github-enterprise.ts similarity index 87% rename from apps/meteor/app/github-enterprise/server/lib.ts rename to apps/meteor/server/lib/auth-providers/github-enterprise.ts index b4f67a1c3a50f..9a0c4db27bfb2 100644 --- a/apps/meteor/app/github-enterprise/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/github-enterprise.ts @@ -1,8 +1,8 @@ import type { OauthConfig } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; +import { settings } from '../../../app/settings/server'; // GitHub Enterprise Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/github_enterprise // In RocketChat -> Administration the URL needs to be http(s)://{github.enterprise.server}/ diff --git a/apps/meteor/app/github/server/lib.ts b/apps/meteor/server/lib/auth-providers/github.ts similarity index 88% rename from apps/meteor/app/github/server/lib.ts rename to apps/meteor/server/lib/auth-providers/github.ts index 5409f7a809803..441c8e696b449 100644 --- a/apps/meteor/app/github/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/github.ts @@ -1,6 +1,6 @@ import type { OauthConfig } from '@rocket.chat/core-typings'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; const config: OauthConfig = { serverURL: 'https://github.com', diff --git a/apps/meteor/app/gitlab/server/lib.ts b/apps/meteor/server/lib/auth-providers/gitlab.ts similarity index 89% rename from apps/meteor/app/gitlab/server/lib.ts rename to apps/meteor/server/lib/auth-providers/gitlab.ts index 27b54517e55fe..ba6189e6d37c6 100644 --- a/apps/meteor/app/gitlab/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/gitlab.ts @@ -3,9 +3,9 @@ import { Meteor } from 'meteor/meteor'; import passport from 'passport'; import _ from 'underscore'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; +import { settings } from '../../../app/settings/server'; const config: Partial = { serverURL: 'https://gitlab.com', diff --git a/apps/meteor/app/google-oauth/server/index.js b/apps/meteor/server/lib/auth-providers/google.js similarity index 100% rename from apps/meteor/app/google-oauth/server/index.js rename to apps/meteor/server/lib/auth-providers/google.js diff --git a/apps/meteor/app/iframe-login/server/iframe_server.ts b/apps/meteor/server/lib/auth-providers/iframe.ts similarity index 100% rename from apps/meteor/app/iframe-login/server/iframe_server.ts rename to apps/meteor/server/lib/auth-providers/iframe.ts diff --git a/apps/meteor/app/linkedin/server/lib.ts b/apps/meteor/server/lib/auth-providers/linkedin.ts similarity index 89% rename from apps/meteor/app/linkedin/server/lib.ts rename to apps/meteor/server/lib/auth-providers/linkedin.ts index 6fb0d450d2fda..46dadddb46e7d 100644 --- a/apps/meteor/app/linkedin/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/linkedin.ts @@ -2,8 +2,8 @@ import type { OAuthConfiguration } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import passport from 'passport'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; const config: Partial = { serverURL: 'https://www.linkedin.com', diff --git a/apps/meteor/app/meteor-developer/server/lib.ts b/apps/meteor/server/lib/auth-providers/meteor-developer.ts similarity index 89% rename from apps/meteor/app/meteor-developer/server/lib.ts rename to apps/meteor/server/lib/auth-providers/meteor-developer.ts index 8a77b47235a25..beb56362743d9 100644 --- a/apps/meteor/app/meteor-developer/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/meteor-developer.ts @@ -2,8 +2,8 @@ import type { OAuthConfiguration } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import passport from 'passport'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; const config: Partial = { serverURL: 'https://www.meteor.com', diff --git a/apps/meteor/app/lib/server/oauth/facebook.js b/apps/meteor/server/lib/auth-providers/oauth/facebook.js similarity index 100% rename from apps/meteor/app/lib/server/oauth/facebook.js rename to apps/meteor/server/lib/auth-providers/oauth/facebook.js diff --git a/apps/meteor/app/lib/server/oauth/google.js b/apps/meteor/server/lib/auth-providers/oauth/google.js similarity index 100% rename from apps/meteor/app/lib/server/oauth/google.js rename to apps/meteor/server/lib/auth-providers/oauth/google.js diff --git a/apps/meteor/app/lib/server/oauth/oauth.js b/apps/meteor/server/lib/auth-providers/oauth/oauth.js similarity index 100% rename from apps/meteor/app/lib/server/oauth/oauth.js rename to apps/meteor/server/lib/auth-providers/oauth/oauth.js diff --git a/apps/meteor/app/lib/server/oauth/proxy.js b/apps/meteor/server/lib/auth-providers/oauth/proxy.js similarity index 86% rename from apps/meteor/app/lib/server/oauth/proxy.js rename to apps/meteor/server/lib/auth-providers/oauth/proxy.js index c66143d8b029d..6d91766fe21e9 100644 --- a/apps/meteor/app/lib/server/oauth/proxy.js +++ b/apps/meteor/server/lib/auth-providers/oauth/proxy.js @@ -1,7 +1,7 @@ import { OAuth } from 'meteor/oauth'; import _ from 'underscore'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; OAuth._redirectUri = _.wrap(OAuth._redirectUri, (func, serviceName, ...args) => { const proxy = settings.get('Accounts_OAuth_Proxy_services').replace(/\s/g, '').split(','); diff --git a/apps/meteor/app/lib/server/oauth/twitter.js b/apps/meteor/server/lib/auth-providers/oauth/twitter.js similarity index 100% rename from apps/meteor/app/lib/server/oauth/twitter.js rename to apps/meteor/server/lib/auth-providers/oauth/twitter.js diff --git a/apps/meteor/app/wordpress/server/lib.ts b/apps/meteor/server/lib/auth-providers/wordpress.ts similarity index 93% rename from apps/meteor/app/wordpress/server/lib.ts rename to apps/meteor/server/lib/auth-providers/wordpress.ts index bf2fcc3e02a32..136f4632fdc19 100644 --- a/apps/meteor/app/wordpress/server/lib.ts +++ b/apps/meteor/server/lib/auth-providers/wordpress.ts @@ -4,9 +4,9 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import passport from 'passport'; import _ from 'underscore'; -import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; -import { settings } from '../../settings/server'; +import { addPassportCustomOAuth } from '../oauth/addPassportCustomOAuth'; +import { CustomOAuth } from './custom-oauth/custom_oauth_server'; +import { settings } from '../../../app/settings/server'; const config: Partial = { serverURL: '', diff --git a/apps/meteor/app/authentication/server/ILoginAttempt.ts b/apps/meteor/server/lib/auth/ILoginAttempt.ts similarity index 100% rename from apps/meteor/app/authentication/server/ILoginAttempt.ts rename to apps/meteor/server/lib/auth/ILoginAttempt.ts diff --git a/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts b/apps/meteor/server/lib/auth/logLoginAttempts.ts similarity index 83% rename from apps/meteor/app/authentication/server/lib/logLoginAttempts.ts rename to apps/meteor/server/lib/auth/logLoginAttempts.ts index 3c50937599063..93807e1c83357 100644 --- a/apps/meteor/app/authentication/server/lib/logLoginAttempts.ts +++ b/apps/meteor/server/lib/auth/logLoginAttempts.ts @@ -1,6 +1,6 @@ -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { settings } from '../../../settings/server'; -import type { ILoginAttempt } from '../ILoginAttempt'; +import type { ILoginAttempt } from './ILoginAttempt'; +import { settings } from '../../../app/settings/server'; +import { SystemLogger } from '../logger/system'; export const logFailedLoginAttempts = (login: ILoginAttempt): void => { if (!settings.get('Login_Logs_Enabled')) { diff --git a/apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts b/apps/meteor/server/lib/auth/restrictLoginAttempts.ts similarity index 94% rename from apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts rename to apps/meteor/server/lib/auth/restrictLoginAttempts.ts index b2d8918d61632..58c3a4d42698f 100644 --- a/apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts +++ b/apps/meteor/server/lib/auth/restrictLoginAttempts.ts @@ -3,11 +3,11 @@ import { ServerEventType } from '@rocket.chat/core-typings'; import { Logger } from '@rocket.chat/logger'; import { Rooms, ServerEvents, Users } from '@rocket.chat/models'; -import { addMinutesToADate } from '../../../../lib/utils/addMinutesToADate'; -import { getClientAddress } from '../../../../server/lib/getClientAddress'; -import { sendMessage } from '../../../../server/lib/messages/sendMessage'; -import { settings } from '../../../settings/server'; -import type { ILoginAttempt } from '../ILoginAttempt'; +import { settings } from '../../../app/settings/server'; +import { addMinutesToADate } from '../../../lib/utils/addMinutesToADate'; +import { getClientAddress } from '../getClientAddress'; +import type { ILoginAttempt } from './ILoginAttempt'; +import { sendMessage } from '../messages/sendMessage'; const logger = new Logger('LoginProtection'); diff --git a/apps/meteor/app/authentication/server/startup/index.js b/apps/meteor/server/lib/auth/startup.js similarity index 92% rename from apps/meteor/app/authentication/server/startup/index.js rename to apps/meteor/server/lib/auth/startup.js index 4ce510573e464..3bb94ad43763c 100644 --- a/apps/meteor/app/authentication/server/startup/index.js +++ b/apps/meteor/server/lib/auth/startup.js @@ -8,23 +8,23 @@ import { Match } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import _ from 'underscore'; -import { parseCSV } from '../../../../lib/utils/parseCSV'; -import { safeHtmlDots } from '../../../../lib/utils/safeHtmlDots'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { beforeCreateUserCallback } from '../../../../server/lib/callbacks/beforeCreateUserCallback'; -import { getClientAddress } from '../../../../server/lib/getClientAddress'; -import { getMaxLoginTokens } from '../../../../server/lib/getMaxLoginTokens'; -import { i18n } from '../../../../server/lib/i18n'; -import { addUserRolesAsync } from '../../../../server/lib/roles/addUserRoles'; -import { joinDefaultChannels } from '../../../../server/lib/rooms/joinDefaultChannels'; -import { getAvatarSuggestionForUser } from '../../../../server/lib/users/getAvatarSuggestionForUser'; -import { setAvatarFromServiceWithValidation } from '../../../../server/lib/users/setUserAvatar'; -import { getNewUserRoles } from '../../../../server/services/user/lib/getNewUserRoles'; -import { notifyOnSettingChangedById } from '../../../lib/server/lib/notifyListener'; -import * as Mailer from '../../../mailer/server/api'; -import { settings } from '../../../settings/server'; -import { getBaseUserFields } from '../../../utils/server/functions/getBaseUserFields'; -import { isValidAttemptByUser, isValidLoginAttemptByIp } from '../lib/restrictLoginAttempts'; +import { isValidAttemptByUser, isValidLoginAttemptByIp } from './restrictLoginAttempts'; +import { notifyOnSettingChangedById } from '../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../app/settings/server'; +import { getBaseUserFields } from '../../../app/utils/server/functions/getBaseUserFields'; +import { parseCSV } from '../../../lib/utils/parseCSV'; +import { safeHtmlDots } from '../../../lib/utils/safeHtmlDots'; +import { getNewUserRoles } from '../../services/user/lib/getNewUserRoles'; +import { callbacks } from '../callbacks'; +import { beforeCreateUserCallback } from '../callbacks/beforeCreateUserCallback'; +import { getClientAddress } from '../getClientAddress'; +import { getMaxLoginTokens } from '../getMaxLoginTokens'; +import { i18n } from '../i18n'; +import * as Mailer from '../notifications/email/api'; +import { addUserRolesAsync } from '../roles/addUserRoles'; +import { joinDefaultChannels } from '../rooms/joinDefaultChannels'; +import { getAvatarSuggestionForUser } from '../users/getAvatarSuggestionForUser'; +import { setAvatarFromServiceWithValidation } from '../users/setUserAvatar'; Accounts.config({ forbidClientAccountCreation: true, diff --git a/apps/meteor/app/token-login/server/login_token_server.js b/apps/meteor/server/lib/auth/token-login.js similarity index 100% rename from apps/meteor/app/token-login/server/login_token_server.js rename to apps/meteor/server/lib/auth/token-login.js diff --git a/apps/meteor/app/autotranslate/server/autotranslate.ts b/apps/meteor/server/lib/autotranslate/autotranslate.ts similarity index 97% rename from apps/meteor/app/autotranslate/server/autotranslate.ts rename to apps/meteor/server/lib/autotranslate/autotranslate.ts index 2f91e02463d58..8a9c8493dbb49 100644 --- a/apps/meteor/app/autotranslate/server/autotranslate.ts +++ b/apps/meteor/server/lib/autotranslate/autotranslate.ts @@ -13,10 +13,10 @@ import { isTruthy } from '@rocket.chat/tools'; import { Meteor } from 'meteor/meteor'; import _ from 'underscore'; -import { callbacks } from '../../../server/lib/callbacks'; -import { notifyOnMessageChange } from '../../lib/server/lib/notifyListener'; -import { Markdown } from '../../markdown/server'; -import { settings } from '../../settings/server'; +import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../app/settings/server'; +import { callbacks } from '../callbacks'; +import { Markdown } from '../messaging/markdown'; const translationLogger = new Logger('AutoTranslate'); diff --git a/apps/meteor/app/autotranslate/server/deeplTranslate.ts b/apps/meteor/server/lib/autotranslate/deeplTranslate.ts similarity index 97% rename from apps/meteor/app/autotranslate/server/deeplTranslate.ts rename to apps/meteor/server/lib/autotranslate/deeplTranslate.ts index d76a7ea2e4901..0ad7314538750 100644 --- a/apps/meteor/app/autotranslate/server/deeplTranslate.ts +++ b/apps/meteor/server/lib/autotranslate/deeplTranslate.ts @@ -7,9 +7,9 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import _ from 'underscore'; import { TranslationProviderRegistry, AutoTranslate } from './autotranslate'; -import { i18n } from '../../../server/lib/i18n'; -import { SystemLogger } from '../../../server/lib/logger/system'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { i18n } from '../i18n'; +import { SystemLogger } from '../logger/system'; const proApiEndpoint = 'https://api.deepl.com/v2/translate'; const freeApiEndpoint = 'https://api-free.deepl.com/v2/translate'; diff --git a/apps/meteor/app/autotranslate/server/functions/getSupportedLanguages.ts b/apps/meteor/server/lib/autotranslate/functions/getSupportedLanguages.ts similarity index 74% rename from apps/meteor/app/autotranslate/server/functions/getSupportedLanguages.ts rename to apps/meteor/server/lib/autotranslate/functions/getSupportedLanguages.ts index 68e1c200480d1..b5b99e32f5839 100644 --- a/apps/meteor/app/autotranslate/server/functions/getSupportedLanguages.ts +++ b/apps/meteor/server/lib/autotranslate/functions/getSupportedLanguages.ts @@ -1,8 +1,8 @@ import { Meteor } from 'meteor/meteor'; -import { TranslationProviderRegistry } from '..'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; +import { TranslationProviderRegistry } from '../index'; export const getSupportedLanguages = async (userId: string, targetLanguage: string) => { if (!settings.get('AutoTranslate_Enabled')) { diff --git a/apps/meteor/app/autotranslate/server/functions/saveSettings.ts b/apps/meteor/server/lib/autotranslate/functions/saveSettings.ts similarity index 92% rename from apps/meteor/app/autotranslate/server/functions/saveSettings.ts rename to apps/meteor/server/lib/autotranslate/functions/saveSettings.ts index 91fd9a7c367fb..453de45a737d7 100644 --- a/apps/meteor/app/autotranslate/server/functions/saveSettings.ts +++ b/apps/meteor/server/lib/autotranslate/functions/saveSettings.ts @@ -2,8 +2,8 @@ import { Subscriptions, Rooms } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { notifyOnSubscriptionChangedById } from '../../../lib/server/lib/notifyListener'; +import { notifyOnSubscriptionChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; export const saveAutoTranslateSettings = async ( userId: string, diff --git a/apps/meteor/app/autotranslate/server/functions/translateMessage.ts b/apps/meteor/server/lib/autotranslate/functions/translateMessage.ts similarity index 91% rename from apps/meteor/app/autotranslate/server/functions/translateMessage.ts rename to apps/meteor/server/lib/autotranslate/functions/translateMessage.ts index 8c0545369dcca..c7c8e79c873ae 100644 --- a/apps/meteor/app/autotranslate/server/functions/translateMessage.ts +++ b/apps/meteor/server/lib/autotranslate/functions/translateMessage.ts @@ -1,7 +1,7 @@ import type { IMessage } from '@rocket.chat/core-typings'; import { Rooms } from '@rocket.chat/models'; -import { TranslationProviderRegistry } from '..'; +import { TranslationProviderRegistry } from '../index'; export const translateMessage = async (targetLanguage?: string, message?: IMessage) => { if (!TranslationProviderRegistry.enabled) { diff --git a/apps/meteor/app/autotranslate/server/googleTranslate.ts b/apps/meteor/server/lib/autotranslate/googleTranslate.ts similarity index 97% rename from apps/meteor/app/autotranslate/server/googleTranslate.ts rename to apps/meteor/server/lib/autotranslate/googleTranslate.ts index 9667ae53c967a..4c78579acbe41 100644 --- a/apps/meteor/app/autotranslate/server/googleTranslate.ts +++ b/apps/meteor/server/lib/autotranslate/googleTranslate.ts @@ -7,9 +7,9 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import _ from 'underscore'; import { AutoTranslate, TranslationProviderRegistry } from './autotranslate'; -import { i18n } from '../../../server/lib/i18n'; -import { SystemLogger } from '../../../server/lib/logger/system'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { i18n } from '../i18n'; +import { SystemLogger } from '../logger/system'; interface IGoogleTranslation { translatedText: string; diff --git a/apps/meteor/app/autotranslate/server/index.ts b/apps/meteor/server/lib/autotranslate/index.ts similarity index 100% rename from apps/meteor/app/autotranslate/server/index.ts rename to apps/meteor/server/lib/autotranslate/index.ts diff --git a/apps/meteor/app/autotranslate/server/libreTranslate.ts b/apps/meteor/server/lib/autotranslate/libreTranslate.ts similarity index 98% rename from apps/meteor/app/autotranslate/server/libreTranslate.ts rename to apps/meteor/server/lib/autotranslate/libreTranslate.ts index fd0134240b5df..dce4a0383303b 100644 --- a/apps/meteor/app/autotranslate/server/libreTranslate.ts +++ b/apps/meteor/server/lib/autotranslate/libreTranslate.ts @@ -3,8 +3,8 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { TranslationProviderRegistry, AutoTranslate } from './autotranslate'; import { libreLogger } from './logger'; -import { i18n } from '../../../server/lib/i18n'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { i18n } from '../i18n'; interface ILibreTranslateLanguage { code: string; diff --git a/apps/meteor/app/autotranslate/server/logger.ts b/apps/meteor/server/lib/autotranslate/logger.ts similarity index 100% rename from apps/meteor/app/autotranslate/server/logger.ts rename to apps/meteor/server/lib/autotranslate/logger.ts diff --git a/apps/meteor/app/autotranslate/server/msTranslate.ts b/apps/meteor/server/lib/autotranslate/msTranslate.ts similarity index 98% rename from apps/meteor/app/autotranslate/server/msTranslate.ts rename to apps/meteor/server/lib/autotranslate/msTranslate.ts index ddb345d3c895a..9c8a4a54c9ce9 100644 --- a/apps/meteor/app/autotranslate/server/msTranslate.ts +++ b/apps/meteor/server/lib/autotranslate/msTranslate.ts @@ -8,8 +8,8 @@ import _ from 'underscore'; import { TranslationProviderRegistry, AutoTranslate } from './autotranslate'; import { msLogger } from './logger'; -import { i18n } from '../../../server/lib/i18n'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { i18n } from '../i18n'; /** * Microsoft translation service provider class representation. diff --git a/apps/meteor/app/autotranslate/server/permissions.ts b/apps/meteor/server/lib/autotranslate/permissions.ts similarity index 100% rename from apps/meteor/app/autotranslate/server/permissions.ts rename to apps/meteor/server/lib/autotranslate/permissions.ts diff --git a/apps/meteor/server/lib/callbacks.ts b/apps/meteor/server/lib/callbacks.ts index cd535365a848e..c04590bb3214a 100644 --- a/apps/meteor/server/lib/callbacks.ts +++ b/apps/meteor/server/lib/callbacks.ts @@ -22,9 +22,9 @@ import type { import type { Updater } from '@rocket.chat/models'; import type { FilterOperators } from 'mongodb'; +import type { ILoginAttempt } from './auth/ILoginAttempt'; import { Callbacks } from './callbacks/callbacksBase'; import type { SendMessageOptions } from './messages/sendMessage'; -import type { ILoginAttempt } from '../../app/authentication/server/ILoginAttempt'; import type { IBusinessHourBehavior } from '../../app/livechat/server/business-hour/AbstractBusinessHour'; import type { CloseRoomParams } from '../../app/livechat/server/lib/localTypes'; diff --git a/apps/meteor/server/lib/cloud/buildRegistrationData.ts b/apps/meteor/server/lib/cloud/buildRegistrationData.ts index d5e7bb00d37bd..63c2fe3471b2c 100644 --- a/apps/meteor/server/lib/cloud/buildRegistrationData.ts +++ b/apps/meteor/server/lib/cloud/buildRegistrationData.ts @@ -1,10 +1,10 @@ import { LivechatContacts, Statistics, Users } from '@rocket.chat/models'; import moment from 'moment'; -import { LICENSE_VERSION } from '../../../app/cloud/server/license'; +import { LICENSE_VERSION } from './license'; import { settings } from '../../../app/settings/server'; -import { statistics } from '../../../app/statistics/server'; import { Info } from '../../../app/utils/rocketchat.info'; +import { statistics } from '../statistics'; export type WorkspaceRegistrationData = { uniqueId: string; diff --git a/apps/meteor/server/lib/cloud/finishOAuthAuthorization.ts b/apps/meteor/server/lib/cloud/finishOAuthAuthorization.ts index 261f7763dfed0..784e827ba2f6a 100644 --- a/apps/meteor/server/lib/cloud/finishOAuthAuthorization.ts +++ b/apps/meteor/server/lib/cloud/finishOAuthAuthorization.ts @@ -3,7 +3,7 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { Meteor } from 'meteor/meteor'; import { getRedirectUri } from './getRedirectUri'; -import { userScopes } from '../../../app/cloud/server/oauthScopes'; +import { userScopes } from './oauthScopes'; import { settings } from '../../../app/settings/server'; import { SystemLogger } from '../logger/system'; diff --git a/apps/meteor/server/lib/cloud/getOAuthAuthorizationUrl.ts b/apps/meteor/server/lib/cloud/getOAuthAuthorizationUrl.ts index cd261410adaab..5618a2b9cd51b 100644 --- a/apps/meteor/server/lib/cloud/getOAuthAuthorizationUrl.ts +++ b/apps/meteor/server/lib/cloud/getOAuthAuthorizationUrl.ts @@ -2,7 +2,7 @@ import { Settings } from '@rocket.chat/models'; import { Random } from '@rocket.chat/random'; import { getRedirectUri } from './getRedirectUri'; -import { userScopes } from '../../../app/cloud/server/oauthScopes'; +import { userScopes } from './oauthScopes'; import { notifyOnSettingChangedById } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; import { updateAuditedBySystem } from '../../settings/lib/auditedSettingUpdates'; diff --git a/apps/meteor/server/lib/cloud/getWorkspaceAccessToken.ts b/apps/meteor/server/lib/cloud/getWorkspaceAccessToken.ts index 7d889e3662061..e88b05319be07 100644 --- a/apps/meteor/server/lib/cloud/getWorkspaceAccessToken.ts +++ b/apps/meteor/server/lib/cloud/getWorkspaceAccessToken.ts @@ -2,8 +2,8 @@ import type { IWorkspaceCredentials } from '@rocket.chat/core-typings'; import { WorkspaceCredentials } from '@rocket.chat/models'; import { getWorkspaceAccessTokenWithScope } from './getWorkspaceAccessTokenWithScope'; +import { workspaceScopes } from './oauthScopes'; import { retrieveRegistrationStatus } from './retrieveRegistrationStatus'; -import { workspaceScopes } from '../../../app/cloud/server/oauthScopes'; import { SystemLogger } from '../logger/system'; const hasWorkspaceAccessTokenExpired = (credentials: IWorkspaceCredentials): boolean => new Date() >= credentials.expirationDate; diff --git a/apps/meteor/server/lib/cloud/getWorkspaceAccessTokenWithScope.ts b/apps/meteor/server/lib/cloud/getWorkspaceAccessTokenWithScope.ts index a693822021bf6..7c55f125db4ea 100644 --- a/apps/meteor/server/lib/cloud/getWorkspaceAccessTokenWithScope.ts +++ b/apps/meteor/server/lib/cloud/getWorkspaceAccessTokenWithScope.ts @@ -2,9 +2,9 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { getRedirectUri } from './getRedirectUri'; import { CloudWorkspaceAccessTokenError } from './getWorkspaceAccessToken'; +import { workspaceScopes } from './oauthScopes'; import { removeWorkspaceRegistrationInfo } from './removeWorkspaceRegistrationInfo'; import { retrieveRegistrationStatus } from './retrieveRegistrationStatus'; -import { workspaceScopes } from '../../../app/cloud/server/oauthScopes'; import { settings } from '../../../app/settings/server'; import { SystemLogger } from '../logger/system'; diff --git a/apps/meteor/server/lib/cloud/getWorkspaceLicense.ts b/apps/meteor/server/lib/cloud/getWorkspaceLicense.ts index 77c94bec34c9e..ec9b2b49bb7c5 100644 --- a/apps/meteor/server/lib/cloud/getWorkspaceLicense.ts +++ b/apps/meteor/server/lib/cloud/getWorkspaceLicense.ts @@ -4,7 +4,7 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import * as z from 'zod'; import { getWorkspaceAccessToken } from './getWorkspaceAccessToken'; -import { LICENSE_VERSION } from '../../../app/cloud/server/license'; +import { LICENSE_VERSION } from './license'; import { settings } from '../../../app/settings/server'; import { CloudWorkspaceConnectionError } from '../../../lib/errors/CloudWorkspaceConnectionError'; import { CloudWorkspaceLicenseError } from '../../../lib/errors/CloudWorkspaceLicenseError'; diff --git a/apps/meteor/app/cloud/server/index.ts b/apps/meteor/server/lib/cloud/index.ts similarity index 76% rename from apps/meteor/app/cloud/server/index.ts rename to apps/meteor/server/lib/cloud/index.ts index cd75bed630e4f..9650996fa518b 100644 --- a/apps/meteor/app/cloud/server/index.ts +++ b/apps/meteor/server/lib/cloud/index.ts @@ -1,13 +1,12 @@ import { cronJobs } from '@rocket.chat/cron'; import { Meteor } from 'meteor/meteor'; -import { connectWorkspace } from '../../../server/lib/cloud/connectWorkspace'; -import { CloudWorkspaceAccessTokenEmptyError, getWorkspaceAccessToken } from '../../../server/lib/cloud/getWorkspaceAccessToken'; -import { getWorkspaceAccessTokenWithScope } from '../../../server/lib/cloud/getWorkspaceAccessTokenWithScope'; -import { retrieveRegistrationStatus } from '../../../server/lib/cloud/retrieveRegistrationStatus'; -import { syncWorkspace } from '../../../server/lib/cloud/syncWorkspace'; -import { SystemLogger } from '../../../server/lib/logger/system'; -import './methods'; +import { connectWorkspace } from './connectWorkspace'; +import { CloudWorkspaceAccessTokenEmptyError, getWorkspaceAccessToken } from './getWorkspaceAccessToken'; +import { getWorkspaceAccessTokenWithScope } from './getWorkspaceAccessTokenWithScope'; +import { retrieveRegistrationStatus } from './retrieveRegistrationStatus'; +import { syncWorkspace } from './syncWorkspace'; +import { SystemLogger } from '../logger/system'; const licenseCronName = 'Cloud Workspace Sync'; diff --git a/apps/meteor/app/cloud/server/license.ts b/apps/meteor/server/lib/cloud/license.ts similarity index 100% rename from apps/meteor/app/cloud/server/license.ts rename to apps/meteor/server/lib/cloud/license.ts diff --git a/apps/meteor/app/license/server/airGappedRestrictionsWrapper.ts b/apps/meteor/server/lib/cloud/license/airGappedRestrictionsWrapper.ts similarity index 100% rename from apps/meteor/app/license/server/airGappedRestrictionsWrapper.ts rename to apps/meteor/server/lib/cloud/license/airGappedRestrictionsWrapper.ts diff --git a/apps/meteor/app/cloud/server/oauthScopes.ts b/apps/meteor/server/lib/cloud/oauthScopes.ts similarity index 100% rename from apps/meteor/app/cloud/server/oauthScopes.ts rename to apps/meteor/server/lib/cloud/oauthScopes.ts diff --git a/apps/meteor/server/lib/cloud/supportedVersionsToken/supportedVersionsToken.ts b/apps/meteor/server/lib/cloud/supportedVersionsToken/supportedVersionsToken.ts index 2f35c026cc54c..76386ea79e828 100644 --- a/apps/meteor/server/lib/cloud/supportedVersionsToken/supportedVersionsToken.ts +++ b/apps/meteor/server/lib/cloud/supportedVersionsToken/supportedVersionsToken.ts @@ -9,10 +9,10 @@ import { supportedVersionsChooseLatest } from './supportedVersionsChooseLatest'; import { notifyOnSettingChangedById } from '../../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../../app/settings/server'; import { supportedVersions as supportedVersionsFromBuild } from '../../../../app/utils/rocketchat-supported-versions.info'; -import { buildVersionUpdateMessage } from '../../../../app/version-check/server/functions/buildVersionUpdateMessage'; import { updateAuditedBySystem } from '../../../settings/lib/auditedSettingUpdates'; import { SystemLogger } from '../../logger/system'; import { generateWorkspaceBearerHttpHeader } from '../getWorkspaceAccessToken'; +import { buildVersionUpdateMessage } from '../version-check/functions/buildVersionUpdateMessage'; declare module '@rocket.chat/core-typings' { interface ILicenseV3 { diff --git a/apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.spec.ts b/apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.spec.ts similarity index 88% rename from apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.spec.ts rename to apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.spec.ts index 0f8f8198e2d5f..d51b1c8310c61 100644 --- a/apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.spec.ts +++ b/apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.spec.ts @@ -1,11 +1,11 @@ import { buildVersionUpdateMessage } from './buildVersionUpdateMessage'; -import { sendMessagesToAdmins } from '../../../../server/lib/sendMessagesToAdmins'; +import { sendMessagesToAdmins } from '../../../sendMessagesToAdmins'; const originalTestMode = process.env.TEST_MODE; const mockInfoVersion = jest.fn(() => '7.5.0'); -jest.mock('../../../utils/rocketchat.info', () => ({ +jest.mock('../../../../../app/utils/rocketchat.info', () => ({ Info: { get version() { return mockInfoVersion(); @@ -28,27 +28,27 @@ jest.mock('@rocket.chat/models', () => ({ const mockSettingsGet = jest.fn(); -jest.mock('../../../settings/server', () => ({ +jest.mock('../../../../../app/settings/server', () => ({ settings: { get: (key: string) => mockSettingsGet(key), }, })); -jest.mock('../../../../server/lib/i18n', () => ({ +jest.mock('../../../i18n', () => ({ i18n: { t: jest.fn((key) => key), }, })); -jest.mock('../../../../server/lib/sendMessagesToAdmins', () => ({ +jest.mock('../../../sendMessagesToAdmins', () => ({ sendMessagesToAdmins: jest.fn(), })); -jest.mock('../../../../server/settings/lib/auditedSettingUpdates', () => ({ +jest.mock('../../../../settings/lib/auditedSettingUpdates', () => ({ updateAuditedBySystem: jest.fn(() => () => Promise.resolve({ modifiedCount: 0 })), })); -jest.mock('../../../lib/server/lib/notifyListener', () => ({ +jest.mock('../../../../../app/lib/server/lib/notifyListener', () => ({ notifyOnSettingChangedById: jest.fn(), })); diff --git a/apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.ts b/apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.ts similarity index 86% rename from apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.ts rename to apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.ts index 9811ae1ec94a6..1667812570e24 100644 --- a/apps/meteor/app/version-check/server/functions/buildVersionUpdateMessage.ts +++ b/apps/meteor/server/lib/cloud/version-check/functions/buildVersionUpdateMessage.ts @@ -2,12 +2,12 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Settings, Users } from '@rocket.chat/models'; import semver from 'semver'; -import { i18n } from '../../../../server/lib/i18n'; -import { sendMessagesToAdmins } from '../../../../server/lib/sendMessagesToAdmins'; -import { updateAuditedBySystem } from '../../../../server/settings/lib/auditedSettingUpdates'; -import { notifyOnSettingChangedById } from '../../../lib/server/lib/notifyListener'; -import { settings } from '../../../settings/server'; -import { Info } from '../../../utils/rocketchat.info'; +import { notifyOnSettingChangedById } from '../../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../../app/settings/server'; +import { Info } from '../../../../../app/utils/rocketchat.info'; +import { updateAuditedBySystem } from '../../../../settings/lib/auditedSettingUpdates'; +import { i18n } from '../../../i18n'; +import { sendMessagesToAdmins } from '../../../sendMessagesToAdmins'; const cleanupOutdatedVersionUpdateBanners = async (): Promise => { const admins = Users.findUsersInRolesWithQuery('admin', { banners: { $exists: true } }, { projection: { _id: 1, banners: 1 } }); diff --git a/apps/meteor/app/version-check/server/functions/checkVersionUpdate.ts b/apps/meteor/server/lib/cloud/version-check/functions/checkVersionUpdate.ts similarity index 93% rename from apps/meteor/app/version-check/server/functions/checkVersionUpdate.ts rename to apps/meteor/server/lib/cloud/version-check/functions/checkVersionUpdate.ts index ca616950a55b4..e494cd4324d9a 100644 --- a/apps/meteor/app/version-check/server/functions/checkVersionUpdate.ts +++ b/apps/meteor/server/lib/cloud/version-check/functions/checkVersionUpdate.ts @@ -1,8 +1,8 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; -import { i18n } from '../../../../server/lib/i18n'; -import { sendMessagesToAdmins } from '../../../../server/lib/sendMessagesToAdmins'; +import { i18n } from '../../../i18n'; +import { sendMessagesToAdmins } from '../../../sendMessagesToAdmins'; import logger from '../logger'; import { buildVersionUpdateMessage } from './buildVersionUpdateMessage'; import { getNewUpdates } from './getNewUpdates'; diff --git a/apps/meteor/app/version-check/server/functions/getNewUpdates.ts b/apps/meteor/server/lib/cloud/version-check/functions/getNewUpdates.ts similarity index 94% rename from apps/meteor/app/version-check/server/functions/getNewUpdates.ts rename to apps/meteor/server/lib/cloud/version-check/functions/getNewUpdates.ts index 2d0ce22a3c427..e9b8dd0b340bc 100644 --- a/apps/meteor/app/version-check/server/functions/getNewUpdates.ts +++ b/apps/meteor/server/lib/cloud/version-check/functions/getNewUpdates.ts @@ -4,8 +4,8 @@ import { Settings } from '@rocket.chat/models'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { check, Match } from 'meteor/check'; -import { getWorkspaceAccessToken } from '../../../cloud/server'; -import { Info } from '../../../utils/rocketchat.info'; +import { getWorkspaceAccessToken } from '../..'; +import { Info } from '../../../../../app/utils/rocketchat.info'; /** @deprecated */ diff --git a/apps/meteor/app/version-check/server/index.ts b/apps/meteor/server/lib/cloud/version-check/index.ts similarity index 90% rename from apps/meteor/app/version-check/server/index.ts rename to apps/meteor/server/lib/cloud/version-check/index.ts index 45e9c5197c305..7c838230355f1 100644 --- a/apps/meteor/app/version-check/server/index.ts +++ b/apps/meteor/server/lib/cloud/version-check/index.ts @@ -2,8 +2,7 @@ import { cronJobs } from '@rocket.chat/cron'; import { Meteor } from 'meteor/meteor'; import { checkVersionUpdate } from './functions/checkVersionUpdate'; -import { settings } from '../../settings/server'; -import './methods/banner_dismiss'; +import { settings } from '../../../../app/settings/server'; const jobName = 'version_check'; diff --git a/apps/meteor/app/version-check/server/logger.ts b/apps/meteor/server/lib/cloud/version-check/logger.ts similarity index 100% rename from apps/meteor/app/version-check/server/logger.ts rename to apps/meteor/server/lib/cloud/version-check/logger.ts diff --git a/apps/meteor/server/lib/dataExport/copyFileUpload.ts b/apps/meteor/server/lib/dataExport/copyFileUpload.ts index b374966f8b0da..072b8f335f182 100644 --- a/apps/meteor/server/lib/dataExport/copyFileUpload.ts +++ b/apps/meteor/server/lib/dataExport/copyFileUpload.ts @@ -1,8 +1,8 @@ import type { FileProp } from '@rocket.chat/core-typings'; import { Uploads } from '@rocket.chat/models'; -import { FileUpload } from '../../../app/file-upload/server'; import { joinPath } from '../fileUtils'; +import { FileUpload } from '../media/file-upload'; export const copyFileUpload = async (attachmentData: Pick, assetsPath: string): Promise => { const file = await Uploads.findOneById(attachmentData._id); diff --git a/apps/meteor/server/lib/dataExport/processDataDownloads.spec.ts b/apps/meteor/server/lib/dataExport/processDataDownloads.spec.ts index 8933f5a6c0489..a802003990154 100644 --- a/apps/meteor/server/lib/dataExport/processDataDownloads.spec.ts +++ b/apps/meteor/server/lib/dataExport/processDataDownloads.spec.ts @@ -149,7 +149,7 @@ const { requestDataDownload } = proxyquire.noCallThru().load('../../meteor-metho const { processDataDownloads } = proxyquire.noCallThru().load('./processDataDownloads.ts', { '@rocket.chat/models': modelsMock, - '../../../app/file-upload/server': { + '../media/file-upload': { FileUpload: { copy: async (fileId: string, _options: any) => { return `copied-${fileId}`; diff --git a/apps/meteor/server/lib/dataExport/processDataDownloads.ts b/apps/meteor/server/lib/dataExport/processDataDownloads.ts index 5c31fcb09c8a1..e45e85e48e0ae 100644 --- a/apps/meteor/server/lib/dataExport/processDataDownloads.ts +++ b/apps/meteor/server/lib/dataExport/processDataDownloads.ts @@ -7,7 +7,6 @@ import { Avatars, ExportOperations, UserDataFiles, Subscriptions } from '@rocket import { escapeHTML } from '@rocket.chat/string-helpers'; import moment from 'moment'; -import { FileUpload } from '../../../app/file-upload/server'; import { settings } from '../../../app/settings/server'; import { getURL } from '../../../app/utils/server/getURL'; import { joinPath } from '../fileUtils'; @@ -19,6 +18,7 @@ import { getRoomData } from './getRoomData'; import { makeZipFile } from './makeZipFile'; import { sendEmail } from './sendEmail'; import { uploadZipFile } from './uploadZipFile'; +import { FileUpload } from '../media/file-upload'; const loadUserSubscriptions = async (_exportOperation: IExportOperation, fileType: 'json' | 'html', userId: IUser['_id']) => { const roomList: ( diff --git a/apps/meteor/server/lib/dataExport/sendEmail.ts b/apps/meteor/server/lib/dataExport/sendEmail.ts index 88ae72d738326..7182ea323cd5a 100644 --- a/apps/meteor/server/lib/dataExport/sendEmail.ts +++ b/apps/meteor/server/lib/dataExport/sendEmail.ts @@ -1,8 +1,8 @@ import type { IUser } from '@rocket.chat/core-typings'; -import * as Mailer from '../../../app/mailer/server/api'; import { settings } from '../../../app/settings/server'; import { getUserEmailAddress } from '../../../lib/getUserEmailAddress'; +import * as Mailer from '../notifications/email/api'; export const sendEmail = async (userData: Pick, subject: string, body: string): Promise => { const emailAddress = getUserEmailAddress(userData); diff --git a/apps/meteor/server/lib/dataExport/sendViaEmail.ts b/apps/meteor/server/lib/dataExport/sendViaEmail.ts index 834128a6a7f2a..88b95ee5f5b82 100644 --- a/apps/meteor/server/lib/dataExport/sendViaEmail.ts +++ b/apps/meteor/server/lib/dataExport/sendViaEmail.ts @@ -3,10 +3,10 @@ import { Messages, Users } from '@rocket.chat/models'; import { escapeHTML } from '@rocket.chat/string-helpers'; import moment from 'moment'; -import * as Mailer from '../../../app/mailer/server/api'; import { settings } from '../../../app/settings/server'; import { Message } from '../../../app/ui-utils/server'; import { getMomentLocale } from '../getMomentLocale'; +import * as Mailer from '../notifications/email/api'; export async function sendViaEmail( data: { diff --git a/apps/meteor/server/lib/dataExport/uploadZipFile.ts b/apps/meteor/server/lib/dataExport/uploadZipFile.ts index abac817561180..50b7493838b97 100644 --- a/apps/meteor/server/lib/dataExport/uploadZipFile.ts +++ b/apps/meteor/server/lib/dataExport/uploadZipFile.ts @@ -5,7 +5,7 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; import { Random } from '@rocket.chat/random'; -import { FileUpload } from '../../../app/file-upload/server'; +import { FileUpload } from '../media/file-upload'; export const uploadZipFile = async (filePath: string, userId: IUser['_id'], exportType: 'json' | 'html'): Promise => { const contentType = 'application/zip'; diff --git a/apps/meteor/app/e2e/server/beforeCreateRoom.ts b/apps/meteor/server/lib/e2e/beforeCreateRoom.ts similarity index 68% rename from apps/meteor/app/e2e/server/beforeCreateRoom.ts rename to apps/meteor/server/lib/e2e/beforeCreateRoom.ts index cb04d0def049d..c643ba3f0c69d 100644 --- a/apps/meteor/app/e2e/server/beforeCreateRoom.ts +++ b/apps/meteor/server/lib/e2e/beforeCreateRoom.ts @@ -1,5 +1,5 @@ -import { prepareCreateRoomCallback } from '../../../server/lib/callbacks/beforeCreateRoomCallback'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { prepareCreateRoomCallback } from '../callbacks/beforeCreateRoomCallback'; prepareCreateRoomCallback.add(({ type, extraData }) => { if ( diff --git a/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts b/apps/meteor/server/lib/e2e/functions/handleSuggestedGroupKey.ts similarity index 96% rename from apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts rename to apps/meteor/server/lib/e2e/functions/handleSuggestedGroupKey.ts index 9d74144517fd2..f54fde4c130c3 100644 --- a/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts +++ b/apps/meteor/server/lib/e2e/functions/handleSuggestedGroupKey.ts @@ -1,7 +1,7 @@ import { Rooms, Subscriptions } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { notifyOnSubscriptionChangedById, notifyOnRoomChangedById } from '../../../lib/server/lib/notifyListener'; +import { notifyOnSubscriptionChangedById, notifyOnRoomChangedById } from '../../../../app/lib/server/lib/notifyListener'; export async function handleSuggestedGroupKey( handle: 'accept' | 'reject', diff --git a/apps/meteor/app/e2e/server/functions/provideUsersSuggestedGroupKeys.ts b/apps/meteor/server/lib/e2e/functions/provideUsersSuggestedGroupKeys.ts similarity index 90% rename from apps/meteor/app/e2e/server/functions/provideUsersSuggestedGroupKeys.ts rename to apps/meteor/server/lib/e2e/functions/provideUsersSuggestedGroupKeys.ts index 81e12b480f5e1..5d1ac38a25ff5 100644 --- a/apps/meteor/app/e2e/server/functions/provideUsersSuggestedGroupKeys.ts +++ b/apps/meteor/server/lib/e2e/functions/provideUsersSuggestedGroupKeys.ts @@ -1,8 +1,8 @@ import type { IRoom, IUser, ISubscription } from '@rocket.chat/core-typings'; import { Rooms, Subscriptions } from '@rocket.chat/models'; -import { canAccessRoomIdAsync } from '../../../../server/lib/authorization/canAccessRoom'; -import { notifyOnSubscriptionChanged, notifyOnRoomChangedById } from '../../../lib/server/lib/notifyListener'; +import { notifyOnSubscriptionChanged, notifyOnRoomChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { canAccessRoomIdAsync } from '../../authorization/canAccessRoom'; export const provideUsersSuggestedGroupKeys = async ( userId: IUser['_id'], diff --git a/apps/meteor/app/e2e/server/functions/resetRoomKey.ts b/apps/meteor/server/lib/e2e/functions/resetRoomKey.ts similarity index 98% rename from apps/meteor/app/e2e/server/functions/resetRoomKey.ts rename to apps/meteor/server/lib/e2e/functions/resetRoomKey.ts index ba9704c5c1a5b..6786f2ca993e6 100644 --- a/apps/meteor/app/e2e/server/functions/resetRoomKey.ts +++ b/apps/meteor/server/lib/e2e/functions/resetRoomKey.ts @@ -2,7 +2,7 @@ import type { ISubscription, IUser, IRoom } from '@rocket.chat/core-typings'; import { Rooms, Subscriptions, Users } from '@rocket.chat/models'; import type { AnyBulkWriteOperation } from 'mongodb'; -import { notifyOnRoomChanged, notifyOnSubscriptionChanged } from '../../../lib/server/lib/notifyListener'; +import { notifyOnRoomChanged, notifyOnSubscriptionChanged } from '../../../../app/lib/server/lib/notifyListener'; export async function resetRoomKey(roomId: string, userId: string, newRoomKey: string, newRoomKeyId: string) { const user = await Users.findOneById>(userId, { projection: { e2e: 1 } }); diff --git a/apps/meteor/app/e2e/server/index.ts b/apps/meteor/server/lib/e2e/index.ts similarity index 80% rename from apps/meteor/app/e2e/server/index.ts rename to apps/meteor/server/lib/e2e/index.ts index 74b5dbcbca589..64051a5b14579 100644 --- a/apps/meteor/app/e2e/server/index.ts +++ b/apps/meteor/server/lib/e2e/index.ts @@ -1,6 +1,6 @@ import { api } from '@rocket.chat/core-services'; -import { callbacks } from '../../../server/lib/callbacks'; +import { callbacks } from '../callbacks'; import './beforeCreateRoom'; diff --git a/apps/meteor/app/importer/server/classes/ImportDataConverter.ts b/apps/meteor/server/lib/import/classes/ImportDataConverter.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/ImportDataConverter.ts rename to apps/meteor/server/lib/import/classes/ImportDataConverter.ts diff --git a/apps/meteor/app/importer/server/classes/Importer.ts b/apps/meteor/server/lib/import/classes/Importer.ts similarity index 98% rename from apps/meteor/app/importer/server/classes/Importer.ts rename to apps/meteor/server/lib/import/classes/Importer.ts index c39da71ed2a31..ce58482c9790d 100644 --- a/apps/meteor/app/importer/server/classes/Importer.ts +++ b/apps/meteor/server/lib/import/classes/Importer.ts @@ -13,15 +13,15 @@ import { Settings, ImportData, Imports } from '@rocket.chat/models'; import AdmZip from 'adm-zip'; import type { MatchKeysAndValues, MongoServerError } from 'mongodb'; -import { Selection, SelectionChannel, SelectionUser } from '..'; import { ImportDataConverter } from './ImportDataConverter'; import type { ConverterOptions } from './ImportDataConverter'; import { ImporterProgress } from './ImporterProgress'; import { ImporterWebsocket } from './ImporterWebsocket'; -import { notifyOnSettingChanged, notifyOnSettingChangedById } from '../../../lib/server/lib/notifyListener'; -import { t } from '../../../utils/lib/i18n'; -import { ProgressStep, ImportPreparingStartedStates } from '../../lib/ImporterProgressStep'; +import { ProgressStep, ImportPreparingStartedStates } from '../../../../app/importer/lib/ImporterProgressStep'; +import { notifyOnSettingChanged, notifyOnSettingChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { t } from '../../../../app/utils/lib/i18n'; import type { ImporterInfo } from '../definitions/ImporterInfo'; +import { Selection, SelectionChannel, SelectionUser } from '../index'; type OldSettings = { allowedDomainList?: string | null; diff --git a/apps/meteor/app/importer/server/classes/ImporterProgress.ts b/apps/meteor/server/lib/import/classes/ImporterProgress.ts similarity index 88% rename from apps/meteor/app/importer/server/classes/ImporterProgress.ts rename to apps/meteor/server/lib/import/classes/ImporterProgress.ts index ff59a5eb20b14..1a82d2cc9e67c 100644 --- a/apps/meteor/app/importer/server/classes/ImporterProgress.ts +++ b/apps/meteor/server/lib/import/classes/ImporterProgress.ts @@ -1,6 +1,6 @@ import type { IImportProgress } from '@rocket.chat/core-typings'; -import { ProgressStep } from '../../lib/ImporterProgressStep'; +import { ProgressStep } from '../../../../app/importer/lib/ImporterProgressStep'; export class ImporterProgress implements IImportProgress { public key: string; diff --git a/apps/meteor/app/importer/server/classes/ImporterSelection.ts b/apps/meteor/server/lib/import/classes/ImporterSelection.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/ImporterSelection.ts rename to apps/meteor/server/lib/import/classes/ImporterSelection.ts diff --git a/apps/meteor/app/importer/server/classes/ImporterSelectionChannel.ts b/apps/meteor/server/lib/import/classes/ImporterSelectionChannel.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/ImporterSelectionChannel.ts rename to apps/meteor/server/lib/import/classes/ImporterSelectionChannel.ts diff --git a/apps/meteor/app/importer/server/classes/ImporterSelectionUser.ts b/apps/meteor/server/lib/import/classes/ImporterSelectionUser.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/ImporterSelectionUser.ts rename to apps/meteor/server/lib/import/classes/ImporterSelectionUser.ts diff --git a/apps/meteor/app/importer/server/classes/ImporterWebsocket.ts b/apps/meteor/server/lib/import/classes/ImporterWebsocket.ts similarity index 76% rename from apps/meteor/app/importer/server/classes/ImporterWebsocket.ts rename to apps/meteor/server/lib/import/classes/ImporterWebsocket.ts index ffcc8aef1ed96..41aeee52c8b28 100644 --- a/apps/meteor/app/importer/server/classes/ImporterWebsocket.ts +++ b/apps/meteor/server/lib/import/classes/ImporterWebsocket.ts @@ -1,7 +1,7 @@ import type { IImportProgress } from '@rocket.chat/core-typings'; -import type { IStreamer } from '../../../../server/modules/streamer/types'; -import notifications from '../../../notifications/server/lib/Notifications'; +import type { IStreamer } from '../../../modules/streamer/types'; +import notifications from '../../notifications/core/lib/Notifications'; class ImporterWebsocketDef { private streamer: IStreamer<'importers'>; diff --git a/apps/meteor/app/importer/server/classes/ImportersContainer.ts b/apps/meteor/server/lib/import/classes/ImportersContainer.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/ImportersContainer.ts rename to apps/meteor/server/lib/import/classes/ImportersContainer.ts diff --git a/apps/meteor/app/importer/server/classes/converters/ContactConverter.ts b/apps/meteor/server/lib/import/classes/converters/ContactConverter.ts similarity index 79% rename from apps/meteor/app/importer/server/classes/converters/ContactConverter.ts rename to apps/meteor/server/lib/import/classes/converters/ContactConverter.ts index 01067cbe118f8..21d97829be5ae 100644 --- a/apps/meteor/app/importer/server/classes/converters/ContactConverter.ts +++ b/apps/meteor/server/lib/import/classes/converters/ContactConverter.ts @@ -2,9 +2,9 @@ import type { IImportContact, IImportContactRecord } from '@rocket.chat/core-typ import { LivechatVisitors } from '@rocket.chat/models'; import { RecordConverter } from './RecordConverter'; -import { createContact } from '../../../../livechat/server/lib/contacts/createContact'; -import { getAllowedCustomFields } from '../../../../livechat/server/lib/contacts/getAllowedCustomFields'; -import { validateCustomFields } from '../../../../livechat/server/lib/contacts/validateCustomFields'; +import { createContact } from '../../../../../app/livechat/server/lib/contacts/createContact'; +import { getAllowedCustomFields } from '../../../../../app/livechat/server/lib/contacts/getAllowedCustomFields'; +import { validateCustomFields } from '../../../../../app/livechat/server/lib/contacts/validateCustomFields'; export class ContactConverter extends RecordConverter { protected async convertCustomFields(customFields: IImportContact['customFields']): Promise { diff --git a/apps/meteor/app/importer/server/classes/converters/ConverterCache.ts b/apps/meteor/server/lib/import/classes/converters/ConverterCache.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/converters/ConverterCache.ts rename to apps/meteor/server/lib/import/classes/converters/ConverterCache.ts diff --git a/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts b/apps/meteor/server/lib/import/classes/converters/MessageConverter.ts similarity index 98% rename from apps/meteor/app/importer/server/classes/converters/MessageConverter.ts rename to apps/meteor/server/lib/import/classes/converters/MessageConverter.ts index a8f785bdf17c7..330e38962ad25 100644 --- a/apps/meteor/app/importer/server/classes/converters/MessageConverter.ts +++ b/apps/meteor/server/lib/import/classes/converters/MessageConverter.ts @@ -5,7 +5,7 @@ import limax from 'limax'; import type { UserIdentification, MentionedChannel } from './ConverterCache'; import { RecordConverter } from './RecordConverter'; -import { insertMessage } from '../../../../../server/lib/messages/insertMessage'; +import { insertMessage } from '../../../messages/insertMessage'; import type { IConversionCallbacks } from '../../definitions/IConversionCallbacks'; export type MessageConversionCallbacks = IConversionCallbacks & { afterImportAllMessagesFn?: (roomIds: string[]) => Promise }; diff --git a/apps/meteor/app/importer/server/classes/converters/RecordConverter.ts b/apps/meteor/server/lib/import/classes/converters/RecordConverter.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/converters/RecordConverter.ts rename to apps/meteor/server/lib/import/classes/converters/RecordConverter.ts diff --git a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts b/apps/meteor/server/lib/import/classes/converters/RoomConverter.ts similarity index 93% rename from apps/meteor/app/importer/server/classes/converters/RoomConverter.ts rename to apps/meteor/server/lib/import/classes/converters/RoomConverter.ts index 1bce98c63a6f5..248db83b44667 100644 --- a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts +++ b/apps/meteor/server/lib/import/classes/converters/RoomConverter.ts @@ -4,11 +4,11 @@ import { removeEmpty } from '@rocket.chat/tools'; import limax from 'limax'; import { RecordConverter } from './RecordConverter'; -import { createDirectMessage } from '../../../../../server/meteor-methods/messages/createDirectMessage'; -import { createChannelMethod } from '../../../../../server/meteor-methods/rooms/createChannel'; -import { createPrivateGroupMethod } from '../../../../../server/meteor-methods/rooms/createPrivateGroup'; -import { saveRoomSettings } from '../../../../../server/meteor-methods/rooms/saveRoomSettings'; -import { notifyOnSubscriptionChangedByRoomId } from '../../../../lib/server/lib/notifyListener'; +import { notifyOnSubscriptionChangedByRoomId } from '../../../../../app/lib/server/lib/notifyListener'; +import { createDirectMessage } from '../../../../meteor-methods/messages/createDirectMessage'; +import { createChannelMethod } from '../../../../meteor-methods/rooms/createChannel'; +import { createPrivateGroupMethod } from '../../../../meteor-methods/rooms/createPrivateGroup'; +import { saveRoomSettings } from '../../../../meteor-methods/rooms/saveRoomSettings'; import type { IConversionCallbacks } from '../../definitions/IConversionCallbacks'; export class RoomConverter extends RecordConverter { diff --git a/apps/meteor/app/importer/server/classes/converters/UserConverter.ts b/apps/meteor/server/lib/import/classes/converters/UserConverter.ts similarity index 95% rename from apps/meteor/app/importer/server/classes/converters/UserConverter.ts rename to apps/meteor/server/lib/import/classes/converters/UserConverter.ts index eb7c857888128..7d7757b523a83 100644 --- a/apps/meteor/app/importer/server/classes/converters/UserConverter.ts +++ b/apps/meteor/server/lib/import/classes/converters/UserConverter.ts @@ -7,12 +7,12 @@ import { Accounts } from 'meteor/accounts-base'; import { RecordConverter, type RecordConverterOptions } from './RecordConverter'; import { generateTempPassword } from './generateTempPassword'; -import { callbacks as systemCallbacks } from '../../../../../server/lib/callbacks'; -import { addUserToDefaultChannels } from '../../../../../server/lib/rooms/addUserToDefaultChannels'; -import { generateUsernameSuggestion } from '../../../../../server/lib/users/getUsernameSuggestion'; -import { saveUserIdentity } from '../../../../../server/lib/users/saveUserIdentity'; -import { setUserActiveStatus } from '../../../../../server/lib/users/setUserActiveStatus'; -import { notifyOnUserChange } from '../../../../lib/server/lib/notifyListener'; +import { notifyOnUserChange } from '../../../../../app/lib/server/lib/notifyListener'; +import { callbacks as systemCallbacks } from '../../../callbacks'; +import { addUserToDefaultChannels } from '../../../rooms/addUserToDefaultChannels'; +import { generateUsernameSuggestion } from '../../../users/getUsernameSuggestion'; +import { saveUserIdentity } from '../../../users/saveUserIdentity'; +import { setUserActiveStatus } from '../../../users/setUserActiveStatus'; import type { IConversionCallbacks } from '../../definitions/IConversionCallbacks'; export type UserConverterOptions = { diff --git a/apps/meteor/app/importer/server/classes/converters/generateTempPassword.ts b/apps/meteor/server/lib/import/classes/converters/generateTempPassword.ts similarity index 100% rename from apps/meteor/app/importer/server/classes/converters/generateTempPassword.ts rename to apps/meteor/server/lib/import/classes/converters/generateTempPassword.ts diff --git a/apps/meteor/app/importer-csv/server/CsvImporter.ts b/apps/meteor/server/lib/import/csv/CsvImporter.ts similarity index 93% rename from apps/meteor/app/importer-csv/server/CsvImporter.ts rename to apps/meteor/server/lib/import/csv/CsvImporter.ts index 7a76677f1662f..c2894a21d68a1 100644 --- a/apps/meteor/app/importer-csv/server/CsvImporter.ts +++ b/apps/meteor/server/lib/import/csv/CsvImporter.ts @@ -3,12 +3,12 @@ import { Settings, Users } from '@rocket.chat/models'; import { Random } from '@rocket.chat/random'; import { parse } from 'csv-parse/lib/sync'; -import { Importer, ProgressStep, ImporterWebsocket } from '../../importer/server'; -import type { ConverterOptions } from '../../importer/server/classes/ImportDataConverter'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; -import type { ImporterInfo } from '../../importer/server/definitions/ImporterInfo'; -import { addParsedContacts } from '../../importer-omnichannel-contacts/server/addParsedContacts'; -import { notifyOnSettingChanged } from '../../lib/server/lib/notifyListener'; +import { Importer, ProgressStep, ImporterWebsocket } from '..'; +import { notifyOnSettingChanged } from '../../../../app/lib/server/lib/notifyListener'; +import type { ConverterOptions } from '../classes/ImportDataConverter'; +import type { ImporterProgress } from '../classes/ImporterProgress'; +import type { ImporterInfo } from '../definitions/ImporterInfo'; +import { addParsedContacts } from '../omnichannel-contacts/addParsedContacts'; export class CsvImporter extends Importer { private csvParser: (csv: string) => string[][]; diff --git a/apps/meteor/app/importer-csv/server/index.ts b/apps/meteor/server/lib/import/csv/index.ts similarity index 69% rename from apps/meteor/app/importer-csv/server/index.ts rename to apps/meteor/server/lib/import/csv/index.ts index f20c375ae9435..9d4a37fe27303 100644 --- a/apps/meteor/app/importer-csv/server/index.ts +++ b/apps/meteor/server/lib/import/csv/index.ts @@ -1,5 +1,5 @@ +import { Importers } from '..'; import { CsvImporter } from './CsvImporter'; -import { Importers } from '../../importer/server'; Importers.add({ key: 'csv', diff --git a/apps/meteor/app/importer/server/definitions/IConversionCallbacks.ts b/apps/meteor/server/lib/import/definitions/IConversionCallbacks.ts similarity index 100% rename from apps/meteor/app/importer/server/definitions/IConversionCallbacks.ts rename to apps/meteor/server/lib/import/definitions/IConversionCallbacks.ts diff --git a/apps/meteor/app/importer/server/definitions/ImporterInfo.ts b/apps/meteor/server/lib/import/definitions/ImporterInfo.ts similarity index 100% rename from apps/meteor/app/importer/server/definitions/ImporterInfo.ts rename to apps/meteor/server/lib/import/definitions/ImporterInfo.ts diff --git a/apps/meteor/app/importer/server/index.ts b/apps/meteor/server/lib/import/index.ts similarity index 89% rename from apps/meteor/app/importer/server/index.ts rename to apps/meteor/server/lib/import/index.ts index 1df27c40aefc6..71266bf0d0092 100644 --- a/apps/meteor/app/importer/server/index.ts +++ b/apps/meteor/server/lib/import/index.ts @@ -1,10 +1,10 @@ -import { ProgressStep } from '../lib/ImporterProgressStep'; import { Importer } from './classes/Importer'; import { ImporterSelection } from './classes/ImporterSelection'; import { SelectionChannel } from './classes/ImporterSelectionChannel'; import { SelectionUser } from './classes/ImporterSelectionUser'; import { ImporterWebsocket } from './classes/ImporterWebsocket'; import { ImportersContainer } from './classes/ImportersContainer'; +import { ProgressStep } from '../../../app/importer/lib/ImporterProgressStep'; import './startup/setImportsToInvalid'; import './startup/store'; diff --git a/apps/meteor/app/importer-omnichannel-contacts/server/ContactImporter.ts b/apps/meteor/server/lib/import/omnichannel-contacts/ContactImporter.ts similarity index 82% rename from apps/meteor/app/importer-omnichannel-contacts/server/ContactImporter.ts rename to apps/meteor/server/lib/import/omnichannel-contacts/ContactImporter.ts index 5415f10e63887..e8bea6e601ca5 100644 --- a/apps/meteor/app/importer-omnichannel-contacts/server/ContactImporter.ts +++ b/apps/meteor/server/lib/import/omnichannel-contacts/ContactImporter.ts @@ -3,11 +3,11 @@ import fs from 'node:fs'; import type { IImport } from '@rocket.chat/core-typings'; import { parse } from 'csv-parse/lib/sync'; +import { Importer, ProgressStep, ImporterWebsocket } from '..'; import { addParsedContacts } from './addParsedContacts'; -import { Importer, ProgressStep, ImporterWebsocket } from '../../importer/server'; -import type { ConverterOptions } from '../../importer/server/classes/ImportDataConverter'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; -import type { ImporterInfo } from '../../importer/server/definitions/ImporterInfo'; +import type { ConverterOptions } from '../classes/ImportDataConverter'; +import type { ImporterProgress } from '../classes/ImporterProgress'; +import type { ImporterInfo } from '../definitions/ImporterInfo'; export class ContactImporter extends Importer { private csvParser: (csv: string) => string[][]; diff --git a/apps/meteor/app/importer-omnichannel-contacts/server/addParsedContacts.ts b/apps/meteor/server/lib/import/omnichannel-contacts/addParsedContacts.ts similarity index 91% rename from apps/meteor/app/importer-omnichannel-contacts/server/addParsedContacts.ts rename to apps/meteor/server/lib/import/omnichannel-contacts/addParsedContacts.ts index ee36150544eb6..55bbb6acee189 100644 --- a/apps/meteor/app/importer-omnichannel-contacts/server/addParsedContacts.ts +++ b/apps/meteor/server/lib/import/omnichannel-contacts/addParsedContacts.ts @@ -1,6 +1,6 @@ import { Random } from '@rocket.chat/random'; -import type { ImportDataConverter } from '../../importer/server/classes/ImportDataConverter'; +import type { ImportDataConverter } from '../classes/ImportDataConverter'; export async function addParsedContacts(this: ImportDataConverter, parsedContacts: string[][]): Promise { const columnNames = parsedContacts.shift(); diff --git a/apps/meteor/app/importer-omnichannel-contacts/server/index.ts b/apps/meteor/server/lib/import/omnichannel-contacts/index.ts similarity index 84% rename from apps/meteor/app/importer-omnichannel-contacts/server/index.ts rename to apps/meteor/server/lib/import/omnichannel-contacts/index.ts index 0ba882650bf07..68d0ce30dfce8 100644 --- a/apps/meteor/app/importer-omnichannel-contacts/server/index.ts +++ b/apps/meteor/server/lib/import/omnichannel-contacts/index.ts @@ -1,7 +1,7 @@ import { License } from '@rocket.chat/license'; +import { Importers } from '..'; import { ContactImporter } from './ContactImporter'; -import { Importers } from '../../importer/server'; License.onValidFeature('contact-id-verification', () => { Importers.add({ diff --git a/apps/meteor/app/importer-pending-avatars/server/PendingAvatarImporter.ts b/apps/meteor/server/lib/import/pending-avatars/PendingAvatarImporter.ts similarity index 89% rename from apps/meteor/app/importer-pending-avatars/server/PendingAvatarImporter.ts rename to apps/meteor/server/lib/import/pending-avatars/PendingAvatarImporter.ts index 52053f8a9c079..caa81baf3c6a6 100644 --- a/apps/meteor/app/importer-pending-avatars/server/PendingAvatarImporter.ts +++ b/apps/meteor/server/lib/import/pending-avatars/PendingAvatarImporter.ts @@ -1,9 +1,9 @@ import type { IImporterShortSelection } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; -import { setAvatarFromServiceWithValidation } from '../../../server/lib/users/setUserAvatar'; -import { Importer, ProgressStep } from '../../importer/server'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; +import { Importer, ProgressStep } from '..'; +import { setAvatarFromServiceWithValidation } from '../../users/setUserAvatar'; +import type { ImporterProgress } from '../classes/ImporterProgress'; export class PendingAvatarImporter extends Importer { async prepareFileCount() { diff --git a/apps/meteor/app/importer-pending-avatars/server/index.ts b/apps/meteor/server/lib/import/pending-avatars/index.ts similarity index 78% rename from apps/meteor/app/importer-pending-avatars/server/index.ts rename to apps/meteor/server/lib/import/pending-avatars/index.ts index 2710c06b9d15b..663b583d01695 100644 --- a/apps/meteor/app/importer-pending-avatars/server/index.ts +++ b/apps/meteor/server/lib/import/pending-avatars/index.ts @@ -1,5 +1,5 @@ +import { Importers } from '..'; import { PendingAvatarImporter } from './PendingAvatarImporter'; -import { Importers } from '../../importer/server'; Importers.add({ key: 'pending-avatars', diff --git a/apps/meteor/app/importer-pending-files/server/PendingFileImporter.ts b/apps/meteor/server/lib/import/pending-files/PendingFileImporter.ts similarity index 93% rename from apps/meteor/app/importer-pending-files/server/PendingFileImporter.ts rename to apps/meteor/server/lib/import/pending-files/PendingFileImporter.ts index 35b88c4267138..9f883e49e9897 100644 --- a/apps/meteor/app/importer-pending-files/server/PendingFileImporter.ts +++ b/apps/meteor/server/lib/import/pending-files/PendingFileImporter.ts @@ -6,11 +6,11 @@ import type { IImport, MessageAttachment, IUpload, IImporterShortSelection } fro import { Messages } from '@rocket.chat/models'; import { Random } from '@rocket.chat/random'; -import { FileUpload } from '../../file-upload/server'; -import { Importer, ProgressStep } from '../../importer/server'; -import type { ConverterOptions } from '../../importer/server/classes/ImportDataConverter'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; -import type { ImporterInfo } from '../../importer/server/definitions/ImporterInfo'; +import { Importer, ProgressStep } from '..'; +import { FileUpload } from '../../media/file-upload'; +import type { ConverterOptions } from '../classes/ImportDataConverter'; +import type { ImporterProgress } from '../classes/ImporterProgress'; +import type { ImporterInfo } from '../definitions/ImporterInfo'; export class PendingFileImporter extends Importer { constructor(info: ImporterInfo, importRecord: IImport, converterOptions: ConverterOptions = {}) { diff --git a/apps/meteor/app/importer-pending-files/server/index.ts b/apps/meteor/server/lib/import/pending-files/index.ts similarity index 77% rename from apps/meteor/app/importer-pending-files/server/index.ts rename to apps/meteor/server/lib/import/pending-files/index.ts index e18b0de0a29e4..a27f979facccc 100644 --- a/apps/meteor/app/importer-pending-files/server/index.ts +++ b/apps/meteor/server/lib/import/pending-files/index.ts @@ -1,5 +1,5 @@ +import { Importers } from '..'; import { PendingFileImporter } from './PendingFileImporter'; -import { Importers } from '../../importer/server'; Importers.add({ key: 'pending-files', diff --git a/apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts b/apps/meteor/server/lib/import/slack-users/SlackUsersImporter.ts similarity index 85% rename from apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts rename to apps/meteor/server/lib/import/slack-users/SlackUsersImporter.ts index dcf2d772bd6f1..8edf4fe211cb4 100644 --- a/apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts +++ b/apps/meteor/server/lib/import/slack-users/SlackUsersImporter.ts @@ -4,12 +4,12 @@ import type { IImport, IImportUser } from '@rocket.chat/core-typings'; import { Settings } from '@rocket.chat/models'; import { parse } from 'csv-parse/lib/sync'; -import { RocketChatFile } from '../../file/server'; -import { Importer, ProgressStep } from '../../importer/server'; -import type { ConverterOptions } from '../../importer/server/classes/ImportDataConverter'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; -import type { ImporterInfo } from '../../importer/server/definitions/ImporterInfo'; -import { notifyOnSettingChanged } from '../../lib/server/lib/notifyListener'; +import { Importer, ProgressStep } from '..'; +import { notifyOnSettingChanged } from '../../../../app/lib/server/lib/notifyListener'; +import { RocketChatFile } from '../../media/file'; +import type { ConverterOptions } from '../classes/ImportDataConverter'; +import type { ImporterProgress } from '../classes/ImporterProgress'; +import type { ImporterInfo } from '../definitions/ImporterInfo'; export class SlackUsersImporter extends Importer { private csvParser: (csv: string) => string[]; diff --git a/apps/meteor/app/importer-slack-users/server/index.ts b/apps/meteor/server/lib/import/slack-users/index.ts similarity index 75% rename from apps/meteor/app/importer-slack-users/server/index.ts rename to apps/meteor/server/lib/import/slack-users/index.ts index 67b2dbdb319a2..007809b78f13d 100644 --- a/apps/meteor/app/importer-slack-users/server/index.ts +++ b/apps/meteor/server/lib/import/slack-users/index.ts @@ -1,5 +1,5 @@ +import { Importers } from '..'; import { SlackUsersImporter } from './SlackUsersImporter'; -import { Importers } from '../../importer/server'; Importers.add({ key: 'slack-users', diff --git a/apps/meteor/app/importer-slack/server/SlackImporter.ts b/apps/meteor/server/lib/import/slack/SlackImporter.ts similarity index 97% rename from apps/meteor/app/importer-slack/server/SlackImporter.ts rename to apps/meteor/server/lib/import/slack/SlackImporter.ts index d7ccfbdec6c49..8bf8d67ed4f37 100644 --- a/apps/meteor/app/importer-slack/server/SlackImporter.ts +++ b/apps/meteor/server/lib/import/slack/SlackImporter.ts @@ -2,12 +2,12 @@ import type { IImportUser, IImportMessage, IImportPendingFile } from '@rocket.ch import { Messages, Settings, ImportData } from '@rocket.chat/models'; import type { IZipEntry } from 'adm-zip'; -import { Importer, ProgressStep, ImporterWebsocket } from '../../importer/server'; -import type { ImporterProgress } from '../../importer/server/classes/ImporterProgress'; -import { notifyOnSettingChanged } from '../../lib/server/lib/notifyListener'; -import { MentionsParser } from '../../mentions/lib/MentionsParser'; -import { settings } from '../../settings/server'; -import { getUserAvatarURL } from '../../utils/server/getUserAvatarURL'; +import { Importer, ProgressStep, ImporterWebsocket } from '..'; +import { notifyOnSettingChanged } from '../../../../app/lib/server/lib/notifyListener'; +import { MentionsParser } from '../../../../app/mentions/lib/MentionsParser'; +import { settings } from '../../../../app/settings/server'; +import { getUserAvatarURL } from '../../../../app/utils/server/getUserAvatarURL'; +import type { ImporterProgress } from '../classes/ImporterProgress'; type SlackChannel = { id: string; diff --git a/apps/meteor/app/importer-slack/server/index.ts b/apps/meteor/server/lib/import/slack/index.ts similarity index 71% rename from apps/meteor/app/importer-slack/server/index.ts rename to apps/meteor/server/lib/import/slack/index.ts index d32edde7271fb..d795904a9814e 100644 --- a/apps/meteor/app/importer-slack/server/index.ts +++ b/apps/meteor/server/lib/import/slack/index.ts @@ -1,5 +1,5 @@ +import { Importers } from '..'; import { SlackImporter } from './SlackImporter'; -import { Importers } from '../../importer/server'; Importers.add({ key: 'slack', diff --git a/apps/meteor/app/importer/server/startup/setImportsToInvalid.js b/apps/meteor/server/lib/import/startup/setImportsToInvalid.js similarity index 85% rename from apps/meteor/app/importer/server/startup/setImportsToInvalid.js rename to apps/meteor/server/lib/import/startup/setImportsToInvalid.js index bca3061efea0d..1524809253bbf 100644 --- a/apps/meteor/app/importer/server/startup/setImportsToInvalid.js +++ b/apps/meteor/server/lib/import/startup/setImportsToInvalid.js @@ -1,7 +1,7 @@ import { Imports } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { ProgressStep } from '../../lib/ImporterProgressStep'; +import { ProgressStep } from '../../../../app/importer/lib/ImporterProgressStep'; Meteor.startup(async () => { const lastOperation = await Imports.findLastImport(); diff --git a/apps/meteor/app/importer/server/startup/store.js b/apps/meteor/server/lib/import/startup/store.js similarity index 81% rename from apps/meteor/app/importer/server/startup/store.js rename to apps/meteor/server/lib/import/startup/store.js index 4cdd3baea2ab0..522fe37221da8 100644 --- a/apps/meteor/app/importer/server/startup/store.js +++ b/apps/meteor/server/lib/import/startup/store.js @@ -1,7 +1,7 @@ import { Meteor } from 'meteor/meteor'; -import { RocketChatFile } from '../../../file/server'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { RocketChatFile } from '../../media/file'; export let RocketChatImportFileInstance; diff --git a/apps/meteor/app/integrations/server/functions/clearIntegrationHistory.ts b/apps/meteor/server/lib/integrations/functions/clearIntegrationHistory.ts similarity index 93% rename from apps/meteor/app/integrations/server/functions/clearIntegrationHistory.ts rename to apps/meteor/server/lib/integrations/functions/clearIntegrationHistory.ts index 29f88d095f8b5..405b409758586 100644 --- a/apps/meteor/app/integrations/server/functions/clearIntegrationHistory.ts +++ b/apps/meteor/server/lib/integrations/functions/clearIntegrationHistory.ts @@ -2,8 +2,8 @@ import type { IOutgoingIntegration, IIntegration } from '@rocket.chat/core-typin import { Integrations, IntegrationHistory } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import notifications from '../../../notifications/server/lib/Notifications'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; +import notifications from '../../notifications/core/lib/Notifications'; import { triggerHandler } from '../lib/triggerHandler'; export const clearIntegrationHistoryMethod = async (userId: string, integrationId: string): Promise => { diff --git a/apps/meteor/app/integrations/server/lib/ScriptEngine.ts b/apps/meteor/server/lib/integrations/lib/ScriptEngine.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/ScriptEngine.ts rename to apps/meteor/server/lib/integrations/lib/ScriptEngine.ts diff --git a/apps/meteor/app/integrations/server/lib/compileIntegrationScript.ts b/apps/meteor/server/lib/integrations/lib/compileIntegrationScript.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/compileIntegrationScript.ts rename to apps/meteor/server/lib/integrations/lib/compileIntegrationScript.ts diff --git a/apps/meteor/app/integrations/server/lib/definition.ts b/apps/meteor/server/lib/integrations/lib/definition.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/definition.ts rename to apps/meteor/server/lib/integrations/lib/definition.ts diff --git a/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts b/apps/meteor/server/lib/integrations/lib/isolated-vm/buildSandbox.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts rename to apps/meteor/server/lib/integrations/lib/isolated-vm/buildSandbox.ts diff --git a/apps/meteor/app/integrations/server/lib/isolated-vm/getCompatibilityScript.ts b/apps/meteor/server/lib/integrations/lib/isolated-vm/getCompatibilityScript.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/isolated-vm/getCompatibilityScript.ts rename to apps/meteor/server/lib/integrations/lib/isolated-vm/getCompatibilityScript.ts diff --git a/apps/meteor/app/integrations/server/lib/isolated-vm/isolated-vm.ts b/apps/meteor/server/lib/integrations/lib/isolated-vm/isolated-vm.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/isolated-vm/isolated-vm.ts rename to apps/meteor/server/lib/integrations/lib/isolated-vm/isolated-vm.ts diff --git a/apps/meteor/app/integrations/server/lib/mountQueriesBasedOnPermission.ts b/apps/meteor/server/lib/integrations/lib/mountQueriesBasedOnPermission.ts similarity index 96% rename from apps/meteor/app/integrations/server/lib/mountQueriesBasedOnPermission.ts rename to apps/meteor/server/lib/integrations/lib/mountQueriesBasedOnPermission.ts index 1ef2ce1bf7258..834f441c46ae1 100644 --- a/apps/meteor/app/integrations/server/lib/mountQueriesBasedOnPermission.ts +++ b/apps/meteor/server/lib/integrations/lib/mountQueriesBasedOnPermission.ts @@ -2,7 +2,7 @@ import type { DeepWritable } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import type { Filter } from 'mongodb'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; export const mountIntegrationQueryBasedOnPermissions = async (userId: string) => { if (!userId) { diff --git a/apps/meteor/app/integrations/server/lib/triggerHandler.ts b/apps/meteor/server/lib/integrations/lib/triggerHandler.ts similarity index 98% rename from apps/meteor/app/integrations/server/lib/triggerHandler.ts rename to apps/meteor/server/lib/integrations/lib/triggerHandler.ts index 458e1e1b3dd1d..2100c4f28be61 100644 --- a/apps/meteor/app/integrations/server/lib/triggerHandler.ts +++ b/apps/meteor/server/lib/integrations/lib/triggerHandler.ts @@ -15,14 +15,14 @@ import { Meteor } from 'meteor/meteor'; import _ from 'underscore'; import type { OutgoingRequestData } from './ScriptEngine'; -import { processWebhookMessage } from '../../../../server/lib/messages/processWebhookMessage'; -import { getRoomByNameOrIdWithOptionToJoin } from '../../../../server/lib/rooms/getRoomByNameOrIdWithOptionToJoin'; -import { notifyOnIntegrationChangedById } from '../../../lib/server/lib/notifyListener'; -import { settings } from '../../../settings/server'; -import { outgoingEvents } from '../../lib/outgoingEvents'; -import { outgoingLogger } from '../logger'; import { IsolatedVMScriptEngine } from './isolated-vm/isolated-vm'; import { updateHistory } from './updateHistory'; +import { outgoingEvents } from '../../../../app/integrations/lib/outgoingEvents'; +import { notifyOnIntegrationChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { processWebhookMessage } from '../../messages/processWebhookMessage'; +import { getRoomByNameOrIdWithOptionToJoin } from '../../rooms/getRoomByNameOrIdWithOptionToJoin'; +import { outgoingLogger } from '../logger'; type Trigger = Record>; diff --git a/apps/meteor/app/integrations/server/lib/updateHistory.ts b/apps/meteor/server/lib/integrations/lib/updateHistory.ts similarity index 97% rename from apps/meteor/app/integrations/server/lib/updateHistory.ts rename to apps/meteor/server/lib/integrations/lib/updateHistory.ts index 1f1849798b192..c8d07ba1d667c 100644 --- a/apps/meteor/app/integrations/server/lib/updateHistory.ts +++ b/apps/meteor/server/lib/integrations/lib/updateHistory.ts @@ -1,8 +1,8 @@ import type { IIntegrationHistory, OutgoingIntegrationEvent, IIntegration, IMessage, AtLeast } from '@rocket.chat/core-typings'; import { IntegrationHistory } from '@rocket.chat/models'; +import { notifyOnIntegrationHistoryChangedById, notifyOnIntegrationHistoryChanged } from '../../../../app/lib/server/lib/notifyListener'; import { omit } from '../../../../lib/utils/omit'; -import { notifyOnIntegrationHistoryChangedById, notifyOnIntegrationHistoryChanged } from '../../../lib/server/lib/notifyListener'; export const updateHistory = async ({ historyId, diff --git a/apps/meteor/app/integrations/server/lib/validateOutgoingIntegration.ts b/apps/meteor/server/lib/integrations/lib/validateOutgoingIntegration.ts similarity index 98% rename from apps/meteor/app/integrations/server/lib/validateOutgoingIntegration.ts rename to apps/meteor/server/lib/integrations/lib/validateOutgoingIntegration.ts index cd97f56b2e928..d6ed64a355e78 100644 --- a/apps/meteor/app/integrations/server/lib/validateOutgoingIntegration.ts +++ b/apps/meteor/server/lib/integrations/lib/validateOutgoingIntegration.ts @@ -5,9 +5,9 @@ import { Meteor } from 'meteor/meteor'; import { compileIntegrationScript } from './compileIntegrationScript'; import { isScriptEngineFrozen } from './validateScriptEngine'; +import { outgoingEvents } from '../../../../app/integrations/lib/outgoingEvents'; import { parseCSV } from '../../../../lib/utils/parseCSV'; -import { hasPermissionAsync, hasAllPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { outgoingEvents } from '../../lib/outgoingEvents'; +import { hasPermissionAsync, hasAllPermissionAsync } from '../../authorization/hasPermission'; const scopedChannels = ['all_public_channels', 'all_private_groups', 'all_direct_messages']; const validChannelChars = ['@', '#']; diff --git a/apps/meteor/app/integrations/server/lib/validateScriptEngine.ts b/apps/meteor/server/lib/integrations/lib/validateScriptEngine.ts similarity index 100% rename from apps/meteor/app/integrations/server/lib/validateScriptEngine.ts rename to apps/meteor/server/lib/integrations/lib/validateScriptEngine.ts diff --git a/apps/meteor/app/integrations/server/logger.ts b/apps/meteor/server/lib/integrations/logger.ts similarity index 100% rename from apps/meteor/app/integrations/server/logger.ts rename to apps/meteor/server/lib/integrations/logger.ts diff --git a/apps/meteor/app/integrations/server/startup.ts b/apps/meteor/server/lib/integrations/startup.ts similarity index 100% rename from apps/meteor/app/integrations/server/startup.ts rename to apps/meteor/server/lib/integrations/startup.ts diff --git a/apps/meteor/app/integrations/server/triggers.ts b/apps/meteor/server/lib/integrations/triggers.ts similarity index 88% rename from apps/meteor/app/integrations/server/triggers.ts rename to apps/meteor/server/lib/integrations/triggers.ts index adf3d5b8bdf4d..871dbd3386fec 100644 --- a/apps/meteor/app/integrations/server/triggers.ts +++ b/apps/meteor/server/lib/integrations/triggers.ts @@ -1,6 +1,6 @@ +import { callbacks } from '../callbacks'; import { triggerHandler } from './lib/triggerHandler'; -import { callbacks } from '../../../server/lib/callbacks'; -import { afterLeaveRoomCallback } from '../../../server/lib/callbacks/afterLeaveRoomCallback'; +import { afterLeaveRoomCallback } from '../callbacks/afterLeaveRoomCallback'; const callbackHandler = function _callbackHandler(eventType: string) { return function _wrapperFunction(...args: any[]) { diff --git a/apps/meteor/server/lib/ldap/Manager.ts b/apps/meteor/server/lib/ldap/Manager.ts index 5f55f6e273dc9..87930505933dd 100644 --- a/apps/meteor/server/lib/ldap/Manager.ts +++ b/apps/meteor/server/lib/ldap/Manager.ts @@ -15,10 +15,10 @@ import { getLDAPConditionalSetting } from './getLDAPConditionalSetting'; import { getLdapDynamicValue } from './getLdapDynamicValue'; import { getLdapString } from './getLdapString'; import { ldapKeyExists } from './ldapKeyExists'; -import type { UserConverterOptions } from '../../../app/importer/server/classes/converters/UserConverter'; import { settings } from '../../../app/settings/server'; import { omit } from '../../../lib/utils/omit'; import { callbacks } from '../callbacks'; +import type { UserConverterOptions } from '../import/classes/converters/UserConverter'; import { setUserAvatar } from '../users/setUserAvatar'; export class LDAPManager { diff --git a/apps/meteor/server/lib/ldap/UserConverter.ts b/apps/meteor/server/lib/ldap/UserConverter.ts index 96225dd78ad75..1905ba2294f51 100644 --- a/apps/meteor/server/lib/ldap/UserConverter.ts +++ b/apps/meteor/server/lib/ldap/UserConverter.ts @@ -4,10 +4,10 @@ import type { Logger } from '@rocket.chat/logger'; import { Users } from '@rocket.chat/models'; import { logger } from './Logger'; -import type { ConverterCache } from '../../../app/importer/server/classes/converters/ConverterCache'; -import type { RecordConverterOptions } from '../../../app/importer/server/classes/converters/RecordConverter'; -import { UserConverter, type UserConverterOptions } from '../../../app/importer/server/classes/converters/UserConverter'; import { settings } from '../../../app/settings/server'; +import type { ConverterCache } from '../import/classes/converters/ConverterCache'; +import type { RecordConverterOptions } from '../import/classes/converters/RecordConverter'; +import { UserConverter, type UserConverterOptions } from '../import/classes/converters/UserConverter'; export class LDAPUserConverter extends UserConverter { private mergeExistingUsers: boolean; diff --git a/apps/meteor/app/assets/server/assets.ts b/apps/meteor/server/lib/media/assets/assets.ts similarity index 96% rename from apps/meteor/app/assets/server/assets.ts rename to apps/meteor/server/lib/media/assets/assets.ts index 2084b57880ef0..0c3819f2bbb6a 100644 --- a/apps/meteor/app/assets/server/assets.ts +++ b/apps/meteor/server/lib/media/assets/assets.ts @@ -9,12 +9,12 @@ import { Meteor } from 'meteor/meteor'; import { WebApp, WebAppInternals } from 'meteor/webapp'; import sharp from 'sharp'; -import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; -import { RocketChatFile } from '../../file/server'; -import { notifyOnSettingChangedById } from '../../lib/server/lib/notifyListener'; -import { settings, settingsRegistry } from '../../settings/server'; -import { getExtension } from '../../utils/lib/mimeTypes'; -import { getURL } from '../../utils/server/getURL'; +import { notifyOnSettingChangedById } from '../../../../app/lib/server/lib/notifyListener'; +import { settings, settingsRegistry } from '../../../../app/settings/server'; +import { getExtension } from '../../../../app/utils/lib/mimeTypes'; +import { getURL } from '../../../../app/utils/server/getURL'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; +import { RocketChatFile } from '../file'; const RocketChatAssetsInstance = new RocketChatFile.GridFS({ name: 'assets', diff --git a/apps/meteor/app/assets/server/index.ts b/apps/meteor/server/lib/media/assets/index.ts similarity index 100% rename from apps/meteor/app/assets/server/index.ts rename to apps/meteor/server/lib/media/assets/index.ts diff --git a/apps/meteor/app/custom-sounds/server/lib/deleteCustomSound.ts b/apps/meteor/server/lib/media/custom-sounds/lib/deleteCustomSound.ts similarity index 100% rename from apps/meteor/app/custom-sounds/server/lib/deleteCustomSound.ts rename to apps/meteor/server/lib/media/custom-sounds/lib/deleteCustomSound.ts diff --git a/apps/meteor/app/custom-sounds/server/lib/insertOrUpdateSound.ts b/apps/meteor/server/lib/media/custom-sounds/lib/insertOrUpdateSound.ts similarity index 95% rename from apps/meteor/app/custom-sounds/server/lib/insertOrUpdateSound.ts rename to apps/meteor/server/lib/media/custom-sounds/lib/insertOrUpdateSound.ts index 856852106eba6..e56b0ae233bee 100644 --- a/apps/meteor/app/custom-sounds/server/lib/insertOrUpdateSound.ts +++ b/apps/meteor/server/lib/media/custom-sounds/lib/insertOrUpdateSound.ts @@ -2,7 +2,7 @@ import { api } from '@rocket.chat/core-services'; import { CustomSounds } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import type { ICustomSoundData } from '../methods/insertOrUpdateSound'; +import type { ICustomSoundData } from '../../../../meteor-methods/media/insertOrUpdateSound'; import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds'; export const insertOrUpdateSound = async (soundData: ICustomSoundData): Promise => { diff --git a/apps/meteor/app/custom-sounds/server/lib/uploadCustomSound.ts b/apps/meteor/server/lib/media/custom-sounds/lib/uploadCustomSound.ts similarity index 89% rename from apps/meteor/app/custom-sounds/server/lib/uploadCustomSound.ts rename to apps/meteor/server/lib/media/custom-sounds/lib/uploadCustomSound.ts index 926b5a2fed540..aaa237bd9a097 100644 --- a/apps/meteor/app/custom-sounds/server/lib/uploadCustomSound.ts +++ b/apps/meteor/server/lib/media/custom-sounds/lib/uploadCustomSound.ts @@ -2,8 +2,8 @@ import { api } from '@rocket.chat/core-services'; import type { RequiredField } from '@rocket.chat/core-typings'; import { CustomSounds } from '@rocket.chat/models'; -import { RocketChatFile } from '../../../file/server'; -import type { ICustomSoundData } from '../methods/insertOrUpdateSound'; +import type { ICustomSoundData } from '../../../../meteor-methods/media/insertOrUpdateSound'; +import { RocketChatFile } from '../../file'; import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds'; export const uploadCustomSound = async ( diff --git a/apps/meteor/app/custom-sounds/server/startup/custom-sounds.js b/apps/meteor/server/lib/media/custom-sounds/startup/custom-sounds.js similarity index 93% rename from apps/meteor/app/custom-sounds/server/startup/custom-sounds.js rename to apps/meteor/server/lib/media/custom-sounds/startup/custom-sounds.js index 601157a884de6..54631ea89ef57 100644 --- a/apps/meteor/app/custom-sounds/server/startup/custom-sounds.js +++ b/apps/meteor/server/lib/media/custom-sounds/startup/custom-sounds.js @@ -2,9 +2,9 @@ import { CustomSounds } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { WebApp } from 'meteor/webapp'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { RocketChatFile } from '../../../file/server'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; +import { SystemLogger } from '../../../logger/system'; +import { RocketChatFile } from '../../file'; export let RocketChatFileCustomSoundsInstance; diff --git a/apps/meteor/app/emoji-custom/server/lib/insertOrUpdateEmoji.ts b/apps/meteor/server/lib/media/emoji-custom/lib/insertOrUpdateEmoji.ts similarity index 97% rename from apps/meteor/app/emoji-custom/server/lib/insertOrUpdateEmoji.ts rename to apps/meteor/server/lib/media/emoji-custom/lib/insertOrUpdateEmoji.ts index 2b01d05198da8..c2f4102f41831 100644 --- a/apps/meteor/app/emoji-custom/server/lib/insertOrUpdateEmoji.ts +++ b/apps/meteor/server/lib/media/emoji-custom/lib/insertOrUpdateEmoji.ts @@ -3,8 +3,8 @@ import { EmojiCustom } from '@rocket.chat/models'; import limax from 'limax'; import { Meteor } from 'meteor/meteor'; -import { trim } from '../../../../lib/utils/stringUtils'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; +import { trim } from '../../../../../lib/utils/stringUtils'; +import { hasPermissionAsync } from '../../../authorization/hasPermission'; import { RocketChatFileEmojiCustomInstance } from '../startup/emoji-custom'; export type EmojiData = { diff --git a/apps/meteor/app/emoji-custom/server/lib/uploadEmojiCustom.ts b/apps/meteor/server/lib/media/emoji-custom/lib/uploadEmojiCustom.ts similarity index 95% rename from apps/meteor/app/emoji-custom/server/lib/uploadEmojiCustom.ts rename to apps/meteor/server/lib/media/emoji-custom/lib/uploadEmojiCustom.ts index 92a7ce0b5ac9f..e39405c3af6a3 100644 --- a/apps/meteor/app/emoji-custom/server/lib/uploadEmojiCustom.ts +++ b/apps/meteor/server/lib/media/emoji-custom/lib/uploadEmojiCustom.ts @@ -6,8 +6,8 @@ import { Meteor } from 'meteor/meteor'; import sharp from 'sharp'; import type { EmojiData } from './insertOrUpdateEmoji'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { RocketChatFile } from '../../../file/server'; +import { hasPermissionAsync } from '../../../authorization/hasPermission'; +import { RocketChatFile } from '../../file'; import { RocketChatFileEmojiCustomInstance } from '../startup/emoji-custom'; const getFile = async (file: Buffer, extension: string) => { diff --git a/apps/meteor/app/emoji-custom/server/startup/emoji-custom.js b/apps/meteor/server/lib/media/emoji-custom/startup/emoji-custom.js similarity index 95% rename from apps/meteor/app/emoji-custom/server/startup/emoji-custom.js rename to apps/meteor/server/lib/media/emoji-custom/startup/emoji-custom.js index d784630013a57..25c2b07bb02f0 100644 --- a/apps/meteor/app/emoji-custom/server/startup/emoji-custom.js +++ b/apps/meteor/server/lib/media/emoji-custom/startup/emoji-custom.js @@ -3,9 +3,9 @@ import { Meteor } from 'meteor/meteor'; import { WebApp } from 'meteor/webapp'; import _ from 'underscore'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { RocketChatFile } from '../../../file/server'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; +import { SystemLogger } from '../../../logger/system'; +import { RocketChatFile } from '../../file'; export let RocketChatFileEmojiCustomInstance; diff --git a/apps/meteor/app/emoji-native/server/callbacks.ts b/apps/meteor/server/lib/media/emoji-native/callbacks.ts similarity index 63% rename from apps/meteor/app/emoji-native/server/callbacks.ts rename to apps/meteor/server/lib/media/emoji-native/callbacks.ts index 547ac33148abd..9c49341585eba 100644 --- a/apps/meteor/app/emoji-native/server/callbacks.ts +++ b/apps/meteor/server/lib/media/emoji-native/callbacks.ts @@ -1,7 +1,7 @@ import { Meteor } from 'meteor/meteor'; -import { callbacks } from '../../../server/lib/callbacks'; -import { shortnameToUnicode } from '../lib/shortnameToUnicode'; +import { shortnameToUnicode } from '../../../../app/emoji-native/lib/shortnameToUnicode'; +import { callbacks } from '../../callbacks'; Meteor.startup(() => { callbacks.add( diff --git a/apps/meteor/app/emoji-native/server/lib.ts b/apps/meteor/server/lib/media/emoji-native/lib.ts similarity index 82% rename from apps/meteor/app/emoji-native/server/lib.ts rename to apps/meteor/server/lib/media/emoji-native/lib.ts index 42ad4fac081cc..49f449fa243bc 100644 --- a/apps/meteor/app/emoji-native/server/lib.ts +++ b/apps/meteor/server/lib/media/emoji-native/lib.ts @@ -1,6 +1,6 @@ -import { emoji } from '../../emoji/server'; -import { getEmojiConfig } from '../lib/getEmojiConfig'; -import { legacyEmojioneMap } from '../lib/legacyEmojioneMap'; +import { getEmojiConfig } from '../../../../app/emoji-native/lib/getEmojiConfig'; +import { legacyEmojioneMap } from '../../../../app/emoji-native/lib/legacyEmojioneMap'; +import { emoji } from '../../messaging/emoji'; const config = getEmojiConfig(emoji); diff --git a/apps/meteor/app/file-upload/server/config/AmazonS3.ts b/apps/meteor/server/lib/media/file-upload/config/AmazonS3.ts similarity index 94% rename from apps/meteor/app/file-upload/server/config/AmazonS3.ts rename to apps/meteor/server/lib/media/file-upload/config/AmazonS3.ts index f5129b1a8daca..5831a71139e63 100644 --- a/apps/meteor/app/file-upload/server/config/AmazonS3.ts +++ b/apps/meteor/server/lib/media/file-upload/config/AmazonS3.ts @@ -4,11 +4,11 @@ import https from 'node:https'; import _ from 'underscore'; import { forceDownload } from './helper'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { settings } from '../../../settings/server'; -import type { S3Options } from '../../ufs/AmazonS3/server'; +import { settings } from '../../../../../app/settings/server'; +import { SystemLogger } from '../../../logger/system'; import { FileUploadClass, FileUpload } from '../lib/FileUpload'; -import '../../ufs/AmazonS3/server'; +import type { S3Options } from '../ufs/AmazonS3/server'; +import '../ufs/AmazonS3/server'; const hasScheme = (value: string) => /^[a-z][a-z0-9+.-]*:\/\//i.test(value); diff --git a/apps/meteor/app/file-upload/server/config/FileSystem.ts b/apps/meteor/server/lib/media/file-upload/config/FileSystem.ts similarity index 97% rename from apps/meteor/app/file-upload/server/config/FileSystem.ts rename to apps/meteor/server/lib/media/file-upload/config/FileSystem.ts index 512b2dd175f20..6d1c33153af62 100644 --- a/apps/meteor/app/file-upload/server/config/FileSystem.ts +++ b/apps/meteor/server/lib/media/file-upload/config/FileSystem.ts @@ -1,8 +1,8 @@ import fsp from 'node:fs/promises'; import { getContentDisposition } from './helper'; -import { UploadFS } from '../../../../server/ufs'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; +import { UploadFS } from '../../../../ufs'; import { FileUploadClass, FileUpload } from '../lib/FileUpload'; import { getFileRange, setRangeHeaders } from '../lib/ranges'; diff --git a/apps/meteor/app/file-upload/server/config/GoogleStorage.ts b/apps/meteor/server/lib/media/file-upload/config/GoogleStorage.ts similarity index 96% rename from apps/meteor/app/file-upload/server/config/GoogleStorage.ts rename to apps/meteor/server/lib/media/file-upload/config/GoogleStorage.ts index fface3fce7d2d..4a1286acc3974 100644 --- a/apps/meteor/app/file-upload/server/config/GoogleStorage.ts +++ b/apps/meteor/server/lib/media/file-upload/config/GoogleStorage.ts @@ -4,9 +4,9 @@ import https from 'node:https'; import _ from 'underscore'; import { forceDownload } from './helper'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; import { FileUploadClass, FileUpload } from '../lib/FileUpload'; -import '../../ufs/GoogleStorage/server'; +import '../ufs/GoogleStorage/server'; const get: FileUploadClass['get'] = async function (this: FileUploadClass, file, req, res) { const forcedDownload = forceDownload(req); diff --git a/apps/meteor/app/file-upload/server/config/GridFS.ts b/apps/meteor/server/lib/media/file-upload/config/GridFS.ts similarity index 99% rename from apps/meteor/app/file-upload/server/config/GridFS.ts rename to apps/meteor/server/lib/media/file-upload/config/GridFS.ts index 94c6629e4f245..3b8569c47f6df 100644 --- a/apps/meteor/app/file-upload/server/config/GridFS.ts +++ b/apps/meteor/server/lib/media/file-upload/config/GridFS.ts @@ -7,7 +7,7 @@ import type { IUpload } from '@rocket.chat/core-typings'; import { Logger } from '@rocket.chat/logger'; import { getContentDisposition } from './helper'; -import { UploadFS } from '../../../../server/ufs'; +import { UploadFS } from '../../../../ufs'; import { FileUploadClass, FileUpload } from '../lib/FileUpload'; import { getFileRange, setRangeHeaders } from '../lib/ranges'; diff --git a/apps/meteor/app/file-upload/server/config/Webdav.ts b/apps/meteor/server/lib/media/file-upload/config/Webdav.ts similarity index 92% rename from apps/meteor/app/file-upload/server/config/Webdav.ts rename to apps/meteor/server/lib/media/file-upload/config/Webdav.ts index 901c74e9c149e..2d17e9322d8ef 100644 --- a/apps/meteor/app/file-upload/server/config/Webdav.ts +++ b/apps/meteor/server/lib/media/file-upload/config/Webdav.ts @@ -1,9 +1,9 @@ import _ from 'underscore'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; +import { SystemLogger } from '../../../logger/system'; import { FileUploadClass, FileUpload } from '../lib/FileUpload'; -import '../../ufs/Webdav/server'; +import '../ufs/Webdav/server'; const get: FileUploadClass['get'] = async function (this: FileUploadClass, file, _req, res) { (await this.store.getReadStream(file._id, file)) diff --git a/apps/meteor/app/file-upload/server/config/_configUploadStorage.ts b/apps/meteor/server/lib/media/file-upload/config/_configUploadStorage.ts similarity index 78% rename from apps/meteor/app/file-upload/server/config/_configUploadStorage.ts rename to apps/meteor/server/lib/media/file-upload/config/_configUploadStorage.ts index 8629304cb2984..cd15603bbee97 100644 --- a/apps/meteor/app/file-upload/server/config/_configUploadStorage.ts +++ b/apps/meteor/server/lib/media/file-upload/config/_configUploadStorage.ts @@ -1,8 +1,8 @@ import _ from 'underscore'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { UploadFS } from '../../../../server/ufs'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../../app/settings/server'; +import { UploadFS } from '../../../../ufs'; +import { SystemLogger } from '../../../logger/system'; import './AmazonS3'; import './FileSystem'; import './GoogleStorage'; diff --git a/apps/meteor/app/file-upload/server/config/helper.ts b/apps/meteor/server/lib/media/file-upload/config/helper.ts similarity index 100% rename from apps/meteor/app/file-upload/server/config/helper.ts rename to apps/meteor/server/lib/media/file-upload/config/helper.ts diff --git a/apps/meteor/app/file-upload/server/index.ts b/apps/meteor/server/lib/media/file-upload/index.ts similarity index 57% rename from apps/meteor/app/file-upload/server/index.ts rename to apps/meteor/server/lib/media/file-upload/index.ts index ff2fc4fabf369..8b9db00b8dc79 100644 --- a/apps/meteor/app/file-upload/server/index.ts +++ b/apps/meteor/server/lib/media/file-upload/index.ts @@ -1,8 +1,6 @@ -import '../lib/FileUploadBase'; +import '../../../../app/file-upload/lib/FileUploadBase'; import { FileUpload } from './lib/FileUpload'; import './lib/requests'; import './config/_configUploadStorage'; -import './methods/sendFileMessage'; -import './methods/getS3FileUrl'; export { FileUpload }; diff --git a/apps/meteor/app/file-upload/server/methods/isImagePreviewSupported.ts b/apps/meteor/server/lib/media/file-upload/isImagePreviewSupported.ts similarity index 100% rename from apps/meteor/app/file-upload/server/methods/isImagePreviewSupported.ts rename to apps/meteor/server/lib/media/file-upload/isImagePreviewSupported.ts diff --git a/apps/meteor/app/file-upload/server/lib/FileUpload.spec.ts b/apps/meteor/server/lib/media/file-upload/lib/FileUpload.spec.ts similarity index 96% rename from apps/meteor/app/file-upload/server/lib/FileUpload.spec.ts rename to apps/meteor/server/lib/media/file-upload/lib/FileUpload.spec.ts index 5139de0a7f884..2320e1c982be7 100644 --- a/apps/meteor/app/file-upload/server/lib/FileUpload.spec.ts +++ b/apps/meteor/server/lib/media/file-upload/lib/FileUpload.spec.ts @@ -3,7 +3,7 @@ import { before, beforeEach, describe, it } from 'mocha'; import proxyquire from 'proxyquire'; import sinon from 'sinon'; -import { createFakeMessageWithAttachment } from '../../../../tests/mocks/data'; +import { createFakeMessageWithAttachment } from '../../../../../tests/mocks/data'; const fakeStorageModel = { findOneById: sinon.stub(), deleteFile: sinon.stub() }; const settingsStub = { watch: sinon.stub(), get: sinon.stub() }; @@ -37,19 +37,19 @@ const { FileUpload, FileUploadClass } = proxyquire.noCallThru().load('./FileUplo 'sharp': sinon.stub(), 'stream-buffers': sinon.stub(), '@rocket.chat/tools': sinon.stub(), - '../../../../server/lib/i18n': sinon.stub(), - '../../../../server/lib/logger/system': { SystemLogger: systemLoggerStub }, - '../../../../server/lib/rooms/roomCoordinator': { roomCoordinator: roomCoordinatorStub }, - '../../../../server/ufs': sinon.stub(), - '../../../../server/ufs/ufs-methods': sinon.stub(), - '../../../settings/server': { settings: settingsStub }, - '../../../utils/lib/mimeTypes': sinon.stub(), - '../../../utils/server/lib/JWTHelper': { + '../../../i18n': sinon.stub(), + '../../../logger/system': { SystemLogger: systemLoggerStub }, + '../../../rooms/roomCoordinator': { roomCoordinator: roomCoordinatorStub }, + '../../../../ufs': sinon.stub(), + '../../../../ufs/ufs-methods': sinon.stub(), + '../../../../../app/settings/server': { settings: settingsStub }, + '../../../../../app/utils/lib/mimeTypes': sinon.stub(), + '../../../../../app/utils/server/lib/JWTHelper': { validateAndDecodeJWT: validateAndDecodeJWTStub, generateJWT: sinon.stub(), }, - '../../../utils/server/restrictions': sinon.stub(), - '../../../../server/api/lib/MultipartUploadHandler': sinon.stub(), + '../../../../../app/utils/server/restrictions': sinon.stub(), + '../../../../api/lib/MultipartUploadHandler': sinon.stub(), '@rocket.chat/account-utils': { hashLoginToken: sinon.stub().callsFake((token) => `hashed_${token}`) }, }); diff --git a/apps/meteor/app/file-upload/server/lib/FileUpload.ts b/apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts similarity index 96% rename from apps/meteor/app/file-upload/server/lib/FileUpload.ts rename to apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts index 6d5d6f0500b8b..5910ee28433a0 100644 --- a/apps/meteor/app/file-upload/server/lib/FileUpload.ts +++ b/apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts @@ -25,19 +25,19 @@ import sharp from 'sharp'; import type { WritableStreamBuffer } from 'stream-buffers'; import streamBuffers from 'stream-buffers'; -import { isRenderableImageType } from '../../../../lib/renderableImageTypes'; -import { MultipartUploadHandler } from '../../../../server/api/lib/MultipartUploadHandler'; -import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../../../server/lib/authorization/canAccessRoom'; -import { i18n } from '../../../../server/lib/i18n'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator'; -import { UploadFS } from '../../../../server/ufs'; -import { ufsComplete } from '../../../../server/ufs/ufs-methods'; -import type { Store, StoreOptions } from '../../../../server/ufs/ufs-store'; -import { settings } from '../../../settings/server'; -import { mime } from '../../../utils/lib/mimeTypes'; -import { validateAndDecodeJWT, generateJWT } from '../../../utils/server/lib/JWTHelper'; -import { fileUploadIsValidContentType } from '../../../utils/server/restrictions'; +import { settings } from '../../../../../app/settings/server'; +import { mime } from '../../../../../app/utils/lib/mimeTypes'; +import { validateAndDecodeJWT, generateJWT } from '../../../../../app/utils/server/lib/JWTHelper'; +import { fileUploadIsValidContentType } from '../../../../../app/utils/server/restrictions'; +import { isRenderableImageType } from '../../../../../lib/renderableImageTypes'; +import { MultipartUploadHandler } from '../../../../api/lib/MultipartUploadHandler'; +import { UploadFS } from '../../../../ufs'; +import { ufsComplete } from '../../../../ufs/ufs-methods'; +import type { Store, StoreOptions } from '../../../../ufs/ufs-store'; +import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../../authorization/canAccessRoom'; +import { i18n } from '../../../i18n'; +import { SystemLogger } from '../../../logger/system'; +import { roomCoordinator } from '../../../rooms/roomCoordinator'; const cookie = new Cookies(); let maxFileSize = 0; diff --git a/apps/meteor/app/file-upload/server/lib/ranges.ts b/apps/meteor/server/lib/media/file-upload/lib/ranges.ts similarity index 100% rename from apps/meteor/app/file-upload/server/lib/ranges.ts rename to apps/meteor/server/lib/media/file-upload/lib/ranges.ts diff --git a/apps/meteor/app/file-upload/server/lib/requests.ts b/apps/meteor/server/lib/media/file-upload/lib/requests.ts similarity index 96% rename from apps/meteor/app/file-upload/server/lib/requests.ts rename to apps/meteor/server/lib/media/file-upload/lib/requests.ts index 22799b5cb5fae..8f509a80ba728 100644 --- a/apps/meteor/app/file-upload/server/lib/requests.ts +++ b/apps/meteor/server/lib/media/file-upload/lib/requests.ts @@ -4,7 +4,7 @@ import { Uploads } from '@rocket.chat/models'; import { WebApp } from 'meteor/webapp'; import { FileUpload } from './FileUpload'; -import { SystemLogger } from '../../../../server/lib/logger/system'; +import { SystemLogger } from '../../../logger/system'; const hasReplyWithRedirectUrlParam = (req: IncomingMessage) => { if (!req.url) { diff --git a/apps/meteor/app/file-upload/server/lib/urlExpiry.spec.ts b/apps/meteor/server/lib/media/file-upload/lib/urlExpiry.spec.ts similarity index 100% rename from apps/meteor/app/file-upload/server/lib/urlExpiry.spec.ts rename to apps/meteor/server/lib/media/file-upload/lib/urlExpiry.spec.ts diff --git a/apps/meteor/app/file-upload/server/lib/urlExpiry.ts b/apps/meteor/server/lib/media/file-upload/lib/urlExpiry.ts similarity index 100% rename from apps/meteor/app/file-upload/server/lib/urlExpiry.ts rename to apps/meteor/server/lib/media/file-upload/lib/urlExpiry.ts diff --git a/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts b/apps/meteor/server/lib/media/file-upload/ufs/AmazonS3/server.ts similarity index 94% rename from apps/meteor/app/file-upload/ufs/AmazonS3/server.ts rename to apps/meteor/server/lib/media/file-upload/ufs/AmazonS3/server.ts index 2ab3312b31f30..9b3004a8e1a0d 100644 --- a/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts +++ b/apps/meteor/server/lib/media/file-upload/ufs/AmazonS3/server.ts @@ -15,10 +15,10 @@ import { Random } from '@rocket.chat/random'; import { check } from 'meteor/check'; import _ from 'underscore'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { UploadFS } from '../../../../server/ufs'; -import type { StoreOptions } from '../../../../server/ufs/ufs-store'; -import { getUrlExpiryTimeSpanWithFallback } from '../../server/lib/urlExpiry'; +import { UploadFS } from '../../../../../ufs'; +import type { StoreOptions } from '../../../../../ufs/ufs-store'; +import { SystemLogger } from '../../../../logger/system'; +import { getUrlExpiryTimeSpanWithFallback } from '../../lib/urlExpiry'; export type S3Options = StoreOptions & { connection: S3ClientConfig; diff --git a/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts b/apps/meteor/server/lib/media/file-upload/ufs/GoogleStorage/server.ts similarity index 93% rename from apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts rename to apps/meteor/server/lib/media/file-upload/ufs/GoogleStorage/server.ts index 03b74df609b01..945790fca6b3e 100644 --- a/apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts +++ b/apps/meteor/server/lib/media/file-upload/ufs/GoogleStorage/server.ts @@ -4,10 +4,10 @@ import type { IUpload } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { check } from 'meteor/check'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { UploadFS } from '../../../../server/ufs'; -import type { StoreOptions } from '../../../../server/ufs/ufs-store'; -import { getUrlExpiryTimeSpanWithFallback } from '../../server/lib/urlExpiry'; +import { UploadFS } from '../../../../../ufs'; +import type { StoreOptions } from '../../../../../ufs/ufs-store'; +import { SystemLogger } from '../../../../logger/system'; +import { getUrlExpiryTimeSpanWithFallback } from '../../lib/urlExpiry'; type GStoreOptions = StoreOptions & { connection: { diff --git a/apps/meteor/app/file-upload/ufs/Webdav/server.ts b/apps/meteor/server/lib/media/file-upload/ufs/Webdav/server.ts similarity index 92% rename from apps/meteor/app/file-upload/ufs/Webdav/server.ts rename to apps/meteor/server/lib/media/file-upload/ufs/Webdav/server.ts index 2bb97017142a7..57352ea731aec 100644 --- a/apps/meteor/app/file-upload/ufs/Webdav/server.ts +++ b/apps/meteor/server/lib/media/file-upload/ufs/Webdav/server.ts @@ -4,10 +4,10 @@ import type { IUpload } from '@rocket.chat/core-typings'; import { Random } from '@rocket.chat/random'; import { check } from 'meteor/check'; -import { WebdavClientAdapter } from '../../../../server/bridges/webdav/lib/webdavClientAdapter'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { UploadFS } from '../../../../server/ufs'; -import type { StoreOptions } from '../../../../server/ufs/ufs-store'; +import { WebdavClientAdapter } from '../../../../../bridges/webdav/lib/webdavClientAdapter'; +import { UploadFS } from '../../../../../ufs'; +import type { StoreOptions } from '../../../../../ufs/ufs-store'; +import { SystemLogger } from '../../../../logger/system'; type WebdavOptions = StoreOptions & { connection: { diff --git a/apps/meteor/app/file/server/file.server.ts b/apps/meteor/server/lib/media/file/file.server.ts similarity index 100% rename from apps/meteor/app/file/server/file.server.ts rename to apps/meteor/server/lib/media/file/file.server.ts diff --git a/apps/meteor/app/file/server/functions/sanitizeFileName.spec.ts b/apps/meteor/server/lib/media/file/functions/sanitizeFileName.spec.ts similarity index 100% rename from apps/meteor/app/file/server/functions/sanitizeFileName.spec.ts rename to apps/meteor/server/lib/media/file/functions/sanitizeFileName.spec.ts diff --git a/apps/meteor/app/file/server/functions/sanitizeFileName.ts b/apps/meteor/server/lib/media/file/functions/sanitizeFileName.ts similarity index 100% rename from apps/meteor/app/file/server/functions/sanitizeFileName.ts rename to apps/meteor/server/lib/media/file/functions/sanitizeFileName.ts diff --git a/apps/meteor/app/file/server/index.ts b/apps/meteor/server/lib/media/file/index.ts similarity index 100% rename from apps/meteor/app/file/server/index.ts rename to apps/meteor/server/lib/media/file/index.ts diff --git a/apps/meteor/server/lib/messages/deleteMessage.ts b/apps/meteor/server/lib/messages/deleteMessage.ts index 9b6fa6a66a623..a05b70ecf252a 100644 --- a/apps/meteor/server/lib/messages/deleteMessage.ts +++ b/apps/meteor/server/lib/messages/deleteMessage.ts @@ -4,7 +4,6 @@ import { isThreadMessage, type AtLeast, type IMessage, type IRoom, type IThreadM import { Messages, Rooms, Uploads, Users, ReadReceipts, ReadReceiptsArchive, Subscriptions } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnRoomChangedById, notifyOnMessageChange, @@ -13,6 +12,7 @@ import { import { settings } from '../../../app/settings/server'; import { canDeleteMessageAsync } from '../authorization/canDeleteMessage'; import { callbacks } from '../callbacks'; +import { FileUpload } from '../media/file-upload'; export const deleteMessageValidatingPermission = async (message: AtLeast, userId: IUser['_id']): Promise => { if (!message?._id) { diff --git a/apps/meteor/server/lib/messages/parseUrlsInMessage.ts b/apps/meteor/server/lib/messages/parseUrlsInMessage.ts index 9eb7c3fd5e9d2..d5439ba113dad 100644 --- a/apps/meteor/server/lib/messages/parseUrlsInMessage.ts +++ b/apps/meteor/server/lib/messages/parseUrlsInMessage.ts @@ -1,9 +1,9 @@ import type { IMessage, AtLeast } from '@rocket.chat/core-typings'; import { extractUrlsFromMessageAST } from './extractUrlsFromMessageAST'; -import { Markdown } from '../../../app/markdown/server'; import { settings } from '../../../app/settings/server'; import { getMessageUrlRegex } from '../../../lib/getMessageUrlRegex'; +import { Markdown } from '../messaging/markdown'; const prepareUrl = (url: string, previewUrls: string[] | undefined) => ({ url, diff --git a/apps/meteor/server/lib/messages/sendMessage.ts b/apps/meteor/server/lib/messages/sendMessage.ts index 519e672865536..7866d17785b2c 100644 --- a/apps/meteor/server/lib/messages/sendMessage.ts +++ b/apps/meteor/server/lib/messages/sendMessage.ts @@ -5,13 +5,13 @@ import { Messages } from '@rocket.chat/models'; import { isAbsoluteURL } from '@rocket.chat/tools'; import { Match, check } from 'meteor/check'; -import { FileUpload } from '../../../app/file-upload/server'; -import { afterSaveMessage } from '../../../app/lib/server/lib/afterSaveMessage'; import { notifyOnRoomChangedById } from '../../../app/lib/server/lib/notifyListener'; import { validateCustomMessageFields } from '../../../app/lib/server/lib/validateCustomMessageFields'; import { settings } from '../../../app/settings/server'; import { isRelativeURL } from '../../../lib/utils/isRelativeURL'; +import { afterSaveMessage } from '../../hooks/messages/afterSaveMessage'; import { hasPermissionAsync } from '../authorization/hasPermission'; +import { FileUpload } from '../media/file-upload'; export type SendMessageOptions = { upsert?: boolean; diff --git a/apps/meteor/server/lib/messages/updateMessage.ts b/apps/meteor/server/lib/messages/updateMessage.ts index 2958923c6d941..3670ad8677bc9 100644 --- a/apps/meteor/server/lib/messages/updateMessage.ts +++ b/apps/meteor/server/lib/messages/updateMessage.ts @@ -4,10 +4,10 @@ import type { IMessage, IUser, AtLeast } from '@rocket.chat/core-typings'; import { Messages, Rooms } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { afterSaveMessage } from '../../../app/lib/server/lib/afterSaveMessage'; import { notifyOnRoomChangedById } from '../../../app/lib/server/lib/notifyListener'; import { validateCustomMessageFields } from '../../../app/lib/server/lib/validateCustomMessageFields'; import { settings } from '../../../app/settings/server'; +import { afterSaveMessage } from '../../hooks/messages/afterSaveMessage'; export const updateMessage = async function ( { diff --git a/apps/meteor/app/discussion/server/permissions.ts b/apps/meteor/server/lib/messaging/discussions/permissions.ts similarity index 100% rename from apps/meteor/app/discussion/server/permissions.ts rename to apps/meteor/server/lib/messaging/discussions/permissions.ts diff --git a/apps/meteor/app/emoji/server/lib.ts b/apps/meteor/server/lib/messaging/emoji.ts similarity index 89% rename from apps/meteor/app/emoji/server/lib.ts rename to apps/meteor/server/lib/messaging/emoji.ts index ecd109579cfe7..5825474b43af7 100644 --- a/apps/meteor/app/emoji/server/lib.ts +++ b/apps/meteor/server/lib/messaging/emoji.ts @@ -1,4 +1,4 @@ -import type { EmojiPackages } from '../lib/rocketchat'; +import type { EmojiPackages } from '../../../app/emoji/lib/rocketchat'; export const emoji: EmojiPackages = { packages: { diff --git a/apps/meteor/app/markdown/server/index.ts b/apps/meteor/server/lib/messaging/markdown.ts similarity index 78% rename from apps/meteor/app/markdown/server/index.ts rename to apps/meteor/server/lib/messaging/markdown.ts index 4642c5fcbe9a1..981979a8eec4c 100644 --- a/apps/meteor/app/markdown/server/index.ts +++ b/apps/meteor/server/lib/messaging/markdown.ts @@ -1,10 +1,10 @@ import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; -import { callbacks } from '../../../server/lib/callbacks'; -import { createMarkdownMessageRenderer, createMarkdownNotificationRenderer } from '../lib/markdown'; +import { createMarkdownMessageRenderer, createMarkdownNotificationRenderer } from '../../../app/markdown/lib/markdown'; +import { callbacks } from '../callbacks'; -export { Markdown } from '../lib/markdown'; +export { Markdown } from '../../../app/markdown/lib/markdown'; Meteor.startup(() => { Tracker.autorun(() => { diff --git a/apps/meteor/app/mentions/server/Mentions.ts b/apps/meteor/server/lib/messaging/mentions/Mentions.ts similarity index 95% rename from apps/meteor/app/mentions/server/Mentions.ts rename to apps/meteor/server/lib/messaging/mentions/Mentions.ts index c43108cc43bce..89b8c72a73a52 100644 --- a/apps/meteor/app/mentions/server/Mentions.ts +++ b/apps/meteor/server/lib/messaging/mentions/Mentions.ts @@ -4,8 +4,8 @@ */ import { isE2EEMessage, type IMessage, type IRoom, type IUser } from '@rocket.chat/core-typings'; -import { extractMentionsFromMessageAST } from '../../../server/lib/messages/extractMentionsFromMessageAST'; -import { type MentionsParserArgs, MentionsParser } from '../lib/MentionsParser'; +import { type MentionsParserArgs, MentionsParser } from '../../../../app/mentions/lib/MentionsParser'; +import { extractMentionsFromMessageAST } from '../../messages/extractMentionsFromMessageAST'; type MentionsServerArgs = MentionsParserArgs & { messageMaxAll: () => number; diff --git a/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts b/apps/meteor/server/lib/messaging/mentions/getMentionedTeamMembers.ts similarity index 88% rename from apps/meteor/app/mentions/server/getMentionedTeamMembers.ts rename to apps/meteor/server/lib/messaging/mentions/getMentionedTeamMembers.ts index 7f7274803a57a..67c1d09e2106e 100644 --- a/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts +++ b/apps/meteor/server/lib/messaging/mentions/getMentionedTeamMembers.ts @@ -1,8 +1,8 @@ import { Team } from '@rocket.chat/core-services'; import type { MessageMention } from '@rocket.chat/core-typings'; -import { callbacks } from '../../../server/lib/callbacks'; -import { settings } from '../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../callbacks'; const beforeGetMentions = async (mentionIds: string[], teamMentions: MessageMention[]): Promise => { if (!teamMentions.length) { diff --git a/apps/meteor/app/message-pin/server/pinMessage.ts b/apps/meteor/server/lib/messaging/pins/pinMessage.ts similarity index 94% rename from apps/meteor/app/message-pin/server/pinMessage.ts rename to apps/meteor/server/lib/messaging/pins/pinMessage.ts index bb0e8ac153ecc..cb2872a813aca 100644 --- a/apps/meteor/app/message-pin/server/pinMessage.ts +++ b/apps/meteor/server/lib/messaging/pins/pinMessage.ts @@ -8,13 +8,13 @@ import { isTruthy } from '@rocket.chat/tools'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; -import { isTheLastMessage } from '../../../server/lib/messages/isTheLastMessage'; -import { canAccessRoomAsync, roomAccessAttributes } from '../../authorization/server'; -import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger'; -import { notifyOnRoomChangedById, notifyOnMessageChange } from '../../lib/server/lib/notifyListener'; -import { settings } from '../../settings/server'; -import { getUserAvatarURL } from '../../utils/server/getUserAvatarURL'; +import { canAccessRoomAsync, roomAccessAttributes } from '../../../../app/authorization/server'; +import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; +import { notifyOnRoomChangedById, notifyOnMessageChange } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { getUserAvatarURL } from '../../../../app/utils/server/getUserAvatarURL'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; +import { isTheLastMessage } from '../../messages/isTheLastMessage'; const recursiveRemove = (msg: MessageAttachment, deep = 1) => { if (!msg || !isQuoteAttachment(msg)) { diff --git a/apps/meteor/app/reactions/server/setReaction.ts b/apps/meteor/server/lib/messaging/reactions/setReaction.ts similarity index 91% rename from apps/meteor/app/reactions/server/setReaction.ts rename to apps/meteor/server/lib/messaging/reactions/setReaction.ts index 4ebe9312541c0..98077253866b6 100644 --- a/apps/meteor/app/reactions/server/setReaction.ts +++ b/apps/meteor/server/lib/messaging/reactions/setReaction.ts @@ -4,13 +4,13 @@ import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings'; import { Messages, EmojiCustom, Rooms, Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; -import { callbacks } from '../../../server/lib/callbacks'; -import { i18n } from '../../../server/lib/i18n'; -import { isTheLastMessage } from '../../../server/lib/messages/isTheLastMessage'; -import { canAccessRoomAsync } from '../../authorization/server'; -import { emoji } from '../../emoji/server'; -import { notifyOnMessageChange } from '../../lib/server/lib/notifyListener'; +import { canAccessRoomAsync } from '../../../../app/authorization/server'; +import { notifyOnMessageChange } from '../../../../app/lib/server/lib/notifyListener'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; +import { callbacks } from '../../callbacks'; +import { i18n } from '../../i18n'; +import { isTheLastMessage } from '../../messages/isTheLastMessage'; +import { emoji } from '../emoji'; export const removeUserReaction = (message: IMessage, reaction: string, username: string) => { if (!message.reactions) { diff --git a/apps/meteor/app/message-star/server/starMessage.ts b/apps/meteor/server/lib/messaging/stars/starMessage.ts similarity index 88% rename from apps/meteor/app/message-star/server/starMessage.ts rename to apps/meteor/server/lib/messaging/stars/starMessage.ts index b2398657efc89..44cbc2c1a24ea 100644 --- a/apps/meteor/app/message-star/server/starMessage.ts +++ b/apps/meteor/server/lib/messaging/stars/starMessage.ts @@ -4,11 +4,11 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Messages, Subscriptions, Rooms } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { isTheLastMessage } from '../../../server/lib/messages/isTheLastMessage'; -import { canAccessRoomAsync, roomAccessAttributes } from '../../authorization/server'; -import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger'; -import { notifyOnRoomChangedById, notifyOnMessageChange } from '../../lib/server/lib/notifyListener'; -import { settings } from '../../settings/server'; +import { canAccessRoomAsync, roomAccessAttributes } from '../../../../app/authorization/server'; +import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; +import { notifyOnRoomChangedById, notifyOnMessageChange } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { isTheLastMessage } from '../../messages/isTheLastMessage'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/threads/server/functions.ts b/apps/meteor/server/lib/messaging/threads/functions.ts similarity index 94% rename from apps/meteor/app/threads/server/functions.ts rename to apps/meteor/server/lib/messaging/threads/functions.ts index 4c5db1ddf70b5..cb12a359ef4c5 100644 --- a/apps/meteor/app/threads/server/functions.ts +++ b/apps/meteor/server/lib/messaging/threads/functions.ts @@ -2,12 +2,12 @@ import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings'; import { isEditedMessage } from '@rocket.chat/core-typings'; import { Messages, Subscriptions, NotificationQueue } from '@rocket.chat/models'; -import { callbacks } from '../../../server/lib/callbacks'; import { notifyOnSubscriptionChangedByRoomIdAndUserIds, notifyOnSubscriptionChangedByRoomIdAndUserId, -} from '../../lib/server/lib/notifyListener'; -import { getMentions, getUserIdsFromHighlights } from '../../lib/server/lib/notifyUsersOnMessage'; +} from '../../../../app/lib/server/lib/notifyListener'; +import { getMentions, getUserIdsFromHighlights } from '../../../hooks/messages/notifyUsersOnMessage'; +import { callbacks } from '../../callbacks'; export async function reply({ tmid }: { tmid?: string }, message: IMessage, parentMessage: IMessage, followers: string[]) { if (!tmid || isEditedMessage(message)) { diff --git a/apps/meteor/app/message-mark-as-unread/server/logger.ts b/apps/meteor/server/lib/messaging/unread/logger.ts similarity index 100% rename from apps/meteor/app/message-mark-as-unread/server/logger.ts rename to apps/meteor/server/lib/messaging/unread/logger.ts diff --git a/apps/meteor/app/message-mark-as-unread/server/unreadMessages.ts b/apps/meteor/server/lib/messaging/unread/unreadMessages.ts similarity index 95% rename from apps/meteor/app/message-mark-as-unread/server/unreadMessages.ts rename to apps/meteor/server/lib/messaging/unread/unreadMessages.ts index cdb4f5d2a31cb..018c199712cac 100644 --- a/apps/meteor/app/message-mark-as-unread/server/unreadMessages.ts +++ b/apps/meteor/server/lib/messaging/unread/unreadMessages.ts @@ -4,8 +4,8 @@ import { Messages, Subscriptions } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import logger from './logger'; -import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger'; -import { notifyOnSubscriptionChangedByRoomIdAndUserId } from '../../lib/server/lib/notifyListener'; +import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; +import { notifyOnSubscriptionChangedByRoomIdAndUserId } from '../../../../app/lib/server/lib/notifyListener'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/metrics/server/index.ts b/apps/meteor/server/lib/metrics/index.ts similarity index 100% rename from apps/meteor/app/metrics/server/index.ts rename to apps/meteor/server/lib/metrics/index.ts diff --git a/apps/meteor/app/metrics/server/lib/collectMetrics.ts b/apps/meteor/server/lib/metrics/lib/collectMetrics.ts similarity index 94% rename from apps/meteor/app/metrics/server/lib/collectMetrics.ts rename to apps/meteor/server/lib/metrics/lib/collectMetrics.ts index 079e4d1be3692..6ff79232ddbca 100644 --- a/apps/meteor/app/metrics/server/lib/collectMetrics.ts +++ b/apps/meteor/server/lib/metrics/lib/collectMetrics.ts @@ -10,11 +10,11 @@ import gcStats from 'prometheus-gc-stats'; import _ from 'underscore'; import { metrics } from './metrics'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { getControl } from '../../../../server/lib/migrations'; -import { settings } from '../../../settings/server'; -import { getAppsStatistics } from '../../../statistics/server/lib/getAppsStatistics'; -import { Info } from '../../../utils/rocketchat.info'; +import { settings } from '../../../../app/settings/server'; +import { Info } from '../../../../app/utils/rocketchat.info'; +import { SystemLogger } from '../../logger/system'; +import { getControl } from '../../migrations'; +import { getAppsStatistics } from '../../statistics/lib/getAppsStatistics'; Facts.incrementServerFact = function (pkg: 'pkg' | 'fact', fact: string | number, increment: number): void { metrics.meteorFacts.inc({ pkg, fact }, increment); diff --git a/apps/meteor/app/metrics/server/lib/metrics.ts b/apps/meteor/server/lib/metrics/lib/metrics.ts similarity index 100% rename from apps/meteor/app/metrics/server/lib/metrics.ts rename to apps/meteor/server/lib/metrics/lib/metrics.ts diff --git a/apps/meteor/app/metrics/server/lib/statsTracker.js b/apps/meteor/server/lib/metrics/lib/statsTracker.js similarity index 100% rename from apps/meteor/app/metrics/server/lib/statsTracker.js rename to apps/meteor/server/lib/metrics/lib/statsTracker.js diff --git a/apps/meteor/server/lib/moderation/deleteReportedMessages.ts b/apps/meteor/server/lib/moderation/deleteReportedMessages.ts index c835c2f9bfe9b..e1ee56dd17788 100644 --- a/apps/meteor/server/lib/moderation/deleteReportedMessages.ts +++ b/apps/meteor/server/lib/moderation/deleteReportedMessages.ts @@ -2,8 +2,8 @@ import { api } from '@rocket.chat/core-services'; import type { IUser, IMessage } from '@rocket.chat/core-typings'; import { Messages, Uploads, ReadReceipts, ReadReceiptsArchive } from '@rocket.chat/models'; -import { FileUpload } from '../../../app/file-upload/server'; import { settings } from '../../../app/settings/server'; +import { FileUpload } from '../media/file-upload'; // heavily inspired from message delete taking place in the user deletion process // in this path we don't care about the apps engine events - it's a "raw" bulk action diff --git a/apps/meteor/app/notifications/server/index.ts b/apps/meteor/server/lib/notifications/core/index.ts similarity index 100% rename from apps/meteor/app/notifications/server/index.ts rename to apps/meteor/server/lib/notifications/core/index.ts diff --git a/apps/meteor/app/notifications/server/lib/Notifications.ts b/apps/meteor/server/lib/notifications/core/lib/Notifications.ts similarity index 84% rename from apps/meteor/app/notifications/server/lib/Notifications.ts rename to apps/meteor/server/lib/notifications/core/lib/Notifications.ts index 3ddb611d76bd1..d5aca0eede04b 100644 --- a/apps/meteor/app/notifications/server/lib/Notifications.ts +++ b/apps/meteor/server/lib/notifications/core/lib/Notifications.ts @@ -3,8 +3,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { DDPCommon } from 'meteor/ddp-common'; import { Meteor } from 'meteor/meteor'; -import { NotificationsModule } from '../../../../server/modules/notifications/notifications.module'; -import { Streamer } from '../../../../server/modules/streamer/streamer.module'; +import { NotificationsModule } from '../../../../modules/notifications/notifications.module'; +import { Streamer } from '../../../../modules/streamer/streamer.module'; import './Presence'; diff --git a/apps/meteor/app/notifications/server/lib/Presence.ts b/apps/meteor/server/lib/notifications/core/lib/Presence.ts similarity index 96% rename from apps/meteor/app/notifications/server/lib/Presence.ts rename to apps/meteor/server/lib/notifications/core/lib/Presence.ts index fa8a2ac9630ab..5eecbfe1ede99 100644 --- a/apps/meteor/app/notifications/server/lib/Presence.ts +++ b/apps/meteor/server/lib/notifications/core/lib/Presence.ts @@ -2,8 +2,8 @@ import type { IUser } from '@rocket.chat/core-typings'; import type { StreamerEvents } from '@rocket.chat/ddp-client'; import { Emitter } from '@rocket.chat/emitter'; -import { Streamer } from '../../../../server/modules/streamer/streamer.module'; -import type { IPublication, IStreamerConstructor, Connection, IStreamer } from '../../../../server/modules/streamer/types'; +import { Streamer } from '../../../../modules/streamer/streamer.module'; +import type { IPublication, IStreamerConstructor, Connection, IStreamer } from '../../../../modules/streamer/types'; type UserPresenceStreamProps = { added: IUser['_id'][]; diff --git a/apps/meteor/app/mailer/server/api.ts b/apps/meteor/server/lib/notifications/email/api.ts similarity index 95% rename from apps/meteor/app/mailer/server/api.ts rename to apps/meteor/server/lib/notifications/email/api.ts index 8fc98f884cb5c..ec26566a51b9f 100644 --- a/apps/meteor/app/mailer/server/api.ts +++ b/apps/meteor/server/lib/notifications/email/api.ts @@ -10,10 +10,10 @@ import { stripHtml } from 'string-strip-html'; import _ from 'underscore'; import { replaceVariables } from './replaceVariables'; -import { strLeft, strRightBack } from '../../../lib/utils/stringUtils'; -import { i18n } from '../../../server/lib/i18n'; -import { notifyOnSettingChanged } from '../../lib/server/lib/notifyListener'; -import { settings } from '../../settings/server'; +import { notifyOnSettingChanged } from '../../../../app/lib/server/lib/notifyListener'; +import { settings } from '../../../../app/settings/server'; +import { strLeft, strRightBack } from '../../../../lib/utils/stringUtils'; +import { i18n } from '../../i18n'; let contentHeader: string | undefined; let contentFooter: string | undefined; diff --git a/apps/meteor/app/mailer/server/replaceVariables.ts b/apps/meteor/server/lib/notifications/email/replaceVariables.ts similarity index 100% rename from apps/meteor/app/mailer/server/replaceVariables.ts rename to apps/meteor/server/lib/notifications/email/replaceVariables.ts diff --git a/apps/meteor/app/mail-messages/server/functions/sendMail.ts b/apps/meteor/server/lib/notifications/mail-messages/functions/sendMail.ts similarity index 89% rename from apps/meteor/app/mail-messages/server/functions/sendMail.ts rename to apps/meteor/server/lib/notifications/mail-messages/functions/sendMail.ts index c0e179d919d0a..4fa229aa5616d 100644 --- a/apps/meteor/app/mail-messages/server/functions/sendMail.ts +++ b/apps/meteor/server/lib/notifications/mail-messages/functions/sendMail.ts @@ -5,10 +5,10 @@ import EJSON from 'ejson'; import { Meteor } from 'meteor/meteor'; import type { Filter } from 'mongodb'; -import { generatePath } from '../../../../lib/utils/generatePath'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import * as Mailer from '../../../mailer/server/api'; -import { placeholders } from '../../../utils/server/placeholders'; +import { placeholders } from '../../../../../app/utils/server/placeholders'; +import { generatePath } from '../../../../../lib/utils/generatePath'; +import { SystemLogger } from '../../../logger/system'; +import * as Mailer from '../../email/api'; export const sendMail = async function ({ from, diff --git a/apps/meteor/app/mail-messages/server/functions/unsubscribe.ts b/apps/meteor/server/lib/notifications/mail-messages/functions/unsubscribe.ts similarity index 85% rename from apps/meteor/app/mail-messages/server/functions/unsubscribe.ts rename to apps/meteor/server/lib/notifications/mail-messages/functions/unsubscribe.ts index 3d14f801fdb2f..8d24df86d4fac 100644 --- a/apps/meteor/app/mail-messages/server/functions/unsubscribe.ts +++ b/apps/meteor/server/lib/notifications/mail-messages/functions/unsubscribe.ts @@ -1,6 +1,6 @@ import { Users } from '@rocket.chat/models'; -import { SystemLogger } from '../../../../server/lib/logger/system'; +import { SystemLogger } from '../../../logger/system'; export const unsubscribe = async function (_id: string, createdAt: string): Promise { if (_id && createdAt) { diff --git a/apps/meteor/app/mail-messages/server/lib/Mailer.ts b/apps/meteor/server/lib/notifications/mail-messages/lib/Mailer.ts similarity index 100% rename from apps/meteor/app/mail-messages/server/lib/Mailer.ts rename to apps/meteor/server/lib/notifications/mail-messages/lib/Mailer.ts diff --git a/apps/meteor/app/push-notifications/server/index.ts b/apps/meteor/server/lib/notifications/push-config/index.ts similarity index 65% rename from apps/meteor/app/push-notifications/server/index.ts rename to apps/meteor/server/lib/notifications/push-config/index.ts index c42819a559039..c39a9296551b1 100644 --- a/apps/meteor/app/push-notifications/server/index.ts +++ b/apps/meteor/server/lib/notifications/push-config/index.ts @@ -1,4 +1,3 @@ -import './methods/saveNotificationSettings'; import PushNotification from './lib/PushNotification'; export { PushNotification }; diff --git a/apps/meteor/app/push-notifications/server/lib/PushNotification.ts b/apps/meteor/server/lib/notifications/push-config/lib/PushNotification.ts similarity index 89% rename from apps/meteor/app/push-notifications/server/lib/PushNotification.ts rename to apps/meteor/server/lib/notifications/push-config/lib/PushNotification.ts index 33c752825ae97..f6ef4c10d2c40 100644 --- a/apps/meteor/app/push-notifications/server/lib/PushNotification.ts +++ b/apps/meteor/server/lib/notifications/push-config/lib/PushNotification.ts @@ -2,13 +2,13 @@ import type { IMessage, IPushNotificationConfig, IRoom, IUser } from '@rocket.ch import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { RocketChatAssets } from '../../../assets/server'; -import { replaceMentionedUsernamesWithFullNames, parseMessageTextPerUser } from '../../../lib/server/functions/notifications'; -import { getPushData } from '../../../lib/server/functions/notifications/mobile'; -import { metrics } from '../../../metrics/server'; -import { Push } from '../../../push/server'; -import { settings } from '../../../settings/server'; +import { replaceMentionedUsernamesWithFullNames, parseMessageTextPerUser } from '../../../../../app/lib/server/functions/notifications'; +import { getPushData } from '../../../../../app/lib/server/functions/notifications/mobile'; +import { settings } from '../../../../../app/settings/server'; +import { callbacks } from '../../../callbacks'; +import { RocketChatAssets } from '../../../media/assets'; +import { metrics } from '../../../metrics'; +import { Push } from '../../push'; type PushNotificationData = { rid: string; diff --git a/apps/meteor/app/push/server/apn.spec.ts b/apps/meteor/server/lib/notifications/push/apn.spec.ts similarity index 100% rename from apps/meteor/app/push/server/apn.spec.ts rename to apps/meteor/server/lib/notifications/push/apn.spec.ts diff --git a/apps/meteor/app/push/server/apn.ts b/apps/meteor/server/lib/notifications/push/apn.ts similarity index 100% rename from apps/meteor/app/push/server/apn.ts rename to apps/meteor/server/lib/notifications/push/apn.ts diff --git a/apps/meteor/app/push/server/definition.ts b/apps/meteor/server/lib/notifications/push/definition.ts similarity index 100% rename from apps/meteor/app/push/server/definition.ts rename to apps/meteor/server/lib/notifications/push/definition.ts diff --git a/apps/meteor/app/push/server/fcm.ts b/apps/meteor/server/lib/notifications/push/fcm.ts similarity index 100% rename from apps/meteor/app/push/server/fcm.ts rename to apps/meteor/server/lib/notifications/push/fcm.ts diff --git a/apps/meteor/app/push/server/index.ts b/apps/meteor/server/lib/notifications/push/index.ts similarity index 59% rename from apps/meteor/app/push/server/index.ts rename to apps/meteor/server/lib/notifications/push/index.ts index 4cfcaa2da26f7..189b11d1c0681 100644 --- a/apps/meteor/app/push/server/index.ts +++ b/apps/meteor/server/lib/notifications/push/index.ts @@ -1,3 +1 @@ -import './methods'; - export { Push } from './push'; diff --git a/apps/meteor/app/push/server/logger.ts b/apps/meteor/server/lib/notifications/push/logger.ts similarity index 100% rename from apps/meteor/app/push/server/logger.ts rename to apps/meteor/server/lib/notifications/push/logger.ts diff --git a/apps/meteor/app/push/server/push.ts b/apps/meteor/server/lib/notifications/push/push.ts similarity index 99% rename from apps/meteor/app/push/server/push.ts rename to apps/meteor/server/lib/notifications/push/push.ts index 38dc3b79afd51..856edc308c523 100644 --- a/apps/meteor/app/push/server/push.ts +++ b/apps/meteor/server/lib/notifications/push/push.ts @@ -12,7 +12,7 @@ import { initAPN, sendAPN, shutdownAPN } from './apn'; import type { PushOptions, PendingPushNotification } from './definition'; import { sendFCM } from './fcm'; import { logger } from './logger'; -import { settings } from '../../settings/server'; +import { settings } from '../../../../app/settings/server'; export const _matchToken = Match.OneOf({ apn: String }, { gcm: String }); diff --git a/apps/meteor/app/notification-queue/server/NotificationQueue.ts b/apps/meteor/server/lib/notifications/queue/NotificationQueue.ts similarity index 94% rename from apps/meteor/app/notification-queue/server/NotificationQueue.ts rename to apps/meteor/server/lib/notifications/queue/NotificationQueue.ts index 87218cb869eb6..7e52afd61a3b8 100644 --- a/apps/meteor/app/notification-queue/server/NotificationQueue.ts +++ b/apps/meteor/server/lib/notifications/queue/NotificationQueue.ts @@ -3,9 +3,9 @@ import { NotificationQueue, Users } from '@rocket.chat/models'; import { tracerSpan } from '@rocket.chat/tracing'; import { Meteor } from 'meteor/meteor'; -import { SystemLogger } from '../../../server/lib/logger/system'; -import { sendEmailFromData } from '../../lib/server/functions/notifications/email'; -import { PushNotification } from '../../push-notifications/server'; +import { sendEmailFromData } from '../../../../app/lib/server/functions/notifications/email'; +import { SystemLogger } from '../../logger/system'; +import { PushNotification } from '../push-config'; const { NOTIFICATIONS_WORKER_TIMEOUT = 2000, diff --git a/apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts b/apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts index 36cf866983df2..3f4d615bdd17c 100644 --- a/apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts +++ b/apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts @@ -5,9 +5,9 @@ import type { DoneCallback, Profile } from 'passport'; import { allowPassportOAuthMiddleware } from './allowPassportOAuthMiddleware'; import { passportOAuthCallback } from './passportOAuthCallback'; import { verifyFunction } from './verifyFunction'; -import { CustomOAuthStrategy } from '../../../app/custom-oauth/server/customOAuth'; import { settings } from '../../../app/settings/server'; import { oAuthRouter } from '../../configuration/configurePassport'; +import { CustomOAuthStrategy } from '../auth-providers/custom-oauth/customOAuth'; export const addPassportCustomOAuth = ( serviceName: string, diff --git a/apps/meteor/server/lib/oauth/twoFactorAuth.ts b/apps/meteor/server/lib/oauth/twoFactorAuth.ts index 2c97ff5fc5244..22302b79bb4a9 100644 --- a/apps/meteor/server/lib/oauth/twoFactorAuth.ts +++ b/apps/meteor/server/lib/oauth/twoFactorAuth.ts @@ -1,8 +1,8 @@ import type { IUser } from '@rocket.chat/core-typings'; -import { getRememberDate } from '../../../app/2fa/server/code'; -import { EmailCheckForOAuth } from '../../../app/2fa/server/code/EmailCheckForOAuth'; -import { TOTPCheckForOAuth } from '../../../app/2fa/server/code/TOTPCheckForOAuth'; +import { getRememberDate } from '../2fa/code'; +import { EmailCheckForOAuth } from '../2fa/code/EmailCheckForOAuth'; +import { TOTPCheckForOAuth } from '../2fa/code/TOTPCheckForOAuth'; export const emailCheckForOAuth = new EmailCheckForOAuth(); export const totpCheckForOAuth = new TOTPCheckForOAuth(); diff --git a/apps/meteor/server/lib/oauth/updateOAuthServices.ts b/apps/meteor/server/lib/oauth/updateOAuthServices.ts index a01755e0a8cfe..7a86c348d5a5b 100644 --- a/apps/meteor/server/lib/oauth/updateOAuthServices.ts +++ b/apps/meteor/server/lib/oauth/updateOAuthServices.ts @@ -9,12 +9,12 @@ import { LoginServiceConfiguration } from '@rocket.chat/models'; import { addPassportCustomOAuth } from './addPassportCustomOAuth'; import { logger } from './logger'; -import { CustomOAuth } from '../../../app/custom-oauth/server/custom_oauth_server'; import { notifyOnLoginServiceConfigurationChanged, notifyOnLoginServiceConfigurationChangedByService, } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server/cached'; +import { CustomOAuth } from '../auth-providers/custom-oauth/custom_oauth_server'; export async function updateOAuthServices(): Promise { const services = settings.getByRegexp(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i); diff --git a/apps/meteor/server/lib/pushConfig.ts b/apps/meteor/server/lib/pushConfig.ts index d841d64376243..015b17afe0b6b 100644 --- a/apps/meteor/server/lib/pushConfig.ts +++ b/apps/meteor/server/lib/pushConfig.ts @@ -5,8 +5,8 @@ import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from './authorization/hasPermission'; import { i18n } from './i18n'; +import { Push } from './notifications/push'; import { RateLimiter } from '../../app/lib/server/lib'; -import { Push } from '../../app/push/server'; import { settings } from '../../app/settings/server'; export const executePushTest = async (userId: IUser['_id'], username: IUser['username']): Promise => { diff --git a/apps/meteor/server/lib/refreshLoginServices.ts b/apps/meteor/server/lib/refreshLoginServices.ts index 41c5691a6de89..2b4ffa6838d4d 100644 --- a/apps/meteor/server/lib/refreshLoginServices.ts +++ b/apps/meteor/server/lib/refreshLoginServices.ts @@ -2,7 +2,7 @@ import { ServiceConfiguration } from 'meteor/service-configuration'; import { updateCasServices } from './cas/updateCasService'; import { updateOAuthServices } from './oauth/updateOAuthServices'; -import { loadSamlServiceProviders } from '../../app/meteor-accounts-saml/server/lib/settings'; +import { loadSamlServiceProviders } from './saml/lib/settings'; export async function refreshLoginServices(): Promise { await ServiceConfiguration.configurations.removeAsync({}); diff --git a/apps/meteor/server/lib/resetUserE2EKey.ts b/apps/meteor/server/lib/resetUserE2EKey.ts index 151916b9bab36..dab5bb90d9dce 100644 --- a/apps/meteor/server/lib/resetUserE2EKey.ts +++ b/apps/meteor/server/lib/resetUserE2EKey.ts @@ -4,8 +4,8 @@ import { Meteor } from 'meteor/meteor'; import { i18n } from './i18n'; import { isUserIdFederated } from './isUserIdFederated'; +import * as Mailer from './notifications/email/api'; import { notifyOnUserChange, notifyOnSubscriptionChangedByUserId } from '../../app/lib/server/lib/notifyListener'; -import * as Mailer from '../../app/mailer/server/api'; import { settings } from '../../app/settings/server'; const sendResetNotification = async function (uid: string): Promise { diff --git a/apps/meteor/server/lib/rooms/addUserToRoom.ts b/apps/meteor/server/lib/rooms/addUserToRoom.ts index fdaf479808684..6a278b2bf6c0b 100644 --- a/apps/meteor/server/lib/rooms/addUserToRoom.ts +++ b/apps/meteor/server/lib/rooms/addUserToRoom.ts @@ -8,9 +8,9 @@ import { Meteor } from 'meteor/meteor'; import { RoomMemberActions } from '../../../definition/IRoomTypeConfig'; import { callbacks } from '../callbacks'; import { roomCoordinator } from './roomCoordinator'; -import { beforeAddUserToRoom as beforeAddUserToRoomPatch } from '../../../app/lib/server/lib/beforeAddUserToRoom'; import { notifyOnRoomChangedById, notifyOnSubscriptionChanged } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; +import { beforeAddUserToRoom as beforeAddUserToRoomPatch } from '../../hooks/rooms/beforeAddUserToRoom'; import { beforeAddUserToRoom } from '../callbacks/beforeAddUserToRoom'; /** diff --git a/apps/meteor/server/lib/rooms/cleanRoomHistory.ts b/apps/meteor/server/lib/rooms/cleanRoomHistory.ts index bdc318d40022f..69879a78ebbc3 100644 --- a/apps/meteor/server/lib/rooms/cleanRoomHistory.ts +++ b/apps/meteor/server/lib/rooms/cleanRoomHistory.ts @@ -3,10 +3,10 @@ import type { IRoom } from '@rocket.chat/core-typings'; import { Messages, Rooms, Subscriptions, ReadReceipts, ReadReceiptsArchive } from '@rocket.chat/models'; import { deleteRoom } from './deleteRoom'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnRoomChangedById, notifyOnSubscriptionChangedById } from '../../../app/lib/server/lib/notifyListener'; import { NOTIFICATION_ATTACHMENT_COLOR } from '../../../lib/constants'; import { i18n } from '../i18n'; +import { FileUpload } from '../media/file-upload'; const FILE_CLEANUP_BATCH_SIZE = 1000; diff --git a/apps/meteor/server/lib/rooms/deleteRoom.ts b/apps/meteor/server/lib/rooms/deleteRoom.ts index 7febb5d7782c2..5b2d03c1aa561 100644 --- a/apps/meteor/server/lib/rooms/deleteRoom.ts +++ b/apps/meteor/server/lib/rooms/deleteRoom.ts @@ -1,8 +1,8 @@ import { Messages, Rooms, Subscriptions } from '@rocket.chat/models'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnRoomChangedById, notifyOnSubscriptionChanged } from '../../../app/lib/server/lib/notifyListener'; import { callbacks } from '../callbacks'; +import { FileUpload } from '../media/file-upload'; export const deleteRoom = async function (rid: string): Promise { await FileUpload.removeFilesByRoomId(rid); diff --git a/apps/meteor/server/lib/rooms/relinquishRoomOwnerships.ts b/apps/meteor/server/lib/rooms/relinquishRoomOwnerships.ts index ab8c5dbaf77f7..d03dd0698a932 100644 --- a/apps/meteor/server/lib/rooms/relinquishRoomOwnerships.ts +++ b/apps/meteor/server/lib/rooms/relinquishRoomOwnerships.ts @@ -2,9 +2,9 @@ import type { IRoom } from '@rocket.chat/core-typings'; import { Messages, Rooms, Subscriptions, ReadReceipts, ReadReceiptsArchive, Team } from '@rocket.chat/models'; import type { SubscribedRoomsForUserWithDetails } from './getRoomsWithSingleOwner'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnSubscriptionChanged } from '../../../app/lib/server/lib/notifyListener'; import { eraseRoomLooseValidation, eraseTeamOnRelinquishRoomOwnerships } from '../../api/lib/eraseTeam'; +import { FileUpload } from '../media/file-upload'; import { addUserRolesAsync } from '../roles/addUserRoles'; const bulkTeamCleanup = async (rids: IRoom['_id'][]) => { diff --git a/apps/meteor/server/lib/rooms/setRoomAvatar.ts b/apps/meteor/server/lib/rooms/setRoomAvatar.ts index cc12f6303f361..7b19f6a14b19b 100644 --- a/apps/meteor/server/lib/rooms/setRoomAvatar.ts +++ b/apps/meteor/server/lib/rooms/setRoomAvatar.ts @@ -4,8 +4,8 @@ import { isRegisterUser } from '@rocket.chat/core-typings'; import { Avatars, Rooms } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { RocketChatFile } from '../../../app/file/server'; -import { FileUpload } from '../../../app/file-upload/server'; +import { RocketChatFile } from '../media/file'; +import { FileUpload } from '../media/file-upload'; export const setRoomAvatar = async function (rid: string, dataURI: string, user: IUser): Promise { if (!isRegisterUser(user)) { diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/IAttributeMapping.ts b/apps/meteor/server/lib/saml/definition/IAttributeMapping.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/IAttributeMapping.ts rename to apps/meteor/server/lib/saml/definition/IAttributeMapping.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/IAuthorizeRequestVariables.ts b/apps/meteor/server/lib/saml/definition/IAuthorizeRequestVariables.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/IAuthorizeRequestVariables.ts rename to apps/meteor/server/lib/saml/definition/IAuthorizeRequestVariables.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutRequestVariables.ts b/apps/meteor/server/lib/saml/definition/ILogoutRequestVariables.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutRequestVariables.ts rename to apps/meteor/server/lib/saml/definition/ILogoutRequestVariables.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutResponse.ts b/apps/meteor/server/lib/saml/definition/ILogoutResponse.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutResponse.ts rename to apps/meteor/server/lib/saml/definition/ILogoutResponse.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutResponseVariables.ts b/apps/meteor/server/lib/saml/definition/ILogoutResponseVariables.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ILogoutResponseVariables.ts rename to apps/meteor/server/lib/saml/definition/ILogoutResponseVariables.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/IMetadataVariables.ts b/apps/meteor/server/lib/saml/definition/IMetadataVariables.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/IMetadataVariables.ts rename to apps/meteor/server/lib/saml/definition/IMetadataVariables.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLAction.ts b/apps/meteor/server/lib/saml/definition/ISAMLAction.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLAction.ts rename to apps/meteor/server/lib/saml/definition/ISAMLAction.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLAssertion.ts b/apps/meteor/server/lib/saml/definition/ISAMLAssertion.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLAssertion.ts rename to apps/meteor/server/lib/saml/definition/ISAMLAssertion.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLGlobalSettings.ts b/apps/meteor/server/lib/saml/definition/ISAMLGlobalSettings.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLGlobalSettings.ts rename to apps/meteor/server/lib/saml/definition/ISAMLGlobalSettings.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLRequest.ts b/apps/meteor/server/lib/saml/definition/ISAMLRequest.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLRequest.ts rename to apps/meteor/server/lib/saml/definition/ISAMLRequest.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLUser.ts b/apps/meteor/server/lib/saml/definition/ISAMLUser.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/ISAMLUser.ts rename to apps/meteor/server/lib/saml/definition/ISAMLUser.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/IServiceProviderOptions.ts b/apps/meteor/server/lib/saml/definition/IServiceProviderOptions.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/IServiceProviderOptions.ts rename to apps/meteor/server/lib/saml/definition/IServiceProviderOptions.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/SAMLEnvelope.ts b/apps/meteor/server/lib/saml/definition/SAMLEnvelope.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/SAMLEnvelope.ts rename to apps/meteor/server/lib/saml/definition/SAMLEnvelope.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/definition/callbacks.ts b/apps/meteor/server/lib/saml/definition/callbacks.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/definition/callbacks.ts rename to apps/meteor/server/lib/saml/definition/callbacks.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts b/apps/meteor/server/lib/saml/lib/SAML.ts similarity index 97% rename from apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts rename to apps/meteor/server/lib/saml/lib/SAML.ts index f8e8369a8ebbb..7fc20a0f6af8e 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts +++ b/apps/meteor/server/lib/saml/lib/SAML.ts @@ -10,14 +10,14 @@ import { Meteor } from 'meteor/meteor'; import { SAMLServiceProvider } from './ServiceProvider'; import { SAMLUtils } from './Utils'; import { getSAMLEnvelope } from './getSAMLEnvelope'; +import { settings } from '../../../../app/settings/server'; +import { i18n } from '../../../../app/utils/lib/i18n'; import { ensureArray } from '../../../../lib/utils/arrayUtils'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { addUserToRoom } from '../../../../server/lib/rooms/addUserToRoom'; -import { createRoom } from '../../../../server/lib/rooms/createRoom'; -import { generateUsernameSuggestion } from '../../../../server/lib/users/getUsernameSuggestion'; -import { saveUserIdentity } from '../../../../server/lib/users/saveUserIdentity'; -import { settings } from '../../../settings/server'; -import { i18n } from '../../../utils/lib/i18n'; +import { SystemLogger } from '../../logger/system'; +import { addUserToRoom } from '../../rooms/addUserToRoom'; +import { createRoom } from '../../rooms/createRoom'; +import { generateUsernameSuggestion } from '../../users/getUsernameSuggestion'; +import { saveUserIdentity } from '../../users/saveUserIdentity'; import type { ISAMLAction } from '../definition/ISAMLAction'; import type { ISAMLUser } from '../definition/ISAMLUser'; import type { IServiceProviderOptions } from '../definition/IServiceProviderOptions'; diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/ServiceProvider.ts b/apps/meteor/server/lib/saml/lib/ServiceProvider.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/ServiceProvider.ts rename to apps/meteor/server/lib/saml/lib/ServiceProvider.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts b/apps/meteor/server/lib/saml/lib/Utils.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts rename to apps/meteor/server/lib/saml/lib/Utils.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/constants.ts b/apps/meteor/server/lib/saml/lib/constants.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/constants.ts rename to apps/meteor/server/lib/saml/lib/constants.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/generators/AuthorizeRequest.ts b/apps/meteor/server/lib/saml/lib/generators/AuthorizeRequest.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/generators/AuthorizeRequest.ts rename to apps/meteor/server/lib/saml/lib/generators/AuthorizeRequest.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/generators/LogoutRequest.ts b/apps/meteor/server/lib/saml/lib/generators/LogoutRequest.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/generators/LogoutRequest.ts rename to apps/meteor/server/lib/saml/lib/generators/LogoutRequest.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/generators/LogoutResponse.ts b/apps/meteor/server/lib/saml/lib/generators/LogoutResponse.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/generators/LogoutResponse.ts rename to apps/meteor/server/lib/saml/lib/generators/LogoutResponse.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/generators/ServiceProviderMetadata.ts b/apps/meteor/server/lib/saml/lib/generators/ServiceProviderMetadata.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/generators/ServiceProviderMetadata.ts rename to apps/meteor/server/lib/saml/lib/generators/ServiceProviderMetadata.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/getSAMLEnvelope.ts b/apps/meteor/server/lib/saml/lib/getSAMLEnvelope.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/getSAMLEnvelope.ts rename to apps/meteor/server/lib/saml/lib/getSAMLEnvelope.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/parsers/LogoutRequest.ts b/apps/meteor/server/lib/saml/lib/parsers/LogoutRequest.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/parsers/LogoutRequest.ts rename to apps/meteor/server/lib/saml/lib/parsers/LogoutRequest.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/parsers/LogoutResponse.ts b/apps/meteor/server/lib/saml/lib/parsers/LogoutResponse.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/parsers/LogoutResponse.ts rename to apps/meteor/server/lib/saml/lib/parsers/LogoutResponse.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/parsers/Response.ts b/apps/meteor/server/lib/saml/lib/parsers/Response.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/parsers/Response.ts rename to apps/meteor/server/lib/saml/lib/parsers/Response.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts b/apps/meteor/server/lib/saml/lib/settings.ts similarity index 98% rename from apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts rename to apps/meteor/server/lib/saml/lib/settings.ts index 7231d6fa59ad8..ce24a426f6e55 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts +++ b/apps/meteor/server/lib/saml/lib/settings.ts @@ -14,12 +14,12 @@ import { defaultMetadataTemplate, defaultMetadataCertificateTemplate, } from './constants'; -import { SystemLogger } from '../../../../server/lib/logger/system'; import { notifyOnLoginServiceConfigurationChanged, notifyOnLoginServiceConfigurationChangedByService, -} from '../../../lib/server/lib/notifyListener'; -import { settings, settingsRegistry } from '../../../settings/server'; +} from '../../../../app/lib/server/lib/notifyListener'; +import { settings, settingsRegistry } from '../../../../app/settings/server'; +import { SystemLogger } from '../../logger/system'; import type { IServiceProviderOptions } from '../definition/IServiceProviderOptions'; const getSamlConfigs = function (service: string): SAMLConfiguration { diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/signature/signatureAlgorithms.ts b/apps/meteor/server/lib/saml/lib/signature/signatureAlgorithms.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/signature/signatureAlgorithms.ts rename to apps/meteor/server/lib/saml/lib/signature/signatureAlgorithms.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/signature/validateRedirectSignature.ts b/apps/meteor/server/lib/saml/lib/signature/validateRedirectSignature.ts similarity index 100% rename from apps/meteor/app/meteor-accounts-saml/server/lib/signature/validateRedirectSignature.ts rename to apps/meteor/server/lib/saml/lib/signature/validateRedirectSignature.ts diff --git a/apps/meteor/app/meteor-accounts-saml/server/listener.ts b/apps/meteor/server/lib/saml/listener.ts similarity index 97% rename from apps/meteor/app/meteor-accounts-saml/server/listener.ts rename to apps/meteor/server/lib/saml/listener.ts index 665be0506531f..588c81230cee0 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/listener.ts +++ b/apps/meteor/server/lib/saml/listener.ts @@ -9,7 +9,7 @@ import { WebApp } from 'meteor/webapp'; import type { ISAMLAction } from './definition/ISAMLAction'; import { SAML } from './lib/SAML'; import { SAMLUtils } from './lib/Utils'; -import { SystemLogger } from '../../../server/lib/logger/system'; +import { SystemLogger } from '../logger/system'; RoutePolicy.declare('/_saml/', 'network'); diff --git a/apps/meteor/app/meteor-accounts-saml/server/loginHandler.ts b/apps/meteor/server/lib/saml/loginHandler.ts similarity index 93% rename from apps/meteor/app/meteor-accounts-saml/server/loginHandler.ts rename to apps/meteor/server/lib/saml/loginHandler.ts index 8b2059489931c..0a7c377fdf047 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/loginHandler.ts +++ b/apps/meteor/server/lib/saml/loginHandler.ts @@ -2,10 +2,10 @@ import { CredentialTokens } from '@rocket.chat/models'; import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; +import { i18n } from '../i18n'; import { SAML } from './lib/SAML'; import { SAMLUtils } from './lib/Utils'; -import { i18n } from '../../../server/lib/i18n'; -import { SystemLogger } from '../../../server/lib/logger/system'; +import { SystemLogger } from '../logger/system'; const makeError = (message: string): Record => ({ type: 'saml', diff --git a/apps/meteor/app/meteor-accounts-saml/server/startup.ts b/apps/meteor/server/lib/saml/startup.ts similarity index 89% rename from apps/meteor/app/meteor-accounts-saml/server/startup.ts rename to apps/meteor/server/lib/saml/startup.ts index 721edce08d463..6a4e3fa0afd3d 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/startup.ts +++ b/apps/meteor/server/lib/saml/startup.ts @@ -4,7 +4,7 @@ import { Meteor } from 'meteor/meteor'; import { SAMLUtils } from './lib/Utils'; import { loadSamlServiceProviders, addSettings } from './lib/settings'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; const logger = new Logger('steffo:meteor-accounts-saml'); SAMLUtils.setLoggerInstance(logger); diff --git a/apps/meteor/app/search/server/events/EventService.ts b/apps/meteor/server/lib/search/events/EventService.ts similarity index 100% rename from apps/meteor/app/search/server/events/EventService.ts rename to apps/meteor/server/lib/search/events/EventService.ts diff --git a/apps/meteor/app/search/server/events/index.ts b/apps/meteor/server/lib/search/events/index.ts similarity index 89% rename from apps/meteor/app/search/server/events/index.ts rename to apps/meteor/server/lib/search/events/index.ts index 30ad122312772..ab34129292a92 100644 --- a/apps/meteor/app/search/server/events/index.ts +++ b/apps/meteor/server/lib/search/events/index.ts @@ -1,9 +1,9 @@ import type { IMessage } from '@rocket.chat/core-typings'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { settings } from '../../../settings/server'; -import { searchProviderService } from '../service'; import { EventService } from './EventService'; +import { settings } from '../../../../app/settings/server'; +import { callbacks } from '../../callbacks'; +import { searchProviderService } from '../service'; export const searchEventService = new EventService(); diff --git a/apps/meteor/app/search/server/logger/logger.ts b/apps/meteor/server/lib/search/logger/logger.ts similarity index 100% rename from apps/meteor/app/search/server/logger/logger.ts rename to apps/meteor/server/lib/search/logger/logger.ts diff --git a/apps/meteor/app/search/server/model/ISearchResult.ts b/apps/meteor/server/lib/search/model/ISearchResult.ts similarity index 100% rename from apps/meteor/app/search/server/model/ISearchResult.ts rename to apps/meteor/server/lib/search/model/ISearchResult.ts diff --git a/apps/meteor/app/search/server/model/SearchProvider.ts b/apps/meteor/server/lib/search/model/SearchProvider.ts similarity index 100% rename from apps/meteor/app/search/server/model/SearchProvider.ts rename to apps/meteor/server/lib/search/model/SearchProvider.ts diff --git a/apps/meteor/app/search/server/model/Setting.ts b/apps/meteor/server/lib/search/model/Setting.ts similarity index 94% rename from apps/meteor/app/search/server/model/Setting.ts rename to apps/meteor/server/lib/search/model/Setting.ts index 450ca3f3b6edb..71b0d762a5a2d 100644 --- a/apps/meteor/app/search/server/model/Setting.ts +++ b/apps/meteor/server/lib/search/model/Setting.ts @@ -1,6 +1,6 @@ import type { SettingValue } from '@rocket.chat/core-typings'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; /** * Setting Object in order to manage settings loading for providers and admin ui display diff --git a/apps/meteor/app/search/server/model/Settings.ts b/apps/meteor/server/lib/search/model/Settings.ts similarity index 100% rename from apps/meteor/app/search/server/model/Settings.ts rename to apps/meteor/server/lib/search/model/Settings.ts diff --git a/apps/meteor/app/search/server/provider/DefaultProvider.ts b/apps/meteor/server/lib/search/provider/DefaultProvider.ts similarity index 94% rename from apps/meteor/app/search/server/provider/DefaultProvider.ts rename to apps/meteor/server/lib/search/provider/DefaultProvider.ts index a59283f9a1d52..2bbef9a873cf1 100644 --- a/apps/meteor/app/search/server/provider/DefaultProvider.ts +++ b/apps/meteor/server/lib/search/provider/DefaultProvider.ts @@ -1,6 +1,6 @@ import type { IRoom, IUser } from '@rocket.chat/core-typings'; -import { messageSearch } from '../../../../server/meteor-methods/messages/messageSearch'; +import { messageSearch } from '../../../meteor-methods/messages/messageSearch'; import type { IRawSearchResult } from '../model/ISearchResult'; import { SearchProvider } from '../model/SearchProvider'; diff --git a/apps/meteor/app/search/server/register.ts b/apps/meteor/server/lib/search/register.ts similarity index 100% rename from apps/meteor/app/search/server/register.ts rename to apps/meteor/server/lib/search/register.ts diff --git a/apps/meteor/app/search/server/search.internalService.ts b/apps/meteor/server/lib/search/search.internalService.ts similarity index 95% rename from apps/meteor/app/search/server/search.internalService.ts rename to apps/meteor/server/lib/search/search.internalService.ts index f5854028a4fbb..837fbd6e14d33 100644 --- a/apps/meteor/app/search/server/search.internalService.ts +++ b/apps/meteor/server/lib/search/search.internalService.ts @@ -3,7 +3,7 @@ import { Users } from '@rocket.chat/models'; import { searchEventService } from './events'; import { searchProviderService } from './service'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; class Search extends ServiceClassInternal { protected name = 'search'; diff --git a/apps/meteor/app/search/server/service/SearchProviderService.ts b/apps/meteor/server/lib/search/service/SearchProviderService.ts similarity index 97% rename from apps/meteor/app/search/server/service/SearchProviderService.ts rename to apps/meteor/server/lib/search/service/SearchProviderService.ts index 82b3cce2a42f2..9217c2bbcb20d 100644 --- a/apps/meteor/app/search/server/service/SearchProviderService.ts +++ b/apps/meteor/server/lib/search/service/SearchProviderService.ts @@ -1,5 +1,5 @@ +import { settings, settingsRegistry } from '../../../../app/settings/server'; import { withDebouncing } from '../../../../lib/utils/highOrderFunctions'; -import { settings, settingsRegistry } from '../../../settings/server'; import { SearchLogger } from '../logger/logger'; import type { SearchProvider } from '../model/SearchProvider'; diff --git a/apps/meteor/app/search/server/service/SearchResultValidationService.ts b/apps/meteor/server/lib/search/service/SearchResultValidationService.ts similarity index 97% rename from apps/meteor/app/search/server/service/SearchResultValidationService.ts rename to apps/meteor/server/lib/search/service/SearchResultValidationService.ts index 8e9f0045889ab..5762e258e3bd8 100644 --- a/apps/meteor/app/search/server/service/SearchResultValidationService.ts +++ b/apps/meteor/server/lib/search/service/SearchResultValidationService.ts @@ -4,7 +4,7 @@ import { isTruthy } from '@rocket.chat/tools'; import mem from 'mem'; import { Meteor } from 'meteor/meteor'; -import { canAccessRoomAsync } from '../../../authorization/server'; +import { canAccessRoomAsync } from '../../../../app/authorization/server'; import { SearchLogger } from '../logger/logger'; import type { IRawSearchResult, ISearchResult } from '../model/ISearchResult'; diff --git a/apps/meteor/app/search/server/service/index.ts b/apps/meteor/server/lib/search/service/index.ts similarity index 100% rename from apps/meteor/app/search/server/service/index.ts rename to apps/meteor/server/lib/search/service/index.ts diff --git a/apps/meteor/app/search/server/startup.ts b/apps/meteor/server/lib/search/startup.ts similarity index 100% rename from apps/meteor/app/search/server/startup.ts rename to apps/meteor/server/lib/search/startup.ts diff --git a/apps/meteor/app/statistics/server/functions/getLastStatistics.ts b/apps/meteor/server/lib/statistics/functions/getLastStatistics.ts similarity index 83% rename from apps/meteor/app/statistics/server/functions/getLastStatistics.ts rename to apps/meteor/server/lib/statistics/functions/getLastStatistics.ts index 3f97a6b8e2447..6b807167fe04c 100644 --- a/apps/meteor/app/statistics/server/functions/getLastStatistics.ts +++ b/apps/meteor/server/lib/statistics/functions/getLastStatistics.ts @@ -1,7 +1,7 @@ import type { IUser } from '@rocket.chat/core-typings'; import { Statistics } from '@rocket.chat/models'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; import { statistics } from '../lib/statistics'; export async function getLastStatistics({ userId, refresh }: { userId: IUser['_id']; refresh?: boolean }) { diff --git a/apps/meteor/app/statistics/server/functions/getStatistics.ts b/apps/meteor/server/lib/statistics/functions/getStatistics.ts similarity index 92% rename from apps/meteor/app/statistics/server/functions/getStatistics.ts rename to apps/meteor/server/lib/statistics/functions/getStatistics.ts index e6b83036a582f..64829b3f7b5e4 100644 --- a/apps/meteor/app/statistics/server/functions/getStatistics.ts +++ b/apps/meteor/server/lib/statistics/functions/getStatistics.ts @@ -2,7 +2,7 @@ import type { IStats } from '@rocket.chat/core-typings'; import { Statistics } from '@rocket.chat/models'; import type { FindOptions, SchemaMember } from 'mongodb'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; +import { hasPermissionAsync } from '../../authorization/hasPermission'; type GetStatisticsParams = { userId: string; diff --git a/apps/meteor/app/statistics/server/functions/sendUsageReport.spec.ts b/apps/meteor/server/lib/statistics/functions/sendUsageReport.spec.ts similarity index 94% rename from apps/meteor/app/statistics/server/functions/sendUsageReport.spec.ts rename to apps/meteor/server/lib/statistics/functions/sendUsageReport.spec.ts index f2fd40e80557a..9adeaac9e6575 100644 --- a/apps/meteor/app/statistics/server/functions/sendUsageReport.spec.ts +++ b/apps/meteor/server/lib/statistics/functions/sendUsageReport.spec.ts @@ -29,10 +29,10 @@ const mocks = { const { sendUsageReport } = proxyquire.noCallThru().load('./sendUsageReport', { '@rocket.chat/models': { Statistics: mocks.Statistics }, '@rocket.chat/server-fetch': { serverFetch: mocks.serverFetch }, - '..': { statistics: mocks.statistics }, - '../../../cloud/server': { getWorkspaceAccessToken: mocks.getWorkspaceAccessToken }, + '../index': { statistics: mocks.statistics }, + '../../cloud': { getWorkspaceAccessToken: mocks.getWorkspaceAccessToken }, 'meteor/meteor': { Meteor: mocks.Meteor }, - '../../../utils/rocketchat.info': { Info: mocks.Info }, + '../../../../app/utils/rocketchat.info': { Info: mocks.Info }, }); describe('sendUsageReport', () => { diff --git a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts b/apps/meteor/server/lib/statistics/functions/sendUsageReport.ts similarity index 92% rename from apps/meteor/app/statistics/server/functions/sendUsageReport.ts rename to apps/meteor/server/lib/statistics/functions/sendUsageReport.ts index b96c8177da17a..0594c917754ae 100644 --- a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts +++ b/apps/meteor/server/lib/statistics/functions/sendUsageReport.ts @@ -5,10 +5,10 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { tracerSpan } from '@rocket.chat/tracing'; import { Meteor } from 'meteor/meteor'; -import { statistics } from '..'; -import { shouldReportStatistics } from '../../../../server/cron/usageReport'; -import { getWorkspaceAccessToken } from '../../../cloud/server'; -import { Info } from '../../../utils/rocketchat.info'; +import { Info } from '../../../../app/utils/rocketchat.info'; +import { shouldReportStatistics } from '../../../cron/usageReport'; +import { getWorkspaceAccessToken } from '../../cloud'; +import { statistics } from '../index'; async function sendStats(logger: Logger, cronStatistics: IStats): Promise { try { diff --git a/apps/meteor/app/statistics/server/functions/slashCommandsStats.ts b/apps/meteor/server/lib/statistics/functions/slashCommandsStats.ts similarity index 100% rename from apps/meteor/app/statistics/server/functions/slashCommandsStats.ts rename to apps/meteor/server/lib/statistics/functions/slashCommandsStats.ts diff --git a/apps/meteor/app/statistics/server/functions/updateStatsCounter.ts b/apps/meteor/server/lib/statistics/functions/updateStatsCounter.ts similarity index 84% rename from apps/meteor/app/statistics/server/functions/updateStatsCounter.ts rename to apps/meteor/server/lib/statistics/functions/updateStatsCounter.ts index 029caac2da12f..0a62de93eb911 100644 --- a/apps/meteor/app/statistics/server/functions/updateStatsCounter.ts +++ b/apps/meteor/server/lib/statistics/functions/updateStatsCounter.ts @@ -1,6 +1,6 @@ import { Settings } from '@rocket.chat/models'; -import { notifyOnSettingChanged } from '../../../lib/server/lib/notifyListener'; +import { notifyOnSettingChanged } from '../../../../app/lib/server/lib/notifyListener'; import telemetryEvent from '../lib/telemetryEvents'; type updateCounterDataType = { settingsId: string }; diff --git a/apps/meteor/app/statistics/server/index.ts b/apps/meteor/server/lib/statistics/index.ts similarity index 90% rename from apps/meteor/app/statistics/server/index.ts rename to apps/meteor/server/lib/statistics/index.ts index 15020aea451a6..a6ca3c249970a 100644 --- a/apps/meteor/app/statistics/server/index.ts +++ b/apps/meteor/server/lib/statistics/index.ts @@ -1,4 +1,3 @@ -import './methods/getStatistics'; import './startup/monitor'; import './functions/slashCommandsStats'; diff --git a/apps/meteor/app/statistics/server/lib/SAUMonitor.ts b/apps/meteor/server/lib/statistics/lib/SAUMonitor.ts similarity index 99% rename from apps/meteor/app/statistics/server/lib/SAUMonitor.ts rename to apps/meteor/server/lib/statistics/lib/SAUMonitor.ts index d712b5b623e9e..e78b4a4a01783 100644 --- a/apps/meteor/app/statistics/server/lib/SAUMonitor.ts +++ b/apps/meteor/server/lib/statistics/lib/SAUMonitor.ts @@ -8,7 +8,7 @@ import UAParser from 'ua-parser-js'; import { UAParserMobile, UAParserDesktop } from './UAParserCustom'; import { getMostImportantRole } from '../../../../lib/roles/getMostImportantRole'; -import { sauEvents } from '../../../../server/services/sauMonitor/events'; +import { sauEvents } from '../../../services/sauMonitor/events'; type DateObj = { day: number; month: number; year: number }; diff --git a/apps/meteor/app/statistics/server/lib/UAParserCustom.js b/apps/meteor/server/lib/statistics/lib/UAParserCustom.js similarity index 100% rename from apps/meteor/app/statistics/server/lib/UAParserCustom.js rename to apps/meteor/server/lib/statistics/lib/UAParserCustom.js diff --git a/apps/meteor/app/statistics/server/lib/getAppsStatistics.ts b/apps/meteor/server/lib/statistics/lib/getAppsStatistics.ts similarity index 94% rename from apps/meteor/app/statistics/server/lib/getAppsStatistics.ts rename to apps/meteor/server/lib/statistics/lib/getAppsStatistics.ts index 1734d175c6c5d..482d5071f367a 100644 --- a/apps/meteor/app/statistics/server/lib/getAppsStatistics.ts +++ b/apps/meteor/server/lib/statistics/lib/getAppsStatistics.ts @@ -3,8 +3,8 @@ import { AppInstallationSource } from '@rocket.chat/apps/dist/server/storage/IAp import { AppStatus, AppStatusUtils } from '@rocket.chat/apps-engine/definition/AppStatus'; import mem from 'mem'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { Info } from '../../../utils/rocketchat.info'; +import { Info } from '../../../../app/utils/rocketchat.info'; +import { SystemLogger } from '../../logger/system'; type AppsStatistics = { engineVersion: string; diff --git a/apps/meteor/app/statistics/server/lib/getContactVerificationStatistics.ts b/apps/meteor/server/lib/statistics/lib/getContactVerificationStatistics.ts similarity index 95% rename from apps/meteor/app/statistics/server/lib/getContactVerificationStatistics.ts rename to apps/meteor/server/lib/statistics/lib/getContactVerificationStatistics.ts index f1072451c9728..7c36feaf00b26 100644 --- a/apps/meteor/app/statistics/server/lib/getContactVerificationStatistics.ts +++ b/apps/meteor/server/lib/statistics/lib/getContactVerificationStatistics.ts @@ -1,7 +1,7 @@ import type { IStats } from '@rocket.chat/core-typings'; import { LivechatContacts } from '@rocket.chat/models'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; export async function getContactVerificationStatistics(): Promise { const [ diff --git a/apps/meteor/app/statistics/server/lib/getEEStatistics.ts b/apps/meteor/server/lib/statistics/lib/getEEStatistics.ts similarity index 100% rename from apps/meteor/app/statistics/server/lib/getEEStatistics.ts rename to apps/meteor/server/lib/statistics/lib/getEEStatistics.ts diff --git a/apps/meteor/app/statistics/server/lib/getImporterStatistics.ts b/apps/meteor/server/lib/statistics/lib/getImporterStatistics.ts similarity index 86% rename from apps/meteor/app/statistics/server/lib/getImporterStatistics.ts rename to apps/meteor/server/lib/statistics/lib/getImporterStatistics.ts index 0f8fc5beccc53..3964cabd91cbc 100644 --- a/apps/meteor/app/statistics/server/lib/getImporterStatistics.ts +++ b/apps/meteor/server/lib/statistics/lib/getImporterStatistics.ts @@ -1,4 +1,4 @@ -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; export function getImporterStatistics(): Record { return { diff --git a/apps/meteor/app/statistics/server/lib/getServicesStatistics.ts b/apps/meteor/server/lib/statistics/lib/getServicesStatistics.ts similarity index 97% rename from apps/meteor/app/statistics/server/lib/getServicesStatistics.ts rename to apps/meteor/server/lib/statistics/lib/getServicesStatistics.ts index 70a0ee73ccfe0..661cd54d690e9 100644 --- a/apps/meteor/app/statistics/server/lib/getServicesStatistics.ts +++ b/apps/meteor/server/lib/statistics/lib/getServicesStatistics.ts @@ -1,8 +1,8 @@ import { Users } from '@rocket.chat/models'; import { MongoInternals } from 'meteor/mongo'; -import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; +import { readSecondaryPreferred } from '../../../database/readSecondaryPreferred'; const { db } = MongoInternals.defaultRemoteCollectionDriver().mongo; diff --git a/apps/meteor/app/statistics/server/lib/statistics.ts b/apps/meteor/server/lib/statistics/lib/statistics.ts similarity index 97% rename from apps/meteor/app/statistics/server/lib/statistics.ts rename to apps/meteor/server/lib/statistics/lib/statistics.ts index 8c810acaad70b..3fb332d5c689d 100644 --- a/apps/meteor/app/statistics/server/lib/statistics.ts +++ b/apps/meteor/server/lib/statistics/lib/statistics.ts @@ -36,14 +36,14 @@ import { getContactVerificationStatistics } from './getContactVerificationStatis import { getStatistics as getEnterpriseStatistics } from './getEEStatistics'; import { getImporterStatistics } from './getImporterStatistics'; import { getServicesStatistics } from './getServicesStatistics'; -import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; -import { isRunningMs } from '../../../../server/lib/isRunningMs'; -import { getControl } from '../../../../server/lib/migrations'; -import { getSettingsStatistics } from '../../../../server/lib/statistics/getSettingsStatistics'; -import { getMatrixFederationStatistics } from '../../../../server/services/federation/infrastructure/rocket-chat/adapters/Statistics'; -import { settings } from '../../../settings/server'; -import { Info } from '../../../utils/rocketchat.info'; -import { getMongoInfo } from '../../../utils/server/functions/getMongoInfo'; +import { settings } from '../../../../app/settings/server'; +import { Info } from '../../../../app/utils/rocketchat.info'; +import { getMongoInfo } from '../../../../app/utils/server/functions/getMongoInfo'; +import { readSecondaryPreferred } from '../../../database/readSecondaryPreferred'; +import { getMatrixFederationStatistics } from '../../../services/federation/infrastructure/rocket-chat/adapters/Statistics'; +import { isRunningMs } from '../../isRunningMs'; +import { getControl } from '../../migrations'; +import { getSettingsStatistics } from '../getSettingsStatistics'; const getUserLanguages = async (totalUsers: number): Promise<{ [key: string]: number }> => { const result = await Users.getUserLanguages(); diff --git a/apps/meteor/app/statistics/server/lib/telemetryEvents.ts b/apps/meteor/server/lib/statistics/lib/telemetryEvents.ts similarity index 100% rename from apps/meteor/app/statistics/server/lib/telemetryEvents.ts rename to apps/meteor/server/lib/statistics/lib/telemetryEvents.ts diff --git a/apps/meteor/app/statistics/server/startup/monitor.ts b/apps/meteor/server/lib/statistics/startup/monitor.ts similarity index 89% rename from apps/meteor/app/statistics/server/startup/monitor.ts rename to apps/meteor/server/lib/statistics/startup/monitor.ts index bae8e36ce541d..1ddcbf5cb125d 100644 --- a/apps/meteor/app/statistics/server/startup/monitor.ts +++ b/apps/meteor/server/lib/statistics/startup/monitor.ts @@ -1,6 +1,6 @@ import { Meteor } from 'meteor/meteor'; -import { settings } from '../../../settings/server'; +import { settings } from '../../../../app/settings/server'; import { SAUMonitorClass } from '../lib/SAUMonitor'; const SAUMonitor = new SAUMonitorClass(); diff --git a/apps/meteor/server/lib/users/deleteUser.ts b/apps/meteor/server/lib/users/deleteUser.ts index 942e28dbc09c4..37ba25640c71d 100644 --- a/apps/meteor/server/lib/users/deleteUser.ts +++ b/apps/meteor/server/lib/users/deleteUser.ts @@ -17,7 +17,6 @@ import { import { Meteor } from 'meteor/meteor'; import { getUserSingleOwnedRooms } from './getUserSingleOwnedRooms'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnRoomChangedById, notifyOnIntegrationChangedByUserId, @@ -27,6 +26,7 @@ import { import { settings } from '../../../app/settings/server'; import { callbacks } from '../callbacks'; import { i18n } from '../i18n'; +import { FileUpload } from '../media/file-upload'; import { getSubscribedRoomsForUserWithDetails, shouldRemoveOrChangeOwner } from '../rooms/getRoomsWithSingleOwner'; import { relinquishRoomOwnerships } from '../rooms/relinquishRoomOwnerships'; import { updateGroupDMsName } from '../rooms/updateGroupDMsName'; diff --git a/apps/meteor/server/lib/users/saveUser/sendUserEmail.ts b/apps/meteor/server/lib/users/saveUser/sendUserEmail.ts index ad205443c1cfa..e4d991c55aa7b 100644 --- a/apps/meteor/server/lib/users/saveUser/sendUserEmail.ts +++ b/apps/meteor/server/lib/users/saveUser/sendUserEmail.ts @@ -2,8 +2,8 @@ import { MeteorError } from '@rocket.chat/core-services'; import { Meteor } from 'meteor/meteor'; import type { SaveUserData } from './saveUser'; -import * as Mailer from '../../../../app/mailer/server/api'; import { settings } from '../../../../app/settings/server'; +import * as Mailer from '../../notifications/email/api'; let html = ''; let passwordChangedHtml = ''; diff --git a/apps/meteor/server/lib/users/saveUserIdentity.ts b/apps/meteor/server/lib/users/saveUserIdentity.ts index d759c289b53ff..d8613e3cf891b 100644 --- a/apps/meteor/server/lib/users/saveUserIdentity.ts +++ b/apps/meteor/server/lib/users/saveUserIdentity.ts @@ -5,7 +5,6 @@ import type { ClientSession } from 'mongodb'; import { setRealName } from './setRealName'; import { _setUsername } from './setUsername'; -import { FileUpload } from '../../../app/file-upload/server'; import { notifyOnRoomChangedByUsernamesOrUids, notifyOnSubscriptionChangedByUserId, @@ -13,6 +12,7 @@ import { } from '../../../app/lib/server/lib/notifyListener'; import { onceTransactionCommitedSuccessfully } from '../../database/utils'; import { SystemLogger } from '../logger/system'; +import { FileUpload } from '../media/file-upload'; import { updateGroupDMsName } from '../rooms/updateGroupDMsName'; import { validateName } from '../shared/validateName'; diff --git a/apps/meteor/server/lib/users/setEmail.ts b/apps/meteor/server/lib/users/setEmail.ts index a9fb8cd1a4274..1e20d94031f2e 100644 --- a/apps/meteor/server/lib/users/setEmail.ts +++ b/apps/meteor/server/lib/users/setEmail.ts @@ -7,10 +7,10 @@ import type { ClientSession } from 'mongodb'; import { checkEmailAvailability } from './checkEmailAvailability'; import { validateEmailDomain } from '../../../app/lib/server/lib'; -import * as Mailer from '../../../app/mailer/server/api'; import { settings } from '../../../app/settings/server'; import { onceTransactionCommitedSuccessfully } from '../../database/utils'; import { sendConfirmationEmail } from '../../meteor-methods/auth/sendConfirmationEmail'; +import * as Mailer from '../notifications/email/api'; let html = ''; Meteor.startup(() => { diff --git a/apps/meteor/server/lib/users/setUserActiveStatus.ts b/apps/meteor/server/lib/users/setUserActiveStatus.ts index 207ba38bd31dd..f8f1991938bf0 100644 --- a/apps/meteor/server/lib/users/setUserActiveStatus.ts +++ b/apps/meteor/server/lib/users/setUserActiveStatus.ts @@ -12,9 +12,9 @@ import { notifyOnSubscriptionChangedByNameAndRoomType, notifyOnUserChange, } from '../../../app/lib/server/lib/notifyListener'; -import * as Mailer from '../../../app/mailer/server/api'; import { settings } from '../../../app/settings/server'; import { callbacks } from '../callbacks'; +import * as Mailer from '../notifications/email/api'; import { closeOmnichannelConversations } from '../omnichannel/closeOmnichannelConversations'; import { shouldRemoveOrChangeOwner, getSubscribedRoomsForUserWithDetails } from '../rooms/getRoomsWithSingleOwner'; import { relinquishRoomOwnerships } from '../rooms/relinquishRoomOwnerships'; diff --git a/apps/meteor/server/lib/users/setUserAvatar.ts b/apps/meteor/server/lib/users/setUserAvatar.ts index 202ddec4cb0d6..e1e44c496b683 100644 --- a/apps/meteor/server/lib/users/setUserAvatar.ts +++ b/apps/meteor/server/lib/users/setUserAvatar.ts @@ -7,13 +7,13 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { Meteor } from 'meteor/meteor'; import type { ClientSession } from 'mongodb'; -import { RocketChatFile } from '../../../app/file/server'; -import { FileUpload } from '../../../app/file-upload/server'; import { settings } from '../../../app/settings/server'; import { isRenderableImageType } from '../../../lib/renderableImageTypes'; import { onceTransactionCommitedSuccessfully } from '../../database/utils'; import { hasPermissionAsync } from '../authorization/hasPermission'; import { SystemLogger } from '../logger/system'; +import { RocketChatFile } from '../media/file'; +import { FileUpload } from '../media/file-upload'; export const setAvatarFromServiceWithValidation = async ( userId: string, diff --git a/apps/meteor/app/meteor-accounts-saml/server/methods/addSamlService.ts b/apps/meteor/server/meteor-methods/auth/addSamlService.ts similarity index 85% rename from apps/meteor/app/meteor-accounts-saml/server/methods/addSamlService.ts rename to apps/meteor/server/meteor-methods/auth/addSamlService.ts index 0b6b5a6c8f6ec..077a431ca8489 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/methods/addSamlService.ts +++ b/apps/meteor/server/meteor-methods/auth/addSamlService.ts @@ -1,7 +1,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { addSamlService } from '../lib/settings'; +import { addSamlService } from '../../lib/saml/lib/settings'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/crowd/server/methods.ts b/apps/meteor/server/meteor-methods/auth/crowd.ts similarity index 89% rename from apps/meteor/app/crowd/server/methods.ts rename to apps/meteor/server/meteor-methods/auth/crowd.ts index 134445731f6df..a7b7b683ad745 100644 --- a/apps/meteor/app/crowd/server/methods.ts +++ b/apps/meteor/server/meteor-methods/auth/crowd.ts @@ -2,10 +2,10 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; import { Meteor } from 'meteor/meteor'; -import { CROWD } from './crowd'; -import { logger } from './logger'; -import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; -import { settings } from '../../settings/server'; +import { settings } from '../../../app/settings/server'; +import { CROWD } from '../../lib/auth-providers/crowd/crowd'; +import { logger } from '../../lib/auth-providers/crowd/logger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/auth/disable.ts b/apps/meteor/server/meteor-methods/auth/disable.ts index 2ce3c63d461d7..8d943a76a5db4 100644 --- a/apps/meteor/server/meteor-methods/auth/disable.ts +++ b/apps/meteor/server/meteor-methods/auth/disable.ts @@ -2,8 +2,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { TOTP } from '../../../app/2fa/server/lib/totp'; import { notifyOnUserChange } from '../../../app/lib/server/lib/notifyListener'; +import { TOTP } from '../../lib/2fa/lib/totp'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/auth/enable.ts b/apps/meteor/server/meteor-methods/auth/enable.ts index 6435d7d1f7622..3511d099fd14a 100644 --- a/apps/meteor/server/meteor-methods/auth/enable.ts +++ b/apps/meteor/server/meteor-methods/auth/enable.ts @@ -2,7 +2,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { TOTP } from '../../../app/2fa/server/lib/totp'; +import { TOTP } from '../../lib/2fa/lib/totp'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/auth/regenerateCodes.ts b/apps/meteor/server/meteor-methods/auth/regenerateCodes.ts index 9f9b91082d669..bb012c1db87b5 100644 --- a/apps/meteor/server/meteor-methods/auth/regenerateCodes.ts +++ b/apps/meteor/server/meteor-methods/auth/regenerateCodes.ts @@ -2,7 +2,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { TOTP } from '../../../app/2fa/server/lib/totp'; +import { TOTP } from '../../lib/2fa/lib/totp'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/meteor-accounts-saml/server/methods/samlLogout.ts b/apps/meteor/server/meteor-methods/auth/samlLogout.ts similarity index 91% rename from apps/meteor/app/meteor-accounts-saml/server/methods/samlLogout.ts rename to apps/meteor/server/meteor-methods/auth/samlLogout.ts index 0570a7e1914ca..6035da90199e2 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/methods/samlLogout.ts +++ b/apps/meteor/server/meteor-methods/auth/samlLogout.ts @@ -2,9 +2,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import type { IServiceProviderOptions } from '../definition/IServiceProviderOptions'; -import { SAMLServiceProvider } from '../lib/ServiceProvider'; -import { SAMLUtils } from '../lib/Utils'; +import type { IServiceProviderOptions } from '../../lib/saml/definition/IServiceProviderOptions'; +import { SAMLServiceProvider } from '../../lib/saml/lib/ServiceProvider'; +import { SAMLUtils } from '../../lib/saml/lib/Utils'; /** * Fetch SAML provider configs for given 'provider'. diff --git a/apps/meteor/server/meteor-methods/auth/validateTempToken.ts b/apps/meteor/server/meteor-methods/auth/validateTempToken.ts index 26bf9b50c6019..083a597154264 100644 --- a/apps/meteor/server/meteor-methods/auth/validateTempToken.ts +++ b/apps/meteor/server/meteor-methods/auth/validateTempToken.ts @@ -3,8 +3,8 @@ import { Users } from '@rocket.chat/models'; import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; -import { TOTP } from '../../../app/2fa/server/lib/totp'; import { notifyOnUserChange, notifyOnUserChangeAsync } from '../../../app/lib/server/lib/notifyListener'; +import { TOTP } from '../../lib/2fa/lib/totp'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts b/apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts index 72519d8cbab50..439613c3ec556 100644 --- a/apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts +++ b/apps/meteor/server/meteor-methods/import/downloadPublicImportFile.ts @@ -8,10 +8,10 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; import { ProgressStep } from '../../../app/importer/lib/ImporterProgressStep'; -import { Importers } from '../../../app/importer/server'; -import { RocketChatImportFileInstance } from '../../../app/importer/server/startup/store'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { Importers } from '../../lib/import'; +import { RocketChatImportFileInstance } from '../../lib/import/startup/store'; function downloadHttpFile(fileUrl: string, writeStream: fs.WriteStream): void { const protocol = fileUrl.startsWith('https') ? https : http; diff --git a/apps/meteor/server/meteor-methods/import/getImportFileData.ts b/apps/meteor/server/meteor-methods/import/getImportFileData.ts index 4068720d10538..063628334eca5 100644 --- a/apps/meteor/server/meteor-methods/import/getImportFileData.ts +++ b/apps/meteor/server/meteor-methods/import/getImportFileData.ts @@ -7,10 +7,10 @@ import { Imports } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { ProgressStep } from '../../../app/importer/lib/ImporterProgressStep'; -import { Importers } from '../../../app/importer/server'; -import { RocketChatImportFileInstance } from '../../../app/importer/server/startup/store'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { Importers } from '../../lib/import'; +import { RocketChatImportFileInstance } from '../../lib/import/startup/store'; export const executeGetImportFileData = async (): Promise => { const operation = await Imports.findLastImport(); diff --git a/apps/meteor/server/meteor-methods/import/getImportProgress.ts b/apps/meteor/server/meteor-methods/import/getImportProgress.ts index 21fd9ac4e3b24..e86b9b8eaddd3 100644 --- a/apps/meteor/server/meteor-methods/import/getImportProgress.ts +++ b/apps/meteor/server/meteor-methods/import/getImportProgress.ts @@ -3,9 +3,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Imports } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { Importers } from '../../../app/importer/server'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { Importers } from '../../lib/import'; export const executeGetImportProgress = async (): Promise => { const operation = await Imports.findLastImport(); diff --git a/apps/meteor/server/meteor-methods/import/startImport.ts b/apps/meteor/server/meteor-methods/import/startImport.ts index 1ecf2a1a5fa27..26fb6892df705 100644 --- a/apps/meteor/server/meteor-methods/import/startImport.ts +++ b/apps/meteor/server/meteor-methods/import/startImport.ts @@ -4,9 +4,9 @@ import { Imports } from '@rocket.chat/models'; import { isStartImportParamsPOST, type StartImportParamsPOST } from '@rocket.chat/rest-typings'; import { Meteor } from 'meteor/meteor'; -import { Importers } from '../../../app/importer/server'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { Importers } from '../../lib/import'; export const executeStartImport = async ({ input }: StartImportParamsPOST, startedByUserId: IUser['_id']) => { const operation = await Imports.findLastImport(); diff --git a/apps/meteor/server/meteor-methods/import/uploadImportFile.ts b/apps/meteor/server/meteor-methods/import/uploadImportFile.ts index 8c5e9c0a4bb55..d0bef121b9c6e 100644 --- a/apps/meteor/server/meteor-methods/import/uploadImportFile.ts +++ b/apps/meteor/server/meteor-methods/import/uploadImportFile.ts @@ -3,12 +3,12 @@ import type { IUser } from '@rocket.chat/core-typings'; import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { RocketChatFile } from '../../../app/file/server'; import { ProgressStep } from '../../../app/importer/lib/ImporterProgressStep'; -import { Importers } from '../../../app/importer/server'; -import { RocketChatImportFileInstance } from '../../../app/importer/server/startup/store'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { Importers } from '../../lib/import'; +import { RocketChatImportFileInstance } from '../../lib/import/startup/store'; +import { RocketChatFile } from '../../lib/media/file'; export const executeUploadImportFile = async ( userId: IUser['_id'], diff --git a/apps/meteor/server/meteor-methods/index.ts b/apps/meteor/server/meteor-methods/index.ts index 2e0c0c6ca0f66..107db7b1c562b 100644 --- a/apps/meteor/server/meteor-methods/index.ts +++ b/apps/meteor/server/meteor-methods/index.ts @@ -2,10 +2,12 @@ import '../../imports/personal-access-tokens/server/api/methods'; import './auth/addOAuthService'; import './auth/addPermissionToRole'; +import './auth/addSamlService'; import './auth/addUserToRole'; import './auth/afterVerifyEmail'; import './auth/checkCodesRemaining'; import './auth/checkRegistrationSecretURL'; +import './auth/crowd'; import './auth/disable'; import './auth/enable'; import './auth/logoutCleanUp'; @@ -13,6 +15,7 @@ import './auth/refreshOAuthService'; import './auth/regenerateCodes'; import './auth/removeOAuthService'; import './auth/removeRoleFromPermission'; +import './auth/samlLogout'; import './auth/sendConfirmationEmail'; import './auth/sendForgotPasswordEmail'; import './auth/validateTempToken'; @@ -30,6 +33,14 @@ import './integrations/outgoing/addOutgoingIntegration'; import './integrations/outgoing/deleteOutgoingIntegration'; import './integrations/outgoing/replayOutgoingIntegration'; import './integrations/outgoing/updateOutgoingIntegration'; +import './media/deleteCustomSound'; +import './media/deleteEmojiCustom'; +import './media/getS3FileUrl'; +import './media/insertOrUpdateEmoji'; +import './media/insertOrUpdateSound'; +import './media/listCustomSounds'; +import './media/uploadCustomSound'; +import './media/uploadEmojiCustom'; import './messages/createDirectMessage'; import './messages/createDiscussion'; import './messages/deleteFileMessage'; @@ -39,6 +50,7 @@ import './messages/getChannelHistory'; import './messages/getMessages'; import './messages/getSingleMessage'; import './messages/getSlashCommandPreviews'; +import './messages/getUserMentionsByChannel'; import './messages/getThreadMessages'; import './messages/getThreadsList'; import './messages/loadHistory'; @@ -48,22 +60,28 @@ import './messages/loadSurroundingMessages'; import './messages/messageSearch'; import './messages/readMessages'; import './messages/readThreads'; +import './messages/sendFileMessage'; import './messages/sendMessage'; import './messages/unfollowMessage'; import './messages/updateMessage'; import './omnichannel/sendFileLivechatMessage'; import './omnichannel/sendMessageLivechat'; import './platform/OEmbedCacheCleanup'; +import './platform/banner_dismiss'; import './platform/checkFederationConfiguration'; +import './platform/cloud'; import './platform/fetchMyKeys'; import './platform/getProviderUiMetadata'; +import './platform/getStatistics'; import './platform/getSupportedLanguages'; import './platform/getUsersOfRoomWithoutKey'; import './platform/loadLocale'; +import './platform/push'; import './platform/requestDataDownload'; import './platform/requestSubscriptionKeys'; import './platform/resetOwnE2EKey'; import './platform/restartServer'; +import './platform/search'; import './platform/saveSettings'; import './platform/setRoomKeyID'; import './platform/setUserPublicAndPrivateKeys'; @@ -113,6 +131,7 @@ import './users/getUsersOfRoom'; import './users/ignoreUser'; import './users/registerUser'; import './users/resetAvatar'; +import './users/saveNotificationSettings'; import './users/saveUserPreferences'; import './users/saveUserProfile'; import './users/setAvatarFromService'; diff --git a/apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts b/apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts index 96315e850286b..09ada3bf5acac 100644 --- a/apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts +++ b/apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts @@ -1,8 +1,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { clearIntegrationHistoryMethod } from '../../../app/integrations/server/functions/clearIntegrationHistory'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { clearIntegrationHistoryMethod } from '../../lib/integrations/functions/clearIntegrationHistory'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/integrations/incoming/addIncomingIntegration.ts b/apps/meteor/server/meteor-methods/integrations/incoming/addIncomingIntegration.ts index b4ec7d0d87171..fd42eae90a396 100644 --- a/apps/meteor/server/meteor-methods/integrations/incoming/addIncomingIntegration.ts +++ b/apps/meteor/server/meteor-methods/integrations/incoming/addIncomingIntegration.ts @@ -6,11 +6,11 @@ import { removeEmpty } from '@rocket.chat/tools'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { compileIntegrationScript } from '../../../../app/integrations/server/lib/compileIntegrationScript'; -import { validateScriptEngine, isScriptEngineFrozen } from '../../../../app/integrations/server/lib/validateScriptEngine'; import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnIntegrationChanged } from '../../../../app/lib/server/lib/notifyListener'; import { hasPermissionAsync, hasAllPermissionAsync } from '../../../lib/authorization/hasPermission'; +import { compileIntegrationScript } from '../../../lib/integrations/lib/compileIntegrationScript'; +import { validateScriptEngine, isScriptEngineFrozen } from '../../../lib/integrations/lib/validateScriptEngine'; const validChannelChars = ['@', '#']; diff --git a/apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts b/apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts index 2c018a6d2e77a..f662564f49515 100644 --- a/apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts +++ b/apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts @@ -4,11 +4,11 @@ import { Integrations, Subscriptions, Users, Rooms } from '@rocket.chat/models'; import { wrapExceptions } from '@rocket.chat/tools'; import { Meteor } from 'meteor/meteor'; -import { compileIntegrationScript } from '../../../../app/integrations/server/lib/compileIntegrationScript'; -import { isScriptEngineFrozen, validateScriptEngine } from '../../../../app/integrations/server/lib/validateScriptEngine'; import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnIntegrationChanged } from '../../../../app/lib/server/lib/notifyListener'; import { hasAllPermissionAsync, hasPermissionAsync } from '../../../lib/authorization/hasPermission'; +import { compileIntegrationScript } from '../../../lib/integrations/lib/compileIntegrationScript'; +import { isScriptEngineFrozen, validateScriptEngine } from '../../../lib/integrations/lib/validateScriptEngine'; const validChannelChars = ['@', '#']; diff --git a/apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts b/apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts index 8ec1832cb25c3..ac64ca256c02e 100644 --- a/apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts +++ b/apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts @@ -5,11 +5,11 @@ import { removeEmpty } from '@rocket.chat/tools'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { validateOutgoingIntegration } from '../../../../app/integrations/server/lib/validateOutgoingIntegration'; -import { validateScriptEngine } from '../../../../app/integrations/server/lib/validateScriptEngine'; import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnIntegrationChanged } from '../../../../app/lib/server/lib/notifyListener'; import { hasPermissionAsync } from '../../../lib/authorization/hasPermission'; +import { validateOutgoingIntegration } from '../../../lib/integrations/lib/validateOutgoingIntegration'; +import { validateScriptEngine } from '../../../lib/integrations/lib/validateScriptEngine'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts b/apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts index d05ebb3f2fe65..01c488b8c86a1 100644 --- a/apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts +++ b/apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts @@ -1,8 +1,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { replayOutgoingIntegrationMethod } from '../../../../app/integrations/server/functions/clearIntegrationHistory'; import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; +import { replayOutgoingIntegrationMethod } from '../../../lib/integrations/functions/clearIntegrationHistory'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/integrations/outgoing/updateOutgoingIntegration.ts b/apps/meteor/server/meteor-methods/integrations/outgoing/updateOutgoingIntegration.ts index d8a83b8ed11df..fbc2d4841eb8f 100644 --- a/apps/meteor/server/meteor-methods/integrations/outgoing/updateOutgoingIntegration.ts +++ b/apps/meteor/server/meteor-methods/integrations/outgoing/updateOutgoingIntegration.ts @@ -4,11 +4,11 @@ import { Integrations, Users } from '@rocket.chat/models'; import { wrapExceptions } from '@rocket.chat/tools'; import { Meteor } from 'meteor/meteor'; -import { validateOutgoingIntegration } from '../../../../app/integrations/server/lib/validateOutgoingIntegration'; -import { isScriptEngineFrozen, validateScriptEngine } from '../../../../app/integrations/server/lib/validateScriptEngine'; import { methodDeprecationLogger } from '../../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnIntegrationChanged } from '../../../../app/lib/server/lib/notifyListener'; import { hasPermissionAsync } from '../../../lib/authorization/hasPermission'; +import { validateOutgoingIntegration } from '../../../lib/integrations/lib/validateOutgoingIntegration'; +import { isScriptEngineFrozen, validateScriptEngine } from '../../../lib/integrations/lib/validateScriptEngine'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/custom-sounds/server/methods/deleteCustomSound.ts b/apps/meteor/server/meteor-methods/media/deleteCustomSound.ts similarity index 74% rename from apps/meteor/app/custom-sounds/server/methods/deleteCustomSound.ts rename to apps/meteor/server/meteor-methods/media/deleteCustomSound.ts index eedc1355a3356..3f79f45c3ddad 100644 --- a/apps/meteor/app/custom-sounds/server/methods/deleteCustomSound.ts +++ b/apps/meteor/server/meteor-methods/media/deleteCustomSound.ts @@ -3,9 +3,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { deleteCustomSound } from '../lib/deleteCustomSound'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { deleteCustomSound } from '../../lib/media/custom-sounds/lib/deleteCustomSound'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/emoji-custom/server/methods/deleteEmojiCustom.ts b/apps/meteor/server/meteor-methods/media/deleteEmojiCustom.ts similarity index 83% rename from apps/meteor/app/emoji-custom/server/methods/deleteEmojiCustom.ts rename to apps/meteor/server/meteor-methods/media/deleteEmojiCustom.ts index aade8285ec5b9..fcaf627b061cc 100644 --- a/apps/meteor/app/emoji-custom/server/methods/deleteEmojiCustom.ts +++ b/apps/meteor/server/meteor-methods/media/deleteEmojiCustom.ts @@ -4,9 +4,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { EmojiCustom } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { RocketChatFileEmojiCustomInstance } from '../startup/emoji-custom'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { RocketChatFileEmojiCustomInstance } from '../../lib/media/emoji-custom/startup/emoji-custom'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/file-upload/server/methods/getS3FileUrl.ts b/apps/meteor/server/meteor-methods/media/getS3FileUrl.ts similarity index 86% rename from apps/meteor/app/file-upload/server/methods/getS3FileUrl.ts rename to apps/meteor/server/meteor-methods/media/getS3FileUrl.ts index 3e9bcd1926744..cf56e466495f5 100644 --- a/apps/meteor/app/file-upload/server/methods/getS3FileUrl.ts +++ b/apps/meteor/server/meteor-methods/media/getS3FileUrl.ts @@ -3,9 +3,9 @@ import { Rooms, Uploads } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { UploadFS } from '../../../../server/ufs'; -import { canAccessRoomAsync } from '../../../authorization/server'; -import { settings } from '../../../settings/server'; +import { canAccessRoomAsync } from '../../../app/authorization/server'; +import { settings } from '../../../app/settings/server'; +import { UploadFS } from '../../ufs'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/emoji-custom/server/methods/insertOrUpdateEmoji.ts b/apps/meteor/server/meteor-methods/media/insertOrUpdateEmoji.ts similarity index 80% rename from apps/meteor/app/emoji-custom/server/methods/insertOrUpdateEmoji.ts rename to apps/meteor/server/meteor-methods/media/insertOrUpdateEmoji.ts index ed3bc693bac05..e7fca91ef819e 100644 --- a/apps/meteor/app/emoji-custom/server/methods/insertOrUpdateEmoji.ts +++ b/apps/meteor/server/meteor-methods/media/insertOrUpdateEmoji.ts @@ -1,8 +1,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { insertOrUpdateEmoji } from '../lib/insertOrUpdateEmoji'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { insertOrUpdateEmoji } from '../../lib/media/emoji-custom/lib/insertOrUpdateEmoji'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts b/apps/meteor/server/meteor-methods/media/insertOrUpdateSound.ts similarity index 79% rename from apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts rename to apps/meteor/server/meteor-methods/media/insertOrUpdateSound.ts index 82f61276f1250..96f92f258eebc 100644 --- a/apps/meteor/app/custom-sounds/server/methods/insertOrUpdateSound.ts +++ b/apps/meteor/server/meteor-methods/media/insertOrUpdateSound.ts @@ -2,9 +2,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { insertOrUpdateSound } from '../lib/insertOrUpdateSound'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { insertOrUpdateSound } from '../../lib/media/custom-sounds/lib/insertOrUpdateSound'; export type ICustomSoundData = { _id?: string; diff --git a/apps/meteor/app/custom-sounds/server/methods/listCustomSounds.ts b/apps/meteor/server/meteor-methods/media/listCustomSounds.ts similarity index 86% rename from apps/meteor/app/custom-sounds/server/methods/listCustomSounds.ts rename to apps/meteor/server/meteor-methods/media/listCustomSounds.ts index e627b96368f47..ac3386783a8be 100644 --- a/apps/meteor/app/custom-sounds/server/methods/listCustomSounds.ts +++ b/apps/meteor/server/meteor-methods/media/listCustomSounds.ts @@ -3,7 +3,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { CustomSounds } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts b/apps/meteor/server/meteor-methods/media/uploadCustomSound.ts similarity index 78% rename from apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts rename to apps/meteor/server/meteor-methods/media/uploadCustomSound.ts index 2d096fcda1649..a5a23a031d62c 100644 --- a/apps/meteor/app/custom-sounds/server/methods/uploadCustomSound.ts +++ b/apps/meteor/server/meteor-methods/media/uploadCustomSound.ts @@ -3,9 +3,9 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; import type { ICustomSoundData } from './insertOrUpdateSound'; -import { hasPermissionAsync } from '../../../../server/lib/authorization/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { uploadCustomSound } from '../lib/uploadCustomSound'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { uploadCustomSound } from '../../lib/media/custom-sounds/lib/uploadCustomSound'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/emoji-custom/server/methods/uploadEmojiCustom.ts b/apps/meteor/server/meteor-methods/media/uploadEmojiCustom.ts similarity index 78% rename from apps/meteor/app/emoji-custom/server/methods/uploadEmojiCustom.ts rename to apps/meteor/server/meteor-methods/media/uploadEmojiCustom.ts index 91e6ed8270265..f67ec2dea80e0 100644 --- a/apps/meteor/app/emoji-custom/server/methods/uploadEmojiCustom.ts +++ b/apps/meteor/server/meteor-methods/media/uploadEmojiCustom.ts @@ -1,8 +1,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { uploadEmojiCustom } from '../lib/uploadEmojiCustom'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { uploadEmojiCustom } from '../../lib/media/emoji-custom/lib/uploadEmojiCustom'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/messages/createDiscussion.ts b/apps/meteor/server/meteor-methods/messages/createDiscussion.ts index fd2b04c849604..e68ef0a0d0be2 100644 --- a/apps/meteor/server/meteor-methods/messages/createDiscussion.ts +++ b/apps/meteor/server/meteor-methods/messages/createDiscussion.ts @@ -6,9 +6,9 @@ import { Random } from '@rocket.chat/random'; import { check, Match } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { afterSaveMessageAsync } from '../../../app/lib/server/lib/afterSaveMessage'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { settings } from '../../../app/settings/server'; +import { afterSaveMessageAsync } from '../../hooks/messages/afterSaveMessage'; import { canSendMessageAsync } from '../../lib/authorization/canSendMessage'; import { hasAtLeastOnePermissionAsync } from '../../lib/authorization/hasPermission'; import { i18n } from '../../lib/i18n'; diff --git a/apps/meteor/server/meteor-methods/messages/deleteFileMessage.ts b/apps/meteor/server/meteor-methods/messages/deleteFileMessage.ts index b5e12f9a76415..bde3279aea23c 100644 --- a/apps/meteor/server/meteor-methods/messages/deleteFileMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/deleteFileMessage.ts @@ -5,8 +5,8 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import type { DeleteResult } from 'mongodb'; -import { FileUpload } from '../../../app/file-upload/server'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { FileUpload } from '../../lib/media/file-upload'; import { deleteMessageValidatingPermission } from '../../lib/messages/deleteMessage'; declare module '@rocket.chat/ddp-client' { diff --git a/apps/meteor/server/meteor-methods/messages/followMessage.ts b/apps/meteor/server/meteor-methods/messages/followMessage.ts index f726bb29aa543..06c6e0150db85 100644 --- a/apps/meteor/server/meteor-methods/messages/followMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/followMessage.ts @@ -9,8 +9,8 @@ import { RateLimiter } from '../../../app/lib/server'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; -import { follow } from '../../../app/threads/server/functions'; import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; +import { follow } from '../../lib/messaging/threads/functions'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/messages/getThreadMessages.ts b/apps/meteor/server/meteor-methods/messages/getThreadMessages.ts index 0311dbe89655d..492c18a436707 100644 --- a/apps/meteor/server/meteor-methods/messages/getThreadMessages.ts +++ b/apps/meteor/server/meteor-methods/messages/getThreadMessages.ts @@ -5,8 +5,8 @@ import { Meteor } from 'meteor/meteor'; import { canAccessRoomAsync } from '../../../app/authorization/server'; import { settings } from '../../../app/settings/server'; -import { readThread } from '../../../app/threads/server/functions'; import { callbacks } from '../../lib/callbacks'; +import { readThread } from '../../lib/messaging/threads/functions'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/mentions/server/methods/getUserMentionsByChannel.ts b/apps/meteor/server/meteor-methods/messages/getUserMentionsByChannel.ts similarity index 90% rename from apps/meteor/app/mentions/server/methods/getUserMentionsByChannel.ts rename to apps/meteor/server/meteor-methods/messages/getUserMentionsByChannel.ts index a9e5b97b81349..cdfb5eac81a86 100644 --- a/apps/meteor/app/mentions/server/methods/getUserMentionsByChannel.ts +++ b/apps/meteor/server/meteor-methods/messages/getUserMentionsByChannel.ts @@ -4,8 +4,8 @@ import { Messages, Users, Rooms } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { canAccessRoomAsync } from '../../../authorization/server'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; +import { canAccessRoomAsync } from '../../../app/authorization/server'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/messages/messageSearch.ts b/apps/meteor/server/meteor-methods/messages/messageSearch.ts index fa4712010eab0..da506b02695f3 100644 --- a/apps/meteor/server/meteor-methods/messages/messageSearch.ts +++ b/apps/meteor/server/meteor-methods/messages/messageSearch.ts @@ -6,11 +6,11 @@ import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; -import type { IRawSearchResult } from '../../../app/search/server/model/ISearchResult'; import { settings } from '../../../app/settings/server'; import { readSecondaryPreferred } from '../../database/readSecondaryPreferred'; import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { parseMessageSearchQuery } from '../../lib/parseMessageSearchQuery'; +import type { IRawSearchResult } from '../../lib/search/model/ISearchResult'; const logger = new Logger('MessageSearch'); diff --git a/apps/meteor/server/meteor-methods/messages/readThreads.ts b/apps/meteor/server/meteor-methods/messages/readThreads.ts index 89d10d8d3efd7..f3f2a82f08ecc 100644 --- a/apps/meteor/server/meteor-methods/messages/readThreads.ts +++ b/apps/meteor/server/meteor-methods/messages/readThreads.ts @@ -6,8 +6,8 @@ import { Meteor } from 'meteor/meteor'; import { canAccessRoomAsync } from '../../../app/authorization/server'; import { settings } from '../../../app/settings/server'; -import { readThread } from '../../../app/threads/server/functions'; import { callbacks } from '../../lib/callbacks'; +import { readThread } from '../../lib/messaging/threads/functions'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/file-upload/server/methods/sendFileMessage.spec.ts b/apps/meteor/server/meteor-methods/messages/sendFileMessage.spec.ts similarity index 84% rename from apps/meteor/app/file-upload/server/methods/sendFileMessage.spec.ts rename to apps/meteor/server/meteor-methods/messages/sendFileMessage.spec.ts index f1f4a41a63de2..900858a7a9066 100644 --- a/apps/meteor/app/file-upload/server/methods/sendFileMessage.spec.ts +++ b/apps/meteor/server/meteor-methods/messages/sendFileMessage.spec.ts @@ -29,15 +29,15 @@ const { parseFileIntoMessageAttachments } = proxyquire.noCallThru().load('./send methods: sinon.stub(), }, }, - '../lib/FileUpload': { + '../../lib/media/file-upload/lib/FileUpload': { FileUpload: { getPath }, }, - './isImagePreviewSupported': { isImagePreviewSupported }, - '../../../../lib/utils/getFileExtension': { getFileExtension }, - '../../../../server/lib/callbacks': { callbacks: { runAsync: sinon.stub() } }, - '../../../../server/lib/logger/system': { SystemLogger: { error: sinon.stub() } }, - '../../../../server/lib/authorization/canAccessRoom': { canAccessRoomAsync: sinon.stub().resolves(true) }, - '../../../../server/meteor-methods/messages/sendMessage': { executeSendMessage: sinon.stub().resolves({}) }, + '../../lib/media/file-upload/isImagePreviewSupported': { isImagePreviewSupported }, + '../../../lib/utils/getFileExtension': { getFileExtension }, + '../../lib/callbacks': { callbacks: { runAsync: sinon.stub() } }, + '../../lib/logger/system': { SystemLogger: { error: sinon.stub() } }, + '../../lib/authorization/canAccessRoom': { canAccessRoomAsync: sinon.stub().resolves(true) }, + './sendMessage': { executeSendMessage: sinon.stub().resolves({}) }, }); describe('sendFileMessage - Mass Assignment & Type Pollution Prevention', () => { diff --git a/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts b/apps/meteor/server/meteor-methods/messages/sendFileMessage.ts similarity index 91% rename from apps/meteor/app/file-upload/server/methods/sendFileMessage.ts rename to apps/meteor/server/meteor-methods/messages/sendFileMessage.ts index fab3372d5da95..917cc14ca4531 100644 --- a/apps/meteor/app/file-upload/server/methods/sendFileMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/sendFileMessage.ts @@ -13,14 +13,14 @@ import { Rooms, Uploads, Users } from '@rocket.chat/models'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { isImagePreviewSupported } from './isImagePreviewSupported'; -import { getFileExtension } from '../../../../lib/utils/getFileExtension'; -import { canAccessRoomAsync } from '../../../../server/lib/authorization/canAccessRoom'; -import { callbacks } from '../../../../server/lib/callbacks'; -import { SystemLogger } from '../../../../server/lib/logger/system'; -import { executeSendMessage } from '../../../../server/meteor-methods/messages/sendMessage'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { FileUpload } from '../lib/FileUpload'; +import { executeSendMessage } from './sendMessage'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { getFileExtension } from '../../../lib/utils/getFileExtension'; +import { canAccessRoomAsync } from '../../lib/authorization/canAccessRoom'; +import { callbacks } from '../../lib/callbacks'; +import { SystemLogger } from '../../lib/logger/system'; +import { isImagePreviewSupported } from '../../lib/media/file-upload/isImagePreviewSupported'; +import { FileUpload } from '../../lib/media/file-upload/lib/FileUpload'; function validateFileRequiredFields(file: Partial): asserts file is AtLeast { const requiredFields = ['_id', 'name', 'type', 'size']; diff --git a/apps/meteor/server/meteor-methods/messages/sendMessage.ts b/apps/meteor/server/meteor-methods/messages/sendMessage.ts index 911a4f34609a2..21c2bf937edb7 100644 --- a/apps/meteor/server/meteor-methods/messages/sendMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/sendMessage.ts @@ -10,14 +10,14 @@ import { Meteor } from 'meteor/meteor'; import moment from 'moment'; import { RateLimiter } from '../../../app/lib/server/lib'; -import { applyAirGappedRestrictionsValidation } from '../../../app/license/server/airGappedRestrictionsWrapper'; -import { metrics } from '../../../app/metrics/server'; import { settings } from '../../../app/settings/server'; import { canSendMessageAsync } from '../../lib/authorization/canSendMessage'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { applyAirGappedRestrictionsValidation } from '../../lib/cloud/license/airGappedRestrictionsWrapper'; import { i18n } from '../../lib/i18n'; import { SystemLogger } from '../../lib/logger/system'; import { sendMessage } from '../../lib/messages/sendMessage'; +import { metrics } from '../../lib/metrics'; /** * * @param uid diff --git a/apps/meteor/server/meteor-methods/messages/unfollowMessage.ts b/apps/meteor/server/meteor-methods/messages/unfollowMessage.ts index bb7bb0ff3b072..20807000d5477 100644 --- a/apps/meteor/server/meteor-methods/messages/unfollowMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/unfollowMessage.ts @@ -9,8 +9,8 @@ import { RateLimiter } from '../../../app/lib/server'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; -import { unfollow } from '../../../app/threads/server/functions'; import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; +import { unfollow } from '../../lib/messaging/threads/functions'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/messages/updateMessage.ts b/apps/meteor/server/meteor-methods/messages/updateMessage.ts index d42b4ced86d74..20eb69d22672b 100644 --- a/apps/meteor/server/meteor-methods/messages/updateMessage.ts +++ b/apps/meteor/server/meteor-methods/messages/updateMessage.ts @@ -5,10 +5,10 @@ import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import moment from 'moment'; -import { applyAirGappedRestrictionsValidation } from '../../../app/license/server/airGappedRestrictionsWrapper'; import { settings } from '../../../app/settings/server'; import { canSendMessageAsync } from '../../lib/authorization/canSendMessage'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { applyAirGappedRestrictionsValidation } from '../../lib/cloud/license/airGappedRestrictionsWrapper'; import { updateMessage } from '../../lib/messages/updateMessage'; const allowedEditedFields = ['tshow', 'alias', 'attachments', 'avatar', 'emoji', 'msg', 'customFields', 'content', 'e2eMentions']; diff --git a/apps/meteor/server/meteor-methods/omnichannel/sendFileLivechatMessage.ts b/apps/meteor/server/meteor-methods/omnichannel/sendFileLivechatMessage.ts index b35afb8953a5a..6e53f166aa967 100644 --- a/apps/meteor/server/meteor-methods/omnichannel/sendFileLivechatMessage.ts +++ b/apps/meteor/server/meteor-methods/omnichannel/sendFileLivechatMessage.ts @@ -10,7 +10,7 @@ import { Random } from '@rocket.chat/random'; import { Match, check } from 'meteor/check'; import { sendMessageLivechat } from './sendMessageLivechat'; -import { FileUpload } from '../../../app/file-upload/server'; +import { FileUpload } from '../../lib/media/file-upload'; interface ISendFileLivechatMessage { roomId: string; diff --git a/apps/meteor/app/version-check/server/methods/banner_dismiss.ts b/apps/meteor/server/meteor-methods/platform/banner_dismiss.ts similarity index 82% rename from apps/meteor/app/version-check/server/methods/banner_dismiss.ts rename to apps/meteor/server/meteor-methods/platform/banner_dismiss.ts index 5b89641262d05..8c3d9367193f0 100644 --- a/apps/meteor/app/version-check/server/methods/banner_dismiss.ts +++ b/apps/meteor/server/meteor-methods/platform/banner_dismiss.ts @@ -2,8 +2,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { notifyOnUserChange } from '../../../lib/server/lib/notifyListener'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { notifyOnUserChange } from '../../../app/lib/server/lib/notifyListener'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/cloud/server/methods.ts b/apps/meteor/server/meteor-methods/platform/cloud.ts similarity index 84% rename from apps/meteor/app/cloud/server/methods.ts rename to apps/meteor/server/meteor-methods/platform/cloud.ts index 5e3a5b5debe95..18d80fdeb4062 100644 --- a/apps/meteor/app/cloud/server/methods.ts +++ b/apps/meteor/server/meteor-methods/platform/cloud.ts @@ -2,17 +2,17 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission'; -import { buildWorkspaceRegistrationData } from '../../../server/lib/cloud/buildRegistrationData'; -import { checkUserHasCloudLogin } from '../../../server/lib/cloud/checkUserHasCloudLogin'; -import { connectWorkspace } from '../../../server/lib/cloud/connectWorkspace'; -import { finishOAuthAuthorization } from '../../../server/lib/cloud/finishOAuthAuthorization'; -import { getOAuthAuthorizationUrl } from '../../../server/lib/cloud/getOAuthAuthorizationUrl'; -import { retrieveRegistrationStatus } from '../../../server/lib/cloud/retrieveRegistrationStatus'; -import { startRegisterWorkspace } from '../../../server/lib/cloud/startRegisterWorkspace'; -import { syncWorkspace } from '../../../server/lib/cloud/syncWorkspace'; -import { userLogout } from '../../../server/lib/cloud/userLogout'; -import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; +import { buildWorkspaceRegistrationData } from '../../lib/cloud/buildRegistrationData'; +import { checkUserHasCloudLogin } from '../../lib/cloud/checkUserHasCloudLogin'; +import { connectWorkspace } from '../../lib/cloud/connectWorkspace'; +import { finishOAuthAuthorization } from '../../lib/cloud/finishOAuthAuthorization'; +import { getOAuthAuthorizationUrl } from '../../lib/cloud/getOAuthAuthorizationUrl'; +import { retrieveRegistrationStatus } from '../../lib/cloud/retrieveRegistrationStatus'; +import { startRegisterWorkspace } from '../../lib/cloud/startRegisterWorkspace'; +import { syncWorkspace } from '../../lib/cloud/syncWorkspace'; +import { userLogout } from '../../lib/cloud/userLogout'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts b/apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts index b1528cc0fba7f..bc12114bb5ef6 100644 --- a/apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts +++ b/apps/meteor/server/meteor-methods/platform/getProviderUiMetadata.ts @@ -1,7 +1,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { TranslationProviderRegistry } from '../../../app/autotranslate/server/autotranslate'; +import { TranslationProviderRegistry } from '../../lib/autotranslate/autotranslate'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/statistics/server/methods/getStatistics.ts b/apps/meteor/server/meteor-methods/platform/getStatistics.ts similarity index 79% rename from apps/meteor/app/statistics/server/methods/getStatistics.ts rename to apps/meteor/server/meteor-methods/platform/getStatistics.ts index 1b383bdc54536..5fa9865217729 100644 --- a/apps/meteor/app/statistics/server/methods/getStatistics.ts +++ b/apps/meteor/server/meteor-methods/platform/getStatistics.ts @@ -2,8 +2,8 @@ import type { IStats } from '@rocket.chat/core-typings'; import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { getLastStatistics } from '../functions/getLastStatistics'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { getLastStatistics } from '../../lib/statistics/functions/getLastStatistics'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/platform/getSupportedLanguages.ts b/apps/meteor/server/meteor-methods/platform/getSupportedLanguages.ts index e7fc7150e551e..9b926a3d72aa6 100644 --- a/apps/meteor/server/meteor-methods/platform/getSupportedLanguages.ts +++ b/apps/meteor/server/meteor-methods/platform/getSupportedLanguages.ts @@ -3,7 +3,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Meteor } from 'meteor/meteor'; -import { getSupportedLanguages } from '../../../app/autotranslate/server/functions/getSupportedLanguages'; +import { getSupportedLanguages } from '../../lib/autotranslate/functions/getSupportedLanguages'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/push/server/methods.ts b/apps/meteor/server/meteor-methods/platform/push.ts similarity index 91% rename from apps/meteor/app/push/server/methods.ts rename to apps/meteor/server/meteor-methods/platform/push.ts index 43514d0f14735..b32f3706f9935 100644 --- a/apps/meteor/app/push/server/methods.ts +++ b/apps/meteor/server/meteor-methods/platform/push.ts @@ -6,9 +6,9 @@ import { Accounts } from 'meteor/accounts-base'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { logger } from './logger'; -import { _matchToken } from './push'; -import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { logger } from '../../lib/notifications/push/logger'; +import { _matchToken } from '../../lib/notifications/push/push'; type PushUpdateOptions = { id?: string; diff --git a/apps/meteor/server/meteor-methods/platform/resetOwnE2EKey.ts b/apps/meteor/server/meteor-methods/platform/resetOwnE2EKey.ts index 41cb4dc7633d4..634c29a1e626a 100644 --- a/apps/meteor/server/meteor-methods/platform/resetOwnE2EKey.ts +++ b/apps/meteor/server/meteor-methods/platform/resetOwnE2EKey.ts @@ -2,8 +2,8 @@ import { MeteorError } from '@rocket.chat/core-services'; import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { twoFactorRequired } from '../../../app/2fa/server/twoFactorRequired'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { twoFactorRequired } from '../../lib/2fa/twoFactorRequired'; import { resetUserE2EEncriptionKey } from '../../lib/resetUserE2EKey'; declare module '@rocket.chat/ddp-client' { diff --git a/apps/meteor/server/meteor-methods/platform/saveSettings.ts b/apps/meteor/server/meteor-methods/platform/saveSettings.ts index 6464935646849..b59a4fee69ef1 100644 --- a/apps/meteor/server/meteor-methods/platform/saveSettings.ts +++ b/apps/meteor/server/meteor-methods/platform/saveSettings.ts @@ -1,8 +1,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { saveAutoTranslateSettings } from '../../../app/autotranslate/server/functions/saveSettings'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { saveAutoTranslateSettings } from '../../lib/autotranslate/functions/saveSettings'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/search/server/methods.ts b/apps/meteor/server/meteor-methods/platform/search.ts similarity index 92% rename from apps/meteor/app/search/server/methods.ts rename to apps/meteor/server/meteor-methods/platform/search.ts index ad8c9641f5238..a95165187ce91 100644 --- a/apps/meteor/app/search/server/methods.ts +++ b/apps/meteor/server/meteor-methods/platform/search.ts @@ -2,9 +2,9 @@ import type { IMessageSearchProvider, IMessageSearchSuggestion, IRoom, IUser } f import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { SearchLogger } from './logger/logger'; -import type { IRawSearchResult, ISearchResult } from './model/ISearchResult'; -import { searchProviderService, validationService } from './service'; +import { SearchLogger } from '../../lib/search/logger/logger'; +import type { IRawSearchResult, ISearchResult } from '../../lib/search/model/ISearchResult'; +import { searchProviderService, validationService } from '../../lib/search/service'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/platform/translateMessage.ts b/apps/meteor/server/meteor-methods/platform/translateMessage.ts index e285fa97e4f6e..ea3eb9fb10697 100644 --- a/apps/meteor/server/meteor-methods/platform/translateMessage.ts +++ b/apps/meteor/server/meteor-methods/platform/translateMessage.ts @@ -5,7 +5,7 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { canAccessRoomAsync } from '../../../app/authorization/server'; -import { translateMessage } from '../../../app/autotranslate/server/functions/translateMessage'; +import { translateMessage } from '../../lib/autotranslate/functions/translateMessage'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts b/apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts index 60a0638d3d9c1..b52032ce43fe6 100644 --- a/apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts +++ b/apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts @@ -5,11 +5,11 @@ import { Subscriptions, Rooms, Users } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { beforeAddUserToRoom } from '../../../app/lib/server/lib/beforeAddUserToRoom'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnSubscriptionChangedById } from '../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../app/settings/server'; import { getDefaultSubscriptionPref } from '../../../app/utils/lib/getDefaultSubscriptionPref'; +import { beforeAddUserToRoom } from '../../hooks/rooms/beforeAddUserToRoom'; import { hasPermissionAsync } from '../../lib/authorization/hasPermission'; import { callbacks } from '../../lib/callbacks'; import { getSubscriptionAutotranslateDefaultConfig } from '../../lib/getSubscriptionAutotranslateDefaultConfig'; diff --git a/apps/meteor/server/meteor-methods/settings/saveSetting.ts b/apps/meteor/server/meteor-methods/settings/saveSetting.ts index d6c8435e12e03..b1e77354fe250 100644 --- a/apps/meteor/server/meteor-methods/settings/saveSetting.ts +++ b/apps/meteor/server/meteor-methods/settings/saveSetting.ts @@ -4,10 +4,10 @@ import { Settings } from '@rocket.chat/models'; import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { twoFactorRequired } from '../../../app/2fa/server/twoFactorRequired'; import { getSettingPermissionId } from '../../../app/authorization/lib'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnSettingChanged } from '../../../app/lib/server/lib/notifyListener'; +import { twoFactorRequired } from '../../lib/2fa/twoFactorRequired'; import { hasPermissionAsync, hasAllPermissionAsync } from '../../lib/authorization/hasPermission'; import { disableCustomScripts } from '../../lib/shared/disableCustomScripts'; import { updateAuditedByUser } from '../../settings/lib/auditedSettingUpdates'; diff --git a/apps/meteor/server/meteor-methods/settings/saveSettings.ts b/apps/meteor/server/meteor-methods/settings/saveSettings.ts index 7ff2c054fb66e..9e3507883f263 100644 --- a/apps/meteor/server/meteor-methods/settings/saveSettings.ts +++ b/apps/meteor/server/meteor-methods/settings/saveSettings.ts @@ -2,9 +2,9 @@ import type { ISetting } from '@rocket.chat/core-typings'; import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Meteor } from 'meteor/meteor'; -import { twoFactorRequired } from '../../../app/2fa/server/twoFactorRequired'; import { saveSettingsBulk } from '../../../app/lib/server/functions/saveSettingsBulk'; import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { twoFactorRequired } from '../../lib/2fa/twoFactorRequired'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts b/apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts index cd1a655972059..c9aefa23efe4f 100644 --- a/apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts +++ b/apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts @@ -2,8 +2,8 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Meteor } from 'meteor/meteor'; -import * as Mailer from '../../../app/mailer/server/api'; import { settings } from '../../../app/settings/server'; +import * as Mailer from '../../lib/notifications/email/api'; declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/apps/meteor/app/push-notifications/server/methods/saveNotificationSettings.ts b/apps/meteor/server/meteor-methods/users/saveNotificationSettings.ts similarity index 95% rename from apps/meteor/app/push-notifications/server/methods/saveNotificationSettings.ts rename to apps/meteor/server/meteor-methods/users/saveNotificationSettings.ts index 1a737384acca7..21b730b07176c 100644 --- a/apps/meteor/app/push-notifications/server/methods/saveNotificationSettings.ts +++ b/apps/meteor/server/meteor-methods/users/saveNotificationSettings.ts @@ -4,9 +4,9 @@ import { Subscriptions } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { notifyOnSubscriptionChangedById } from '../../../lib/server/lib/notifyListener'; -import { getUserNotificationPreference } from '../../../utils/server/getUserNotificationPreference'; +import { methodDeprecationLogger } from '../../../app/lib/server/lib/deprecationWarningLogger'; +import { notifyOnSubscriptionChangedById } from '../../../app/lib/server/lib/notifyListener'; +import { getUserNotificationPreference } from '../../../app/utils/server/getUserNotificationPreference'; const saveAudioNotificationValue = (subId: ISubscription['_id'], value: string) => value === 'default' ? Subscriptions.clearAudioNotificationValueById(subId) : Subscriptions.updateAudioNotificationValueById(subId, value); diff --git a/apps/meteor/server/meteor-methods/users/saveUserProfile.ts b/apps/meteor/server/meteor-methods/users/saveUserProfile.ts index 67d13ec5de1ee..2902aa6f403a2 100644 --- a/apps/meteor/server/meteor-methods/users/saveUserProfile.ts +++ b/apps/meteor/server/meteor-methods/users/saveUserProfile.ts @@ -7,12 +7,12 @@ import { Meteor } from 'meteor/meteor'; import type { UpdateFilter } from 'mongodb'; import { setEmailFunction } from './setEmail'; -import { type AuthenticatedContext, twoFactorRequired } from '../../../app/2fa/server/twoFactorRequired'; import { notifyOnUserChange } from '../../../app/lib/server/lib/notifyListener'; import { passwordPolicy } from '../../../app/lib/server/lib/passwordPolicy'; import { settings as rcSettings } from '../../../app/settings/server'; import { setUserStatusMethod } from '../../../app/user-status/server/methods/setUserStatus'; import { getUserInfo } from '../../api/lib/getUserInfo'; +import { type AuthenticatedContext, twoFactorRequired } from '../../lib/2fa/twoFactorRequired'; import { callbacks } from '../../lib/callbacks'; import { compareUserPassword } from '../../lib/compareUserPassword'; import { compareUserPasswordHistory } from '../../lib/compareUserPasswordHistory'; diff --git a/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts b/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts index 4059baa63c7cd..d32f4f7351377 100644 --- a/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts +++ b/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts @@ -11,11 +11,11 @@ import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { isTruthy } from '@rocket.chat/tools'; import type * as UiKit from '@rocket.chat/ui-kit'; -import { getWorkspaceAccessToken } from '../../../app/cloud/server'; import { settings } from '../../../app/settings/server'; import { CloudWorkspaceConnectionError } from '../../../lib/errors/CloudWorkspaceConnectionError'; import { InvalidCloudAnnouncementInteractionError } from '../../../lib/errors/InvalidCloudAnnouncementInteractionError'; import { InvalidCoreAppInteractionError } from '../../../lib/errors/InvalidCoreAppInteractionError'; +import { getWorkspaceAccessToken } from '../../lib/cloud'; import { syncWorkspace } from '../../lib/cloud/syncWorkspace'; import { SystemLogger } from '../../lib/logger/system'; diff --git a/apps/meteor/server/modules/notifications/notifications.module.ts b/apps/meteor/server/modules/notifications/notifications.module.ts index bf37c25401b80..36c06bbac88b0 100644 --- a/apps/meteor/server/modules/notifications/notifications.module.ts +++ b/apps/meteor/server/modules/notifications/notifications.module.ts @@ -3,9 +3,9 @@ import type { ISubscription, IOmnichannelRoom, IUser, IUserDataEvent, PresenceSo import type { StreamerCallbackArgs, StreamKeys, StreamNames } from '@rocket.chat/ddp-client'; import { Rooms, Subscriptions, Users } from '@rocket.chat/models'; -import type { ImporterProgress } from '../../../app/importer/server/classes/ImporterProgress'; -import { emit, StreamPresence } from '../../../app/notifications/server/lib/Presence'; +import type { ImporterProgress } from '../../lib/import/classes/ImporterProgress'; import { SystemLogger } from '../../lib/logger/system'; +import { emit, StreamPresence } from '../../lib/notifications/core/lib/Presence'; import { getCachedUserForPublication } from '../streamer/publication-user-cache'; import { Streamer as StreamerModule } from '../streamer/streamer.module'; import type { IStreamer, IStreamerConstructor } from '../streamer/types'; diff --git a/apps/meteor/server/routes/avatar/utils.spec.ts b/apps/meteor/server/routes/avatar/utils.spec.ts index 5c31e286467ab..db02daa19601b 100644 --- a/apps/meteor/server/routes/avatar/utils.spec.ts +++ b/apps/meteor/server/routes/avatar/utils.spec.ts @@ -35,7 +35,7 @@ const { findOneByIdAndLoginToken: mocks.findOneByIdAndLoginToken, }, }, - '../../../app/file-upload/server': { + '../../lib/media/file-upload': { FileUpload: { get: mocks.fileUploadGet, }, diff --git a/apps/meteor/server/routes/avatar/utils.ts b/apps/meteor/server/routes/avatar/utils.ts index b7f4bcae4668b..795c9b594eaf3 100644 --- a/apps/meteor/server/routes/avatar/utils.ts +++ b/apps/meteor/server/routes/avatar/utils.ts @@ -9,9 +9,9 @@ import sanitizeHtml from 'sanitize-html'; import sharp from 'sharp'; import { throttle } from 'underscore'; -import { FileUpload } from '../../../app/file-upload/server'; import { settings } from '../../../app/settings/server'; import { getAvatarColor } from '../../../app/utils/lib/getAvatarColor'; +import { FileUpload } from '../../lib/media/file-upload'; const FALLBACK_LAST_MODIFIED = 'Thu, 01 Jan 2015 00:00:00 GMT'; diff --git a/apps/meteor/server/routes/userDataDownload.ts b/apps/meteor/server/routes/userDataDownload.ts index 71a4129f1dc19..ca7437ec3ed03 100644 --- a/apps/meteor/server/routes/userDataDownload.ts +++ b/apps/meteor/server/routes/userDataDownload.ts @@ -7,8 +7,8 @@ import { Cookies } from 'meteor/ostrio:cookies'; import { WebApp } from 'meteor/webapp'; import { match } from 'path-to-regexp'; -import { FileUpload } from '../../app/file-upload/server'; import { settings } from '../../app/settings/server'; +import { FileUpload } from '../lib/media/file-upload'; const cookies = new Cookies(); diff --git a/apps/meteor/server/services/authorization/service.ts b/apps/meteor/server/services/authorization/service.ts index 1896abadc2cf1..09719c0b35388 100644 --- a/apps/meteor/server/services/authorization/service.ts +++ b/apps/meteor/server/services/authorization/service.ts @@ -103,10 +103,6 @@ export class Authorization extends ServiceClass implements IAuthorization { return this.canAccessRoom(room, { _id: user }); } - async addRoleRestrictions(role: IRole['_id'], permissions: string[]): Promise { - AuthorizationUtils.addRolePermissionWhiteList(role, permissions); - } - async getUsersFromPublicRoles(): Promise< { _id: string; diff --git a/apps/meteor/server/services/import/service.spec.ts b/apps/meteor/server/services/import/service.spec.ts index 7b9330ac5a2bb..9e7f77eaa71fc 100644 --- a/apps/meteor/server/services/import/service.spec.ts +++ b/apps/meteor/server/services/import/service.spec.ts @@ -34,7 +34,7 @@ jest.mock('@rocket.chat/models', () => ({ })); const mockImportersGet = jest.fn(); -jest.mock('../../../app/importer/server', () => ({ +jest.mock('../../lib/import', () => ({ Importers: { get: (...args: unknown[]) => mockImportersGet(...args), }, diff --git a/apps/meteor/server/services/import/service.ts b/apps/meteor/server/services/import/service.ts index 636bf4d1877ee..f71f460bd3bab 100644 --- a/apps/meteor/server/services/import/service.ts +++ b/apps/meteor/server/services/import/service.ts @@ -4,8 +4,8 @@ import type { IImportUser, IImport, ImportStatus } from '@rocket.chat/core-typin import { Imports, ImportData } from '@rocket.chat/models'; import { ObjectId } from 'mongodb'; -import { Importers } from '../../../app/importer/server'; import { settings } from '../../../app/settings/server'; +import { Importers } from '../../lib/import'; import { validateRoleList } from '../../lib/roles/validateRoleList'; import { getNewUserRoles } from '../user/lib/getNewUserRoles'; diff --git a/apps/meteor/server/services/media-call/push/sendVoipPushNotification.ts b/apps/meteor/server/services/media-call/push/sendVoipPushNotification.ts index 391339a9e1104..5068dcbd3e1fb 100644 --- a/apps/meteor/server/services/media-call/push/sendVoipPushNotification.ts +++ b/apps/meteor/server/services/media-call/push/sendVoipPushNotification.ts @@ -4,12 +4,12 @@ import { MediaCalls, Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { getPushNotificationType } from './getPushNotificationType'; -import { metrics } from '../../../../app/metrics/server/lib/metrics'; -import { Push } from '../../../../app/push/server/push'; -import PushNotification from '../../../../app/push-notifications/server/lib/PushNotification'; import { settings } from '../../../../app/settings/server'; import { getUserAvatarURL } from '../../../../app/utils/server/getUserAvatarURL'; import { getUserPreference } from '../../../../app/utils/server/lib/getUserPreference'; +import { metrics } from '../../../lib/metrics/lib/metrics'; +import { Push } from '../../../lib/notifications/push/push'; +import PushNotification from '../../../lib/notifications/push-config/lib/PushNotification'; import { logger } from '../logger'; async function getActorUser(actor: MediaCallContact): Promise | null> { diff --git a/apps/meteor/server/services/messages/hooks/BeforeSaveMentions.ts b/apps/meteor/server/services/messages/hooks/BeforeSaveMentions.ts index bcf022587e8aa..590815368be75 100644 --- a/apps/meteor/server/services/messages/hooks/BeforeSaveMentions.ts +++ b/apps/meteor/server/services/messages/hooks/BeforeSaveMentions.ts @@ -2,9 +2,9 @@ import { api, Team, MeteorError } from '@rocket.chat/core-services'; import type { IMessage, IUser, IRoom } from '@rocket.chat/core-typings'; import { Subscriptions, Users, Rooms } from '@rocket.chat/models'; -import { MentionsServer } from '../../../../app/mentions/server/Mentions'; import { settings } from '../../../../app/settings/server'; import { i18n } from '../../../lib/i18n'; +import { MentionsServer } from '../../../lib/messaging/mentions/Mentions'; class MentionQueries { async getUsers(usernames: string[]): Promise<{ type: 'team' | 'user'; _id: string; username?: string; name?: string }[]> { diff --git a/apps/meteor/server/services/messages/service.ts b/apps/meteor/server/services/messages/service.ts index fa89dd8c9b3e3..7a3d9278e8494 100644 --- a/apps/meteor/server/services/messages/service.ts +++ b/apps/meteor/server/services/messages/service.ts @@ -6,7 +6,6 @@ import type { MessageUrl, IMessage, MessageTypesValues, IUser, IRoom, AtLeast } import { Messages, Rooms } from '@rocket.chat/models'; import { OEmbed } from './hooks/AfterSaveOEmbed'; -import { executeSetReaction } from '../../../app/reactions/server/setReaction'; import { settings } from '../../../app/settings/server'; import { getUserAvatarURL } from '../../../app/utils/server/getUserAvatarURL'; import { BeforeSaveCannedResponse } from '../../../ee/server/hooks/messages/BeforeSaveCannedResponse'; @@ -20,12 +19,13 @@ import { mentionServer } from './hooks/BeforeSaveMentions'; import { BeforeSavePreventMention } from './hooks/BeforeSavePreventMention'; import { BeforeSaveSpotify } from './hooks/BeforeSaveSpotify'; import { notifyOnRoomChangedById, notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; -import { notifyUsersOnSystemMessage } from '../../../app/lib/server/lib/notifyUsersOnMessage'; import { closeUnclosedCodeBlock } from '../../../lib/utils/closeUnclosedCodeBlock'; +import { notifyUsersOnSystemMessage } from '../../hooks/messages/notifyUsersOnMessage'; import { deleteMessage } from '../../lib/messages/deleteMessage'; import { parseUrlsInMessage } from '../../lib/messages/parseUrlsInMessage'; import { sendMessage } from '../../lib/messages/sendMessage'; import { updateMessage } from '../../lib/messages/updateMessage'; +import { executeSetReaction } from '../../lib/messaging/reactions/setReaction'; import { shouldBreakInVersion } from '../../lib/shouldBreakInVersion'; import { executeSendMessage } from '../../meteor-methods/messages/sendMessage'; diff --git a/apps/meteor/server/services/meteor/service.ts b/apps/meteor/server/services/meteor/service.ts index 474057af71c20..0974e73a58629 100644 --- a/apps/meteor/server/services/meteor/service.ts +++ b/apps/meteor/server/services/meteor/service.ts @@ -7,17 +7,17 @@ import { wrapExceptions } from '@rocket.chat/tools'; import { Meteor } from 'meteor/meteor'; import { processOnChange, serviceConfigCallbacks } from './userReactivity'; -import { isOutgoingIntegration } from '../../../app/integrations/server/lib/definition'; -import { triggerHandler } from '../../../app/integrations/server/lib/triggerHandler'; import { notifyGuestStatusChanged } from '../../../app/livechat/server/lib/guests'; import { onlineAgents, monitorAgents } from '../../../app/livechat/server/lib/stream/agentStatus'; -import { metrics } from '../../../app/metrics/server'; -import notifications from '../../../app/notifications/server/lib/Notifications'; import { settings } from '../../../app/settings/server'; import { use } from '../../../app/settings/server/Middleware'; import { setValue, updateValue } from '../../../app/settings/server/raw'; import { getURL } from '../../../app/utils/server/getURL'; import { configureEmailInboxes } from '../../features/EmailInbox/EmailInbox'; +import { isOutgoingIntegration } from '../../lib/integrations/lib/definition'; +import { triggerHandler } from '../../lib/integrations/lib/triggerHandler'; +import { metrics } from '../../lib/metrics'; +import notifications from '../../lib/notifications/core/lib/Notifications'; import { roomCoordinator } from '../../lib/rooms/roomCoordinator'; import { ListenersModule } from '../../modules/listeners/listeners.module'; import { invalidate as invalidatePublicationUserCache } from '../../modules/streamer/publication-user-cache'; diff --git a/apps/meteor/server/services/nps/getAndCreateNpsSurvey.ts b/apps/meteor/server/services/nps/getAndCreateNpsSurvey.ts index dd01db90803a9..cf07c2d5425ee 100644 --- a/apps/meteor/server/services/nps/getAndCreateNpsSurvey.ts +++ b/apps/meteor/server/services/nps/getAndCreateNpsSurvey.ts @@ -3,8 +3,8 @@ import type { IBanner, BannerPlatform } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import type * as UiKit from '@rocket.chat/ui-kit'; -import { getWorkspaceAccessToken } from '../../../app/cloud/server'; import { settings } from '../../../app/settings/server'; +import { getWorkspaceAccessToken } from '../../lib/cloud'; import { SystemLogger } from '../../lib/logger/system'; type NpsSurveyData = { diff --git a/apps/meteor/server/services/nps/sendNpsResults.ts b/apps/meteor/server/services/nps/sendNpsResults.ts index 74b4f270f114b..8e93d41a7b89b 100644 --- a/apps/meteor/server/services/nps/sendNpsResults.ts +++ b/apps/meteor/server/services/nps/sendNpsResults.ts @@ -1,8 +1,8 @@ import type { INpsVote } from '@rocket.chat/core-typings'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; -import { getWorkspaceAccessToken } from '../../../app/cloud/server'; import { settings } from '../../../app/settings/server'; +import { getWorkspaceAccessToken } from '../../lib/cloud'; import { SystemLogger } from '../../lib/logger/system'; type NPSResultPayload = { diff --git a/apps/meteor/server/services/omnichannel/queue.ts b/apps/meteor/server/services/omnichannel/queue.ts index 8fd3de8586f01..5511abcfd2680 100644 --- a/apps/meteor/server/services/omnichannel/queue.ts +++ b/apps/meteor/server/services/omnichannel/queue.ts @@ -10,8 +10,8 @@ import { getOmniChatSortQuery } from '../../../app/livechat/lib/inquiries'; import { dispatchAgentDelegated } from '../../../app/livechat/server/lib/Helper'; import { RoutingManager } from '../../../app/livechat/server/lib/RoutingManager'; import { getInquirySortMechanismSetting } from '../../../app/livechat/server/lib/settings'; -import { metrics } from '../../../app/metrics/server'; import { settings } from '../../../app/settings/server'; +import { metrics } from '../../lib/metrics'; const DEFAULT_RACE_TIMEOUT = 5000; diff --git a/apps/meteor/server/services/room/service.ts b/apps/meteor/server/services/room/service.ts index 027bec4c9f66c..bd73034b6b155 100644 --- a/apps/meteor/server/services/room/service.ts +++ b/apps/meteor/server/services/room/service.ts @@ -21,11 +21,11 @@ import { notifyOnSubscriptionChangedById, notifyOnSubscriptionChangedByRoomIdAndUserId, } from '../../../app/lib/server/lib/notifyListener'; -import { readThread } from '../../../app/threads/server/functions'; import { getDefaultSubscriptionPref } from '../../../app/utils/lib/getDefaultSubscriptionPref'; import { getValidRoomName } from '../../../app/utils/server/lib/getValidRoomName'; import { RoomMemberActions } from '../../../definition/IRoomTypeConfig'; import { getSubscriptionAutotranslateDefaultConfig } from '../../lib/getSubscriptionAutotranslateDefaultConfig'; +import { readThread } from '../../lib/messaging/threads/functions'; import { readMessages } from '../../lib/readMessages'; import { performAcceptRoomInvite } from '../../lib/rooms/acceptRoomInvite'; import { addUserToRoom } from '../../lib/rooms/addUserToRoom'; diff --git a/apps/meteor/server/services/upload/service.ts b/apps/meteor/server/services/upload/service.ts index d15019b06b195..ac956815716ca 100644 --- a/apps/meteor/server/services/upload/service.ts +++ b/apps/meteor/server/services/upload/service.ts @@ -11,14 +11,14 @@ import { Uploads, Users } from '@rocket.chat/models'; import { Random } from '@rocket.chat/random'; import sharp from 'sharp'; -import { FileUpload } from '../../../app/file-upload/server'; -import { parseFileIntoMessageAttachments, sendFileMessage } from '../../../app/file-upload/server/methods/sendFileMessage'; import { NOTIFICATION_ATTACHMENT_COLOR } from '../../../lib/constants'; import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { canDeleteMessageAsync } from '../../lib/authorization/canDeleteMessage'; import { i18n } from '../../lib/i18n'; +import { FileUpload } from '../../lib/media/file-upload'; import { updateMessage } from '../../lib/messages/updateMessage'; import { setUserAvatar } from '../../lib/users/setUserAvatar'; +import { parseFileIntoMessageAttachments, sendFileMessage } from '../../meteor-methods/messages/sendFileMessage'; import { sendFileLivechatMessage } from '../../meteor-methods/omnichannel/sendFileLivechatMessage'; import { UploadFS } from '../../ufs'; diff --git a/apps/meteor/server/services/video-conference/service.ts b/apps/meteor/server/services/video-conference/service.ts index c6b3c51dcf9a2..9e64bc0dc1657 100644 --- a/apps/meteor/server/services/video-conference/service.ts +++ b/apps/meteor/server/services/video-conference/service.ts @@ -40,13 +40,8 @@ import type * as UiKit from '@rocket.chat/ui-kit'; import { Meteor } from 'meteor/meteor'; import { MongoInternals } from 'meteor/mongo'; -import { RocketChatAssets } from '../../../app/assets/server'; import { notifyOnMessageChange } from '../../../app/lib/server/lib/notifyListener'; -import { metrics } from '../../../app/metrics/server/lib/metrics'; -import { Push } from '../../../app/push/server/push'; -import PushNotification from '../../../app/push-notifications/server/lib/PushNotification'; import { settings } from '../../../app/settings/server'; -import { updateCounter } from '../../../app/statistics/server/functions/updateStatsCounter'; import { getUserAvatarURL } from '../../../app/utils/server/getUserAvatarURL'; import { getUserPreference } from '../../../app/utils/server/lib/getUserPreference'; import { availabilityErrors } from '../../../lib/videoConference/constants'; @@ -55,9 +50,14 @@ import { canAccessRoomIdAsync } from '../../lib/authorization/canAccessRoom'; import { callbacks } from '../../lib/callbacks'; import { i18n } from '../../lib/i18n'; import { isRoomCompatibleWithVideoConfRinging } from '../../lib/isRoomCompatibleWithVideoConfRinging'; +import { RocketChatAssets } from '../../lib/media/assets'; import { sendMessage } from '../../lib/messages/sendMessage'; +import { metrics } from '../../lib/metrics/lib/metrics'; +import { Push } from '../../lib/notifications/push/push'; +import PushNotification from '../../lib/notifications/push-config/lib/PushNotification'; import { createRoom } from '../../lib/rooms/createRoom'; import { roomCoordinator } from '../../lib/rooms/roomCoordinator'; +import { updateCounter } from '../../lib/statistics/functions/updateStatsCounter'; import { videoConfProviders } from '../../lib/videoConfProviders'; import { videoConfTypes } from '../../lib/videoConfTypes'; diff --git a/apps/meteor/server/startup/callbacks.ts b/apps/meteor/server/startup/callbacks.ts index ac42ed58137b0..e2e2676fad418 100644 --- a/apps/meteor/server/startup/callbacks.ts +++ b/apps/meteor/server/startup/callbacks.ts @@ -1,8 +1,8 @@ import { Logger } from '@rocket.chat/logger'; import { performance } from 'universal-perf-hooks'; -import { metrics, StatsTracker } from '../../app/metrics/server'; import { callbacks } from '../lib/callbacks'; +import { metrics, StatsTracker } from '../lib/metrics'; callbacks.setLogger(new Logger('Callbacks')); diff --git a/apps/meteor/server/startup/initialData.ts b/apps/meteor/server/startup/initialData.ts index 1170eaac02b0a..f593e51b0c500 100644 --- a/apps/meteor/server/startup/initialData.ts +++ b/apps/meteor/server/startup/initialData.ts @@ -6,9 +6,9 @@ import { Accounts } from 'meteor/accounts-base'; import { Meteor } from 'meteor/meteor'; import { addCallHistoryTestData } from './callHistoryTestData'; -import { FileUpload } from '../../app/file-upload/server'; import { notifyOnSettingChangedById } from '../../app/lib/server/lib/notifyListener'; import { settings } from '../../app/settings/server'; +import { FileUpload } from '../lib/media/file-upload'; import { addUserRolesAsync } from '../lib/roles/addUserRoles'; import { addUserToDefaultChannels } from '../lib/rooms/addUserToDefaultChannels'; import { checkUsernameAvailability } from '../lib/users/checkUsernameAvailability'; diff --git a/apps/meteor/startRocketChat.ts b/apps/meteor/startRocketChat.ts index 3d9b803742bda..d69bf8d0ebc38 100644 --- a/apps/meteor/startRocketChat.ts +++ b/apps/meteor/startRocketChat.ts @@ -1,5 +1,5 @@ -import { startLicense } from './ee/app/license/server/startup'; import { registerEEBroker } from './ee/server'; +import { startLicense } from './ee/server/lib/license/startup'; import { startFederationService as startFederationMatrixService } from './ee/server/startup/federation'; const loadBeforeLicense = async () => { diff --git a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts index 0208c3afccacc..3d4c5fd15c967 100644 --- a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts +++ b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts @@ -5,7 +5,7 @@ import type { Apps } from '@rocket.chat/core-services'; import type { LicenseImp } from '@rocket.chat/license'; import { expect } from 'chai'; -import { _canEnableApp } from '../../../../../ee/app/license/server/canEnableApp'; +import { _canEnableApp } from '../../../../../ee/server/lib/license/canEnableApp'; const getDefaultApp = (): IAppStorageItem => ({ _id: '6706d9258e0ca97c2f0cc885', diff --git a/apps/meteor/tests/unit/app/livechat/server/lib/sendTranscript.spec.ts b/apps/meteor/tests/unit/app/livechat/server/lib/sendTranscript.spec.ts index 130638ba1289a..6cca6e41c3c10 100644 --- a/apps/meteor/tests/unit/app/livechat/server/lib/sendTranscript.spec.ts +++ b/apps/meteor/tests/unit/app/livechat/server/lib/sendTranscript.spec.ts @@ -66,11 +66,11 @@ const { sendTranscript } = p.noCallThru().load('../../../../../../app/livechat/s }, }, '../../../../server/lib/i18n': { i18n: { t: tStub } }, - '../../../mailer/server/api': { send: mailerMock }, + '../../../../server/lib/notifications/email/api': { send: mailerMock }, '../../../settings/server': { settings: { get: settingsMock } }, '../../../utils/server/lib/getTimezone': { getTimezone: getTimezoneMock }, // TODO: add tests for file handling on transcripts - '../../../file-upload/server': { FileUpload: {} }, + '../../../../server/lib/media/file-upload': { FileUpload: {} }, }); describe('Send transcript', () => { diff --git a/apps/meteor/tests/unit/app/livechat/server/lib/webhooks.spec.ts b/apps/meteor/tests/unit/app/livechat/server/lib/webhooks.spec.ts index 6266a13fdcb68..4949678e6ef62 100644 --- a/apps/meteor/tests/unit/app/livechat/server/lib/webhooks.spec.ts +++ b/apps/meteor/tests/unit/app/livechat/server/lib/webhooks.spec.ts @@ -58,7 +58,7 @@ function buildSubject(options?: { const { sendRequest } = proxyquire.noCallThru().load(MODULE_PATH, { '@rocket.chat/server-fetch': { serverFetch: fetchStub }, './logger': { webhooksLogger: logger }, - '../../../metrics/server': { metrics }, + '../../../../server/lib/metrics': { metrics }, '../../../settings/server': { settings }, }); diff --git a/apps/meteor/tests/unit/app/mailer/api.spec.ts b/apps/meteor/tests/unit/app/mailer/api.spec.ts index 9ed6cba110eef..2f80cc69cfef1 100644 --- a/apps/meteor/tests/unit/app/mailer/api.spec.ts +++ b/apps/meteor/tests/unit/app/mailer/api.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { replaceVariables } from '../../../../app/mailer/server/replaceVariables'; +import { replaceVariables } from '../../../../server/lib/notifications/email/replaceVariables'; describe('Mailer-API', () => { describe('replaceVariables', () => { diff --git a/apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts b/apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts index 6ffbe4dbfd247..84a694f2b93a4 100644 --- a/apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts +++ b/apps/meteor/tests/unit/app/mailer/getEmailContent.spec.ts @@ -30,7 +30,7 @@ const mocks = { getRoomName: () => '', }, }, - '../../../../mailer/server/api': { + '../../../../../server/lib/notifications/email/api': { getTemplate: () => {}, send: () => {}, replace: () => {}, @@ -41,7 +41,7 @@ const mocks = { watch: () => {}, }, }, - '../../../../metrics/server': { + '../../../../../server/lib/metrics': { metrics: {}, }, '../../../../utils/server/getURL': { diff --git a/apps/meteor/tests/unit/server/livechat/hooks/beforeNewRoom.spec.ts b/apps/meteor/tests/unit/server/hooks/omnichannel/beforeNewRoom.spec.ts similarity index 93% rename from apps/meteor/tests/unit/server/livechat/hooks/beforeNewRoom.spec.ts rename to apps/meteor/tests/unit/server/hooks/omnichannel/beforeNewRoom.spec.ts index 11b256ee57b3b..c17e6a3768ba3 100644 --- a/apps/meteor/tests/unit/server/livechat/hooks/beforeNewRoom.spec.ts +++ b/apps/meteor/tests/unit/server/hooks/omnichannel/beforeNewRoom.spec.ts @@ -5,7 +5,7 @@ import sinon from 'sinon'; const findStub = sinon.stub(); -const { beforeNewRoomPatched } = proxyquire.noCallThru().load('../../../../../ee/app/livechat-enterprise/server/hooks/beforeNewRoom.ts', { +const { beforeNewRoomPatched } = proxyquire.noCallThru().load('../../../../../ee/server/hooks/omnichannel/beforeNewRoom.ts', { 'meteor/meteor': { Meteor: { Error, @@ -16,7 +16,7 @@ const { beforeNewRoomPatched } = proxyquire.noCallThru().load('../../../../../ee findOneByIdOrName: findStub, }, }, - '../../../../../app/livechat/server/lib/hooks': { + '../../../../app/livechat/server/lib/hooks': { beforeNewRoom: { patch: sinon.stub() }, }, }); diff --git a/apps/meteor/tests/unit/server/livechat/hooks/markRoomResponded.spec.ts b/apps/meteor/tests/unit/server/hooks/omnichannel/markRoomResponded.spec.ts similarity index 93% rename from apps/meteor/tests/unit/server/livechat/hooks/markRoomResponded.spec.ts rename to apps/meteor/tests/unit/server/hooks/omnichannel/markRoomResponded.spec.ts index eb6e08d87e784..8461ec6aca9b0 100644 --- a/apps/meteor/tests/unit/server/livechat/hooks/markRoomResponded.spec.ts +++ b/apps/meteor/tests/unit/server/hooks/omnichannel/markRoomResponded.spec.ts @@ -21,12 +21,12 @@ const settingsGetMock = { const isMessageFromBotMock = { isMessageFromBot: Sinon.stub() }; -const { markRoomResponded } = proxyquire.noCallThru().load('../../../../../app/livechat/server/hooks/markRoomResponded.ts', { - '../../../../server/lib/callbacks': { callbacks: { add: Sinon.stub(), priority: { HIGH: 'high' } } }, - '../../../lib/server/lib/notifyListener': { notifyOnLivechatInquiryChanged: Sinon.stub() }, +const { markRoomResponded } = proxyquire.noCallThru().load('../../../../../server/hooks/omnichannel/markRoomResponded.ts', { + '../../lib/callbacks': { callbacks: { add: Sinon.stub(), priority: { HIGH: 'high' } } }, + '../../../app/lib/server/lib/notifyListener': { notifyOnLivechatInquiryChanged: Sinon.stub() }, '@rocket.chat/models': models, - '../../../settings/server': { settings: settingsGetMock }, - '../lib/isMessageFromBot': isMessageFromBotMock, + '../../../app/settings/server': { settings: settingsGetMock }, + '../../../app/livechat/server/lib/isMessageFromBot': isMessageFromBotMock, }); describe('markRoomResponded', () => { diff --git a/apps/meteor/tests/unit/app/livechat/server/hooks/processRoomAbandonment.spec.ts b/apps/meteor/tests/unit/server/hooks/omnichannel/processRoomAbandonment.spec.ts similarity index 98% rename from apps/meteor/tests/unit/app/livechat/server/hooks/processRoomAbandonment.spec.ts rename to apps/meteor/tests/unit/server/hooks/omnichannel/processRoomAbandonment.spec.ts index e91cc71e5d622..005b44eff9088 100644 --- a/apps/meteor/tests/unit/app/livechat/server/hooks/processRoomAbandonment.spec.ts +++ b/apps/meteor/tests/unit/server/hooks/omnichannel/processRoomAbandonment.spec.ts @@ -25,15 +25,15 @@ const businessHourManagerMock = { const { getSecondsWhenOfficeHoursIsDisabled, parseDays, getSecondsSinceLastAgentResponse, onCloseRoom } = p .noCallThru() - .load('../../../../../../app/livechat/server/hooks/processRoomAbandonment.ts', { + .load('../../../../../server/hooks/omnichannel/processRoomAbandonment.ts', { '@rocket.chat/models': models, - '../../../../server/lib/callbacks': { + '../../lib/callbacks': { callbacks: { add: sinon.stub(), priority: { HIGH: 'high' } }, }, - '../../../settings/server': { + '../../../app/settings/server': { settings: { get: settingsStub }, }, - '../business-hour': { businessHourManager: businessHourManagerMock }, + '../../../app/livechat/server/business-hour': { businessHourManager: businessHourManagerMock }, }); describe('processRoomAbandonment', () => { diff --git a/apps/meteor/tests/unit/app/livechat/server/hooks/sendToCRM.tests.ts b/apps/meteor/tests/unit/server/hooks/omnichannel/sendToCRM.tests.ts similarity index 93% rename from apps/meteor/tests/unit/app/livechat/server/hooks/sendToCRM.tests.ts rename to apps/meteor/tests/unit/server/hooks/omnichannel/sendToCRM.tests.ts index 79651cea1a52c..af2eebfc25d96 100644 --- a/apps/meteor/tests/unit/app/livechat/server/hooks/sendToCRM.tests.ts +++ b/apps/meteor/tests/unit/server/hooks/omnichannel/sendToCRM.tests.ts @@ -8,19 +8,19 @@ const resultObj = { const { sendMessageType, isOmnichannelNavigationMessage, isOmnichannelClosingMessage, getAdditionalFieldsByType } = p .noCallThru() - .load('../../../../../../app/livechat/server/hooks/sendToCRM', { - '../../../settings/server': { + .load('../../../../../server/hooks/omnichannel/sendToCRM', { + '../../../app/settings/server': { settings: { get() { return resultObj.result; }, }, }, - '../../../utils/server/functions/normalizeMessageFileUpload': { + '../../../app/utils/server/functions/normalizeMessageFileUpload': { normalizeMessageFileUpload: sinon.stub().returnsArg(0), }, - '../lib/webhooks': {}, - '../lib/guests': { getLivechatRoomGuestInfo: sinon.stub() }, + '../../../app/livechat/server/lib/webhooks': {}, + '../../../app/livechat/server/lib/guests': { getLivechatRoomGuestInfo: sinon.stub() }, }); describe('[OC] Send TO CRM', () => { diff --git a/apps/meteor/tests/unit/app/custom-oauth/server/transform_helpers.tests.js b/apps/meteor/tests/unit/server/lib/auth-providers/custom-oauth/transform_helpers.tests.js similarity index 97% rename from apps/meteor/tests/unit/app/custom-oauth/server/transform_helpers.tests.js rename to apps/meteor/tests/unit/server/lib/auth-providers/custom-oauth/transform_helpers.tests.js index 17455dec833fd..ac6fa44255674 100644 --- a/apps/meteor/tests/unit/app/custom-oauth/server/transform_helpers.tests.js +++ b/apps/meteor/tests/unit/server/lib/auth-providers/custom-oauth/transform_helpers.tests.js @@ -6,7 +6,7 @@ import { renameInvalidProperties, getNestedValue, getRegexpMatch, -} from '../../../../../app/custom-oauth/server/transform_helpers'; +} from '../../../../../../server/lib/auth-providers/custom-oauth/transform_helpers'; const data = { 'id': '123456', diff --git a/apps/meteor/tests/unit/server/lib/dataExport/uploadZipFile.spec.ts b/apps/meteor/tests/unit/server/lib/dataExport/uploadZipFile.spec.ts index 30f849823a6e6..635e033fa7c69 100644 --- a/apps/meteor/tests/unit/server/lib/dataExport/uploadZipFile.spec.ts +++ b/apps/meteor/tests/unit/server/lib/dataExport/uploadZipFile.spec.ts @@ -30,7 +30,7 @@ const { uploadZipFile } = proxyquire.noCallThru().load('../../../../../server/li 'node:fs': { createReadStream: stubs.createReadStream, }, - '../../../app/file-upload/server': { + '../media/file-upload': { FileUpload: { getStore: stubs.getStore, }, diff --git a/apps/meteor/tests/unit/app/e2e/server/functions/resetRoomKey.spec.ts b/apps/meteor/tests/unit/server/lib/e2e/functions/resetRoomKey.spec.ts similarity index 98% rename from apps/meteor/tests/unit/app/e2e/server/functions/resetRoomKey.spec.ts rename to apps/meteor/tests/unit/server/lib/e2e/functions/resetRoomKey.spec.ts index de95bbe546938..c370ce4e7b1d6 100644 --- a/apps/meteor/tests/unit/app/e2e/server/functions/resetRoomKey.spec.ts +++ b/apps/meteor/tests/unit/server/lib/e2e/functions/resetRoomKey.spec.ts @@ -28,9 +28,9 @@ const models = { const { resetRoomKey, pushToLimit, replicateMongoSlice } = proxyquire .noCallThru() - .load('../../../../../../app/e2e/server/functions/resetRoomKey', { + .load('../../../../../../server/lib/e2e/functions/resetRoomKey', { '@rocket.chat/models': models, - '../../../lib/server/lib/notifyListener': { + '../../../../app/lib/server/lib/notifyListener': { notifyOnRoomChanged: sinon.stub(), notifyOnSubscriptionChanged: sinon.stub(), }, diff --git a/apps/meteor/tests/unit/app/importer/server/messageConverter.spec.ts b/apps/meteor/tests/unit/server/lib/import/messageConverter.spec.ts similarity index 98% rename from apps/meteor/tests/unit/app/importer/server/messageConverter.spec.ts rename to apps/meteor/tests/unit/server/lib/import/messageConverter.spec.ts index 378a5835e00bd..914381b148782 100644 --- a/apps/meteor/tests/unit/app/importer/server/messageConverter.spec.ts +++ b/apps/meteor/tests/unit/server/lib/import/messageConverter.spec.ts @@ -10,11 +10,11 @@ const modelsMock = { }; const insertMessage = sinon.stub(); -const { MessageConverter } = proxyquire.noCallThru().load('../../../../../app/importer/server/classes/converters/MessageConverter', { +const { MessageConverter } = proxyquire.noCallThru().load('../../../../../server/lib/import/classes/converters/MessageConverter', { '../../../settings/server': { settings: { get: settingsStub }, }, - '../../../../../server/lib/messages/insertMessage': { + '../../../messages/insertMessage': { insertMessage, }, 'meteor/check': sinon.stub(), diff --git a/apps/meteor/tests/unit/app/importer/server/recordConverter.spec.ts b/apps/meteor/tests/unit/server/lib/import/recordConverter.spec.ts similarity index 98% rename from apps/meteor/tests/unit/app/importer/server/recordConverter.spec.ts rename to apps/meteor/tests/unit/server/lib/import/recordConverter.spec.ts index 71ebb277f3dd5..5de2583377294 100644 --- a/apps/meteor/tests/unit/app/importer/server/recordConverter.spec.ts +++ b/apps/meteor/tests/unit/server/lib/import/recordConverter.spec.ts @@ -14,7 +14,7 @@ const modelsMock = { }, }; -const { RecordConverter } = proxyquire.noCallThru().load('../../../../../app/importer/server/classes/converters/RecordConverter', { +const { RecordConverter } = proxyquire.noCallThru().load('../../../../../server/lib/import/classes/converters/RecordConverter', { '../../../settings/server': { settings: { get: settingsStub }, }, diff --git a/apps/meteor/tests/unit/app/importer/server/roomConverter.spec.ts b/apps/meteor/tests/unit/server/lib/import/roomConverter.spec.ts similarity index 95% rename from apps/meteor/tests/unit/app/importer/server/roomConverter.spec.ts rename to apps/meteor/tests/unit/server/lib/import/roomConverter.spec.ts index b6037a7029302..734d4e55b8e89 100644 --- a/apps/meteor/tests/unit/app/importer/server/roomConverter.spec.ts +++ b/apps/meteor/tests/unit/server/lib/import/roomConverter.spec.ts @@ -18,23 +18,23 @@ const modelsMock = { const createDirectMessage = sinon.stub(); const saveRoomSettings = sinon.stub(); -const { RoomConverter } = proxyquire.noCallThru().load('../../../../../app/importer/server/classes/converters/RoomConverter', { +const { RoomConverter } = proxyquire.noCallThru().load('../../../../../server/lib/import/classes/converters/RoomConverter', { '../../../settings/server': { settings: { get: settingsStub }, }, - '../../../../../server/meteor-methods/messages/createDirectMessage': { + '../../../../meteor-methods/messages/createDirectMessage': { createDirectMessage, }, - '../../../../../server/meteor-methods/rooms/saveRoomSettings': { + '../../../../meteor-methods/rooms/saveRoomSettings': { saveRoomSettings, }, - '../../../../lib/server/lib/notifyListener': { + '../../../../../app/lib/server/lib/notifyListener': { notifyOnSubscriptionChangedByRoomId: sinon.stub(), }, - '../../../../../server/meteor-methods/rooms/createChannel': { + '../../../../meteor-methods/rooms/createChannel': { createChannelMethod: sinon.stub(), }, - '../../../../../server/meteor-methods/rooms/createPrivateGroup': { + '../../../../meteor-methods/rooms/createPrivateGroup': { createPrivateGroupMethod: sinon.stub(), }, 'meteor/check': sinon.stub(), diff --git a/apps/meteor/tests/unit/app/importer/server/transformMappedData.spec.ts b/apps/meteor/tests/unit/server/lib/import/transformMappedData.spec.ts similarity index 100% rename from apps/meteor/tests/unit/app/importer/server/transformMappedData.spec.ts rename to apps/meteor/tests/unit/server/lib/import/transformMappedData.spec.ts diff --git a/apps/meteor/tests/unit/app/importer/server/userConverter.spec.ts b/apps/meteor/tests/unit/server/lib/import/userConverter.spec.ts similarity index 97% rename from apps/meteor/tests/unit/app/importer/server/userConverter.spec.ts rename to apps/meteor/tests/unit/server/lib/import/userConverter.spec.ts index f84bc3d9344c2..e96536ee4efd2 100644 --- a/apps/meteor/tests/unit/app/importer/server/userConverter.spec.ts +++ b/apps/meteor/tests/unit/server/lib/import/userConverter.spec.ts @@ -20,26 +20,26 @@ const bcryptHash = sinon.stub(); const sha = sinon.stub(); const generateTempPassword = sinon.stub(); -const { UserConverter } = proxyquire.noCallThru().load('../../../../../app/importer/server/classes/converters/UserConverter', { - '../../../../../server/lib/callbacks': { +const { UserConverter } = proxyquire.noCallThru().load('../../../../../server/lib/import/classes/converters/UserConverter', { + '../../../callbacks': { callbacks, }, '../../../settings/server': { settings: { get: settingsStub }, }, - '../../../../../server/lib/rooms/addUserToDefaultChannels': { + '../../../rooms/addUserToDefaultChannels': { addUserToDefaultChannels, }, - '../../../../../server/lib/users/getUsernameSuggestion': { + '../../../users/getUsernameSuggestion': { generateUsernameSuggestion, }, - '../../../../../server/lib/users/saveUserIdentity': { + '../../../users/saveUserIdentity': { saveUserIdentity: sinon.stub(), }, - '../../../../../server/lib/users/setUserActiveStatus': { + '../../../users/setUserActiveStatus': { setUserActiveStatus: sinon.stub(), }, - '../../../../lib/server/lib/notifyListener': { + '../../../../../app/lib/server/lib/notifyListener': { notifyOnUserChange: sinon.stub(), }, './generateTempPassword': { diff --git a/apps/meteor/tests/unit/app/mentions/server.tests.js b/apps/meteor/tests/unit/server/lib/messaging/mentions/server.tests.js similarity index 98% rename from apps/meteor/tests/unit/app/mentions/server.tests.js rename to apps/meteor/tests/unit/server/lib/messaging/mentions/server.tests.js index 04064de7c3cab..c21ec426fa3f6 100644 --- a/apps/meteor/tests/unit/app/mentions/server.tests.js +++ b/apps/meteor/tests/unit/server/lib/messaging/mentions/server.tests.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { MentionsServer } from '../../../../app/mentions/server/Mentions'; +import { MentionsServer } from '../../../../../../server/lib/messaging/mentions/Mentions'; let mention; diff --git a/apps/meteor/tests/unit/app/reactions/server/setReaction.spec.ts b/apps/meteor/tests/unit/server/lib/messaging/reactions/setReaction.spec.ts similarity index 94% rename from apps/meteor/tests/unit/app/reactions/server/setReaction.spec.ts rename to apps/meteor/tests/unit/server/lib/messaging/reactions/setReaction.spec.ts index a5b39700236c8..3e37658f7ec1e 100644 --- a/apps/meteor/tests/unit/app/reactions/server/setReaction.spec.ts +++ b/apps/meteor/tests/unit/server/lib/messaging/reactions/setReaction.spec.ts @@ -35,20 +35,22 @@ const meteorErrorMock = class extends Error { } }; -const { removeUserReaction, executeSetReaction, setReaction } = p.noCallThru().load('../../../../../app/reactions/server/setReaction.ts', { - '@rocket.chat/models': modelsMock, - '@rocket.chat/core-services': { Message: { beforeReacted: sinon.stub() } }, - 'meteor/meteor': { Meteor: { methods: meteorMethodsMock, Error: meteorErrorMock } }, - '../../../server/lib/callbacks': { callbacks: { run: callbacksRunMock } }, - '../../../server/lib/i18n': { i18n: i18nMock }, - '../../authorization/server': { canAccessRoomAsync: canAccessRoomAsyncMock }, - '../../../server/lib/authorization/hasPermission': { hasPermissionAsync: hasPermissionAsyncMock }, - '../../emoji/server': { emoji: { list: emojiList } }, - '../../../server/lib/messages/isTheLastMessage': { isTheLastMessage: isTheLastMessageMock }, - '../../lib/server/lib/notifyListener': { - notifyOnMessageChange: notifyOnMessageChangeMock, - }, -}); +const { removeUserReaction, executeSetReaction, setReaction } = p + .noCallThru() + .load('../../../../../../server/lib/messaging/reactions/setReaction.ts', { + '@rocket.chat/models': modelsMock, + '@rocket.chat/core-services': { Message: { beforeReacted: sinon.stub() } }, + 'meteor/meteor': { Meteor: { methods: meteorMethodsMock, Error: meteorErrorMock } }, + '../../callbacks': { callbacks: { run: callbacksRunMock } }, + '../../i18n': { i18n: i18nMock }, + '../../../../app/authorization/server': { canAccessRoomAsync: canAccessRoomAsyncMock }, + '../../authorization/hasPermission': { hasPermissionAsync: hasPermissionAsyncMock }, + '../emoji': { emoji: { list: emojiList } }, + '../../messages/isTheLastMessage': { isTheLastMessage: isTheLastMessageMock }, + '../../../../app/lib/server/lib/notifyListener': { + notifyOnMessageChange: notifyOnMessageChangeMock, + }, + }); describe('Reactions', () => { describe('removeUserReaction', () => { diff --git a/apps/meteor/tests/unit/app/push/push.spec.ts b/apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts similarity index 94% rename from apps/meteor/tests/unit/app/push/push.spec.ts rename to apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts index cfabd30d0291d..fff31de1aec26 100644 --- a/apps/meteor/tests/unit/app/push/push.spec.ts +++ b/apps/meteor/tests/unit/server/lib/notifications/push/push.spec.ts @@ -7,9 +7,9 @@ import sinon from 'sinon'; const loggerStub = { debug: sinon.stub(), warn: sinon.stub(), error: sinon.stub(), info: sinon.stub(), log: sinon.stub() }; const settingsStub = { get: sinon.stub().returns('') }; -const { Push } = proxyquire.noCallThru().load('../../../../app/push/server/push', { +const { Push } = proxyquire.noCallThru().load('../../../../../../server/lib/notifications/push/push', { './logger': { logger: loggerStub }, - '../../settings/server': { settings: settingsStub }, + '../../../../app/settings/server': { settings: settingsStub }, '@rocket.chat/tools': { pick, truncateString }, 'meteor/check': { check: sinon.stub(), diff --git a/apps/meteor/tests/unit/app/meteor-accounts-saml/data.ts b/apps/meteor/tests/unit/server/lib/saml/data.ts similarity index 99% rename from apps/meteor/tests/unit/app/meteor-accounts-saml/data.ts rename to apps/meteor/tests/unit/server/lib/saml/data.ts index c2cc56bc6d422..de9134960c829 100644 --- a/apps/meteor/tests/unit/app/meteor-accounts-saml/data.ts +++ b/apps/meteor/tests/unit/server/lib/saml/data.ts @@ -1,4 +1,4 @@ -import type { IServiceProviderOptions } from '../../../../app/meteor-accounts-saml/server/definition/IServiceProviderOptions'; +import type { IServiceProviderOptions } from '../../../../../server/lib/saml/definition/IServiceProviderOptions'; export const serviceProviderOptions: IServiceProviderOptions = { provider: '[test-provider]', diff --git a/apps/meteor/tests/unit/app/meteor-accounts-saml/helpers.ts b/apps/meteor/tests/unit/server/lib/saml/helpers.ts similarity index 88% rename from apps/meteor/tests/unit/app/meteor-accounts-saml/helpers.ts rename to apps/meteor/tests/unit/server/lib/saml/helpers.ts index be2c1ba020270..71298aa874b77 100644 --- a/apps/meteor/tests/unit/app/meteor-accounts-saml/helpers.ts +++ b/apps/meteor/tests/unit/server/lib/saml/helpers.ts @@ -1,8 +1,4 @@ -import type { - SAMLDocumentType, - SAMLPOSTEnvelope, - SAMLRedirectEnvelope, -} from '../../../../app/meteor-accounts-saml/server/definition/SAMLEnvelope'; +import type { SAMLDocumentType, SAMLPOSTEnvelope, SAMLRedirectEnvelope } from '../../../../../server/lib/saml/definition/SAMLEnvelope'; export function makeLogoutEnvelope( type: T, diff --git a/apps/meteor/tests/unit/app/meteor-accounts-saml/loginHandler.spec.ts b/apps/meteor/tests/unit/server/lib/saml/loginHandler.spec.ts similarity index 90% rename from apps/meteor/tests/unit/app/meteor-accounts-saml/loginHandler.spec.ts rename to apps/meteor/tests/unit/server/lib/saml/loginHandler.spec.ts index 42e3ba8cde170..c50516518c2ca 100644 --- a/apps/meteor/tests/unit/app/meteor-accounts-saml/loginHandler.spec.ts +++ b/apps/meteor/tests/unit/server/lib/saml/loginHandler.spec.ts @@ -13,7 +13,7 @@ const samlUtilsMock = { }; const handler = sinon.stub(); -proxyquire.noCallThru().load('../../../../app/meteor-accounts-saml/server/loginHandler', { +proxyquire.noCallThru().load('../../../../../server/lib/saml/loginHandler', { '@rocket.chat/models': { CredentialTokens: { removeById }, }, @@ -34,8 +34,8 @@ proxyquire.noCallThru().load('../../../../app/meteor-accounts-saml/server/loginH './lib/Utils': { SAMLUtils: samlUtilsMock, }, - '../../../server/lib/i18n': { i18n: { t: sinon.stub().returns('') } }, - '../../../server/lib/logger/system': { SystemLogger: { error: sinon.stub() } }, + '../i18n': { i18n: { t: sinon.stub().returns('') } }, + '../logger/system': { SystemLogger: { error: sinon.stub() } }, }); describe('SAML loginHandler', () => { diff --git a/apps/meteor/tests/unit/app/meteor-accounts-saml/server.tests.ts b/apps/meteor/tests/unit/server/lib/saml/server.tests.ts similarity index 96% rename from apps/meteor/tests/unit/app/meteor-accounts-saml/server.tests.ts rename to apps/meteor/tests/unit/server/lib/saml/server.tests.ts index 5651ab7d7536d..b3810e5f31a03 100644 --- a/apps/meteor/tests/unit/app/meteor-accounts-saml/server.tests.ts +++ b/apps/meteor/tests/unit/server/lib/saml/server.tests.ts @@ -36,13 +36,13 @@ import { privateKey, } from './data'; import { makeLoginResponseEnvelope, makeLogoutRequestEnvelope, makeLogoutResponseEnvelope } from './helpers'; -import { SAMLUtils } from '../../../../app/meteor-accounts-saml/server/lib/Utils'; -import { AuthorizeRequest } from '../../../../app/meteor-accounts-saml/server/lib/generators/AuthorizeRequest'; -import { LogoutRequest } from '../../../../app/meteor-accounts-saml/server/lib/generators/LogoutRequest'; -import { LogoutResponse } from '../../../../app/meteor-accounts-saml/server/lib/generators/LogoutResponse'; -import { LogoutRequestParser } from '../../../../app/meteor-accounts-saml/server/lib/parsers/LogoutRequest'; -import { LogoutResponseParser } from '../../../../app/meteor-accounts-saml/server/lib/parsers/LogoutResponse'; -import { ResponseParser } from '../../../../app/meteor-accounts-saml/server/lib/parsers/Response'; +import { SAMLUtils } from '../../../../../server/lib/saml/lib/Utils'; +import { AuthorizeRequest } from '../../../../../server/lib/saml/lib/generators/AuthorizeRequest'; +import { LogoutRequest } from '../../../../../server/lib/saml/lib/generators/LogoutRequest'; +import { LogoutResponse } from '../../../../../server/lib/saml/lib/generators/LogoutResponse'; +import { LogoutRequestParser } from '../../../../../server/lib/saml/lib/parsers/LogoutRequest'; +import { LogoutResponseParser } from '../../../../../server/lib/saml/lib/parsers/LogoutResponse'; +import { ResponseParser } from '../../../../../server/lib/saml/lib/parsers/Response'; const meteorStub = { 'meteor/meteor': { @@ -57,9 +57,9 @@ const meteorStub = { const { ServiceProviderMetadata } = proxyquire .noCallThru() - .load('../../../../app/meteor-accounts-saml/server/lib/generators/ServiceProviderMetadata', meteorStub); + .load('../../../../../server/lib/saml/lib/generators/ServiceProviderMetadata', meteorStub); -const { SAMLServiceProvider } = proxyquire.noCallThru().load('../../../../app/meteor-accounts-saml/server/lib/ServiceProvider', meteorStub); +const { SAMLServiceProvider } = proxyquire.noCallThru().load('../../../../../server/lib/saml/lib/ServiceProvider', meteorStub); describe('SAML', () => { describe('[AuthorizeRequest]', () => { @@ -1159,7 +1159,7 @@ describe('SAML', () => { }; const loadSAML = () => - proxyquire.noCallThru().load('../../../../app/meteor-accounts-saml/server/lib/SAML', { + proxyquire.noCallThru().load('../../../../../server/lib/saml/lib/SAML', { '@rocket.chat/models': { SamlUsedAssertions: { markUsed }, CredentialTokens: { create: credentialCreate }, @@ -1189,13 +1189,13 @@ describe('SAML', () => { }, './getSAMLEnvelope': { getSAMLEnvelope: async () => ({ relayState: null }) }, '../../../../lib/utils/arrayUtils': { ensureArray: (v: any) => v }, - '../../../../server/lib/logger/system': { SystemLogger: { error: sinon.stub(), warn: sinon.stub() } }, - '../../../../server/lib/rooms/addUserToRoom': { addUserToRoom: sinon.stub() }, - '../../../../server/lib/rooms/createRoom': { createRoom: sinon.stub() }, - '../../../../server/lib/users/getUsernameSuggestion': { generateUsernameSuggestion: sinon.stub() }, - '../../../../server/lib/users/saveUserIdentity': { saveUserIdentity: sinon.stub() }, - '../../../settings/server': { settings: { get: sinon.stub() } }, - '../../../utils/lib/i18n': { i18n: { t: (s: string) => s, languages: [] } }, + '../../logger/system': { SystemLogger: { error: sinon.stub(), warn: sinon.stub() } }, + '../../rooms/addUserToRoom': { addUserToRoom: sinon.stub() }, + '../../rooms/createRoom': { createRoom: sinon.stub() }, + '../../users/getUsernameSuggestion': { generateUsernameSuggestion: sinon.stub() }, + '../../users/saveUserIdentity': { saveUserIdentity: sinon.stub() }, + '../../../../app/settings/server': { settings: { get: sinon.stub() } }, + '../../../../app/utils/lib/i18n': { i18n: { t: (s: string) => s, languages: [] } }, }).SAML; const service = { ...serviceProviderOptions } as any; diff --git a/apps/meteor/tests/unit/app/statistics/server/lib/UAParserCustom.tests.js b/apps/meteor/tests/unit/server/lib/statistics/lib/UAParserCustom.tests.js similarity index 97% rename from apps/meteor/tests/unit/app/statistics/server/lib/UAParserCustom.tests.js rename to apps/meteor/tests/unit/server/lib/statistics/lib/UAParserCustom.tests.js index 24e961c53ebc7..954cfe2b68913 100644 --- a/apps/meteor/tests/unit/app/statistics/server/lib/UAParserCustom.tests.js +++ b/apps/meteor/tests/unit/server/lib/statistics/lib/UAParserCustom.tests.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { UAParserMobile, UAParserDesktop } from '../../../../../../app/statistics/server/lib/UAParserCustom'; +import { UAParserMobile, UAParserDesktop } from '../../../../../../server/lib/statistics/lib/UAParserCustom'; const UAMobile = 'RC Mobile; iOS 12.2; v3.4.0 (250)'; const UADesktop = diff --git a/apps/meteor/tests/unit/server/lib/users/saveUser/sendUserEmail.spec.ts b/apps/meteor/tests/unit/server/lib/users/saveUser/sendUserEmail.spec.ts index 6dc5743623049..797d38006505c 100644 --- a/apps/meteor/tests/unit/server/lib/users/saveUser/sendUserEmail.spec.ts +++ b/apps/meteor/tests/unit/server/lib/users/saveUser/sendUserEmail.spec.ts @@ -55,7 +55,7 @@ describe('sendUserEmail (Mocha + TS)', () => { MeteorStub = stubs.MeteorStub as any; const mod = mock.noCallThru().load('../../../../../../server/lib/users/saveUser/sendUserEmail.ts', { - '../../../../app/mailer/server/api': MailerStub, + '../../notifications/email/api': MailerStub, '../../../../app/settings/server': SettingsStub, 'meteor/meteor': MeteorStub, }) as any; diff --git a/apps/meteor/tests/unit/server/meteor-methods/messages/deleteFileMessage.spec.ts b/apps/meteor/tests/unit/server/meteor-methods/messages/deleteFileMessage.spec.ts index 51c47732a9b38..ec9f3c17e0655 100644 --- a/apps/meteor/tests/unit/server/meteor-methods/messages/deleteFileMessage.spec.ts +++ b/apps/meteor/tests/unit/server/meteor-methods/messages/deleteFileMessage.spec.ts @@ -39,7 +39,7 @@ p.noCallThru().load('../../../../../server/meteor-methods/messages/deleteFileMes '@rocket.chat/core-services': { Upload: { canDeleteFile: canDeleteFileMock }, }, - '../../../app/file-upload/server': { + '../../lib/media/file-upload': { FileUpload: { getStore: fileUploadGetStoreMock }, }, '../../lib/messages/deleteMessage': { diff --git a/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts b/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts index 470b79daa8fa3..896e27cb7fd15 100644 --- a/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts +++ b/apps/meteor/tests/unit/server/services/omnichannel/queue.tests.ts @@ -57,7 +57,7 @@ const { OmnichannelQueue } = p.noCallThru().load('../../../../../server/services './logger': { queueLogger }, '@rocket.chat/models': models, '@rocket.chat/license': { License: license }, - '../../../app/metrics/server': { + '../../lib/metrics': { metrics: { timeToQueueProcessingByQueue: { observe: Sinon.stub() }, timeToQueueProcessingByQueueHistogram: { observe: Sinon.stub() }, diff --git a/apps/meteor/tests/unit/server/startup/initialData.tests.ts b/apps/meteor/tests/unit/server/startup/initialData.tests.ts index fd72368ade26e..74c71571a949c 100644 --- a/apps/meteor/tests/unit/server/startup/initialData.tests.ts +++ b/apps/meteor/tests/unit/server/startup/initialData.tests.ts @@ -31,7 +31,7 @@ const { insertAdminUserFromEnv } = proxyquire.noCallThru().load('../../../../ser startup: sinon.stub(), }, }, - '../../app/file-upload/server': {}, + '../lib/media/file-upload': {}, '../../app/file/server': {}, '../lib/rooms/addUserToDefaultChannels': {}, '../lib/users/checkUsernameAvailability': { diff --git a/apps/meteor/tests/unit/server/users/saveUserIdentity.spec.ts b/apps/meteor/tests/unit/server/users/saveUserIdentity.spec.ts index 836dbd435bc59..f82b3729cb060 100644 --- a/apps/meteor/tests/unit/server/users/saveUserIdentity.spec.ts +++ b/apps/meteor/tests/unit/server/users/saveUserIdentity.spec.ts @@ -42,7 +42,7 @@ const { saveUserIdentity } = proxyquire.noCallThru().load('../../../../server/li '@global': true, }, '../../database/utils': { onceTransactionCommitedSuccessfully: async (cb: any, _sess: any) => cb() }, - '../../../app/file-upload/server': { + '../media/file-upload': { FileUpload: stubs.FileUpload, }, './setUsername': {