9321f67c7915116bf385f27231c2cabae9844870
[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 _0x8a55=['updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','online','smsPause','paused','available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting'];(function(_0x2e914,_0x1c7566){var _0x936e45=function(_0x1b22e4){while(--_0x1b22e4){_0x2e914['push'](_0x2e914['shift']());}};_0x936e45(++_0x1c7566);}(_0x8a55,0x185));var _0x58a5=function(_0x59c94d,_0x5c7f5f){_0x59c94d=_0x59c94d-0x0;var _0x369e14=_0x8a55[_0x59c94d];return _0x369e14;};'use strict';var _=require(_0x58a5('0x0'));var md5=require(_0x58a5('0x1'));var util=require(_0x58a5('0x2'));var Redis=require(_0x58a5('0x3'));var config=require(_0x58a5('0x4'));config[_0x58a5('0x5')]=_[_0x58a5('0x6')](config[_0x58a5('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x58a5('0x7'))(new Redis(config[_0x58a5('0x5')]));function SmsQueue(_0x4e2752){this['id']=_0x4e2752['id']||0x0;this[_0x58a5('0x8')]=_0x4e2752[_0x58a5('0x8')]||'';this[_0x58a5('0x9')]=_0x4e2752[_0x58a5('0x9')]||0xa;this[_0x58a5('0xa')]=_0x4e2752[_0x58a5('0xa')]||'beepall';this[_0x58a5('0xb')]=_0x4e2752[_0x58a5('0xb')];this[_0x58a5('0xc')]={};this[_0x58a5('0xd')]=0x0;this[_0x58a5('0x1')]='';this[_0x58a5('0xe')]();this[_0x58a5('0xf')]();}SmsQueue[_0x58a5('0x10')][_0x58a5('0xe')]=function(){var _0x2f6bd9=this[_0x58a5('0xc')][_0x58a5('0x11')];this[_0x58a5('0xc')]=_[_0x58a5('0x12')](this['Agents'],'id');this[_0x58a5('0xc')][_0x58a5('0x11')]=_0x2f6bd9;};SmsQueue[_0x58a5('0x10')][_0x58a5('0xf')]=function(){this[_0x58a5('0x13')]=0x0;this['paused']=0x0;for(var _0x504295=0x0;_0x504295<this[_0x58a5('0xb')][_0x58a5('0x14')];_0x504295+=0x1){if(this[_0x58a5('0xb')][_0x504295][_0x58a5('0x15')]){this[_0x58a5('0x13')]+=0x1;}if(this['Agents'][_0x504295][_0x58a5('0x16')]){this[_0x58a5('0x17')]+=0x1;}}this['available']=this[_0x58a5('0x13')]-this[_0x58a5('0x17')];this['available']=this[_0x58a5('0x18')]>=0x0?this[_0x58a5('0x18')]:0x0;var _0x59c170={'id':this['id'],'available':this['available'],'loggedIn':this[_0x58a5('0x13')],'name':this['name'],'paused':this['paused'],'waiting':this['waiting']};var _0x12abb2=md5(JSON[_0x58a5('0x19')](_0x59c170));if(this['md5']!==_0x12abb2){this[_0x58a5('0x1')]=_0x12abb2;io['to'](util[_0x58a5('0x1a')](_0x58a5('0x1b'),_0x59c170['name']))[_0x58a5('0x1c')](_0x58a5('0x1d'),_0x59c170);}};module[_0x58a5('0x1e')]=SmsQueue;