194585a7307ec814314f90ffad4ef666974a0271
[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 _0x7764=['updateRealtime','prototype','_rr','map','paused','length','online','loggedIn','smsPause','available','stringify','sms:queue:%s','emit','sms_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting'];(function(_0x12fc36,_0x6530d3){var _0x55c667=function(_0x39ed70){while(--_0x39ed70){_0x12fc36['push'](_0x12fc36['shift']());}};_0x55c667(++_0x6530d3);}(_0x7764,0xa4));var _0x4776=function(_0x221ba2,_0x79208){_0x221ba2=_0x221ba2-0x0;var _0x47d08e=_0x7764[_0x221ba2];return _0x47d08e;};'use strict';var _=require(_0x4776('0x0'));var md5=require(_0x4776('0x1'));var util=require(_0x4776('0x2'));var Redis=require(_0x4776('0x3'));var config=require(_0x4776('0x4'));config[_0x4776('0x5')]=_[_0x4776('0x6')](config[_0x4776('0x5')],{'host':_0x4776('0x7'),'port':0x18eb});var io=require(_0x4776('0x8'))(new Redis(config['redis']));function SmsQueue(_0x5a1e38){this['id']=_0x5a1e38['id']||0x0;this[_0x4776('0x9')]=_0x5a1e38[_0x4776('0x9')]||'';this['timeout']=_0x5a1e38[_0x4776('0xa')]||0xa;this[_0x4776('0xb')]=_0x5a1e38['strategy']||'beepall';this[_0x4776('0xc')]=_0x5a1e38['Agents'];this[_0x4776('0xd')]={};this[_0x4776('0xe')]=0x0;this[_0x4776('0x1')]='';this[_0x4776('0xf')]();this[_0x4776('0x10')]();}SmsQueue[_0x4776('0x11')][_0x4776('0xf')]=function(){var _0x3fb889=this[_0x4776('0xd')][_0x4776('0x12')];this[_0x4776('0xd')]=_[_0x4776('0x13')](this[_0x4776('0xc')],'id');this[_0x4776('0xd')][_0x4776('0x12')]=_0x3fb889;};SmsQueue[_0x4776('0x11')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x4776('0x14')]=0x0;for(var _0x46429e=0x0;_0x46429e<this[_0x4776('0xc')][_0x4776('0x15')];_0x46429e+=0x1){if(this[_0x4776('0xc')][_0x46429e][_0x4776('0x16')]){this[_0x4776('0x17')]+=0x1;}if(this[_0x4776('0xc')][_0x46429e][_0x4776('0x18')]){this[_0x4776('0x14')]+=0x1;}}this['available']=this[_0x4776('0x17')]-this['paused'];this[_0x4776('0x19')]=this[_0x4776('0x19')]>=0x0?this[_0x4776('0x19')]:0x0;var _0xed81b5={'id':this['id'],'available':this[_0x4776('0x19')],'loggedIn':this['loggedIn'],'name':this[_0x4776('0x9')],'paused':this[_0x4776('0x14')],'waiting':this['waiting']};var _0x3659fa=md5(JSON[_0x4776('0x1a')](_0xed81b5));if(this[_0x4776('0x1')]!==_0x3659fa){this[_0x4776('0x1')]=_0x3659fa;io['to'](util['format'](_0x4776('0x1b'),_0xed81b5[_0x4776('0x9')]))[_0x4776('0x1c')](_0x4776('0x1d'),_0xed81b5);}};module['exports']=SmsQueue;