a7fe54f5186020fe1abdd21bee90a4425197b0b8
[motion2.git] / server / services / routing / model / faxQueue.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 _0x4f00=['strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','_rr','updateRealtime','loggedIn','online','faxPause','paused','available','stringify','format','emit','exports','lodash','ioredis','defaults','localhost','socket.io-emitter','name','timeout'];(function(_0x191483,_0x3303fa){var _0x5763c8=function(_0xfd7dc4){while(--_0xfd7dc4){_0x191483['push'](_0x191483['shift']());}};_0x5763c8(++_0x3303fa);}(_0x4f00,0x8f));var _0x04f0=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x4f00[_0x3bf83f];return _0x22c4a9;};'use strict';var _=require(_0x04f0('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x04f0('0x1'));var config=require('../../../config/environment');config['redis']=_[_0x04f0('0x2')](config['redis'],{'host':_0x04f0('0x3'),'port':0x18eb});var io=require(_0x04f0('0x4'))(new Redis(config['redis']));function FaxQueue(_0xa498c6){this['id']=_0xa498c6['id']||0x0;this[_0x04f0('0x5')]=_0xa498c6['name']||'';this[_0x04f0('0x6')]=_0xa498c6['timeout']||0xa;this[_0x04f0('0x7')]=_0xa498c6['strategy']||_0x04f0('0x8');this[_0x04f0('0x9')]=_0xa498c6['Agents'];this[_0x04f0('0xa')]={};this[_0x04f0('0xb')]=0x0;this[_0x04f0('0xc')]='';this[_0x04f0('0xd')]();this['updateRealtime']();}FaxQueue['prototype'][_0x04f0('0xd')]=function(){var _0x41bf5a=this['mapAgentsId']['_rr'];this[_0x04f0('0xa')]=_['map'](this[_0x04f0('0x9')],'id');this[_0x04f0('0xa')][_0x04f0('0xe')]=_0x41bf5a;};FaxQueue['prototype'][_0x04f0('0xf')]=function(){this[_0x04f0('0x10')]=0x0;this['paused']=0x0;for(var _0x3d15b9=0x0;_0x3d15b9<this[_0x04f0('0x9')]['length'];_0x3d15b9+=0x1){if(this[_0x04f0('0x9')][_0x3d15b9][_0x04f0('0x11')]){this[_0x04f0('0x10')]+=0x1;}if(this['Agents'][_0x3d15b9][_0x04f0('0x12')]){this[_0x04f0('0x13')]+=0x1;}}this[_0x04f0('0x14')]=this['loggedIn']-this[_0x04f0('0x13')];this['available']=this['available']>=0x0?this[_0x04f0('0x14')]:0x0;var _0x343012={'id':this['id'],'available':this[_0x04f0('0x14')],'loggedIn':this[_0x04f0('0x10')],'name':this[_0x04f0('0x5')],'paused':this[_0x04f0('0x13')],'waiting':this['waiting']};var _0x38b1f1=md5(JSON[_0x04f0('0x15')](_0x343012));if(this[_0x04f0('0xc')]!==_0x38b1f1){this[_0x04f0('0xc')]=_0x38b1f1;io['to'](util[_0x04f0('0x16')]('fax:queue:%s',_0x343012[_0x04f0('0x5')]))[_0x04f0('0x17')]('fax_queue:save',_0x343012);}};module[_0x04f0('0x18')]=FaxQueue;