diff --git a/.changeset/unlucky-ducks-arrive.md b/.changeset/unlucky-ducks-arrive.md new file mode 100644 index 000000000000..3500d95e44be --- /dev/null +++ b/.changeset/unlucky-ducks-arrive.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes deprecated method `livechat:sendOfflineMessage`. Moving forward, use the endpoint `livechat/offline.message`. diff --git a/apps/meteor/app/livechat/server/api/v1/offlineMessage.ts b/apps/meteor/app/livechat/server/api/v1/offlineMessage.ts index 6acd6ab98ea1..a367df7a04ad 100644 --- a/apps/meteor/app/livechat/server/api/v1/offlineMessage.ts +++ b/apps/meteor/app/livechat/server/api/v1/offlineMessage.ts @@ -6,7 +6,10 @@ import { Livechat } from '../../lib/LivechatTyped'; API.v1.addRoute( 'livechat/offline.message', - { validateParams: isPOSTLivechatOfflineMessageParams }, + { + validateParams: isPOSTLivechatOfflineMessageParams, + rateLimiterOptions: { numRequestsAllowed: 1, intervalTimeInMS: 5000 }, + }, { async post() { const { name, email, message, department, host } = this.bodyParams; diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index ef8fb5067e22..d365b8af5a1b 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -43,7 +43,6 @@ import './methods/saveIntegration'; import './methods/saveTrigger'; import './methods/sendMessageLivechat'; import './methods/sendFileLivechatMessage'; -import './methods/sendOfflineMessage'; import './methods/setCustomField'; import './methods/setDepartmentForVisitor'; import './methods/transfer'; diff --git a/apps/meteor/app/livechat/server/methods/sendOfflineMessage.ts b/apps/meteor/app/livechat/server/methods/sendOfflineMessage.ts deleted file mode 100644 index b620aa434100..000000000000 --- a/apps/meteor/app/livechat/server/methods/sendOfflineMessage.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { check } from 'meteor/check'; -import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; -import { Meteor } from 'meteor/meteor'; - -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { Livechat } from '../lib/LivechatTyped'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:sendOfflineMessage'(data: { name: string; email: string; message: string }): Promise; - } -} - -Meteor.methods({ - async 'livechat:sendOfflineMessage'(data) { - methodDeprecationLogger.method('livechat:sendOfflineMessage', '7.0.0'); - - check(data, { - name: String, - email: String, - message: String, - }); - - await Livechat.sendOfflineMessage(data); - }, -}); - -DDPRateLimiter.addRule( - { - type: 'method', - name: 'livechat:sendOfflineMessage', - connectionId() { - return true; - }, - }, - 1, - 5000, -);