From 58f80ad889a44b3e0c5e65664454eba52db0c732 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 10 Oct 2024 01:11:25 +0530 Subject: [PATCH] chore!: remove deprecated livechat:saveSurveyFeedback method (#33443) --- .changeset/rude-dodos-agree.md | 5 ++ apps/meteor/app/livechat/server/index.ts | 1 - .../server/methods/saveSurveyFeedback.ts | 57 ------------------- 3 files changed, 5 insertions(+), 58 deletions(-) create mode 100644 .changeset/rude-dodos-agree.md delete mode 100644 apps/meteor/app/livechat/server/methods/saveSurveyFeedback.ts diff --git a/.changeset/rude-dodos-agree.md b/.changeset/rude-dodos-agree.md new file mode 100644 index 000000000000..cd8d737e7113 --- /dev/null +++ b/.changeset/rude-dodos-agree.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removed deprecated method `livechat:saveSurveyFeedback`. Moving forward use the endpoint `livechat/room.survey`. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index 38462ef56c84..e9ba895cbb92 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -42,7 +42,6 @@ import './methods/saveDepartment'; import './methods/saveDepartmentAgents'; import './methods/saveInfo'; import './methods/saveIntegration'; -import './methods/saveSurveyFeedback'; import './methods/saveTrigger'; import './methods/sendMessageLivechat'; import './methods/sendFileLivechatMessage'; diff --git a/apps/meteor/app/livechat/server/methods/saveSurveyFeedback.ts b/apps/meteor/app/livechat/server/methods/saveSurveyFeedback.ts deleted file mode 100644 index 36fc3f775b9f..000000000000 --- a/apps/meteor/app/livechat/server/methods/saveSurveyFeedback.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatRooms, LivechatVisitors } from '@rocket.chat/models'; -import { Match, check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; -import type { UpdateResult } from 'mongodb'; -import _ from 'underscore'; - -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:saveSurveyFeedback'( - visitorToken: string, - visitorRoom: string, - formData: { - name: 'satisfaction' | 'agentKnowledge' | 'agentResposiveness' | 'agentFriendliness' | 'additionalFeedback'; - value: '1' | '2' | '3' | '4' | '5'; - }[], - ): UpdateResult | undefined; - } -} - -Meteor.methods({ - async 'livechat:saveSurveyFeedback'(visitorToken, visitorRoom, formData) { - methodDeprecationLogger.method('livechat:saveSurveyFeedback', '7.0.0'); - - check(visitorToken, String); - check(visitorRoom, String); - check(formData, [Match.ObjectIncluding({ name: String, value: String })]); - - const visitor = (await LivechatVisitors.getVisitorByToken(visitorToken)) ?? undefined; - const room = (await LivechatRooms.findOneById(visitorRoom)) ?? undefined; - - if (visitor !== undefined && room !== undefined && room.v !== undefined && room.v.token === visitor.token) { - const updateData: Partial< - Record< - 'satisfaction' | 'agentKnowledge' | 'agentResposiveness' | 'agentFriendliness' | 'additionalFeedback', - '1' | '2' | '3' | '4' | '5' - > - > = {}; - for (const item of formData) { - if ( - ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness'].includes(item.name) && - ['1', '2', '3', '4', '5'].includes(item.value) - ) { - updateData[item.name] = item.value; - } else if (item.name === 'additionalFeedback') { - updateData[item.name] = item.value; - } - } - if (!_.isEmpty(updateData)) { - return LivechatRooms.updateSurveyFeedbackById(room._id, updateData); - } - } - }, -});