Built motion from commit 19a84241.|2.5.34
[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 _0x0c02=['sms_queue:save','exports','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','beepall','Agents','mapAgentsId','waiting','_rr','map','updateRealtime','loggedIn','paused','length','online','smsPause','available','stringify','sms:queue:%s','emit'];(function(_0x58b6a8,_0x307021){var _0xc566dc=function(_0x59bd76){while(--_0x59bd76){_0x58b6a8['push'](_0x58b6a8['shift']());}};_0xc566dc(++_0x307021);}(_0x0c02,0x84));var _0x20c0=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0c02[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var md5=require(_0x20c0('0x0'));var util=require(_0x20c0('0x1'));var Redis=require('ioredis');var config=require(_0x20c0('0x2'));config[_0x20c0('0x3')]=_[_0x20c0('0x4')](config[_0x20c0('0x3')],{'host':_0x20c0('0x5'),'port':0x18eb});var io=require(_0x20c0('0x6'))(new Redis(config[_0x20c0('0x3')]));function SmsQueue(_0x1474f7){this['id']=_0x1474f7['id']||0x0;this[_0x20c0('0x7')]=_0x1474f7[_0x20c0('0x7')]||'';this['timeout']=_0x1474f7['timeout']||0xa;this['strategy']=_0x1474f7['strategy']||_0x20c0('0x8');this[_0x20c0('0x9')]=_0x1474f7[_0x20c0('0x9')];this[_0x20c0('0xa')]={};this[_0x20c0('0xb')]=0x0;this[_0x20c0('0x0')]='';this['updateRouting']();this['updateRealtime']();}SmsQueue['prototype']['updateRouting']=function(){var _0x56770a=this[_0x20c0('0xa')][_0x20c0('0xc')];this[_0x20c0('0xa')]=_[_0x20c0('0xd')](this['Agents'],'id');this[_0x20c0('0xa')]['_rr']=_0x56770a;};SmsQueue['prototype'][_0x20c0('0xe')]=function(){this[_0x20c0('0xf')]=0x0;this[_0x20c0('0x10')]=0x0;for(var _0x3b2bba=0x0;_0x3b2bba<this[_0x20c0('0x9')][_0x20c0('0x11')];_0x3b2bba+=0x1){if(this[_0x20c0('0x9')][_0x3b2bba][_0x20c0('0x12')]){this[_0x20c0('0xf')]+=0x1;}if(this['Agents'][_0x3b2bba][_0x20c0('0x13')]){this[_0x20c0('0x10')]+=0x1;}}this[_0x20c0('0x14')]=this[_0x20c0('0xf')]-this[_0x20c0('0x10')];this[_0x20c0('0x14')]=this['available']>=0x0?this['available']:0x0;var _0x529cad={'id':this['id'],'available':this[_0x20c0('0x14')],'loggedIn':this[_0x20c0('0xf')],'name':this[_0x20c0('0x7')],'paused':this[_0x20c0('0x10')],'waiting':this['waiting']};var _0x33620c=md5(JSON[_0x20c0('0x15')](_0x529cad));if(this[_0x20c0('0x0')]!==_0x33620c){this['md5']=_0x33620c;io['to'](util['format'](_0x20c0('0x16'),_0x529cad[_0x20c0('0x7')]))[_0x20c0('0x17')](_0x20c0('0x18'),_0x529cad);}};module[_0x20c0('0x19')]=SmsQueue;