-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: Adds deprecation warning on livechat:takeInquiry
#36993
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a4c200f
chore: adds deprecation warning to livechat:takeInquiry
lucas-a-pelegrino a00d88f
chore: move takeInquiry func to a single file under lib/
lucas-a-pelegrino 29d85d2
chore: updates endpoint params to expect options
lucas-a-pelegrino daa8e61
chore: replaces use of livechat:takeInquiry for livechat/inquiries.ta…
lucas-a-pelegrino 3108bea
docs: adds changeset
lucas-a-pelegrino 7b03fe5
fix: lint import paths
lucas-a-pelegrino 4793ef8
fix: lint import paths
lucas-a-pelegrino d31d655
Merge remote-tracking branch 'origin/chore/v7/CTZ-70' into chore/v7/C…
lucas-a-pelegrino e852e69
chore: adds minor improvements to takeInquiry
lucas-a-pelegrino b9db48f
chore: removed double space
lucas-a-pelegrino ae822fe
Merge branch 'develop' into chore/v7/CTZ-70
kodiakhq[bot] adb17a6
Merge branch 'develop' into chore/v7/CTZ-70
kodiakhq[bot] d910c57
Merge branch 'develop' into chore/v7/CTZ-70
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@rocket.chat/meteor": patch | ||
| "@rocket.chat/rest-typings": patch | ||
| --- | ||
|
|
||
| Adds deprecation warning on `livechat:removeRoom`, use `livechat/inquiries.take` instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { Omnichannel } from '@rocket.chat/core-services'; | ||
| import { LivechatInquiry, LivechatRooms, Users } from '@rocket.chat/models'; | ||
| import { Meteor } from 'meteor/meteor'; | ||
|
|
||
| import { RoutingManager } from './RoutingManager'; | ||
| import { isAgentAvailableToTakeContactInquiry } from './contacts/isAgentAvailableToTakeContactInquiry'; | ||
| import { migrateVisitorIfMissingContact } from './contacts/migrateVisitorIfMissingContact'; | ||
| import { settings } from '../../../settings/server'; | ||
|
|
||
| export const takeInquiry = async ( | ||
| userId: string, | ||
| inquiryId: string, | ||
| options?: { clientAction: boolean; forwardingToDepartment?: { oldDepartmentId: string; transferData: any } }, | ||
| ): Promise<void> => { | ||
| const inquiry = await LivechatInquiry.findOneById(inquiryId); | ||
|
|
||
| if (!inquiry) { | ||
| throw new Meteor.Error('error-not-found', 'Inquiry not found', { | ||
| method: 'livechat:takeInquiry', | ||
| }); | ||
| } | ||
|
|
||
| if (inquiry.status === 'taken') { | ||
| throw new Meteor.Error('error-inquiry-taken', 'Inquiry already taken', { | ||
| method: 'livechat:takeInquiry', | ||
| }); | ||
| } | ||
|
|
||
| const user = await Users.findOneOnlineAgentById(userId, settings.get<boolean>('Livechat_enabled_when_agent_idle')); | ||
| if (!user) { | ||
| throw new Meteor.Error('error-agent-status-service-offline', 'Agent status is offline or Omnichannel service is not active', { | ||
| method: 'livechat:takeInquiry', | ||
| }); | ||
| } | ||
|
|
||
| const room = await LivechatRooms.findOneById(inquiry.rid); | ||
| if (!room || !(await Omnichannel.isWithinMACLimit(room))) { | ||
| throw new Meteor.Error('error-mac-limit-reached'); | ||
| } | ||
|
|
||
| const contactId = room.contactId ?? (await migrateVisitorIfMissingContact(room.v._id, room.source)); | ||
| if (contactId) { | ||
| const isAgentAvailableToTakeContactInquiryResult = await isAgentAvailableToTakeContactInquiry(inquiry.v._id, room.source, contactId); | ||
| if (!isAgentAvailableToTakeContactInquiryResult.value) { | ||
| throw new Meteor.Error(isAgentAvailableToTakeContactInquiryResult.error); | ||
| } | ||
| } | ||
|
|
||
| const agent = { | ||
| agentId: user._id, | ||
| username: user.username, | ||
| }; | ||
|
|
||
| try { | ||
| await RoutingManager.takeInquiry(inquiry, agent, options ?? {}, room); | ||
| } catch (e: any) { | ||
| throw new Meteor.Error(e.message); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.