[FIX] Close omnichannel conversations when agent is deactivated (#22917)
* close omnichannel conversations when agent is deactivated * Remove console.log * remove unnecesary props from type * Update app/lib/server/functions/setUserActiveStatus.js Co-authored-by: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com>pull/22929/head^2
parent
f7501deb7e
commit
e4342b397c
@ -0,0 +1,19 @@ |
||||
import { TAPi18n } from 'meteor/rocketchat:tap-i18n'; |
||||
|
||||
import { LivechatRooms } from '../../../models/server'; |
||||
import { IUser } from '../../../../definition/IUser'; |
||||
import { settings } from '../../../settings/server'; |
||||
import { Livechat } from '../../../livechat/server/lib/Livechat'; |
||||
|
||||
type SubscribedRooms = { |
||||
rid: string; |
||||
t: string; |
||||
} |
||||
|
||||
export const closeOmnichannelConversations = (user: IUser, subscribedRooms: SubscribedRooms[]): void => { |
||||
const roomsInfo = LivechatRooms.findByIds(subscribedRooms.map(({ rid }) => rid)); |
||||
const language = settings.get('Language') || 'en'; |
||||
roomsInfo.map((room: any) => |
||||
Livechat.closeRoom({ user, visitor: {}, room, comment: TAPi18n.__('Agent_deactivated', { lng: language }) }), |
||||
); |
||||
}; |
||||
Loading…
Reference in new issue