Built motion from commit 9c91e9f5.|2.6.29
[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 _0xff96=['mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','available','stringify','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents'];(function(_0x22eafa,_0x2d11bd){var _0x1ff6f2=function(_0xb0fef0){while(--_0xb0fef0){_0x22eafa['push'](_0x22eafa['shift']());}};_0x1ff6f2(++_0x2d11bd);}(_0xff96,0x179));var _0x6ff9=function(_0x475bf1,_0x5235b6){_0x475bf1=_0x475bf1-0x0;var _0x4095d1=_0xff96[_0x475bf1];return _0x4095d1;};'use strict';var _=require(_0x6ff9('0x0'));var md5=require(_0x6ff9('0x1'));var util=require(_0x6ff9('0x2'));var Redis=require(_0x6ff9('0x3'));var config=require(_0x6ff9('0x4'));config[_0x6ff9('0x5')]=_[_0x6ff9('0x6')](config[_0x6ff9('0x5')],{'host':_0x6ff9('0x7'),'port':0x18eb});var io=require(_0x6ff9('0x8'))(new Redis(config[_0x6ff9('0x5')]));function SmsQueue(_0x367a07){this['id']=_0x367a07['id']||0x0;this['name']=_0x367a07[_0x6ff9('0x9')]||'';this['timeout']=_0x367a07['timeout']||0xa;this['strategy']=_0x367a07[_0x6ff9('0xa')]||_0x6ff9('0xb');this[_0x6ff9('0xc')]=_0x367a07[_0x6ff9('0xc')];this[_0x6ff9('0xd')]={};this[_0x6ff9('0xe')]=0x0;this['md5']='';this[_0x6ff9('0xf')]();this[_0x6ff9('0x10')]();}SmsQueue[_0x6ff9('0x11')][_0x6ff9('0xf')]=function(){var _0x3763ea=this[_0x6ff9('0xd')][_0x6ff9('0x12')];this[_0x6ff9('0xd')]=_[_0x6ff9('0x13')](this['Agents'],'id');this['mapAgentsId'][_0x6ff9('0x12')]=_0x3763ea;};SmsQueue['prototype'][_0x6ff9('0x10')]=function(){this[_0x6ff9('0x14')]=0x0;this[_0x6ff9('0x15')]=0x0;for(var _0x58022a=0x0;_0x58022a<this['Agents'][_0x6ff9('0x16')];_0x58022a+=0x1){if(this[_0x6ff9('0xc')][_0x58022a][_0x6ff9('0x17')]){this[_0x6ff9('0x14')]+=0x1;}if(this['Agents'][_0x58022a]['smsPause']){this[_0x6ff9('0x15')]+=0x1;}}this[_0x6ff9('0x18')]=this[_0x6ff9('0x14')]-this[_0x6ff9('0x15')];this[_0x6ff9('0x18')]=this['available']>=0x0?this[_0x6ff9('0x18')]:0x0;var _0x4756be={'id':this['id'],'available':this[_0x6ff9('0x18')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this['paused'],'waiting':this[_0x6ff9('0xe')]};var _0x1b4753=md5(JSON[_0x6ff9('0x19')](_0x4756be));if(this[_0x6ff9('0x1')]!==_0x1b4753){this[_0x6ff9('0x1')]=_0x1b4753;io['to'](util['format'](_0x6ff9('0x1a'),_0x4756be[_0x6ff9('0x9')]))[_0x6ff9('0x1b')](_0x6ff9('0x1c'),_0x4756be);}};module[_0x6ff9('0x1d')]=SmsQueue;