Built motion from commit 9d0783e6.|2.6.13
[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 _0x55e0=['waiting','updateRouting','updateRealtime','prototype','mapAgentsId','map','_rr','paused','length','loggedIn','smsPause','available','name','format','sms:queue:%s','emit','exports','lodash','md5','util','ioredis','defaults','redis','localhost','socket.io-emitter','timeout','strategy','beepall','Agents'];(function(_0x35574e,_0x98e27e){var _0x315a66=function(_0x5025a8){while(--_0x5025a8){_0x35574e['push'](_0x35574e['shift']());}};_0x315a66(++_0x98e27e);}(_0x55e0,0xdc));var _0x055e=function(_0x152b1d,_0x32d2e9){_0x152b1d=_0x152b1d-0x0;var _0x3d008a=_0x55e0[_0x152b1d];return _0x3d008a;};'use strict';var _=require(_0x055e('0x0'));var md5=require(_0x055e('0x1'));var util=require(_0x055e('0x2'));var Redis=require(_0x055e('0x3'));var config=require('../../../config/environment');config['redis']=_[_0x055e('0x4')](config[_0x055e('0x5')],{'host':_0x055e('0x6'),'port':0x18eb});var io=require(_0x055e('0x7'))(new Redis(config[_0x055e('0x5')]));function SmsQueue(_0x196394){this['id']=_0x196394['id']||0x0;this['name']=_0x196394['name']||'';this[_0x055e('0x8')]=_0x196394['timeout']||0xa;this[_0x055e('0x9')]=_0x196394[_0x055e('0x9')]||_0x055e('0xa');this[_0x055e('0xb')]=_0x196394[_0x055e('0xb')];this['mapAgentsId']={};this[_0x055e('0xc')]=0x0;this[_0x055e('0x1')]='';this[_0x055e('0xd')]();this[_0x055e('0xe')]();}SmsQueue[_0x055e('0xf')]['updateRouting']=function(){var _0x56c78a=this[_0x055e('0x10')]['_rr'];this[_0x055e('0x10')]=_[_0x055e('0x11')](this[_0x055e('0xb')],'id');this[_0x055e('0x10')][_0x055e('0x12')]=_0x56c78a;};SmsQueue[_0x055e('0xf')][_0x055e('0xe')]=function(){this['loggedIn']=0x0;this[_0x055e('0x13')]=0x0;for(var _0xb80d83=0x0;_0xb80d83<this[_0x055e('0xb')][_0x055e('0x14')];_0xb80d83+=0x1){if(this[_0x055e('0xb')][_0xb80d83]['online']){this[_0x055e('0x15')]+=0x1;}if(this[_0x055e('0xb')][_0xb80d83][_0x055e('0x16')]){this['paused']+=0x1;}}this[_0x055e('0x17')]=this[_0x055e('0x15')]-this[_0x055e('0x13')];this[_0x055e('0x17')]=this[_0x055e('0x17')]>=0x0?this['available']:0x0;var _0x36ef10={'id':this['id'],'available':this[_0x055e('0x17')],'loggedIn':this[_0x055e('0x15')],'name':this[_0x055e('0x18')],'paused':this['paused'],'waiting':this[_0x055e('0xc')]};var _0x3cdd68=md5(JSON['stringify'](_0x36ef10));if(this[_0x055e('0x1')]!==_0x3cdd68){this[_0x055e('0x1')]=_0x3cdd68;io['to'](util[_0x055e('0x19')](_0x055e('0x1a'),_0x36ef10[_0x055e('0x18')]))[_0x055e('0x1b')]('sms_queue:save',_0x36ef10);}};module[_0x055e('0x1c')]=SmsQueue;