20a57e4b49f86dbac399238b388af863a405acdc
[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 _0xfa2f=['loggedIn','smsPause','paused','available','stringify','format','sms:queue:%s','sms_queue:save','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRealtime','_rr','map','prototype','length','online'];(function(_0x50c211,_0x50933a){var _0x5408a3=function(_0x10e425){while(--_0x10e425){_0x50c211['push'](_0x50c211['shift']());}};_0x5408a3(++_0x50933a);}(_0xfa2f,0xe8));var _0xffa2=function(_0x348db8,_0x2a84a6){_0x348db8=_0x348db8-0x0;var _0x14bec4=_0xfa2f[_0x348db8];return _0x14bec4;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xffa2('0x0'));var Redis=require('ioredis');var config=require(_0xffa2('0x1'));config[_0xffa2('0x2')]=_[_0xffa2('0x3')](config['redis'],{'host':_0xffa2('0x4'),'port':0x18eb});var io=require(_0xffa2('0x5'))(new Redis(config[_0xffa2('0x2')]));function SmsQueue(_0x14787c){this['id']=_0x14787c['id']||0x0;this[_0xffa2('0x6')]=_0x14787c[_0xffa2('0x6')]||'';this[_0xffa2('0x7')]=_0x14787c['timeout']||0xa;this['strategy']=_0x14787c[_0xffa2('0x8')]||_0xffa2('0x9');this[_0xffa2('0xa')]=_0x14787c[_0xffa2('0xa')];this[_0xffa2('0xb')]={};this[_0xffa2('0xc')]=0x0;this[_0xffa2('0xd')]='';this['updateRouting']();this[_0xffa2('0xe')]();}SmsQueue['prototype']['updateRouting']=function(){var _0x2eb5bb=this[_0xffa2('0xb')][_0xffa2('0xf')];this[_0xffa2('0xb')]=_[_0xffa2('0x10')](this['Agents'],'id');this[_0xffa2('0xb')][_0xffa2('0xf')]=_0x2eb5bb;};SmsQueue[_0xffa2('0x11')][_0xffa2('0xe')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x32e54e=0x0;_0x32e54e<this[_0xffa2('0xa')][_0xffa2('0x12')];_0x32e54e+=0x1){if(this['Agents'][_0x32e54e][_0xffa2('0x13')]){this[_0xffa2('0x14')]+=0x1;}if(this[_0xffa2('0xa')][_0x32e54e][_0xffa2('0x15')]){this[_0xffa2('0x16')]+=0x1;}}this[_0xffa2('0x17')]=this[_0xffa2('0x14')]-this['paused'];this[_0xffa2('0x17')]=this[_0xffa2('0x17')]>=0x0?this[_0xffa2('0x17')]:0x0;var _0x2ae03f={'id':this['id'],'available':this[_0xffa2('0x17')],'loggedIn':this[_0xffa2('0x14')],'name':this[_0xffa2('0x6')],'paused':this[_0xffa2('0x16')],'waiting':this[_0xffa2('0xc')]};var _0xc10cfb=md5(JSON[_0xffa2('0x18')](_0x2ae03f));if(this[_0xffa2('0xd')]!==_0xc10cfb){this['md5']=_0xc10cfb;io['to'](util[_0xffa2('0x19')](_0xffa2('0x1a'),_0x2ae03f[_0xffa2('0x6')]))['emit'](_0xffa2('0x1b'),_0x2ae03f);}};module['exports']=SmsQueue;