Built motion from commit 896e83a8.|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 _0x0212=['exports','lodash','md5','util','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','prototype','loggedIn','length','faxPause','available','paused','format','fax:queue:%s','fax_queue:save'];(function(_0x5a9c0c,_0x4ec485){var _0x53c77d=function(_0x1cf384){while(--_0x1cf384){_0x5a9c0c['push'](_0x5a9c0c['shift']());}};_0x53c77d(++_0x4ec485);}(_0x0212,0xfd));var _0x2021=function(_0x53a7f3,_0x102923){_0x53a7f3=_0x53a7f3-0x0;var _0x5e8e66=_0x0212[_0x53a7f3];return _0x5e8e66;};'use strict';var _=require(_0x2021('0x0'));var md5=require(_0x2021('0x1'));var util=require(_0x2021('0x2'));var Redis=require('ioredis');var config=require(_0x2021('0x3'));config[_0x2021('0x4')]=_[_0x2021('0x5')](config[_0x2021('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x2021('0x6'))(new Redis(config[_0x2021('0x4')]));function FaxQueue(_0x3004db){this['id']=_0x3004db['id']||0x0;this['name']=_0x3004db[_0x2021('0x7')]||'';this[_0x2021('0x8')]=_0x3004db[_0x2021('0x8')]||0xa;this['strategy']=_0x3004db[_0x2021('0x9')]||_0x2021('0xa');this['Agents']=_0x3004db[_0x2021('0xb')];this[_0x2021('0xc')]={};this[_0x2021('0xd')]=0x0;this[_0x2021('0x1')]='';this[_0x2021('0xe')]();this[_0x2021('0xf')]();}FaxQueue['prototype'][_0x2021('0xe')]=function(){var _0x46c848=this[_0x2021('0xc')][_0x2021('0x10')];this[_0x2021('0xc')]=_[_0x2021('0x11')](this[_0x2021('0xb')],'id');this['mapAgentsId']['_rr']=_0x46c848;};FaxQueue[_0x2021('0x12')]['updateRealtime']=function(){this[_0x2021('0x13')]=0x0;this['paused']=0x0;for(var _0x5dd753=0x0;_0x5dd753<this[_0x2021('0xb')][_0x2021('0x14')];_0x5dd753+=0x1){if(this['Agents'][_0x5dd753]['online']){this[_0x2021('0x13')]+=0x1;}if(this['Agents'][_0x5dd753][_0x2021('0x15')]){this['paused']+=0x1;}}this[_0x2021('0x16')]=this[_0x2021('0x13')]-this[_0x2021('0x17')];this['available']=this[_0x2021('0x16')]>=0x0?this[_0x2021('0x16')]:0x0;var _0x4def85={'id':this['id'],'available':this[_0x2021('0x16')],'loggedIn':this[_0x2021('0x13')],'name':this[_0x2021('0x7')],'paused':this[_0x2021('0x17')],'waiting':this[_0x2021('0xd')]};var _0x2bbf41=md5(JSON['stringify'](_0x4def85));if(this['md5']!==_0x2bbf41){this[_0x2021('0x1')]=_0x2bbf41;io['to'](util[_0x2021('0x18')](_0x2021('0x19'),_0x4def85[_0x2021('0x7')]))['emit'](_0x2021('0x1a'),_0x4def85);}};module[_0x2021('0x1b')]=FaxQueue;