Built motion from commit 5293bb2a.|2.6.30
[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 _0x0c16=['available','paused','stringify','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','loggedIn','length','online','faxPause'];(function(_0x2cdf7b,_0x5c2075){var _0x1b25f9=function(_0x5cd30d){while(--_0x5cd30d){_0x2cdf7b['push'](_0x2cdf7b['shift']());}};_0x1b25f9(++_0x5c2075);}(_0x0c16,0x164));var _0x60c1=function(_0x49fe8d,_0x44ab0f){_0x49fe8d=_0x49fe8d-0x0;var _0x23e887=_0x0c16[_0x49fe8d];return _0x23e887;};'use strict';var _=require(_0x60c1('0x0'));var md5=require(_0x60c1('0x1'));var util=require('util');var Redis=require(_0x60c1('0x2'));var config=require(_0x60c1('0x3'));config[_0x60c1('0x4')]=_[_0x60c1('0x5')](config['redis'],{'host':_0x60c1('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function FaxQueue(_0x902132){this['id']=_0x902132['id']||0x0;this['name']=_0x902132[_0x60c1('0x7')]||'';this[_0x60c1('0x8')]=_0x902132[_0x60c1('0x8')]||0xa;this[_0x60c1('0x9')]=_0x902132['strategy']||_0x60c1('0xa');this[_0x60c1('0xb')]=_0x902132[_0x60c1('0xb')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x60c1('0x1')]='';this[_0x60c1('0xc')]();this[_0x60c1('0xd')]();}FaxQueue[_0x60c1('0xe')]['updateRouting']=function(){var _0x41cec6=this[_0x60c1('0xf')][_0x60c1('0x10')];this['mapAgentsId']=_['map'](this[_0x60c1('0xb')],'id');this[_0x60c1('0xf')][_0x60c1('0x10')]=_0x41cec6;};FaxQueue[_0x60c1('0xe')][_0x60c1('0xd')]=function(){this[_0x60c1('0x11')]=0x0;this['paused']=0x0;for(var _0x502649=0x0;_0x502649<this[_0x60c1('0xb')][_0x60c1('0x12')];_0x502649+=0x1){if(this['Agents'][_0x502649][_0x60c1('0x13')]){this[_0x60c1('0x11')]+=0x1;}if(this[_0x60c1('0xb')][_0x502649][_0x60c1('0x14')]){this['paused']+=0x1;}}this[_0x60c1('0x15')]=this[_0x60c1('0x11')]-this['paused'];this[_0x60c1('0x15')]=this['available']>=0x0?this[_0x60c1('0x15')]:0x0;var _0x1e8756={'id':this['id'],'available':this[_0x60c1('0x15')],'loggedIn':this[_0x60c1('0x11')],'name':this[_0x60c1('0x7')],'paused':this[_0x60c1('0x16')],'waiting':this['waiting']};var _0x43876a=md5(JSON[_0x60c1('0x17')](_0x1e8756));if(this['md5']!==_0x43876a){this[_0x60c1('0x1')]=_0x43876a;io['to'](util[_0x60c1('0x18')](_0x60c1('0x19'),_0x1e8756[_0x60c1('0x7')]))[_0x60c1('0x1a')](_0x60c1('0x1b'),_0x1e8756);}};module[_0x60c1('0x1c')]=FaxQueue;