Skip to content

Commit 6250fd7

Browse files
chore: remove deprecated methods for 8.0 (#6852)
* feat: mark methods to change * chore: deprecate methods * feat: finished deprecated methods * chore: code improvements * fix: lint * fix: type * chore: code improvements * chore: code improvements * code improvements * remove logs * code improvements
1 parent 7215cda commit 6250fd7

File tree

8 files changed

+71
-21
lines changed

8 files changed

+71
-21
lines changed

app/definitions/rest/v1/omnichannel.ts

Lines changed: 21 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;
@@ -122,6 +135,14 @@ export type OmnichannelEndpoints = {
122135
}>;
123136
};
124137

138+
'livechat/inquiries.take': {
139+
POST: (params: { inquiryId: string }) => void;
140+
};
141+
142+
'livechat/inquiries.returnAsInquiry': {
143+
POST: (params: { roomId: string; departmentId?: string }) => boolean;
144+
};
145+
125146
'livechat/rooms': {
126147
GET: (params: {
127148
guest: string;

app/definitions/rest/v1/rooms.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ 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+
success: boolean;
50+
};
51+
};
52+
'rooms.unmuteUser': {
53+
POST: (params: { rid: string; userId: string }) => {
54+
success: boolean;
55+
};
56+
};
4757
};
4858

4959
export type TRoomsMediaResponse = {

app/ee/omnichannel/lib/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ export const getInquiriesQueued = (serverVersion: string) => {
2020
// this inquiry is added to the db by the subscriptions stream
2121
// and will be removed by the queue stream
2222
// RC 2.4.0
23-
export const takeInquiry = (inquiryId: string) => sdk.methodCallWrapper('livechat:takeInquiry', inquiryId);
23+
export const takeInquiry = (inquiryId: string, serverVersion: string) => {
24+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
25+
return sdk.post('livechat/inquiries.take', { inquiryId });
26+
}
27+
// Method removed in 8.0.0
28+
return sdk.methodCallWrapper('livechat:takeInquiry', inquiryId);
29+
};
2430

2531
// RC 4.26
2632
export const takeResume = (roomId: string) => sdk.methodCallWrapper('livechat:resumeOnHold', roomId);

app/lib/services/restApi.ts

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

433-
export const returnLivechat = (rid: string): Promise<boolean> =>
433+
export const returnLivechat = (rid: string, departmentId?: string): Promise<any> => {
434+
const serverVersion = reduxStore.getState().server.version;
435+
436+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.12.0')) {
437+
return sdk.post('livechat/inquiries.returnAsInquiry', { roomId: rid, departmentId });
438+
}
439+
434440
// RC 0.72.0
435-
sdk.methodCallWrapper('livechat:returnAsInquiry', rid);
441+
return sdk.methodCallWrapper('livechat:returnAsInquiry', rid);
442+
};
436443

437444
export const onHoldLivechat = (roomId: string) => sdk.post('livechat/room.onHold', { roomId });
438445

@@ -461,17 +468,26 @@ export const usersAutoComplete = (selector: any) =>
461468
// RC 2.4.0
462469
sdk.get('users.autocomplete', { selector });
463470

464-
export const getRoutingConfig = (): Promise<{
471+
export const getRoutingConfig = async (): Promise<{
465472
previewRoom: boolean;
466473
showConnecting: boolean;
467474
showQueue: boolean;
468475
showQueueLink: boolean;
469476
returnQueue: boolean;
470477
enableTriggerAction: boolean;
471478
autoAssignAgent: boolean;
472-
}> =>
479+
}> => {
480+
const serverVersion = reduxStore.getState().server.version;
481+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
482+
const result = await sdk.get('livechat/config/routing');
483+
if (result.success) {
484+
return result.config;
485+
}
486+
}
487+
473488
// RC 2.0.0
474-
sdk.methodCallWrapper('livechat:getRoutingConfig');
489+
return sdk.methodCallWrapper('livechat:getRoutingConfig');
490+
};
475491

476492
export const getTagsList = (): Promise<ILivechatTag[]> =>
477493
// RC 2.0.0
@@ -515,17 +531,13 @@ export const deleteRoom = (roomId: string, t: RoomTypes) =>
515531
// RC 0.49.0
516532
sdk.post(`${roomTypeToApiType(t)}.delete`, { roomId });
517533

518-
export const toggleMuteUserInRoom = (
519-
rid: string,
520-
username: string,
521-
mute: boolean
522-
): Promise<{ message: { msg: string; result: boolean }; success: boolean }> => {
523-
if (mute) {
524-
// RC 0.51.0
525-
return sdk.methodCallWrapper('muteUserInRoom', { rid, username });
534+
export const toggleMuteUserInRoom = (rid: string, username: string, userId: string, mute: boolean) => {
535+
const serverVersion = reduxStore.getState().server.version;
536+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) {
537+
return sdk.post(mute ? 'rooms.muteUser' : 'rooms.unmuteUser', { roomId: rid, userId });
526538
}
527539
// RC 0.51.0
528-
return sdk.methodCallWrapper('unmuteUserInRoom', { rid, username });
540+
return sdk.methodCallWrapper(mute ? 'muteUserInRoom' : 'unmuteUserInRoom', { rid, username });
529541
};
530542

531543
export const toggleRoomOwner = ({

app/views/RoomActionsView/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,14 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
447447

448448
handleReturnLivechat = () => {
449449
const {
450-
room: { rid }
450+
room: { rid, departmentId }
451451
} = this.state;
452452
showConfirmationAlert({
453453
message: I18n.t('Would_you_like_to_return_the_inquiry'),
454454
confirmationText: I18n.t('Yes'),
455455
onPress: async () => {
456456
try {
457-
await returnLivechat(rid);
457+
await returnLivechat(rid, departmentId);
458458
} catch (e: any) {
459459
showErrorAlert(e.reason, I18n.t('Oops'));
460460
}

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
});

app/views/RoomView/RightButtons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
232232
};
233233

234234
returnLivechat = () => {
235-
const { rid } = this.props;
235+
const { rid, departmentId } = this.props;
236236
if (rid) {
237237
showConfirmationAlert({
238238
message: i18n.t('Would_you_like_to_return_the_inquiry'),
239239
confirmationText: i18n.t('Yes'),
240240
onPress: async () => {
241241
try {
242-
await returnLivechat(rid);
242+
await returnLivechat(rid, departmentId);
243243
} catch (e: any) {
244244
showErrorAlert(e.reason, i18n.t('Oops'));
245245
}

app/views/RoomView/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,11 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
10881088
logEvent(events.ROOM_JOIN);
10891089
try {
10901090
const { room } = this.state;
1091+
const { serverVersion } = this.props;
10911092

10921093
if (this.isOmnichannel) {
10931094
if ('_id' in room) {
1094-
await takeInquiry(room._id);
1095+
await takeInquiry(room._id, serverVersion as string);
10951096
}
10961097
this.onJoin();
10971098
} else {

0 commit comments

Comments
 (0)