Built motion from commit 6362bb75.|2.6.13
[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 _0xc3d6=['exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','map','_rr','prototype','loggedIn','length','online','paused','available','stringify','format','emit','fax_queue:save'];(function(_0x15eb4e,_0x2ebb6d){var _0x5146fc=function(_0x3152ae){while(--_0x3152ae){_0x15eb4e['push'](_0x15eb4e['shift']());}};_0x5146fc(++_0x2ebb6d);}(_0xc3d6,0x106));var _0x6c3d=function(_0x4a4dd7,_0x3b0452){_0x4a4dd7=_0x4a4dd7-0x0;var _0x17e912=_0xc3d6[_0x4a4dd7];return _0x17e912;};'use strict';var _=require('lodash');var md5=require(_0x6c3d('0x0'));var util=require(_0x6c3d('0x1'));var Redis=require(_0x6c3d('0x2'));var config=require(_0x6c3d('0x3'));config[_0x6c3d('0x4')]=_[_0x6c3d('0x5')](config['redis'],{'host':_0x6c3d('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6c3d('0x4')]));function FaxQueue(_0x3b8880){this['id']=_0x3b8880['id']||0x0;this['name']=_0x3b8880[_0x6c3d('0x7')]||'';this['timeout']=_0x3b8880[_0x6c3d('0x8')]||0xa;this[_0x6c3d('0x9')]=_0x3b8880[_0x6c3d('0x9')]||_0x6c3d('0xa');this[_0x6c3d('0xb')]=_0x3b8880['Agents'];this[_0x6c3d('0xc')]={};this[_0x6c3d('0xd')]=0x0;this['md5']='';this[_0x6c3d('0xe')]();this[_0x6c3d('0xf')]();}FaxQueue['prototype'][_0x6c3d('0xe')]=function(){var _0x16659c=this[_0x6c3d('0xc')]['_rr'];this[_0x6c3d('0xc')]=_[_0x6c3d('0x10')](this[_0x6c3d('0xb')],'id');this[_0x6c3d('0xc')][_0x6c3d('0x11')]=_0x16659c;};FaxQueue[_0x6c3d('0x12')][_0x6c3d('0xf')]=function(){this[_0x6c3d('0x13')]=0x0;this['paused']=0x0;for(var _0x43d480=0x0;_0x43d480<this[_0x6c3d('0xb')][_0x6c3d('0x14')];_0x43d480+=0x1){if(this[_0x6c3d('0xb')][_0x43d480][_0x6c3d('0x15')]){this[_0x6c3d('0x13')]+=0x1;}if(this[_0x6c3d('0xb')][_0x43d480]['faxPause']){this[_0x6c3d('0x16')]+=0x1;}}this[_0x6c3d('0x17')]=this[_0x6c3d('0x13')]-this[_0x6c3d('0x16')];this[_0x6c3d('0x17')]=this[_0x6c3d('0x17')]>=0x0?this['available']:0x0;var _0x502933={'id':this['id'],'available':this[_0x6c3d('0x17')],'loggedIn':this[_0x6c3d('0x13')],'name':this[_0x6c3d('0x7')],'paused':this[_0x6c3d('0x16')],'waiting':this[_0x6c3d('0xd')]};var _0xd285af=md5(JSON[_0x6c3d('0x18')](_0x502933));if(this[_0x6c3d('0x0')]!==_0xd285af){this[_0x6c3d('0x0')]=_0xd285af;io['to'](util[_0x6c3d('0x19')]('fax:queue:%s',_0x502933[_0x6c3d('0x7')]))[_0x6c3d('0x1a')](_0x6c3d('0x1b'),_0x502933);}};module[_0x6c3d('0x1c')]=FaxQueue;