Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / services / routing / model / chatQueue.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 _0x6396=['updateRouting','mapAgentsId','_rr','loggedIn','paused','online','chatPause','available','format','chat:queue:%s','exports','lodash','md5','util','ioredis','../../../config/environment','localhost','socket.io-emitter','redis','name','timeout','strategy','beepall','Agents','waiting','updateRealtime','prototype'];(function(_0x3fbe9d,_0x3989f4){var _0x3a5f4a=function(_0x3b978e){while(--_0x3b978e){_0x3fbe9d['push'](_0x3fbe9d['shift']());}};_0x3a5f4a(++_0x3989f4);}(_0x6396,0x1a0));var _0x6639=function(_0x198446,_0x119c8f){_0x198446=_0x198446-0x0;var _0x38d7b7=_0x6396[_0x198446];return _0x38d7b7;};'use strict';var _=require(_0x6639('0x0'));var md5=require(_0x6639('0x1'));var util=require(_0x6639('0x2'));var Redis=require(_0x6639('0x3'));var config=require(_0x6639('0x4'));config['redis']=_['defaults'](config['redis'],{'host':_0x6639('0x5'),'port':0x18eb});var io=require(_0x6639('0x6'))(new Redis(config[_0x6639('0x7')]));function ChatQueue(_0x4c21a7){this['id']=_0x4c21a7['id']||0x0;this[_0x6639('0x8')]=_0x4c21a7[_0x6639('0x8')]||'';this[_0x6639('0x9')]=_0x4c21a7[_0x6639('0x9')]||0xa;this[_0x6639('0xa')]=_0x4c21a7[_0x6639('0xa')]||_0x6639('0xb');this[_0x6639('0xc')]=_0x4c21a7[_0x6639('0xc')];this['mapAgentsId']={};this[_0x6639('0xd')]=0x0;this[_0x6639('0x1')]='';this['updateRouting']();this[_0x6639('0xe')]();}ChatQueue[_0x6639('0xf')][_0x6639('0x10')]=function(){var _0x30dc1a=this[_0x6639('0x11')]['_rr'];this[_0x6639('0x11')]=_['map'](this['Agents'],'id');this[_0x6639('0x11')][_0x6639('0x12')]=_0x30dc1a;};ChatQueue[_0x6639('0xf')][_0x6639('0xe')]=function(){this[_0x6639('0x13')]=0x0;this[_0x6639('0x14')]=0x0;for(var _0x18dc8f=0x0;_0x18dc8f<this[_0x6639('0xc')]['length'];_0x18dc8f+=0x1){if(this[_0x6639('0xc')][_0x18dc8f][_0x6639('0x15')]){this[_0x6639('0x13')]+=0x1;}if(this[_0x6639('0xc')][_0x18dc8f][_0x6639('0x16')]){this[_0x6639('0x14')]+=0x1;}}this['available']=this['loggedIn']-this[_0x6639('0x14')];this['available']=this[_0x6639('0x17')]>=0x0?this['available']:0x0;var _0x442b7d={'id':this['id'],'available':this[_0x6639('0x17')],'loggedIn':this[_0x6639('0x13')],'name':this[_0x6639('0x8')],'paused':this['paused'],'waiting':this[_0x6639('0xd')]};var _0x58af2f=md5(JSON['stringify'](_0x442b7d));if(this[_0x6639('0x1')]!==_0x58af2f){this[_0x6639('0x1')]=_0x58af2f;io['to'](util[_0x6639('0x18')](_0x6639('0x19'),_0x442b7d[_0x6639('0x8')]))['emit']('chat_queue:save',_0x442b7d);}};module[_0x6639('0x1a')]=ChatQueue;