23ba284d18b8bb349fad559589d48fda8ece0ac1
[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 _0xdace=['sms_queue:save','lodash','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','updateRouting','updateRealtime','_rr','prototype','loggedIn','paused','length','online','available','stringify','md5','format','sms:queue:%s','emit'];(function(_0x29bf80,_0x4af855){var _0x932096=function(_0x1528d7){while(--_0x1528d7){_0x29bf80['push'](_0x29bf80['shift']());}};_0x932096(++_0x4af855);}(_0xdace,0xc5));var _0xedac=function(_0x77d310,_0x2b2fe7){_0x77d310=_0x77d310-0x0;var _0x2cdce4=_0xdace[_0x77d310];return _0x2cdce4;};'use strict';var _=require(_0xedac('0x0'));var md5=require('md5');var util=require(_0xedac('0x1'));var Redis=require(_0xedac('0x2'));var config=require(_0xedac('0x3'));config['redis']=_[_0xedac('0x4')](config[_0xedac('0x5')],{'host':_0xedac('0x6'),'port':0x18eb});var io=require(_0xedac('0x7'))(new Redis(config['redis']));function SmsQueue(_0x32b066){this['id']=_0x32b066['id']||0x0;this[_0xedac('0x8')]=_0x32b066[_0xedac('0x8')]||'';this['timeout']=_0x32b066[_0xedac('0x9')]||0xa;this[_0xedac('0xa')]=_0x32b066[_0xedac('0xa')]||'beepall';this[_0xedac('0xb')]=_0x32b066[_0xedac('0xb')];this[_0xedac('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0xedac('0xd')]();this[_0xedac('0xe')]();}SmsQueue['prototype']['updateRouting']=function(){var _0x4db2ad=this[_0xedac('0xc')]['_rr'];this[_0xedac('0xc')]=_['map'](this[_0xedac('0xb')],'id');this[_0xedac('0xc')][_0xedac('0xf')]=_0x4db2ad;};SmsQueue[_0xedac('0x10')][_0xedac('0xe')]=function(){this[_0xedac('0x11')]=0x0;this[_0xedac('0x12')]=0x0;for(var _0x11f0b0=0x0;_0x11f0b0<this['Agents'][_0xedac('0x13')];_0x11f0b0+=0x1){if(this[_0xedac('0xb')][_0x11f0b0][_0xedac('0x14')]){this[_0xedac('0x11')]+=0x1;}if(this[_0xedac('0xb')][_0x11f0b0]['smsPause']){this[_0xedac('0x12')]+=0x1;}}this['available']=this[_0xedac('0x11')]-this[_0xedac('0x12')];this[_0xedac('0x15')]=this[_0xedac('0x15')]>=0x0?this['available']:0x0;var _0x4b2563={'id':this['id'],'available':this[_0xedac('0x15')],'loggedIn':this[_0xedac('0x11')],'name':this[_0xedac('0x8')],'paused':this[_0xedac('0x12')],'waiting':this['waiting']};var _0x4a699b=md5(JSON[_0xedac('0x16')](_0x4b2563));if(this[_0xedac('0x17')]!==_0x4a699b){this[_0xedac('0x17')]=_0x4a699b;io['to'](util[_0xedac('0x18')](_0xedac('0x19'),_0x4b2563[_0xedac('0x8')]))[_0xedac('0x1a')](_0xedac('0x1b'),_0x4b2563);}};module['exports']=SmsQueue;