1d5f75de5164fc678eb46c3c48a484b01099e87b
[motion2.git] / server / services / routing / model / agent.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x7e22=['mail','chat','openchannel','fax','whatsapp','getChannelStatus','toNumber','format','Status','mailStatus','faxStatusTime','smsCurrentCapacity','whatsappStatus','busyQueue','stringify','emit','lodash','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','unknown','chatStatusTime','chatCapacity','chatCurrentCapacity','mailStatusTime','mailCapacity','mailCurrentCapacity','faxCapacity','faxCurrentCapacity','smsStatus','smsStatusTime','smsCapacity','whatsappStatusTime','whatsappCapacity','whatsappCurrentCapacity','openchannelStatus','openchannelStatusTime','openchannelCapacity','openchannelCurrentCapacity','busy','updateRealtime','CurrentCapacity','Capacity','maxcapacity','working'];(function(_0x19fdf3,_0x4507d0){var _0x2e3ce3=function(_0x538450){while(--_0x538450){_0x19fdf3['push'](_0x19fdf3['shift']());}};_0x2e3ce3(++_0x4507d0);}(_0x7e22,0x1d8));var _0x27e2=function(_0x295370,_0x4d044f){_0x295370=_0x295370-0x0;var _0x384d11=_0x7e22[_0x295370];return _0x384d11;};'use strict';var _=require(_0x27e2('0x0'));var moment=require('moment');var md5=require(_0x27e2('0x1'));var Redis=require(_0x27e2('0x2'));var config=require(_0x27e2('0x3'));config[_0x27e2('0x4')]=_[_0x27e2('0x5')](config[_0x27e2('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x27e2('0x6'))(new Redis(config['redis']));function Agent(_0x3b7d1e){this['id']=_0x3b7d1e['id']||0x0;this[_0x27e2('0x7')]=_0x3b7d1e[_0x27e2('0x7')]||'';this[_0x27e2('0x8')]=_0x3b7d1e['online']||!![];this[_0x27e2('0x9')]=_0x3b7d1e[_0x27e2('0x9')]||![];this[_0x27e2('0xa')]=_0x3b7d1e[_0x27e2('0xa')]||![];this[_0x27e2('0xb')]=_0x3b7d1e[_0x27e2('0xb')]||![];this[_0x27e2('0xc')]=_0x3b7d1e[_0x27e2('0xc')]||![];this['smsPause']=_0x3b7d1e[_0x27e2('0xd')]||![];this[_0x27e2('0xe')]=_0x3b7d1e['openchannelPause']||![];this[_0x27e2('0xf')]=_0x27e2('0x10');this[_0x27e2('0x11')]=0x0;this[_0x27e2('0x12')]=_0x3b7d1e['chatCapacity']||0x0;this[_0x27e2('0x13')]=0x0;this['mailStatus']=_0x27e2('0x10');this[_0x27e2('0x14')]=0x0;this[_0x27e2('0x15')]=_0x3b7d1e[_0x27e2('0x15')]||0x0;this[_0x27e2('0x16')]=0x0;this['faxStatus']=_0x27e2('0x10');this['faxStatusTime']=0x0;this[_0x27e2('0x17')]=_0x3b7d1e[_0x27e2('0x17')]||0x0;this[_0x27e2('0x18')]=0x0;this[_0x27e2('0x19')]=_0x27e2('0x10');this[_0x27e2('0x1a')]=0x0;this[_0x27e2('0x1b')]=_0x3b7d1e[_0x27e2('0x1b')]||0x0;this['smsCurrentCapacity']=0x0;this['whatsappStatus']=_0x27e2('0x10');this[_0x27e2('0x1c')]=0x0;this['whatsappCapacity']=_0x3b7d1e[_0x27e2('0x1d')]||0x0;this[_0x27e2('0x1e')]=0x0;this[_0x27e2('0x1f')]=_0x27e2('0x10');this[_0x27e2('0x20')]=0x0;this['openchannelCapacity']=_0x3b7d1e[_0x27e2('0x21')]||0x0;this[_0x27e2('0x22')]=0x0;this[_0x27e2('0x23')]=![];this['busyQueue']=undefined;this[_0x27e2('0x1')]='';this[_0x27e2('0x24')]();}Agent['prototype']['getChannelStatus']=function(_0x227eab){if(this[_0x227eab+_0x27e2('0x25')]>0x0){if(this[_0x227eab+_0x27e2('0x26')]>0x0&&this[_0x227eab+_0x27e2('0x25')]>=this[_0x227eab+_0x27e2('0x26')]){return _0x27e2('0x27');}else{return _0x27e2('0x28');}}else{return'idle';}};Agent['prototype'][_0x27e2('0x24')]=function(){var _0x1f1b14=[_0x27e2('0x29'),_0x27e2('0x2a'),_0x27e2('0x2b'),_0x27e2('0x2c'),'sms',_0x27e2('0x2d')];for(var _0x30b0a9=0x0;_0x30b0a9<_0x1f1b14['length'];_0x30b0a9+=0x1){var _0x212e9a=this[_0x27e2('0x2e')](_0x1f1b14[_0x30b0a9]);if(this[_0x1f1b14[_0x30b0a9]+'Status']!==_0x212e9a){this[_0x1f1b14[_0x30b0a9]+'StatusTime']=_[_0x27e2('0x2f')](moment()[_0x27e2('0x30')]('x'));}this[_0x1f1b14[_0x30b0a9]+_0x27e2('0x31')]=_0x212e9a;}var _0x46ca56={'id':this['id'],'name':this[_0x27e2('0x7')],'online':this[_0x27e2('0x8')],'voicePause':this[_0x27e2('0x9')],'chatPause':this[_0x27e2('0xa')],'mailPause':this['mailPause'],'smsPause':this['smsPause'],'faxPause':this[_0x27e2('0xc')],'openchannelPause':this['openchannelPause'],'chatStatus':this[_0x27e2('0xf')],'chatStatusTime':this['chatStatusTime'],'chatCapacity':this[_0x27e2('0x12')],'chatCurrentCapacity':this[_0x27e2('0x13')],'mailStatus':this[_0x27e2('0x32')],'mailStatusTime':this[_0x27e2('0x14')],'mailCapacity':this[_0x27e2('0x15')],'mailCurrentCapacity':this[_0x27e2('0x16')],'faxStatus':this['faxStatus'],'faxStatusTime':this[_0x27e2('0x33')],'faxCapacity':this['faxCapacity'],'faxCurrentCapacity':this['faxCurrentCapacity'],'smsStatus':this[_0x27e2('0x19')],'smsStatusTime':this[_0x27e2('0x1a')],'smsCapacity':this[_0x27e2('0x1b')],'smsCurrentCapacity':this[_0x27e2('0x34')],'whatsappStatus':this[_0x27e2('0x35')],'whatsappStatusTime':this[_0x27e2('0x1c')],'whatsappCapacity':this[_0x27e2('0x1d')],'whatsappCurrentCapacity':this[_0x27e2('0x1e')],'openchannelStatus':this[_0x27e2('0x1f')],'openchannelStatusTime':this[_0x27e2('0x20')],'openchannelCapacity':this[_0x27e2('0x21')],'openchannelCurrentCapacity':this['openchannelCurrentCapacity'],'busy':this['busy'],'busyQueue':this[_0x27e2('0x36')]};var _0x576678=md5(JSON[_0x27e2('0x37')](_0x46ca56));if(this['md5']!==_0x576678){this[_0x27e2('0x1')]=_0x576678;io[_0x27e2('0x38')]('user:save',_0x46ca56);}};module['exports']=Agent;