28e248a09c8c5e8cd8c47a5103b4080ef94b5a95
[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 _0xa2ee=['exports','util','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','updateRouting','map','updateRealtime','loggedIn','paused','online','faxPause','available','waiting','stringify','md5','format','fax_queue:save'];(function(_0x187499,_0x5e416a){var _0x2965fe=function(_0xc6645e){while(--_0xc6645e){_0x187499['push'](_0x187499['shift']());}};_0x2965fe(++_0x5e416a);}(_0xa2ee,0x1dc));var _0xea2e=function(_0x50cd41,_0x4874a7){_0x50cd41=_0x50cd41-0x0;var _0x399475=_0xa2ee[_0x50cd41];return _0x399475;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0xea2e('0x0'));var Redis=require(_0xea2e('0x1'));var config=require(_0xea2e('0x2'));config[_0xea2e('0x3')]=_['defaults'](config['redis'],{'host':_0xea2e('0x4'),'port':0x18eb});var io=require(_0xea2e('0x5'))(new Redis(config['redis']));function FaxQueue(_0xcad0a0){this['id']=_0xcad0a0['id']||0x0;this[_0xea2e('0x6')]=_0xcad0a0[_0xea2e('0x6')]||'';this['timeout']=_0xcad0a0[_0xea2e('0x7')]||0xa;this[_0xea2e('0x8')]=_0xcad0a0['strategy']||'beepall';this['Agents']=_0xcad0a0[_0xea2e('0x9')];this[_0xea2e('0xa')]={};this['waiting']=0x0;this['md5']='';this[_0xea2e('0xb')]();this['updateRealtime']();}FaxQueue['prototype'][_0xea2e('0xb')]=function(){var _0x31fe51=this['mapAgentsId']['_rr'];this[_0xea2e('0xa')]=_[_0xea2e('0xc')](this['Agents'],'id');this[_0xea2e('0xa')]['_rr']=_0x31fe51;};FaxQueue['prototype'][_0xea2e('0xd')]=function(){this[_0xea2e('0xe')]=0x0;this[_0xea2e('0xf')]=0x0;for(var _0x5149c5=0x0;_0x5149c5<this['Agents']['length'];_0x5149c5+=0x1){if(this[_0xea2e('0x9')][_0x5149c5][_0xea2e('0x10')]){this[_0xea2e('0xe')]+=0x1;}if(this[_0xea2e('0x9')][_0x5149c5][_0xea2e('0x11')]){this['paused']+=0x1;}}this[_0xea2e('0x12')]=this[_0xea2e('0xe')]-this[_0xea2e('0xf')];this['available']=this[_0xea2e('0x12')]>=0x0?this['available']:0x0;var _0x26a166={'id':this['id'],'available':this[_0xea2e('0x12')],'loggedIn':this[_0xea2e('0xe')],'name':this[_0xea2e('0x6')],'paused':this[_0xea2e('0xf')],'waiting':this[_0xea2e('0x13')]};var _0x1d21a5=md5(JSON[_0xea2e('0x14')](_0x26a166));if(this[_0xea2e('0x15')]!==_0x1d21a5){this[_0xea2e('0x15')]=_0x1d21a5;io['to'](util[_0xea2e('0x16')]('fax:queue:%s',_0x26a166[_0xea2e('0x6')]))['emit'](_0xea2e('0x17'),_0x26a166);}};module[_0xea2e('0x18')]=FaxQueue;