Skip to content

Commit

Permalink
fix: Managers allowed to make deactivated agent's available (#30303)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Aleman <11577696+KevLehman@users.noreply.github.com>
  • Loading branch information
murtaza98 and KevLehman committed Sep 7, 2023
1 parent 72347b6 commit cada29b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-bugs-jam.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Managers allowed to make deactivated agent's available
7 changes: 6 additions & 1 deletion apps/meteor/app/livechat/server/api/v1/agent.ts
Expand Up @@ -73,16 +73,21 @@ API.v1.addRoute(

const agentId = inputAgentId || this.userId;

const agent = await Users.findOneAgentById<Pick<ILivechatAgent, 'status' | 'statusLivechat'>>(agentId, {
const agent = await Users.findOneAgentById<Pick<ILivechatAgent, 'status' | 'statusLivechat' | 'active'>>(agentId, {
projection: {
status: 1,
statusLivechat: 1,
active: 1,
},
});
if (!agent) {
return API.v1.notFound('Agent not found');
}

if (!agent.active) {
return API.v1.failure('error-user-deactivated');
}

const newStatus: ILivechatAgentStatus =
status ||
(agent.statusLivechat === ILivechatAgentStatus.AVAILABLE ? ILivechatAgentStatus.NOT_AVAILABLE : ILivechatAgentStatus.AVAILABLE);
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Expand Up @@ -2073,6 +2073,7 @@
"error-too-many-requests": "Error, too many requests. Please slow down. You must wait {{seconds}} seconds before trying again.",
"error-transcript-already-requested": "Transcript already requested",
"error-unpinning-message": "Message could not be unpinned",
"error-user-deactivated": "User is not active",
"error-user-has-no-roles": "User has no roles",
"error-user-is-not-activated": "User is not activated",
"error-user-is-not-agent": "User is not an Omnichannel Agent",
Expand Down Expand Up @@ -6044,4 +6045,4 @@
"Filter_by_room": "Filter by room type",
"Filter_by_visibility": "Filter by visibility",
"Theme_Appearence": "Theme Appearence"
}
}

0 comments on commit cada29b

Please sign in to comment.