0167527a88a39c923d7ef5248eea2f78dc95f7ea
[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 _0x7bae=['Agents','waiting','md5','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','paused','length','online','available','stringify','format','emit','exports','util','ioredis','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x5d79a4,_0x2ea791){var _0x3c947b=function(_0x782d2f){while(--_0x782d2f){_0x5d79a4['push'](_0x5d79a4['shift']());}};_0x3c947b(++_0x2ea791);}(_0x7bae,0x13b));var _0xe7ba=function(_0x3826ad,_0x49a30d){_0x3826ad=_0x3826ad-0x0;var _0x17b900=_0x7bae[_0x3826ad];return _0x17b900;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xe7ba('0x0'));var Redis=require(_0xe7ba('0x1'));var config=require('../../../config/environment');config[_0xe7ba('0x2')]=_['defaults'](config[_0xe7ba('0x2')],{'host':_0xe7ba('0x3'),'port':0x18eb});var io=require(_0xe7ba('0x4'))(new Redis(config[_0xe7ba('0x2')]));function SmsQueue(_0x398a6a){this['id']=_0x398a6a['id']||0x0;this[_0xe7ba('0x5')]=_0x398a6a[_0xe7ba('0x5')]||'';this[_0xe7ba('0x6')]=_0x398a6a[_0xe7ba('0x6')]||0xa;this[_0xe7ba('0x7')]=_0x398a6a[_0xe7ba('0x7')]||_0xe7ba('0x8');this[_0xe7ba('0x9')]=_0x398a6a[_0xe7ba('0x9')];this['mapAgentsId']={};this[_0xe7ba('0xa')]=0x0;this[_0xe7ba('0xb')]='';this[_0xe7ba('0xc')]();this[_0xe7ba('0xd')]();}SmsQueue[_0xe7ba('0xe')][_0xe7ba('0xc')]=function(){var _0x99a86f=this[_0xe7ba('0xf')][_0xe7ba('0x10')];this['mapAgentsId']=_[_0xe7ba('0x11')](this['Agents'],'id');this[_0xe7ba('0xf')][_0xe7ba('0x10')]=_0x99a86f;};SmsQueue[_0xe7ba('0xe')][_0xe7ba('0xd')]=function(){this[_0xe7ba('0x12')]=0x0;this[_0xe7ba('0x13')]=0x0;for(var _0x561dbb=0x0;_0x561dbb<this['Agents'][_0xe7ba('0x14')];_0x561dbb+=0x1){if(this[_0xe7ba('0x9')][_0x561dbb][_0xe7ba('0x15')]){this['loggedIn']+=0x1;}if(this[_0xe7ba('0x9')][_0x561dbb]['smsPause']){this['paused']+=0x1;}}this['available']=this[_0xe7ba('0x12')]-this['paused'];this[_0xe7ba('0x16')]=this['available']>=0x0?this['available']:0x0;var _0x5a82b5={'id':this['id'],'available':this[_0xe7ba('0x16')],'loggedIn':this[_0xe7ba('0x12')],'name':this[_0xe7ba('0x5')],'paused':this[_0xe7ba('0x13')],'waiting':this[_0xe7ba('0xa')]};var _0x58550c=md5(JSON[_0xe7ba('0x17')](_0x5a82b5));if(this[_0xe7ba('0xb')]!==_0x58550c){this[_0xe7ba('0xb')]=_0x58550c;io['to'](util[_0xe7ba('0x18')]('sms:queue:%s',_0x5a82b5[_0xe7ba('0x5')]))[_0xe7ba('0x19')]('sms_queue:save',_0x5a82b5);}};module[_0xe7ba('0x1a')]=SmsQueue;