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] Chat Transfer Failure due to Unrecognized stage name departmentId #22838

Closed

Conversation

Shailesh351
Copy link
Contributor

Proposed changes (including videos or screenshots)

This PR fixes typo in the collection name and modifies aggregator query to pass the customFilter properly

Issue(s)

https://open.rocket.chat/channel/omnichannel/thread/sxL6dbZBDoAoYJDqN

Because of extraQuery(customFilter) is being passed as a stage in aggregator here, It is giving MongoError: Unrecognized pipeline stage name: 'departmentId'

Steps to test or reproduce

Call modify.getUpdater().getLivechatUpdater().transferVisitor from RC App

Further comments

@@ -273,7 +273,7 @@ export class Users extends Base {
},
},
},
...customFilter ? [customFilter] : [],
...customFilter ? [{ $match: customFilter }] : [],
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this was required? TBH, I don't think this is required because customFilters are getting defined by this callback and as you can see here and here both these return values apply a $match filter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I logged what we are receiving in this function, It was showing {departmentId: 'string'}.

FYI I don't have enterprise edition, so /ee/app/livechat-enterprise/server/hooks/applySimultaneousChatsRestrictions.ts hook won't be called.

Maybe the issue is only with a non-enterprise server?

Copy link
Contributor

@murtaza98 murtaza98 Aug 3, 2021

Choose a reason for hiding this comment

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

Okay got it. I found out that this was happening because livechat.applySimultaneousChatRestrictions callback was simply returning the first param passed to it incase the callback was not found, which happens in the community edition.

So I think the correct way to use this callback was to pass the params/constants in the second param and keep the first param empty/default.

PS: I took the liberty of raising a PR for the same #22839

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @murtaza98 🙃

@Shailesh351
Copy link
Contributor Author

Closing in favor of #22839

@Shailesh351 Shailesh351 closed this Aug 3, 2021
@sampaiodiego sampaiodiego mentioned this pull request Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants