c24a7cb27835c9c62f94263f1f99cf77996023db
[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 _0x323d=['strategy','Agents','mapAgentsId','waiting','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','paused','length','online','faxPause','available','format','emit','fax_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','redis','socket.io-emitter','name','timeout'];(function(_0x44afa4,_0x5be27b){var _0xcad289=function(_0x206272){while(--_0x206272){_0x44afa4['push'](_0x44afa4['shift']());}};_0xcad289(++_0x5be27b);}(_0x323d,0x6a));var _0xd323=function(_0x57e00e,_0x36e79a){_0x57e00e=_0x57e00e-0x0;var _0x415e60=_0x323d[_0x57e00e];return _0x415e60;};'use strict';var _=require(_0xd323('0x0'));var md5=require(_0xd323('0x1'));var util=require(_0xd323('0x2'));var Redis=require(_0xd323('0x3'));var config=require(_0xd323('0x4'));config['redis']=_[_0xd323('0x5')](config[_0xd323('0x6')],{'host':'localhost','port':0x18eb});var io=require(_0xd323('0x7'))(new Redis(config[_0xd323('0x6')]));function FaxQueue(_0xb3fa78){this['id']=_0xb3fa78['id']||0x0;this[_0xd323('0x8')]=_0xb3fa78[_0xd323('0x8')]||'';this[_0xd323('0x9')]=_0xb3fa78[_0xd323('0x9')]||0xa;this[_0xd323('0xa')]=_0xb3fa78[_0xd323('0xa')]||'beepall';this[_0xd323('0xb')]=_0xb3fa78[_0xd323('0xb')];this[_0xd323('0xc')]={};this[_0xd323('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0xd323('0xe')]();}FaxQueue[_0xd323('0xf')][_0xd323('0x10')]=function(){var _0x46a695=this[_0xd323('0xc')][_0xd323('0x11')];this[_0xd323('0xc')]=_[_0xd323('0x12')](this[_0xd323('0xb')],'id');this['mapAgentsId'][_0xd323('0x11')]=_0x46a695;};FaxQueue[_0xd323('0xf')][_0xd323('0xe')]=function(){this[_0xd323('0x13')]=0x0;this[_0xd323('0x14')]=0x0;for(var _0xaf8042=0x0;_0xaf8042<this[_0xd323('0xb')][_0xd323('0x15')];_0xaf8042+=0x1){if(this['Agents'][_0xaf8042][_0xd323('0x16')]){this[_0xd323('0x13')]+=0x1;}if(this[_0xd323('0xb')][_0xaf8042][_0xd323('0x17')]){this[_0xd323('0x14')]+=0x1;}}this['available']=this[_0xd323('0x13')]-this[_0xd323('0x14')];this[_0xd323('0x18')]=this[_0xd323('0x18')]>=0x0?this[_0xd323('0x18')]:0x0;var _0x94fe38={'id':this['id'],'available':this[_0xd323('0x18')],'loggedIn':this['loggedIn'],'name':this[_0xd323('0x8')],'paused':this[_0xd323('0x14')],'waiting':this['waiting']};var _0x53c92a=md5(JSON['stringify'](_0x94fe38));if(this[_0xd323('0x1')]!==_0x53c92a){this[_0xd323('0x1')]=_0x53c92a;io['to'](util[_0xd323('0x19')]('fax:queue:%s',_0x94fe38[_0xd323('0x8')]))[_0xd323('0x1a')](_0xd323('0x1b'),_0x94fe38);}};module[_0xd323('0x1c')]=FaxQueue;