Skip to content

Commit

Permalink
Merge branch 'develop' into fix/sidebar-item-template-props
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 7, 2024
2 parents c21bb8a + 322bafd commit 40a371a
Show file tree
Hide file tree
Showing 41 changed files with 322 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-terms-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes the issue where newly created teams are incorrectly displayed as channels on the sidebar when the DISABLE_DB_WATCHERS environment variable is enabled
5 changes: 5 additions & 0 deletions .changeset/old-coins-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/apps-engine': patch
---

Fixes an issue that would cause apps to appear disabled after a subprocess restart
5 changes: 5 additions & 0 deletions .changeset/serious-mice-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes client-side updates for recent emoji list when custom emojis are modified.
5 changes: 5 additions & 0 deletions .changeset/stale-actors-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes `waiting queue` feature. When `Livechat_waiting_queue` setting is enabled, incoming conversations should be sent to the queue instead of being assigned directly.
6 changes: 6 additions & 0 deletions .changeset/unlucky-kangaroos-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/i18n": patch
---

Updates VoIP field labels from 'Free Extension Numbers' to 'Available Extensions' to better describe the field's purpose and improve clarity.
9 changes: 6 additions & 3 deletions apps/meteor/app/emoji-custom/client/lib/emojiCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';

import { emoji, updateRecent } from '../../../emoji/client';
import { emoji, removeFromRecent, replaceEmojiInRecent } from '../../../emoji/client';
import { CachedCollectionManager } from '../../../ui-cached-collection/client';
import { getURL } from '../../../utils/client';
import { sdk } from '../../../utils/client/lib/SDKClient';
Expand Down Expand Up @@ -49,7 +49,8 @@ export const deleteEmojiCustom = (emojiData: IEmoji) => {
}
}
}
updateRecent(['rocket']);

removeFromRecent(emojiData.name, emoji.packages.base.emojisByCategory.recent);
};

export const updateEmojiCustom = (emojiData: IEmoji) => {
Expand Down Expand Up @@ -94,7 +95,9 @@ export const updateEmojiCustom = (emojiData: IEmoji) => {
}
}

updateRecent(['rocket']);
if (previousExists) {
replaceEmojiInRecent({ oldEmoji: emojiData.previousName, newEmoji: emojiData.name });
}
};

