Built motion from commit e6806ed6.|2.6.0
[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 _0x2ce1=['../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','prototype','map','_rr','loggedIn','length','online','smsPause','paused','available','format','emit','sms_queue:save','exports','ioredis'];(function(_0x3cf5a3,_0x5a4492){var _0x39ba2d=function(_0x3ed989){while(--_0x3ed989){_0x3cf5a3['push'](_0x3cf5a3['shift']());}};_0x39ba2d(++_0x5a4492);}(_0x2ce1,0x8b));var _0x12ce=function(_0x5e1213,_0x3b87df){_0x5e1213=_0x5e1213-0x0;var _0x59d66f=_0x2ce1[_0x5e1213];return _0x59d66f;};'use strict';var _=require('lodash');var md5=require('md5');var util=require('util');var Redis=require(_0x12ce('0x0'));var config=require(_0x12ce('0x1'));config[_0x12ce('0x2')]=_[_0x12ce('0x3')](config['redis'],{'host':_0x12ce('0x4'),'port':0x18eb});var io=require(_0x12ce('0x5'))(new Redis(config['redis']));function SmsQueue(_0xf5b373){this['id']=_0xf5b373['id']||0x0;this[_0x12ce('0x6')]=_0xf5b373[_0x12ce('0x6')]||'';this['timeout']=_0xf5b373[_0x12ce('0x7')]||0xa;this['strategy']=_0xf5b373[_0x12ce('0x8')]||_0x12ce('0x9');this[_0x12ce('0xa')]=_0xf5b373['Agents'];this[_0x12ce('0xb')]={};this[_0x12ce('0xc')]=0x0;this[_0x12ce('0xd')]='';this[_0x12ce('0xe')]();this['updateRealtime']();}SmsQueue[_0x12ce('0xf')]['updateRouting']=function(){var _0x3a3d4d=this['mapAgentsId']['_rr'];this[_0x12ce('0xb')]=_[_0x12ce('0x10')](this[_0x12ce('0xa')],'id');this[_0x12ce('0xb')][_0x12ce('0x11')]=_0x3a3d4d;};SmsQueue[_0x12ce('0xf')]['updateRealtime']=function(){this[_0x12ce('0x12')]=0x0;this['paused']=0x0;for(var _0x12bcf2=0x0;_0x12bcf2<this[_0x12ce('0xa')][_0x12ce('0x13')];_0x12bcf2+=0x1){if(this['Agents'][_0x12bcf2][_0x12ce('0x14')]){this[_0x12ce('0x12')]+=0x1;}if(this[_0x12ce('0xa')][_0x12bcf2][_0x12ce('0x15')]){this[_0x12ce('0x16')]+=0x1;}}this[_0x12ce('0x17')]=this['loggedIn']-this['paused'];this[_0x12ce('0x17')]=this['available']>=0x0?this[_0x12ce('0x17')]:0x0;var _0x2a0f3f={'id':this['id'],'available':this['available'],'loggedIn':this[_0x12ce('0x12')],'name':this['name'],'paused':this[_0x12ce('0x16')],'waiting':this['waiting']};var _0xe24a11=md5(JSON['stringify'](_0x2a0f3f));if(this[_0x12ce('0xd')]!==_0xe24a11){this['md5']=_0xe24a11;io['to'](util[_0x12ce('0x18')]('sms:queue:%s',_0x2a0f3f['name']))[_0x12ce('0x19')](_0x12ce('0x1a'),_0x2a0f3f);}};module[_0x12ce('0x1b')]=SmsQueue;