e1b4c0d096687f1b03ea7bde5503e0ea4ed44557
[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 _0xc577=['loggedIn','available','stringify','format','sms:queue:%s','emit','lodash','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','Agents','mapAgentsId','waiting','md5','updateRouting','prototype','_rr','map','paused','length','online'];(function(_0x4e9628,_0x250573){var _0x27bc8c=function(_0xb3b7ae){while(--_0xb3b7ae){_0x4e9628['push'](_0x4e9628['shift']());}};_0x27bc8c(++_0x250573);}(_0xc577,0x172));var _0x7c57=function(_0xaf025d,_0x586d7a){_0xaf025d=_0xaf025d-0x0;var _0x1c77cb=_0xc577[_0xaf025d];return _0x1c77cb;};'use strict';var _=require(_0x7c57('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x7c57('0x1'));var config=require(_0x7c57('0x2'));config[_0x7c57('0x3')]=_[_0x7c57('0x4')](config[_0x7c57('0x3')],{'host':_0x7c57('0x5'),'port':0x18eb});var io=require(_0x7c57('0x6'))(new Redis(config['redis']));function SmsQueue(_0x447d52){this['id']=_0x447d52['id']||0x0;this[_0x7c57('0x7')]=_0x447d52[_0x7c57('0x7')]||'';this[_0x7c57('0x8')]=_0x447d52[_0x7c57('0x8')]||0xa;this['strategy']=_0x447d52['strategy']||'beepall';this[_0x7c57('0x9')]=_0x447d52['Agents'];this[_0x7c57('0xa')]={};this[_0x7c57('0xb')]=0x0;this[_0x7c57('0xc')]='';this[_0x7c57('0xd')]();this['updateRealtime']();}SmsQueue[_0x7c57('0xe')][_0x7c57('0xd')]=function(){var _0x4b5b56=this[_0x7c57('0xa')][_0x7c57('0xf')];this[_0x7c57('0xa')]=_[_0x7c57('0x10')](this[_0x7c57('0x9')],'id');this[_0x7c57('0xa')][_0x7c57('0xf')]=_0x4b5b56;};SmsQueue['prototype']['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x7c57('0x11')]=0x0;for(var _0x373a4b=0x0;_0x373a4b<this[_0x7c57('0x9')][_0x7c57('0x12')];_0x373a4b+=0x1){if(this[_0x7c57('0x9')][_0x373a4b][_0x7c57('0x13')]){this[_0x7c57('0x14')]+=0x1;}if(this[_0x7c57('0x9')][_0x373a4b]['smsPause']){this['paused']+=0x1;}}this[_0x7c57('0x15')]=this[_0x7c57('0x14')]-this[_0x7c57('0x11')];this[_0x7c57('0x15')]=this[_0x7c57('0x15')]>=0x0?this['available']:0x0;var _0x20dd80={'id':this['id'],'available':this[_0x7c57('0x15')],'loggedIn':this[_0x7c57('0x14')],'name':this[_0x7c57('0x7')],'paused':this[_0x7c57('0x11')],'waiting':this[_0x7c57('0xb')]};var _0x2931c4=md5(JSON[_0x7c57('0x16')](_0x20dd80));if(this[_0x7c57('0xc')]!==_0x2931c4){this['md5']=_0x2931c4;io['to'](util[_0x7c57('0x17')](_0x7c57('0x18'),_0x20dd80[_0x7c57('0x7')]))[_0x7c57('0x19')]('sms_queue:save',_0x20dd80);}};module['exports']=SmsQueue;