Built motion from commit 14588770.|2.5.38
[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 _0xe43c=['available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','waiting','prototype','_rr','map','Agents','updateRealtime','loggedIn','length','smsPause','paused'];(function(_0x29b43d,_0x5c70c3){var _0x4c2587=function(_0x3e0a7e){while(--_0x3e0a7e){_0x29b43d['push'](_0x29b43d['shift']());}};_0x4c2587(++_0x5c70c3);}(_0xe43c,0x180));var _0xce43=function(_0x5f1391,_0x19c132){_0x5f1391=_0x5f1391-0x0;var _0x50ebe3=_0xe43c[_0x5f1391];return _0x50ebe3;};'use strict';var _=require(_0xce43('0x0'));var md5=require(_0xce43('0x1'));var util=require(_0xce43('0x2'));var Redis=require(_0xce43('0x3'));var config=require(_0xce43('0x4'));config[_0xce43('0x5')]=_['defaults'](config[_0xce43('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0xce43('0x6'))(new Redis(config[_0xce43('0x5')]));function SmsQueue(_0xcec0ef){this['id']=_0xcec0ef['id']||0x0;this[_0xce43('0x7')]=_0xcec0ef['name']||'';this[_0xce43('0x8')]=_0xcec0ef['timeout']||0xa;this[_0xce43('0x9')]=_0xcec0ef['strategy']||_0xce43('0xa');this['Agents']=_0xcec0ef['Agents'];this[_0xce43('0xb')]={};this[_0xce43('0xc')]=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}SmsQueue[_0xce43('0xd')]['updateRouting']=function(){var _0x2f1926=this['mapAgentsId'][_0xce43('0xe')];this['mapAgentsId']=_[_0xce43('0xf')](this[_0xce43('0x10')],'id');this[_0xce43('0xb')][_0xce43('0xe')]=_0x2f1926;};SmsQueue[_0xce43('0xd')][_0xce43('0x11')]=function(){this[_0xce43('0x12')]=0x0;this['paused']=0x0;for(var _0x3034c7=0x0;_0x3034c7<this[_0xce43('0x10')][_0xce43('0x13')];_0x3034c7+=0x1){if(this[_0xce43('0x10')][_0x3034c7]['online']){this['loggedIn']+=0x1;}if(this[_0xce43('0x10')][_0x3034c7][_0xce43('0x14')]){this[_0xce43('0x15')]+=0x1;}}this[_0xce43('0x16')]=this[_0xce43('0x12')]-this[_0xce43('0x15')];this['available']=this[_0xce43('0x16')]>=0x0?this[_0xce43('0x16')]:0x0;var _0xbc38f0={'id':this['id'],'available':this[_0xce43('0x16')],'loggedIn':this['loggedIn'],'name':this[_0xce43('0x7')],'paused':this[_0xce43('0x15')],'waiting':this[_0xce43('0xc')]};var _0x2506de=md5(JSON[_0xce43('0x17')](_0xbc38f0));if(this[_0xce43('0x1')]!==_0x2506de){this['md5']=_0x2506de;io['to'](util[_0xce43('0x18')](_0xce43('0x19'),_0xbc38f0['name']))[_0xce43('0x1a')](_0xce43('0x1b'),_0xbc38f0);}};module[_0xce43('0x1c')]=SmsQueue;