Built motion from commit 06a208af.|2.6.26
[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 _0xfb3f=['name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','available','waiting','format','sms:queue:%s','emit','sms_queue:save','lodash','md5','ioredis','defaults','localhost','socket.io-emitter','redis'];(function(_0x5d0671,_0x1c89cb){var _0x23615d=function(_0x5d56e4){while(--_0x5d56e4){_0x5d0671['push'](_0x5d0671['shift']());}};_0x23615d(++_0x1c89cb);}(_0xfb3f,0xd9));var _0xffb3=function(_0x4e755a,_0x4c8eac){_0x4e755a=_0x4e755a-0x0;var _0x3f31ea=_0xfb3f[_0x4e755a];return _0x3f31ea;};'use strict';var _=require(_0xffb3('0x0'));var md5=require(_0xffb3('0x1'));var util=require('util');var Redis=require(_0xffb3('0x2'));var config=require('../../../config/environment');config['redis']=_[_0xffb3('0x3')](config['redis'],{'host':_0xffb3('0x4'),'port':0x18eb});var io=require(_0xffb3('0x5'))(new Redis(config[_0xffb3('0x6')]));function SmsQueue(_0x15cb2c){this['id']=_0x15cb2c['id']||0x0;this[_0xffb3('0x7')]=_0x15cb2c[_0xffb3('0x7')]||'';this[_0xffb3('0x8')]=_0x15cb2c[_0xffb3('0x8')]||0xa;this['strategy']=_0x15cb2c[_0xffb3('0x9')]||_0xffb3('0xa');this[_0xffb3('0xb')]=_0x15cb2c[_0xffb3('0xb')];this[_0xffb3('0xc')]={};this['waiting']=0x0;this[_0xffb3('0x1')]='';this[_0xffb3('0xd')]();this[_0xffb3('0xe')]();}SmsQueue[_0xffb3('0xf')][_0xffb3('0xd')]=function(){var _0x3667d9=this[_0xffb3('0xc')][_0xffb3('0x10')];this['mapAgentsId']=_[_0xffb3('0x11')](this[_0xffb3('0xb')],'id');this['mapAgentsId'][_0xffb3('0x10')]=_0x3667d9;};SmsQueue[_0xffb3('0xf')][_0xffb3('0xe')]=function(){this[_0xffb3('0x12')]=0x0;this[_0xffb3('0x13')]=0x0;for(var _0x420156=0x0;_0x420156<this[_0xffb3('0xb')][_0xffb3('0x14')];_0x420156+=0x1){if(this[_0xffb3('0xb')][_0x420156][_0xffb3('0x15')]){this[_0xffb3('0x12')]+=0x1;}if(this[_0xffb3('0xb')][_0x420156]['smsPause']){this[_0xffb3('0x13')]+=0x1;}}this[_0xffb3('0x16')]=this[_0xffb3('0x12')]-this['paused'];this['available']=this[_0xffb3('0x16')]>=0x0?this[_0xffb3('0x16')]:0x0;var _0x57d096={'id':this['id'],'available':this[_0xffb3('0x16')],'loggedIn':this[_0xffb3('0x12')],'name':this[_0xffb3('0x7')],'paused':this['paused'],'waiting':this[_0xffb3('0x17')]};var _0x45fdd6=md5(JSON['stringify'](_0x57d096));if(this[_0xffb3('0x1')]!==_0x45fdd6){this[_0xffb3('0x1')]=_0x45fdd6;io['to'](util[_0xffb3('0x18')](_0xffb3('0x19'),_0x57d096[_0xffb3('0x7')]))[_0xffb3('0x1a')](_0xffb3('0x1b'),_0x57d096);}};module['exports']=SmsQueue;