d0ac765b398d32394adf9113a24e8bc0cec7323b
[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 _0x2d38=['lodash','md5','util','ioredis','../../../config/environment','redis','defaults','name','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','paused','online','available','stringify','format','fax:queue:%s','emit','fax_queue:save'];(function(_0x20d457,_0x260dfb){var _0x4078ca=function(_0x288d2e){while(--_0x288d2e){_0x20d457['push'](_0x20d457['shift']());}};_0x4078ca(++_0x260dfb);}(_0x2d38,0x1b0));var _0x82d3=function(_0x55fc1b,_0x16d022){_0x55fc1b=_0x55fc1b-0x0;var _0x26257d=_0x2d38[_0x55fc1b];return _0x26257d;};'use strict';var _=require(_0x82d3('0x0'));var md5=require(_0x82d3('0x1'));var util=require(_0x82d3('0x2'));var Redis=require(_0x82d3('0x3'));var config=require(_0x82d3('0x4'));config[_0x82d3('0x5')]=_[_0x82d3('0x6')](config[_0x82d3('0x5')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x82d3('0x5')]));function FaxQueue(_0x934918){this['id']=_0x934918['id']||0x0;this[_0x82d3('0x7')]=_0x934918[_0x82d3('0x7')]||'';this['timeout']=_0x934918['timeout']||0xa;this[_0x82d3('0x8')]=_0x934918[_0x82d3('0x8')]||_0x82d3('0x9');this['Agents']=_0x934918[_0x82d3('0xa')];this['mapAgentsId']={};this[_0x82d3('0xb')]=0x0;this[_0x82d3('0x1')]='';this[_0x82d3('0xc')]();this[_0x82d3('0xd')]();}FaxQueue[_0x82d3('0xe')]['updateRouting']=function(){var _0x182167=this[_0x82d3('0xf')][_0x82d3('0x10')];this[_0x82d3('0xf')]=_[_0x82d3('0x11')](this['Agents'],'id');this[_0x82d3('0xf')][_0x82d3('0x10')]=_0x182167;};FaxQueue[_0x82d3('0xe')][_0x82d3('0xd')]=function(){this[_0x82d3('0x12')]=0x0;this[_0x82d3('0x13')]=0x0;for(var _0x5435e2=0x0;_0x5435e2<this['Agents']['length'];_0x5435e2+=0x1){if(this[_0x82d3('0xa')][_0x5435e2][_0x82d3('0x14')]){this['loggedIn']+=0x1;}if(this[_0x82d3('0xa')][_0x5435e2]['faxPause']){this[_0x82d3('0x13')]+=0x1;}}this['available']=this[_0x82d3('0x12')]-this[_0x82d3('0x13')];this[_0x82d3('0x15')]=this[_0x82d3('0x15')]>=0x0?this[_0x82d3('0x15')]:0x0;var _0x37ae7e={'id':this['id'],'available':this[_0x82d3('0x15')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x82d3('0x13')],'waiting':this[_0x82d3('0xb')]};var _0x319472=md5(JSON[_0x82d3('0x16')](_0x37ae7e));if(this[_0x82d3('0x1')]!==_0x319472){this['md5']=_0x319472;io['to'](util[_0x82d3('0x17')](_0x82d3('0x18'),_0x37ae7e['name']))[_0x82d3('0x19')](_0x82d3('0x1a'),_0x37ae7e);}};module['exports']=FaxQueue;