e7381a4bbe21a41284bdb46223563fa40db6c711
[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 _0x5ad3=['sms_queue:save','exports','lodash','md5','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','updateRouting','prototype','_rr','mapAgentsId','updateRealtime','loggedIn','paused','length','online','smsPause','available','stringify','format','sms:queue:%s','emit'];(function(_0x594bdb,_0x5b42a9){var _0x7f732a=function(_0x125461){while(--_0x125461){_0x594bdb['push'](_0x594bdb['shift']());}};_0x7f732a(++_0x5b42a9);}(_0x5ad3,0x1e2));var _0x35ad=function(_0x14a4d0,_0x4c7068){_0x14a4d0=_0x14a4d0-0x0;var _0x18c8ab=_0x5ad3[_0x14a4d0];return _0x18c8ab;};'use strict';var _=require(_0x35ad('0x0'));var md5=require(_0x35ad('0x1'));var util=require(_0x35ad('0x2'));var Redis=require(_0x35ad('0x3'));var config=require('../../../config/environment');config[_0x35ad('0x4')]=_[_0x35ad('0x5')](config[_0x35ad('0x4')],{'host':_0x35ad('0x6'),'port':0x18eb});var io=require(_0x35ad('0x7'))(new Redis(config[_0x35ad('0x4')]));function SmsQueue(_0x729a01){this['id']=_0x729a01['id']||0x0;this[_0x35ad('0x8')]=_0x729a01[_0x35ad('0x8')]||'';this[_0x35ad('0x9')]=_0x729a01['timeout']||0xa;this[_0x35ad('0xa')]=_0x729a01[_0x35ad('0xa')]||_0x35ad('0xb');this['Agents']=_0x729a01[_0x35ad('0xc')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x35ad('0x1')]='';this[_0x35ad('0xd')]();this['updateRealtime']();}SmsQueue[_0x35ad('0xe')][_0x35ad('0xd')]=function(){var _0x4ad760=this['mapAgentsId'][_0x35ad('0xf')];this[_0x35ad('0x10')]=_['map'](this[_0x35ad('0xc')],'id');this[_0x35ad('0x10')]['_rr']=_0x4ad760;};SmsQueue['prototype'][_0x35ad('0x11')]=function(){this[_0x35ad('0x12')]=0x0;this[_0x35ad('0x13')]=0x0;for(var _0x4b7ad9=0x0;_0x4b7ad9<this[_0x35ad('0xc')][_0x35ad('0x14')];_0x4b7ad9+=0x1){if(this['Agents'][_0x4b7ad9][_0x35ad('0x15')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x4b7ad9][_0x35ad('0x16')]){this[_0x35ad('0x13')]+=0x1;}}this[_0x35ad('0x17')]=this['loggedIn']-this[_0x35ad('0x13')];this[_0x35ad('0x17')]=this[_0x35ad('0x17')]>=0x0?this[_0x35ad('0x17')]:0x0;var _0x3a73c8={'id':this['id'],'available':this[_0x35ad('0x17')],'loggedIn':this['loggedIn'],'name':this[_0x35ad('0x8')],'paused':this[_0x35ad('0x13')],'waiting':this['waiting']};var _0x53b8e3=md5(JSON[_0x35ad('0x18')](_0x3a73c8));if(this[_0x35ad('0x1')]!==_0x53b8e3){this['md5']=_0x53b8e3;io['to'](util[_0x35ad('0x19')](_0x35ad('0x1a'),_0x3a73c8['name']))[_0x35ad('0x1b')](_0x35ad('0x1c'),_0x3a73c8);}};module[_0x35ad('0x1d')]=SmsQueue;