Skip to content
21 changes: 21 additions & 0 deletions app/definitions/rest/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ export type OmnichannelEndpoints = {
appearance: ISetting[];
};
};
'livechat/config/routing': {
GET: () => {
config: {
previewRoom: boolean;
showConnecting: boolean;
showQueue: boolean;
showQueueLink: boolean;
returnQueue: boolean;
enableTriggerAction: boolean;
autoAssignAgent: boolean;
};
};
};
'livechat/visitors.info': {
GET: (params: { visitorId: string }) => {
visitor: ILivechatVisitor;
Expand Down Expand Up @@ -122,6 +135,14 @@ export type OmnichannelEndpoints = {
}>;
};

'livechat/inquiries.take': {
POST: (params: { inquiryId: string }) => void;
};

'livechat/inquiries.returnAsInquiry': {
POST: (params: { roomId: string; departmentId?: string }) => boolean;
};

'livechat/rooms': {
GET: (params: {
guest: string;
Expand Down
10 changes: 10 additions & 0 deletions app/definitions/rest/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export type RoomsEndpoints = {
'rooms.saveNotification': {
POST: (params: { roomId: string; notifications: IRoomNotifications }) => {};
};
'rooms.muteUser': {
POST: (params: { roomId: string; userId: string }) => {
success: boolean;
};
};
'rooms.unmuteUser': {
POST: (params: { rid: string; userId: string }) => {
success: boolean;
};
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};

export type TRoomsMediaResponse = {
Expand Down
8 changes: 7 additions & 1 deletion app/ee/omnichannel/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export const getInquiriesQueued = (serverVersion: string) => {
// this inquiry is added to the db by the subscriptions stream
// and will be removed by the queue stream
// RC 2.4.0
export const takeInquiry = (inquiryId: string) => sdk.methodCallWrapper('livechat:takeInquiry', inquiryId);
export const takeInquiry = (inquiryId: string, serverVersion: string) => {
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
return sdk.post('livechat/inquiries.take', { inquiryId });
}
// Method removed in 8.0.0
return sdk.methodCallWrapper('livechat:takeInquiry', inquiryId);
};

// RC 4.26
export const takeResume = (roomId: string) => sdk.methodCallWrapper('livechat:resumeOnHold', roomId);
Expand Down
40 changes: 26 additions & 14 deletions app/lib/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,16 @@ export const editLivechat = (userData: TParams, roomData: TParams): Promise<{ er
return sdk.post('livechat/room.saveInfo', { guestData: userData, roomData }) as any;
};

export const returnLivechat = (rid: string): Promise<boolean> =>
export const returnLivechat = (rid: string, departmentId?: string): Promise<any> => {
const serverVersion = reduxStore.getState().server.version;

if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.12.0')) {
return sdk.post('livechat/inquiries.returnAsInquiry', { roomId: rid, departmentId });
}

// RC 0.72.0
sdk.methodCallWrapper('livechat:returnAsInquiry', rid);
return sdk.methodCallWrapper('livechat:returnAsInquiry', rid);
};

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

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

export const getRoutingConfig = (): Promise<{
export const getRoutingConfig = async (): Promise<{
previewRoom: boolean;
showConnecting: boolean;
showQueue: boolean;
showQueueLink: boolean;
returnQueue: boolean;
enableTriggerAction: boolean;
autoAssignAgent: boolean;
}> =>
}> => {
const serverVersion = reduxStore.getState().server.version;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.11.0')) {
const result = await sdk.get('livechat/config/routing');
if (result.success) {
return result.config;
}
}

// RC 2.0.0
sdk.methodCallWrapper('livechat:getRoutingConfig');
return sdk.methodCallWrapper('livechat:getRoutingConfig');
};

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

export const toggleMuteUserInRoom = (
rid: string,
username: string,
mute: boolean
): Promise<{ message: { msg: string; result: boolean }; success: boolean }> => {
if (mute) {
// RC 0.51.0
return sdk.methodCallWrapper('muteUserInRoom', { rid, username });
export const toggleMuteUserInRoom = (rid: string, username: string, userId: string, mute: boolean) => {
const serverVersion = reduxStore.getState().server.version;
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) {
return sdk.post(mute ? 'rooms.muteUser' : 'rooms.unmuteUser', { roomId: rid, userId });
}
// RC 0.51.0
return sdk.methodCallWrapper('unmuteUserInRoom', { rid, username });
return sdk.methodCallWrapper(mute ? 'muteUserInRoom' : 'unmuteUserInRoom', { rid, username });
};

export const toggleRoomOwner = ({
Expand Down
4 changes: 2 additions & 2 deletions app/views/RoomActionsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,14 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction

handleReturnLivechat = () => {
const {
room: { rid }
room: { rid, departmentId }
} = this.state;
showConfirmationAlert({
message: I18n.t('Would_you_like_to_return_the_inquiry'),
confirmationText: I18n.t('Yes'),
onPress: async () => {
try {
await returnLivechat(rid);
await returnLivechat(rid, departmentId);
} catch (e: any) {
showErrorAlert(e.reason, I18n.t('Oops'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomMembersView/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const fetchRoomMembersRoles = async (roomType: TRoomType, rid: string, up

export const handleMute = async (user: TUserModel, rid: string) => {
try {
await toggleMuteUserInRoom(rid, user?.username, !user.muted);
await toggleMuteUserInRoom(rid, user?.username, user?._id, !user.muted);
EventEmitter.emit(LISTENER, {
message: I18n.t('User_has_been_key', { key: user?.muted ? I18n.t('unmuted') : I18n.t('muted') })
});
Expand Down
4 changes: 2 additions & 2 deletions app/views/RoomView/RightButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
};

returnLivechat = () => {
const { rid } = this.props;
const { rid, departmentId } = this.props;
if (rid) {
showConfirmationAlert({
message: i18n.t('Would_you_like_to_return_the_inquiry'),
confirmationText: i18n.t('Yes'),
onPress: async () => {
try {
await returnLivechat(rid);
await returnLivechat(rid, departmentId);
} catch (e: any) {
showErrorAlert(e.reason, i18n.t('Oops'));
}
Expand Down
3 changes: 2 additions & 1 deletion app/views/RoomView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,11 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
logEvent(events.ROOM_JOIN);
try {
const { room } = this.state;
const { serverVersion } = this.props;

if (this.isOmnichannel) {
if ('_id' in room) {
await takeInquiry(room._id);
await takeInquiry(room._id, serverVersion as string);
}
this.onJoin();
} else {
Expand Down
Loading