Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / services / routing / model / smsQueue.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 _0xfa2b=['strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','paused','length','online','smsPause','available','stringify','format','sms:queue:%s','emit','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0x62b70f,_0x1c6f1e){var _0xe4b1e1=function(_0xe5db69){while(--_0xe5db69){_0x62b70f['push'](_0x62b70f['shift']());}};_0xe4b1e1(++_0x1c6f1e);}(_0xfa2b,0x1b7));var _0xbfa2=function(_0x46c688,_0x4d1849){_0x46c688=_0x46c688-0x0;var _0x188dbb=_0xfa2b[_0x46c688];return _0x188dbb;};'use strict';var _=require(_0xbfa2('0x0'));var md5=require(_0xbfa2('0x1'));var util=require(_0xbfa2('0x2'));var Redis=require(_0xbfa2('0x3'));var config=require(_0xbfa2('0x4'));config[_0xbfa2('0x5')]=_[_0xbfa2('0x6')](config[_0xbfa2('0x5')],{'host':_0xbfa2('0x7'),'port':0x18eb});var io=require(_0xbfa2('0x8'))(new Redis(config[_0xbfa2('0x5')]));function SmsQueue(_0x2e8f3b){this['id']=_0x2e8f3b['id']||0x0;this[_0xbfa2('0x9')]=_0x2e8f3b[_0xbfa2('0x9')]||'';this[_0xbfa2('0xa')]=_0x2e8f3b[_0xbfa2('0xa')]||0xa;this['strategy']=_0x2e8f3b[_0xbfa2('0xb')]||'beepall';this[_0xbfa2('0xc')]=_0x2e8f3b[_0xbfa2('0xc')];this[_0xbfa2('0xd')]={};this[_0xbfa2('0xe')]=0x0;this[_0xbfa2('0x1')]='';this[_0xbfa2('0xf')]();this[_0xbfa2('0x10')]();}SmsQueue[_0xbfa2('0x11')][_0xbfa2('0xf')]=function(){var _0x4e0f1e=this['mapAgentsId']['_rr'];this[_0xbfa2('0xd')]=_[_0xbfa2('0x12')](this[_0xbfa2('0xc')],'id');this[_0xbfa2('0xd')][_0xbfa2('0x13')]=_0x4e0f1e;};SmsQueue[_0xbfa2('0x11')]['updateRealtime']=function(){this[_0xbfa2('0x14')]=0x0;this[_0xbfa2('0x15')]=0x0;for(var _0x458653=0x0;_0x458653<this[_0xbfa2('0xc')][_0xbfa2('0x16')];_0x458653+=0x1){if(this['Agents'][_0x458653][_0xbfa2('0x17')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x458653][_0xbfa2('0x18')]){this['paused']+=0x1;}}this['available']=this[_0xbfa2('0x14')]-this[_0xbfa2('0x15')];this['available']=this[_0xbfa2('0x19')]>=0x0?this[_0xbfa2('0x19')]:0x0;var _0x28fe6f={'id':this['id'],'available':this[_0xbfa2('0x19')],'loggedIn':this[_0xbfa2('0x14')],'name':this[_0xbfa2('0x9')],'paused':this[_0xbfa2('0x15')],'waiting':this['waiting']};var _0xb805f7=md5(JSON[_0xbfa2('0x1a')](_0x28fe6f));if(this[_0xbfa2('0x1')]!==_0xb805f7){this['md5']=_0xb805f7;io['to'](util[_0xbfa2('0x1b')](_0xbfa2('0x1c'),_0x28fe6f['name']))[_0xbfa2('0x1d')]('sms_queue:save',_0x28fe6f);}};module['exports']=SmsQueue;