Built motion from commit b5413ace.|2.6.9
[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 _0xb903=['updateRealtime','online','loggedIn','smsPause','paused','available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents','prototype','updateRouting','mapAgentsId','_rr','map'];(function(_0xedbbe2,_0xbd686d){var _0x1d014a=function(_0x3bedab){while(--_0x3bedab){_0xedbbe2['push'](_0xedbbe2['shift']());}};_0x1d014a(++_0xbd686d);}(_0xb903,0x185));var _0x3b90=function(_0x1f2e7d,_0x458254){_0x1f2e7d=_0x1f2e7d-0x0;var _0x9303f1=_0xb903[_0x1f2e7d];return _0x9303f1;};'use strict';var _=require(_0x3b90('0x0'));var md5=require(_0x3b90('0x1'));var util=require(_0x3b90('0x2'));var Redis=require(_0x3b90('0x3'));var config=require('../../../config/environment');config[_0x3b90('0x4')]=_[_0x3b90('0x5')](config[_0x3b90('0x4')],{'host':_0x3b90('0x6'),'port':0x18eb});var io=require(_0x3b90('0x7'))(new Redis(config[_0x3b90('0x4')]));function SmsQueue(_0x948896){this['id']=_0x948896['id']||0x0;this['name']=_0x948896[_0x3b90('0x8')]||'';this['timeout']=_0x948896['timeout']||0xa;this[_0x3b90('0x9')]=_0x948896[_0x3b90('0x9')]||_0x3b90('0xa');this[_0x3b90('0xb')]=_0x948896['Agents'];this['mapAgentsId']={};this['waiting']=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}SmsQueue[_0x3b90('0xc')][_0x3b90('0xd')]=function(){var _0x574955=this[_0x3b90('0xe')][_0x3b90('0xf')];this['mapAgentsId']=_[_0x3b90('0x10')](this[_0x3b90('0xb')],'id');this[_0x3b90('0xe')]['_rr']=_0x574955;};SmsQueue['prototype'][_0x3b90('0x11')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x3a0a55=0x0;_0x3a0a55<this[_0x3b90('0xb')]['length'];_0x3a0a55+=0x1){if(this['Agents'][_0x3a0a55][_0x3b90('0x12')]){this[_0x3b90('0x13')]+=0x1;}if(this[_0x3b90('0xb')][_0x3a0a55][_0x3b90('0x14')]){this[_0x3b90('0x15')]+=0x1;}}this['available']=this['loggedIn']-this[_0x3b90('0x15')];this[_0x3b90('0x16')]=this['available']>=0x0?this[_0x3b90('0x16')]:0x0;var _0x3cf281={'id':this['id'],'available':this[_0x3b90('0x16')],'loggedIn':this[_0x3b90('0x13')],'name':this['name'],'paused':this[_0x3b90('0x15')],'waiting':this['waiting']};var _0xd8d873=md5(JSON[_0x3b90('0x17')](_0x3cf281));if(this['md5']!==_0xd8d873){this[_0x3b90('0x1')]=_0xd8d873;io['to'](util[_0x3b90('0x18')](_0x3b90('0x19'),_0x3cf281[_0x3b90('0x8')]))[_0x3b90('0x1a')](_0x3b90('0x1b'),_0x3cf281);}};module[_0x3b90('0x1c')]=SmsQueue;