Built motion from commit ddca4d0d.|2.5.47
[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 _0xf29c=['openchannelCurrentCapacity','busyQueue','stringify','user:save','exports','lodash','moment','md5','../../../config/environment','redis','socket.io-emitter','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','unknown','chatCapacity','chatCurrentCapacity','mailStatus','mailCapacity','mailCurrentCapacity','faxStatus','faxStatusTime','faxCapacity','smsCapacity','smsCurrentCapacity','whatsappStatus','whatsappStatusTime','whatsappCapacity','whatsappCurrentCapacity','openchannelStatus','openchannelCapacity','busy','updateRealtime','prototype','getChannelStatus','CurrentCapacity','Capacity','maxcapacity','working','mail','chat','openchannel','fax','length','Status','StatusTime','toNumber','chatStatusTime','mailStatusTime','faxCurrentCapacity','smsStatus','smsStatusTime','openchannelStatusTime'];(function(_0xd7591,_0x441a7a){var _0x5bf82f=function(_0x91a04f){while(--_0x91a04f){_0xd7591['push'](_0xd7591['shift']());}};_0x5bf82f(++_0x441a7a);}(_0xf29c,0xf1));var _0xcf29=function(_0x49f02d,_0x234585){_0x49f02d=_0x49f02d-0x0;var _0x4da9bb=_0xf29c[_0x49f02d];return _0x4da9bb;};'use strict';var _=require(_0xcf29('0x0'));var moment=require(_0xcf29('0x1'));var md5=require(_0xcf29('0x2'));var Redis=require('ioredis');var config=require(_0xcf29('0x3'));config['redis']=_['defaults'](config[_0xcf29('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xcf29('0x5'))(new Redis(config[_0xcf29('0x4')]));function Agent(_0x4d51af){this['id']=_0x4d51af['id']||0x0;this[_0xcf29('0x6')]=_0x4d51af[_0xcf29('0x6')]||'';this['online']=_0x4d51af[_0xcf29('0x7')]||!![];this[_0xcf29('0x8')]=_0x4d51af[_0xcf29('0x8')]||![];this[_0xcf29('0x9')]=_0x4d51af[_0xcf29('0x9')]||![];this[_0xcf29('0xa')]=_0x4d51af[_0xcf29('0xa')]||![];this[_0xcf29('0xb')]=_0x4d51af[_0xcf29('0xb')]||![];this['smsPause']=_0x4d51af[_0xcf29('0xc')]||![];this[_0xcf29('0xd')]=_0x4d51af['openchannelPause']||![];this[_0xcf29('0xe')]=_0xcf29('0xf');this['chatStatusTime']=0x0;this[_0xcf29('0x10')]=_0x4d51af[_0xcf29('0x10')]||0x0;this[_0xcf29('0x11')]=0x0;this[_0xcf29('0x12')]=_0xcf29('0xf');this['mailStatusTime']=0x0;this['mailCapacity']=_0x4d51af[_0xcf29('0x13')]||0x0;this[_0xcf29('0x14')]=0x0;this[_0xcf29('0x15')]=_0xcf29('0xf');this[_0xcf29('0x16')]=0x0;this[_0xcf29('0x17')]=_0x4d51af['faxCapacity']||0x0;this['faxCurrentCapacity']=0x0;this['smsStatus']=_0xcf29('0xf');this['smsStatusTime']=0x0;this[_0xcf29('0x18')]=_0x4d51af[_0xcf29('0x18')]||0x0;this[_0xcf29('0x19')]=0x0;this[_0xcf29('0x1a')]=_0xcf29('0xf');this[_0xcf29('0x1b')]=0x0;this[_0xcf29('0x1c')]=_0x4d51af['whatsappCapacity']||0x0;this[_0xcf29('0x1d')]=0x0;this[_0xcf29('0x1e')]=_0xcf29('0xf');this['openchannelStatusTime']=0x0;this['openchannelCapacity']=_0x4d51af[_0xcf29('0x1f')]||0x0;this['openchannelCurrentCapacity']=0x0;this[_0xcf29('0x20')]=![];this['busyQueue']=undefined;this['md5']='';this[_0xcf29('0x21')]();}Agent[_0xcf29('0x22')][_0xcf29('0x23')]=function(_0x2dbca4){if(this[_0x2dbca4+'CurrentCapacity']>0x0){if(this[_0x2dbca4+'Capacity']>0x0&&this[_0x2dbca4+_0xcf29('0x24')]>=this[_0x2dbca4+_0xcf29('0x25')]){return _0xcf29('0x26');}else{return _0xcf29('0x27');}}else{return'idle';}};Agent['prototype'][_0xcf29('0x21')]=function(){var _0x2499fc=[_0xcf29('0x28'),_0xcf29('0x29'),_0xcf29('0x2a'),_0xcf29('0x2b'),'sms','whatsapp'];for(var _0x288b2c=0x0;_0x288b2c<_0x2499fc[_0xcf29('0x2c')];_0x288b2c+=0x1){var _0x2c4275=this['getChannelStatus'](_0x2499fc[_0x288b2c]);if(this[_0x2499fc[_0x288b2c]+_0xcf29('0x2d')]!==_0x2c4275){this[_0x2499fc[_0x288b2c]+_0xcf29('0x2e')]=_[_0xcf29('0x2f')](moment()['format']('x'));}this[_0x2499fc[_0x288b2c]+_0xcf29('0x2d')]=_0x2c4275;}var _0x49e127={'id':this['id'],'name':this[_0xcf29('0x6')],'online':this[_0xcf29('0x7')],'voicePause':this[_0xcf29('0x8')],'chatPause':this['chatPause'],'mailPause':this[_0xcf29('0xa')],'smsPause':this['smsPause'],'faxPause':this[_0xcf29('0xb')],'openchannelPause':this['openchannelPause'],'chatStatus':this[_0xcf29('0xe')],'chatStatusTime':this[_0xcf29('0x30')],'chatCapacity':this[_0xcf29('0x10')],'chatCurrentCapacity':this['chatCurrentCapacity'],'mailStatus':this[_0xcf29('0x12')],'mailStatusTime':this[_0xcf29('0x31')],'mailCapacity':this[_0xcf29('0x13')],'mailCurrentCapacity':this[_0xcf29('0x14')],'faxStatus':this[_0xcf29('0x15')],'faxStatusTime':this[_0xcf29('0x16')],'faxCapacity':this[_0xcf29('0x17')],'faxCurrentCapacity':this[_0xcf29('0x32')],'smsStatus':this[_0xcf29('0x33')],'smsStatusTime':this[_0xcf29('0x34')],'smsCapacity':this[_0xcf29('0x18')],'smsCurrentCapacity':this[_0xcf29('0x19')],'whatsappStatus':this[_0xcf29('0x1a')],'whatsappStatusTime':this[_0xcf29('0x1b')],'whatsappCapacity':this[_0xcf29('0x1c')],'whatsappCurrentCapacity':this['whatsappCurrentCapacity'],'openchannelStatus':this[_0xcf29('0x1e')],'openchannelStatusTime':this[_0xcf29('0x35')],'openchannelCapacity':this['openchannelCapacity'],'openchannelCurrentCapacity':this[_0xcf29('0x36')],'busy':this[_0xcf29('0x20')],'busyQueue':this[_0xcf29('0x37')]};var _0x23ccc6=md5(JSON[_0xcf29('0x38')](_0x49e127));if(this[_0xcf29('0x2')]!==_0x23ccc6){this[_0xcf29('0x2')]=_0x23ccc6;io['emit'](_0xcf29('0x39'),_0x49e127);}};module[_0xcf29('0x3a')]=Agent;