359a053fb61f56150ee83997fae648ece23ecfdf
[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 _0x5645=['loggedIn','length','online','smsPause','paused','available','waiting','stringify','sms:queue:%s','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype','_rr','map','updateRealtime'];(function(_0x134d30,_0x3671db){var _0x1ae1ba=function(_0x333d3e){while(--_0x333d3e){_0x134d30['push'](_0x134d30['shift']());}};_0x1ae1ba(++_0x3671db);}(_0x5645,0x19e));var _0x5564=function(_0x5e0f7b,_0x4ea2b6){_0x5e0f7b=_0x5e0f7b-0x0;var _0x409287=_0x5645[_0x5e0f7b];return _0x409287;};'use strict';var _=require(_0x5564('0x0'));var md5=require(_0x5564('0x1'));var util=require(_0x5564('0x2'));var Redis=require(_0x5564('0x3'));var config=require(_0x5564('0x4'));config['redis']=_[_0x5564('0x5')](config[_0x5564('0x6')],{'host':_0x5564('0x7'),'port':0x18eb});var io=require(_0x5564('0x8'))(new Redis(config[_0x5564('0x6')]));function SmsQueue(_0x1ee755){this['id']=_0x1ee755['id']||0x0;this[_0x5564('0x9')]=_0x1ee755[_0x5564('0x9')]||'';this[_0x5564('0xa')]=_0x1ee755['timeout']||0xa;this['strategy']=_0x1ee755[_0x5564('0xb')]||_0x5564('0xc');this[_0x5564('0xd')]=_0x1ee755[_0x5564('0xd')];this[_0x5564('0xe')]={};this['waiting']=0x0;this[_0x5564('0x1')]='';this[_0x5564('0xf')]();this['updateRealtime']();}SmsQueue[_0x5564('0x10')][_0x5564('0xf')]=function(){var _0x1c124a=this[_0x5564('0xe')][_0x5564('0x11')];this[_0x5564('0xe')]=_[_0x5564('0x12')](this[_0x5564('0xd')],'id');this['mapAgentsId'][_0x5564('0x11')]=_0x1c124a;};SmsQueue['prototype'][_0x5564('0x13')]=function(){this[_0x5564('0x14')]=0x0;this['paused']=0x0;for(var _0xe7cd0c=0x0;_0xe7cd0c<this[_0x5564('0xd')][_0x5564('0x15')];_0xe7cd0c+=0x1){if(this[_0x5564('0xd')][_0xe7cd0c][_0x5564('0x16')]){this[_0x5564('0x14')]+=0x1;}if(this['Agents'][_0xe7cd0c][_0x5564('0x17')]){this[_0x5564('0x18')]+=0x1;}}this[_0x5564('0x19')]=this[_0x5564('0x14')]-this['paused'];this[_0x5564('0x19')]=this[_0x5564('0x19')]>=0x0?this[_0x5564('0x19')]:0x0;var _0x2a4d8f={'id':this['id'],'available':this[_0x5564('0x19')],'loggedIn':this[_0x5564('0x14')],'name':this[_0x5564('0x9')],'paused':this[_0x5564('0x18')],'waiting':this[_0x5564('0x1a')]};var _0x29ec28=md5(JSON[_0x5564('0x1b')](_0x2a4d8f));if(this[_0x5564('0x1')]!==_0x29ec28){this[_0x5564('0x1')]=_0x29ec28;io['to'](util['format'](_0x5564('0x1c'),_0x2a4d8f[_0x5564('0x9')]))['emit'](_0x5564('0x1d'),_0x2a4d8f);}};module[_0x5564('0x1e')]=SmsQueue;