Built motion from commit (unavailable).|2.2.4
[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 _0xe32d=['ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','map','prototype','loggedIn','paused','smsPause','available','stringify','emit','sms_queue:save','lodash','md5','util'];(function(_0x1d24eb,_0x12295b){var _0x1dc576=function(_0x4d5770){while(--_0x4d5770){_0x1d24eb['push'](_0x1d24eb['shift']());}};_0x1dc576(++_0x12295b);}(_0xe32d,0xf9));var _0xde32=function(_0x1e89d4,_0x2cc37d){_0x1e89d4=_0x1e89d4-0x0;var _0x171c4c=_0xe32d[_0x1e89d4];return _0x171c4c;};'use strict';var _=require(_0xde32('0x0'));var md5=require(_0xde32('0x1'));var util=require(_0xde32('0x2'));var Redis=require(_0xde32('0x3'));var config=require(_0xde32('0x4'));config[_0xde32('0x5')]=_[_0xde32('0x6')](config[_0xde32('0x5')],{'host':_0xde32('0x7'),'port':0x18eb});var io=require(_0xde32('0x8'))(new Redis(config['redis']));function SmsQueue(_0x3c5ab8){this['id']=_0x3c5ab8['id']||0x0;this[_0xde32('0x9')]=_0x3c5ab8[_0xde32('0x9')]||'';this['timeout']=_0x3c5ab8[_0xde32('0xa')]||0xa;this[_0xde32('0xb')]=_0x3c5ab8[_0xde32('0xb')]||_0xde32('0xc');this[_0xde32('0xd')]=_0x3c5ab8['Agents'];this['mapAgentsId']={};this[_0xde32('0xe')]=0x0;this[_0xde32('0x1')]='';this[_0xde32('0xf')]();this[_0xde32('0x10')]();}SmsQueue['prototype']['updateRouting']=function(){var _0x548ef6=this[_0xde32('0x11')][_0xde32('0x12')];this[_0xde32('0x11')]=_[_0xde32('0x13')](this['Agents'],'id');this[_0xde32('0x11')][_0xde32('0x12')]=_0x548ef6;};SmsQueue[_0xde32('0x14')][_0xde32('0x10')]=function(){this[_0xde32('0x15')]=0x0;this[_0xde32('0x16')]=0x0;for(var _0xda0e86=0x0;_0xda0e86<this[_0xde32('0xd')]['length'];_0xda0e86+=0x1){if(this[_0xde32('0xd')][_0xda0e86]['online']){this['loggedIn']+=0x1;}if(this[_0xde32('0xd')][_0xda0e86][_0xde32('0x17')]){this['paused']+=0x1;}}this[_0xde32('0x18')]=this[_0xde32('0x15')]-this[_0xde32('0x16')];this[_0xde32('0x18')]=this['available']>=0x0?this[_0xde32('0x18')]:0x0;var _0x3c5c6f={'id':this['id'],'available':this[_0xde32('0x18')],'loggedIn':this[_0xde32('0x15')],'name':this['name'],'paused':this['paused'],'waiting':this[_0xde32('0xe')]};var _0x31bfd8=md5(JSON[_0xde32('0x19')](_0x3c5c6f));if(this['md5']!==_0x31bfd8){this[_0xde32('0x1')]=_0x31bfd8;io['to'](util['format']('sms:queue:%s',_0x3c5c6f[_0xde32('0x9')]))[_0xde32('0x1a')](_0xde32('0x1b'),_0x3c5c6f);}};module['exports']=SmsQueue;