Built motion from commit 9d0783e6.|2.6.13
[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 _0x4c13=['chatPause','available','paused','stringify','md5','format','chat:queue:%s','emit','chat_queue:save','lodash','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','_rr','map','prototype','loggedIn','length','online'];(function(_0x1a8565,_0xc941eb){var _0x593764=function(_0xed13df){while(--_0xed13df){_0x1a8565['push'](_0x1a8565['shift']());}};_0x593764(++_0xc941eb);}(_0x4c13,0x9a));var _0x34c1=function(_0x4e2570,_0xca2204){_0x4e2570=_0x4e2570-0x0;var _0x3cfbfd=_0x4c13[_0x4e2570];return _0x3cfbfd;};'use strict';var _=require(_0x34c1('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require(_0x34c1('0x1'));config[_0x34c1('0x2')]=_[_0x34c1('0x3')](config[_0x34c1('0x2')],{'host':_0x34c1('0x4'),'port':0x18eb});var io=require(_0x34c1('0x5'))(new Redis(config[_0x34c1('0x2')]));function ChatQueue(_0x313ae5){this['id']=_0x313ae5['id']||0x0;this[_0x34c1('0x6')]=_0x313ae5[_0x34c1('0x6')]||'';this['timeout']=_0x313ae5[_0x34c1('0x7')]||0xa;this[_0x34c1('0x8')]=_0x313ae5[_0x34c1('0x8')]||_0x34c1('0x9');this[_0x34c1('0xa')]=_0x313ae5[_0x34c1('0xa')];this[_0x34c1('0xb')]={};this[_0x34c1('0xc')]=0x0;this['md5']='';this[_0x34c1('0xd')]();this['updateRealtime']();}ChatQueue['prototype']['updateRouting']=function(){var _0x5d7c28=this[_0x34c1('0xb')][_0x34c1('0xe')];this[_0x34c1('0xb')]=_[_0x34c1('0xf')](this[_0x34c1('0xa')],'id');this[_0x34c1('0xb')][_0x34c1('0xe')]=_0x5d7c28;};ChatQueue[_0x34c1('0x10')]['updateRealtime']=function(){this[_0x34c1('0x11')]=0x0;this['paused']=0x0;for(var _0x30efba=0x0;_0x30efba<this['Agents'][_0x34c1('0x12')];_0x30efba+=0x1){if(this[_0x34c1('0xa')][_0x30efba][_0x34c1('0x13')]){this[_0x34c1('0x11')]+=0x1;}if(this[_0x34c1('0xa')][_0x30efba][_0x34c1('0x14')]){this['paused']+=0x1;}}this[_0x34c1('0x15')]=this[_0x34c1('0x11')]-this[_0x34c1('0x16')];this[_0x34c1('0x15')]=this['available']>=0x0?this['available']:0x0;var _0x12c51f={'id':this['id'],'available':this['available'],'loggedIn':this[_0x34c1('0x11')],'name':this['name'],'paused':this[_0x34c1('0x16')],'waiting':this[_0x34c1('0xc')]};var _0x1c67ad=md5(JSON[_0x34c1('0x17')](_0x12c51f));if(this[_0x34c1('0x18')]!==_0x1c67ad){this[_0x34c1('0x18')]=_0x1c67ad;io['to'](util[_0x34c1('0x19')](_0x34c1('0x1a'),_0x12c51f[_0x34c1('0x6')]))[_0x34c1('0x1b')](_0x34c1('0x1c'),_0x12c51f);}};module['exports']=ChatQueue;