@@ -48,7 +48,12 @@ type Routing = {
4848 options ?: { clientAction ?: boolean ; forwardingToDepartment ?: { oldDepartmentId ?: string ; transferData ?: any } } ,
4949 room ?: IOmnichannelRoom ,
5050 ) : Promise < ( IOmnichannelRoom & { chatQueued ?: boolean } ) | null | void > ;
51- unassignAgent ( inquiry : ILivechatInquiryRecord , departmentId ?: string , shouldQueue ?: boolean ) : Promise < boolean > ;
51+ unassignAgent (
52+ inquiry : ILivechatInquiryRecord ,
53+ departmentId ?: string ,
54+ shouldQueue ?: boolean ,
55+ agent ?: SelectedAgent | null ,
56+ ) : Promise < boolean > ;
5257 takeInquiry (
5358 inquiry : Omit <
5459 ILivechatInquiryRecord ,
@@ -157,11 +162,19 @@ export const RoutingManager: Routing = {
157162 return { inquiry, user } ;
158163 } ,
159164
160- async unassignAgent ( inquiry , departmentId , shouldQueue = false ) {
165+ async unassignAgent ( inquiry , departmentId , shouldQueue = false , defaultAgent ?: SelectedAgent | null ) {
161166 const { rid, department } = inquiry ;
162167 const room = await LivechatRooms . findOneById ( rid ) ;
163168
164- logger . debug ( `Removing assignations of inquiry ${ inquiry . _id } ` ) ;
169+ logger . debug ( {
170+ msg : 'Removing assignations of inquiry' ,
171+ inquiryId : inquiry . _id ,
172+ departmentId,
173+ room : { _id : room ?. _id , open : room ?. open , servedBy : room ?. servedBy } ,
174+ shouldQueue,
175+ defaultAgent,
176+ } ) ;
177+
165178 if ( ! room ?. open ) {
166179 logger . debug ( `Cannot unassign agent from inquiry ${ inquiry . _id } : Room already closed` ) ;
167180 return false ;
@@ -187,7 +200,7 @@ export const RoutingManager: Routing = {
187200 }
188201
189202 if ( shouldQueue ) {
190- const queuedInquiry = await LivechatInquiry . queueInquiry ( inquiry . _id , room . lastMessage ) ;
203+ const queuedInquiry = await LivechatInquiry . queueInquiry ( inquiry . _id , room . lastMessage , defaultAgent ) ;
191204 if ( queuedInquiry ) {
192205 inquiry = queuedInquiry ;
193206 void notifyOnLivechatInquiryChanged ( inquiry , 'updated' , {
0 commit comments