Skip to content

Commit b58e3fd

Browse files
committed
feat: finished deprecated methods
1 parent adf100f commit b58e3fd

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

app/definitions/rest/v1/omnichannel.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ export type OmnichannelEndpoints = {
1919
appearance: ISetting[];
2020
};
2121
};
22+
'livechat/config/routing': {
23+
GET: () => {
24+
config: {
25+
previewRoom: boolean;
26+
showConnecting: boolean;
27+
showQueue: boolean;
28+
showQueueLink: boolean;
29+
returnQueue: boolean;
30+
enableTriggerAction: boolean;
31+
autoAssignAgent: boolean;
32+
};
33+
};
34+
};
2235
'livechat/visitors.info': {
2336
GET: (params: { visitorId: string }) => {
2437
visitor: ILivechatVisitor;

app/definitions/rest/v1/rooms.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ export type RoomsEndpoints = {
4444
'rooms.saveNotification': {
4545
POST: (params: { roomId: string; notifications: IRoomNotifications }) => {};
4646
};
47+
'rooms.muteUser': {
48+
POST: (params: { roomId: string; userId: string }) => {
49+
message: { msg: string; result: boolean };
50+
success: boolean;
51+
};
52+
};
53+
'rooms.unmuteUser': {
54+
POST: (params: { rid: string; userId: string }) => {
55+
message: { msg: string; result: boolean };
56+
success: boolean;
57+
};
58+
};
4759
};
4860

4961
export type TRoomsMediaResponse = {

app/lib/services/restApi.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ export const editLivechat = (userData: TParams, roomData: TParams): Promise<{ er
430430
return sdk.post('livechat/room.saveInfo', { guestData: userData, roomData }) as any;
431431
};
432432

433-
// change it
434433
export const returnLivechat = (rid: string, departmentId?: string): Promise<any> => {
435434
const serverVersion = reduxStore.getState().server.version;
436435

@@ -467,18 +466,26 @@ export const usersAutoComplete = (selector: any) =>
467466
// RC 2.4.0
468467
sdk.get('users.autocomplete', { selector });
469468

470-
// change it
471-
export const getRoutingConfig = (): Promise<{
469+
export const getRoutingConfig = async (): Promise<{
472470
previewRoom: boolean;
473471
showConnecting: boolean;
474472
showQueue: boolean;
475473
showQueueLink: boolean;
476474
returnQueue: boolean;
477475
enableTriggerAction: boolean;
478476
autoAssignAgent: boolean;
479-
}> =>
477+
}> => {
478+
const serverVersion = reduxStore.getState().server.version;
479+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
480+
const result = await sdk.get('livechat/config/routing');
481+
if (result.success) {
482+
return result.config;
483+
}
484+
}
485+
480486
// RC 2.0.0
481-
sdk.methodCallWrapper('livechat:getRoutingConfig');
487+
return sdk.methodCallWrapper('livechat:getRoutingConfig');
488+
};
482489

483490
export const getTagsList = (): Promise<ILivechatTag[]> =>
484491
// RC 2.0.0
@@ -522,12 +529,27 @@ export const deleteRoom = (roomId: string, t: RoomTypes) =>
522529
// RC 0.49.0
523530
sdk.post(`${roomTypeToApiType(t)}.delete`, { roomId });
524531

525-
// change it
526532
export const toggleMuteUserInRoom = (
527533
rid: string,
528534
username: string,
535+
userId: string,
529536
mute: boolean
530537
): Promise<{ message: { msg: string; result: boolean }; success: boolean }> => {
538+
const serverVersion = reduxStore.getState().server.version;
539+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) {
540+
if (mute) {
541+
return sdk.post('rooms.muteUser', { roomId: rid, userId }) as Promise<{
542+
message: { msg: string; result: boolean };
543+
success: boolean;
544+
}>;
545+
}
546+
547+
return sdk.post('rooms.unmuteUser', { rid, userId }) as Promise<{
548+
message: { msg: string; result: boolean };
549+
success: boolean;
550+
}>;
551+
}
552+
531553
if (mute) {
532554
// RC 0.51.0
533555
return sdk.methodCallWrapper('muteUserInRoom', { rid, username });
@@ -666,7 +688,6 @@ export const getSingleMessage = (msgId: string) =>
666688
// RC 0.47.0
667689
sdk.get('chat.getMessage', { msgId });
668690

669-
// change it
670691
export const getRoomRoles = (
671692
roomId: string,
672693
type: SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL

app/views/RoomMembersView/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const fetchRoomMembersRoles = async (roomType: TRoomType, rid: string, up
4949

5050
export const handleMute = async (user: TUserModel, rid: string) => {
5151
try {
52-
await toggleMuteUserInRoom(rid, user?.username, !user.muted);
52+
await toggleMuteUserInRoom(rid, user?.username, user.id, !user.muted);
5353
EventEmitter.emit(LISTENER, {
5454
message: I18n.t('User_has_been_key', { key: user?.muted ? I18n.t('unmuted') : I18n.t('muted') })
5555
});

0 commit comments

Comments
 (0)