58c2cf68db2e9ee14c30badeb01c54de5cef1bc6
[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 _0xc6ab=['lodash','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','updateRouting','updateRealtime','map','loggedIn','paused','smsPause','available','waiting','stringify','format','sms:queue:%s','emit'];(function(_0x573497,_0x109afa){var _0x623a01=function(_0x5724cb){while(--_0x5724cb){_0x573497['push'](_0x573497['shift']());}};_0x623a01(++_0x109afa);}(_0xc6ab,0x96));var _0xbc6a=function(_0x2e9889,_0x136b5c){_0x2e9889=_0x2e9889-0x0;var _0x2f769c=_0xc6ab[_0x2e9889];return _0x2f769c;};'use strict';var _=require(_0xbc6a('0x0'));var md5=require(_0xbc6a('0x1'));var util=require(_0xbc6a('0x2'));var Redis=require(_0xbc6a('0x3'));var config=require(_0xbc6a('0x4'));config['redis']=_['defaults'](config[_0xbc6a('0x5')],{'host':_0xbc6a('0x6'),'port':0x18eb});var io=require(_0xbc6a('0x7'))(new Redis(config[_0xbc6a('0x5')]));function SmsQueue(_0x2767db){this['id']=_0x2767db['id']||0x0;this['name']=_0x2767db[_0xbc6a('0x8')]||'';this[_0xbc6a('0x9')]=_0x2767db[_0xbc6a('0x9')]||0xa;this[_0xbc6a('0xa')]=_0x2767db[_0xbc6a('0xa')]||'beepall';this['Agents']=_0x2767db[_0xbc6a('0xb')];this[_0xbc6a('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0xbc6a('0xd')]();this[_0xbc6a('0xe')]();}SmsQueue['prototype'][_0xbc6a('0xd')]=function(){var _0xe1c7bd=this[_0xbc6a('0xc')]['_rr'];this[_0xbc6a('0xc')]=_[_0xbc6a('0xf')](this[_0xbc6a('0xb')],'id');this[_0xbc6a('0xc')]['_rr']=_0xe1c7bd;};SmsQueue['prototype']['updateRealtime']=function(){this[_0xbc6a('0x10')]=0x0;this[_0xbc6a('0x11')]=0x0;for(var _0x48d94a=0x0;_0x48d94a<this[_0xbc6a('0xb')]['length'];_0x48d94a+=0x1){if(this[_0xbc6a('0xb')][_0x48d94a]['online']){this[_0xbc6a('0x10')]+=0x1;}if(this[_0xbc6a('0xb')][_0x48d94a][_0xbc6a('0x12')]){this[_0xbc6a('0x11')]+=0x1;}}this[_0xbc6a('0x13')]=this[_0xbc6a('0x10')]-this[_0xbc6a('0x11')];this['available']=this['available']>=0x0?this[_0xbc6a('0x13')]:0x0;var _0x2e8b88={'id':this['id'],'available':this[_0xbc6a('0x13')],'loggedIn':this[_0xbc6a('0x10')],'name':this[_0xbc6a('0x8')],'paused':this[_0xbc6a('0x11')],'waiting':this[_0xbc6a('0x14')]};var _0x31dc65=md5(JSON[_0xbc6a('0x15')](_0x2e8b88));if(this[_0xbc6a('0x1')]!==_0x31dc65){this[_0xbc6a('0x1')]=_0x31dc65;io['to'](util[_0xbc6a('0x16')](_0xbc6a('0x17'),_0x2e8b88['name']))[_0xbc6a('0x18')]('sms_queue:save',_0x2e8b88);}};module['exports']=SmsQueue;