98487869ab44dac4678903c5859891e1b4f23f90
[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 _0xb49a=['loggedIn','paused','online','smsPause','available','sms:queue:%s','emit','sms_queue:save','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','map','_rr'];(function(_0x3d8681,_0x759ee6){var _0x3063f3=function(_0x15ec3d){while(--_0x15ec3d){_0x3d8681['push'](_0x3d8681['shift']());}};_0x3063f3(++_0x759ee6);}(_0xb49a,0xfb));var _0xab49=function(_0x1d6a12,_0x49b3d3){_0x1d6a12=_0x1d6a12-0x0;var _0x3a79ca=_0xb49a[_0x1d6a12];return _0x3a79ca;};'use strict';var _=require(_0xab49('0x0'));var md5=require(_0xab49('0x1'));var util=require(_0xab49('0x2'));var Redis=require(_0xab49('0x3'));var config=require(_0xab49('0x4'));config['redis']=_[_0xab49('0x5')](config[_0xab49('0x6')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xab49('0x6')]));function SmsQueue(_0x287cd5){this['id']=_0x287cd5['id']||0x0;this[_0xab49('0x7')]=_0x287cd5[_0xab49('0x7')]||'';this[_0xab49('0x8')]=_0x287cd5[_0xab49('0x8')]||0xa;this[_0xab49('0x9')]=_0x287cd5['strategy']||_0xab49('0xa');this[_0xab49('0xb')]=_0x287cd5[_0xab49('0xb')];this[_0xab49('0xc')]={};this[_0xab49('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0xab49('0xe')]();}SmsQueue[_0xab49('0xf')][_0xab49('0x10')]=function(){var _0x126f00=this[_0xab49('0xc')]['_rr'];this[_0xab49('0xc')]=_[_0xab49('0x11')](this[_0xab49('0xb')],'id');this[_0xab49('0xc')][_0xab49('0x12')]=_0x126f00;};SmsQueue[_0xab49('0xf')][_0xab49('0xe')]=function(){this[_0xab49('0x13')]=0x0;this[_0xab49('0x14')]=0x0;for(var _0x389ebb=0x0;_0x389ebb<this[_0xab49('0xb')]['length'];_0x389ebb+=0x1){if(this[_0xab49('0xb')][_0x389ebb][_0xab49('0x15')]){this[_0xab49('0x13')]+=0x1;}if(this[_0xab49('0xb')][_0x389ebb][_0xab49('0x16')]){this['paused']+=0x1;}}this[_0xab49('0x17')]=this[_0xab49('0x13')]-this[_0xab49('0x14')];this[_0xab49('0x17')]=this[_0xab49('0x17')]>=0x0?this['available']:0x0;var _0x167a2a={'id':this['id'],'available':this[_0xab49('0x17')],'loggedIn':this[_0xab49('0x13')],'name':this['name'],'paused':this['paused'],'waiting':this[_0xab49('0xd')]};var _0xa039ed=md5(JSON['stringify'](_0x167a2a));if(this[_0xab49('0x1')]!==_0xa039ed){this[_0xab49('0x1')]=_0xa039ed;io['to'](util['format'](_0xab49('0x18'),_0x167a2a['name']))[_0xab49('0x19')](_0xab49('0x1a'),_0x167a2a);}};module['exports']=SmsQueue;