Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: customFields ignored in livechat room creation #33047

Merged
merged 9 commits into from
Aug 19, 2024

Conversation

abhinavkrin
Copy link
Member

@abhinavkrin abhinavkrin commented Aug 14, 2024

Proposed changes (including videos or screenshots)

The function createLivechatRoom does not take into account the customFields passed in the extraData param

export const createLivechatRoom = async <

In various places the functions is passed customFields in extraData param. This extraData is passed to livechat.beforeRoom callback and expects to receive extraRoomInfo. But the customField is not taken into account in this callback

const extraRoomInfo = await callbacks.run('livechat.beforeRoom', roomInfo, extraData);

callbacks.add(
'livechat.beforeRoom',
async (roomInfo, extraData) => {
if (!extraData) {
return roomInfo;
}
const { sla: searchTerm, customFields } = extraData;
const roomInfoWithExtraData = { ...roomInfo, ...(!!customFields && { customFields }) };
if (!searchTerm) {
return roomInfoWithExtraData;
}
const sla = await OmnichannelServiceLevelAgreements.findOneByIdOrName(searchTerm);
if (!sla) {
throw new Meteor.Error('error-invalid-sla', 'Invalid sla', {
function: 'livechat.beforeRoom',
});
}
const { _id: slaId } = sla;
return { ...roomInfoWithExtraData, slaId };
},

This PR fixes the callback to also include the customFields in the result from the callback livechat.beforeRoom

I found this bug while investigating the issue related to on premise whatsapp app. In which, a new room was created everytime a message was sent from WA to RC. Since the custom fields was not being saved in the room data (due to the reason above), the wa app was not able to find existing room related to what whatsapp number and created a new room everytime.

I believe this bug can affect other apps as well as the rc where function is used.

Issue(s)

Steps to test or reproduce

Further comments

CORE-643

Copy link
Contributor

dionisio-bot bot commented Aug 14, 2024

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Aug 14, 2024

🦋 Changeset detected

Latest commit: 9d27458

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/api-client Patch
@rocket.chat/ddp-client Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.40%. Comparing base (a40541b) to head (9d27458).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #33047   +/-   ##
========================================
  Coverage    59.39%   59.40%           
========================================
  Files         2541     2543    +2     
  Lines        63174    63192   +18     
  Branches     14219    14224    +5     
========================================
+ Hits         37525    37541   +16     
- Misses       22934    22935    +1     
- Partials      2715     2716    +1     
Flag Coverage Δ
unit 76.03% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Signed-off-by: Abhinav Kumar <[email protected]>
ricardogarim
ricardogarim previously approved these changes Aug 14, 2024
@abhinavkrin abhinavkrin marked this pull request as ready for review August 14, 2024 16:05
@abhinavkrin abhinavkrin requested a review from a team as a code owner August 14, 2024 16:05
Copy link
Member

@ggazzo ggazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we provide some kind of tests here?

Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
@abhinavkrin abhinavkrin added this to the 6.12 milestone Aug 16, 2024
Signed-off-by: Abhinav Kumar <[email protected]>
@KevLehman
Copy link
Contributor

@abhinavkrin just one small thing: this PR should have its own task related to 589 instead of being linked directly to it as this fix will require it's own QA (and it's not related to the issue described on 589)

@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Aug 19, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 19, 2024
@kodiakhq kodiakhq bot merged commit 7e2facc into develop Aug 19, 2024
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/customFields-ignored-in-livechat-room-creation branch August 19, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants