Built motion from commit 85328c08.|2.5.50
[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 _0xe205=['_rr','map','prototype','loggedIn','length','online','paused','available','stringify','format','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','strategy','Agents','waiting','updateRouting','updateRealtime','mapAgentsId'];(function(_0x365b81,_0x240945){var _0x4b3f21=function(_0x43fa3a){while(--_0x43fa3a){_0x365b81['push'](_0x365b81['shift']());}};_0x4b3f21(++_0x240945);}(_0xe205,0xa7));var _0x5e20=function(_0x4d0bc1,_0x3ad0dd){_0x4d0bc1=_0x4d0bc1-0x0;var _0x3f824a=_0xe205[_0x4d0bc1];return _0x3f824a;};'use strict';var _=require(_0x5e20('0x0'));var md5=require(_0x5e20('0x1'));var util=require(_0x5e20('0x2'));var Redis=require(_0x5e20('0x3'));var config=require(_0x5e20('0x4'));config[_0x5e20('0x5')]=_[_0x5e20('0x6')](config[_0x5e20('0x5')],{'host':_0x5e20('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x5e20('0x5')]));function SmsQueue(_0x1b26a2){this['id']=_0x1b26a2['id']||0x0;this[_0x5e20('0x8')]=_0x1b26a2[_0x5e20('0x8')]||'';this['timeout']=_0x1b26a2['timeout']||0xa;this[_0x5e20('0x9')]=_0x1b26a2['strategy']||'beepall';this[_0x5e20('0xa')]=_0x1b26a2[_0x5e20('0xa')];this['mapAgentsId']={};this[_0x5e20('0xb')]=0x0;this[_0x5e20('0x1')]='';this[_0x5e20('0xc')]();this[_0x5e20('0xd')]();}SmsQueue['prototype'][_0x5e20('0xc')]=function(){var _0xda6476=this[_0x5e20('0xe')][_0x5e20('0xf')];this[_0x5e20('0xe')]=_[_0x5e20('0x10')](this['Agents'],'id');this[_0x5e20('0xe')][_0x5e20('0xf')]=_0xda6476;};SmsQueue[_0x5e20('0x11')]['updateRealtime']=function(){this[_0x5e20('0x12')]=0x0;this['paused']=0x0;for(var _0x1f47f3=0x0;_0x1f47f3<this['Agents'][_0x5e20('0x13')];_0x1f47f3+=0x1){if(this[_0x5e20('0xa')][_0x1f47f3][_0x5e20('0x14')]){this[_0x5e20('0x12')]+=0x1;}if(this[_0x5e20('0xa')][_0x1f47f3]['smsPause']){this[_0x5e20('0x15')]+=0x1;}}this[_0x5e20('0x16')]=this[_0x5e20('0x12')]-this[_0x5e20('0x15')];this[_0x5e20('0x16')]=this[_0x5e20('0x16')]>=0x0?this[_0x5e20('0x16')]:0x0;var _0xf3488f={'id':this['id'],'available':this['available'],'loggedIn':this[_0x5e20('0x12')],'name':this[_0x5e20('0x8')],'paused':this['paused'],'waiting':this[_0x5e20('0xb')]};var _0x1b1457=md5(JSON[_0x5e20('0x17')](_0xf3488f));if(this[_0x5e20('0x1')]!==_0x1b1457){this['md5']=_0x1b1457;io['to'](util[_0x5e20('0x18')]('sms:queue:%s',_0xf3488f['name']))['emit']('sms_queue:save',_0xf3488f);}};module[_0x5e20('0x19')]=SmsQueue;