const customRender = (html: string) => {
Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/app/emoji/client/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ export const getEmojisBySearchTerm = (
return emojis;
};

export const removeFromRecent = (emoji: string, recentEmojis: string[], setRecentEmojis: (emojis: string[]) => void) => {
export const removeFromRecent = (emoji: string, recentEmojis: string[], setRecentEmojis?: (emojis: string[]) => void) => {
const _emoji = emoji.replace(/(^:|:$)/g, '');
const pos = recentEmojis.indexOf(_emoji as never);

if (pos === -1) {
return;
}
recentEmojis.splice(pos, 1);
setRecentEmojis(recentEmojis);
setRecentEmojis?.(recentEmojis);
};

export const updateRecent = (recentList: string[]) => {
Expand All @@ -156,6 +156,15 @@ export const updateRecent = (recentList: string[]) => {
});
};

export const replaceEmojiInRecent = ({ oldEmoji, newEmoji }: { oldEmoji: string; newEmoji: string }) => {
const recentPkgList: string[] = emoji.packages.base.emojisByCategory.recent;
const pos = recentPkgList.indexOf(oldEmoji);

if (pos !== -1) {
recentPkgList[pos] = newEmoji;
}
};

const getEmojiRender = (emojiName: string) => {
const emojiPackageName = emoji.list[emojiName]?.emojiPackage;
const emojiPackage = emoji.packages[emojiPackageName];
Expand Down
18 changes: 15 additions & 3 deletions apps/meteor/app/livechat/server/lib/QueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ export class QueueManager {

const inquiryAgent = await RoutingManager.delegateAgent(defaultAgent, inquiry);
logger.debug(`Delegating inquiry with id ${inquiry._id} to agent ${defaultAgent?.username}`);
await callbacks.run('livechat.beforeRouteChat', inquiry, inquiryAgent);
const dbInquiry = await LivechatInquiry.findOneById(inquiry._id);
const dbInquiry = await callbacks.run('livechat.beforeRouteChat', inquiry, inquiryAgent);

if (!dbInquiry) {
throw new Error('inquiry-not-found');
Expand All @@ -122,6 +121,10 @@ export class QueueManager {
return LivechatInquiryStatus.QUEUED;
}

if (settings.get('Livechat_waiting_queue')) {
return LivechatInquiryStatus.QUEUED;
}

if (RoutingManager.getConfig()?.autoAssignAgent) {
return LivechatInquiryStatus.READY;
}
Expand All @@ -135,6 +138,7 @@ export class QueueManager {

static async queueInquiry(inquiry: ILivechatInquiryRecord, room: IOmnichannelRoom, defaultAgent?: SelectedAgent | null) {
if (inquiry.status === 'ready') {
logger.debug({ msg: 'Inquiry is ready. Delegating', inquiry, defaultAgent });
return RoutingManager.delegateInquiry(inquiry, defaultAgent, undefined, room);
}

Expand Down Expand Up @@ -252,7 +256,11 @@ export class QueueManager {
throw new Error('room-not-found');
}

if (!newRoom.servedBy && settings.get('Omnichannel_calculate_dispatch_service_queue_statistics')) {
if (
!newRoom.servedBy &&
settings.get('Livechat_waiting_queue') &&
settings.get('Omnichannel_calculate_dispatch_service_queue_statistics')
) {
const [inq] = await LivechatInquiry.getCurrentSortedQueueAsync({
inquiryId: inquiry._id,
department,
Expand Down Expand Up @@ -320,6 +328,10 @@ export class QueueManager {
}

private static dispatchInquiryQueued = async (inquiry: ILivechatInquiryRecord, room: IOmnichannelRoom, agent?: SelectedAgent | null) => {
if (RoutingManager.getConfig()?.autoAssignAgent) {
return;
}

logger.debug(`Notifying agents of new inquiry ${inquiry._id} queued`);

const { department, rid, v } = inquiry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const AssignAgentModal = ({ existingExtension, closeModal, reload }: AssignAgent
</FieldRow>
</Field>
<Field>
<FieldLabel>{t('Free_Extension_Numbers')}</FieldLabel>
<FieldLabel>{t('Available_extensions')}</FieldLabel>
<FieldRow>
<Select
disabled={state === AsyncStatePhase.LOADING || agent === ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ it.todo('should load with default user');

it.todo('should load with default extension');

it('should only enable "Free Extension Numbers" field if username is informed', async () => {
it('should only enable "Available extensions" field if username is informed', async () => {
render(<AssignExtensionModal onClose={() => undefined} />, {
legacyRoot: true,
wrapper: appRoot.build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const AssignExtensionModal = ({ defaultExtension, defaultUsername, onClose }: As
</Field>

<Field>
<FieldLabel htmlFor={freeExtensionNumberId}>{t('Free_Extension_Numbers')}</FieldLabel>
<FieldLabel htmlFor={freeExtensionNumberId}>{t('Available_extensions')}</FieldLabel>
<FieldRow>
<Controller
control={control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ callbacks.add(
}

await saveQueueInquiry(inquiry);

return LivechatInquiry.findOneById(inquiry._id);
},
callbacks.priority.HIGH,
'livechat-before-routing-chat',
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/server/services/team/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { addUserToRoom } from '../../../app/lib/server/functions/addUserToRoom';
import { checkUsernameAvailability } from '../../../app/lib/server/functions/checkUsernameAvailability';
import { getSubscribedRoomsForUserWithDetails } from '../../../app/lib/server/functions/getRoomsWithSingleOwner';
import { removeUserFromRoom } from '../../../app/lib/server/functions/removeUserFromRoom';
import { notifyOnSubscriptionChangedByRoomIdAndUserId } from '../../../app/lib/server/lib/notifyListener';
import { notifyOnSubscriptionChangedByRoomIdAndUserId, notifyOnRoomChangedById } from '../../../app/lib/server/lib/notifyListener';
import { settings } from '../../../app/settings/server';

export class TeamService extends ServiceClassInternal implements ITeamService {
Expand Down Expand Up @@ -131,6 +131,8 @@ export class TeamService extends ServiceClassInternal implements ITeamService {
await Message.saveSystemMessage('user-converted-to-team', roomId, team.name, createdBy);
}

void notifyOnRoomChangedById(roomId, 'inserted');

return {
_id: teamId,
...teamData,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/startup/serverRunning.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Meteor.startup(async () => {
}

if (semver.satisfies(semver.coerce(mongoVersion), '<5.0.0')) {
msg += ['', '', 'YOUR CURRENT MONGODB VERSION IS NOT SUPPORTED,', 'PLEASE UPGRADE TO VERSION 5.0 OR LATER'].join('\n');
msg += ['', '', 'YOUR CURRENT MONGODB VERSION IS NOT SUPPORTED BY ROCKET.CHAT,', 'PLEASE UPGRADE TO VERSION 5.0 OR LATER'].join('\n');
showErrorBox('SERVER ERROR', msg);

exitIfNotBypassed(process.env.BYPASS_MONGO_VALIDATION);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { createFakeVisitor } from '../../mocks/data';
import { IS_EE } from '../config/constants';
import { createAuxContext } from '../fixtures/createAuxContext';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects';
import { test, expect } from '../utils/test';

const firstVisitor = createFakeVisitor();

const secondVisitor = createFakeVisitor();

test.use({ storageState: Users.user1.state });

test.describe('OC - Livechat - Queue Management', () => {
test.skip(!IS_EE, 'Enterprise Only');

let poHomeOmnichannel: HomeOmnichannel;
let poLiveChat: OmnichannelLiveChat;

const waitingQueueMessage = 'This is a message from Waiting Queue';

test.beforeAll(async ({ api, browser }) => {
await Promise.all([
api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }),
api.post('/settings/Livechat_accept_chats_with_no_agents', { value: true }),
api.post('/settings/Livechat_waiting_queue', { value: true }),
api.post('/settings/Livechat_waiting_queue_message', { value: waitingQueueMessage }),
api.post('/livechat/users/agent', { username: 'user1' }),
]);

const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true);
poHomeOmnichannel = new HomeOmnichannel(omniPage);

// Agent will be offline for these tests
await poHomeOmnichannel.sidenav.switchOmnichannelStatus('offline');
});

test.beforeEach(async ({ browser, api }) => {
const context = await browser.newContext();
const page2 = await context.newPage();

poLiveChat = new OmnichannelLiveChat(page2, api);
await poLiveChat.page.goto('/livechat');
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.post('/settings/Livechat_waiting_queue', { value: false }),
api.post('/settings/Livechat_waiting_queue_message', { value: '' }),
api.delete('/livechat/users/agent/user1'),
]);
await poHomeOmnichannel.page.close();
});

test.describe('OC - Queue Management - Auto Selection', () => {
let poLiveChat2: OmnichannelLiveChat;

test.beforeEach(async ({ browser, api }) => {
const context = await browser.newContext();
const page = await context.newPage();
poLiveChat2 = new OmnichannelLiveChat(page, api);
await poLiveChat2.page.goto('/livechat');
});

test.afterEach(async () => {
await poLiveChat2.closeChat();
await poLiveChat2.page.close();
await poLiveChat.closeChat();
await poLiveChat.page.close();
});

test('Update user position on Queue', async () => {
await test.step('should start livechat session', async () => {
await poLiveChat.openAnyLiveChatAndSendMessage({
liveChatUser: firstVisitor,
message: 'Test message',
isOffline: false,
});
});

await test.step('expect to receive Waiting Queue message on chat', async () => {
await expect(poLiveChat.page.locator(`div >> text=${waitingQueueMessage}`)).toBeVisible();
});

await test.step('expect to be on spot #1', async () => {
await expect(poLiveChat.queuePosition(1)).toBeVisible();
});

await test.step('should start secondary livechat session', async () => {
await poLiveChat2.openAnyLiveChatAndSendMessage({
liveChatUser: secondVisitor,
message: 'Test message',
isOffline: false,
});
});

await test.step('should start secondary livechat on spot #2', async () => {
await expect(poLiveChat2.queuePosition(2)).toBeVisible();
});

await test.step('should start the queue by making the agent available again', async () => {
await poHomeOmnichannel.sidenav.switchOmnichannelStatus('online');
});

await test.step('user1 should get assigned to the first chat', async () => {
await expect(poLiveChat.queuePosition(1)).not.toBeVisible();
});

await test.step('secondary session should be on position #1', async () => {
await expect(poLiveChat2.queuePosition(1)).toBeVisible();
});

await test.step('secondary session should be taken by user1', async () => {
await expect(poLiveChat2.queuePosition(1)).not.toBeVisible();
});
});
});
});
4 changes: 4 additions & 0 deletions apps/meteor/tests/e2e/page-objects/omnichannel-livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,8 @@ export class OmnichannelLiveChat {

await this.fileUploadTarget.dispatchEvent('drop', { dataTransfer });
}

queuePosition(position: number): Locator {
return this.page.locator(`div[role='alert'] >> text=Your spot is #${position}`);
}
}
Loading

0 comments on commit 40a371a

Please sign in to comment.