Built motion from commit 25580385.|2.6.2
[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 _0x4b1d=['exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','length','online','chatPause','available','stringify','format','chat:queue:%s'];(function(_0x439d59,_0x11ccdf){var _0x3670c7=function(_0x11cfcb){while(--_0x11cfcb){_0x439d59['push'](_0x439d59['shift']());}};_0x3670c7(++_0x11ccdf);}(_0x4b1d,0x1cc));var _0xd4b1=function(_0x102165,_0x509db2){_0x102165=_0x102165-0x0;var _0x18bac4=_0x4b1d[_0x102165];return _0x18bac4;};'use strict';var _=require(_0xd4b1('0x0'));var md5=require(_0xd4b1('0x1'));var util=require('util');var Redis=require(_0xd4b1('0x2'));var config=require(_0xd4b1('0x3'));config[_0xd4b1('0x4')]=_[_0xd4b1('0x5')](config[_0xd4b1('0x4')],{'host':_0xd4b1('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd4b1('0x4')]));function ChatQueue(_0x339b65){this['id']=_0x339b65['id']||0x0;this[_0xd4b1('0x7')]=_0x339b65[_0xd4b1('0x7')]||'';this[_0xd4b1('0x8')]=_0x339b65['timeout']||0xa;this['strategy']=_0x339b65[_0xd4b1('0x9')]||'beepall';this[_0xd4b1('0xa')]=_0x339b65[_0xd4b1('0xa')];this[_0xd4b1('0xb')]={};this[_0xd4b1('0xc')]=0x0;this['md5']='';this[_0xd4b1('0xd')]();this[_0xd4b1('0xe')]();}ChatQueue[_0xd4b1('0xf')]['updateRouting']=function(){var _0x20c9a2=this[_0xd4b1('0xb')][_0xd4b1('0x10')];this['mapAgentsId']=_['map'](this['Agents'],'id');this[_0xd4b1('0xb')][_0xd4b1('0x10')]=_0x20c9a2;};ChatQueue[_0xd4b1('0xf')][_0xd4b1('0xe')]=function(){this[_0xd4b1('0x11')]=0x0;this[_0xd4b1('0x12')]=0x0;for(var _0x543453=0x0;_0x543453<this[_0xd4b1('0xa')][_0xd4b1('0x13')];_0x543453+=0x1){if(this[_0xd4b1('0xa')][_0x543453][_0xd4b1('0x14')]){this['loggedIn']+=0x1;}if(this[_0xd4b1('0xa')][_0x543453][_0xd4b1('0x15')]){this[_0xd4b1('0x12')]+=0x1;}}this['available']=this[_0xd4b1('0x11')]-this['paused'];this['available']=this[_0xd4b1('0x16')]>=0x0?this[_0xd4b1('0x16')]:0x0;var _0x447eeb={'id':this['id'],'available':this['available'],'loggedIn':this[_0xd4b1('0x11')],'name':this[_0xd4b1('0x7')],'paused':this['paused'],'waiting':this[_0xd4b1('0xc')]};var _0x428966=md5(JSON[_0xd4b1('0x17')](_0x447eeb));if(this[_0xd4b1('0x1')]!==_0x428966){this[_0xd4b1('0x1')]=_0x428966;io['to'](util[_0xd4b1('0x18')](_0xd4b1('0x19'),_0x447eeb['name']))['emit']('chat_queue:save',_0x447eeb);}};module[_0xd4b1('0x1a')]=ChatQueue;