f77093ae8043b3d499948d72ecbccc9e794442a4
[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 _0xc818=['strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','map','_rr','updateRealtime','loggedIn','paused','length','online','smsPause','available','format','emit','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0xe180e7,_0x25b896){var _0x2f6417=function(_0x339004){while(--_0x339004){_0xe180e7['push'](_0xe180e7['shift']());}};_0x2f6417(++_0x25b896);}(_0xc818,0x1e3));var _0x8c81=function(_0x1a2670,_0x330920){_0x1a2670=_0x1a2670-0x0;var _0x553791=_0xc818[_0x1a2670];return _0x553791;};'use strict';var _=require(_0x8c81('0x0'));var md5=require(_0x8c81('0x1'));var util=require(_0x8c81('0x2'));var Redis=require(_0x8c81('0x3'));var config=require('../../../config/environment');config[_0x8c81('0x4')]=_[_0x8c81('0x5')](config[_0x8c81('0x4')],{'host':_0x8c81('0x6'),'port':0x18eb});var io=require(_0x8c81('0x7'))(new Redis(config[_0x8c81('0x4')]));function SmsQueue(_0x377b23){this['id']=_0x377b23['id']||0x0;this['name']=_0x377b23[_0x8c81('0x8')]||'';this[_0x8c81('0x9')]=_0x377b23[_0x8c81('0x9')]||0xa;this[_0x8c81('0xa')]=_0x377b23['strategy']||_0x8c81('0xb');this[_0x8c81('0xc')]=_0x377b23[_0x8c81('0xc')];this[_0x8c81('0xd')]={};this[_0x8c81('0xe')]=0x0;this[_0x8c81('0x1')]='';this[_0x8c81('0xf')]();this['updateRealtime']();}SmsQueue[_0x8c81('0x10')][_0x8c81('0xf')]=function(){var _0x639c8f=this[_0x8c81('0xd')]['_rr'];this[_0x8c81('0xd')]=_[_0x8c81('0x11')](this[_0x8c81('0xc')],'id');this[_0x8c81('0xd')][_0x8c81('0x12')]=_0x639c8f;};SmsQueue[_0x8c81('0x10')][_0x8c81('0x13')]=function(){this[_0x8c81('0x14')]=0x0;this[_0x8c81('0x15')]=0x0;for(var _0x5a6e72=0x0;_0x5a6e72<this['Agents'][_0x8c81('0x16')];_0x5a6e72+=0x1){if(this[_0x8c81('0xc')][_0x5a6e72][_0x8c81('0x17')]){this[_0x8c81('0x14')]+=0x1;}if(this[_0x8c81('0xc')][_0x5a6e72][_0x8c81('0x18')]){this['paused']+=0x1;}}this[_0x8c81('0x19')]=this[_0x8c81('0x14')]-this[_0x8c81('0x15')];this[_0x8c81('0x19')]=this[_0x8c81('0x19')]>=0x0?this['available']:0x0;var _0x31069a={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x8c81('0x15')],'waiting':this[_0x8c81('0xe')]};var _0x2c3da3=md5(JSON['stringify'](_0x31069a));if(this[_0x8c81('0x1')]!==_0x2c3da3){this[_0x8c81('0x1')]=_0x2c3da3;io['to'](util[_0x8c81('0x1a')]('sms:queue:%s',_0x31069a[_0x8c81('0x8')]))[_0x8c81('0x1b')]('sms_queue:save',_0x31069a);}};module[_0x8c81('0x1c')]=SmsQueue;