Built motion from commit c116dc8b.|2.6.30
[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 _0x4ab0=['Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','online','smsPause','available','waiting','stringify','format','emit','sms_queue:save','md5','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x3d371a,_0x1be5ff){var _0x52b3aa=function(_0x694624){while(--_0x694624){_0x3d371a['push'](_0x3d371a['shift']());}};_0x52b3aa(++_0x1be5ff);}(_0x4ab0,0xd5));var _0x04ab=function(_0x577a13,_0x41e9e9){_0x577a13=_0x577a13-0x0;var _0x5a5294=_0x4ab0[_0x577a13];return _0x5a5294;};'use strict';var _=require('lodash');var md5=require(_0x04ab('0x0'));var util=require(_0x04ab('0x1'));var Redis=require(_0x04ab('0x2'));var config=require(_0x04ab('0x3'));config[_0x04ab('0x4')]=_['defaults'](config['redis'],{'host':_0x04ab('0x5'),'port':0x18eb});var io=require(_0x04ab('0x6'))(new Redis(config['redis']));function SmsQueue(_0xfe58ca){this['id']=_0xfe58ca['id']||0x0;this[_0x04ab('0x7')]=_0xfe58ca['name']||'';this[_0x04ab('0x8')]=_0xfe58ca[_0x04ab('0x8')]||0xa;this[_0x04ab('0x9')]=_0xfe58ca['strategy']||_0x04ab('0xa');this[_0x04ab('0xb')]=_0xfe58ca[_0x04ab('0xb')];this[_0x04ab('0xc')]={};this['waiting']=0x0;this[_0x04ab('0x0')]='';this[_0x04ab('0xd')]();this[_0x04ab('0xe')]();}SmsQueue[_0x04ab('0xf')]['updateRouting']=function(){var _0x3f91fe=this[_0x04ab('0xc')][_0x04ab('0x10')];this[_0x04ab('0xc')]=_[_0x04ab('0x11')](this[_0x04ab('0xb')],'id');this['mapAgentsId'][_0x04ab('0x10')]=_0x3f91fe;};SmsQueue['prototype'][_0x04ab('0xe')]=function(){this[_0x04ab('0x12')]=0x0;this[_0x04ab('0x13')]=0x0;for(var _0x428798=0x0;_0x428798<this['Agents']['length'];_0x428798+=0x1){if(this['Agents'][_0x428798][_0x04ab('0x14')]){this[_0x04ab('0x12')]+=0x1;}if(this[_0x04ab('0xb')][_0x428798][_0x04ab('0x15')]){this[_0x04ab('0x13')]+=0x1;}}this[_0x04ab('0x16')]=this[_0x04ab('0x12')]-this[_0x04ab('0x13')];this[_0x04ab('0x16')]=this[_0x04ab('0x16')]>=0x0?this['available']:0x0;var _0x45c328={'id':this['id'],'available':this[_0x04ab('0x16')],'loggedIn':this[_0x04ab('0x12')],'name':this[_0x04ab('0x7')],'paused':this[_0x04ab('0x13')],'waiting':this[_0x04ab('0x17')]};var _0x32c2bb=md5(JSON[_0x04ab('0x18')](_0x45c328));if(this[_0x04ab('0x0')]!==_0x32c2bb){this['md5']=_0x32c2bb;io['to'](util[_0x04ab('0x19')]('sms:queue:%s',_0x45c328[_0x04ab('0x7')]))[_0x04ab('0x1a')](_0x04ab('0x1b'),_0x45c328);}};module['exports']=SmsQueue;