2f77a2d3060c1595ff2fd4b122124574e941905d
[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 _0x444c=['redis','defaults','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','paused','online','loggedIn','available','stringify','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5','util','../../../config/environment'];(function(_0x2509bc,_0x344aed){var _0x5b98f4=function(_0x430a5a){while(--_0x430a5a){_0x2509bc['push'](_0x2509bc['shift']());}};_0x5b98f4(++_0x344aed);}(_0x444c,0x1e9));var _0xc444=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x444c[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xc444('0x0'));var md5=require(_0xc444('0x1'));var util=require(_0xc444('0x2'));var Redis=require('ioredis');var config=require(_0xc444('0x3'));config[_0xc444('0x4')]=_[_0xc444('0x5')](config['redis'],{'host':_0xc444('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xc444('0x4')]));function FaxQueue(_0x25fa8d){this['id']=_0x25fa8d['id']||0x0;this[_0xc444('0x7')]=_0x25fa8d['name']||'';this[_0xc444('0x8')]=_0x25fa8d[_0xc444('0x8')]||0xa;this[_0xc444('0x9')]=_0x25fa8d[_0xc444('0x9')]||_0xc444('0xa');this[_0xc444('0xb')]=_0x25fa8d[_0xc444('0xb')];this[_0xc444('0xc')]={};this[_0xc444('0xd')]=0x0;this[_0xc444('0x1')]='';this[_0xc444('0xe')]();this[_0xc444('0xf')]();}FaxQueue[_0xc444('0x10')][_0xc444('0xe')]=function(){var _0x5d81e3=this[_0xc444('0xc')][_0xc444('0x11')];this[_0xc444('0xc')]=_[_0xc444('0x12')](this[_0xc444('0xb')],'id');this[_0xc444('0xc')][_0xc444('0x11')]=_0x5d81e3;};FaxQueue[_0xc444('0x10')][_0xc444('0xf')]=function(){this['loggedIn']=0x0;this[_0xc444('0x13')]=0x0;for(var _0x816b5e=0x0;_0x816b5e<this[_0xc444('0xb')]['length'];_0x816b5e+=0x1){if(this[_0xc444('0xb')][_0x816b5e][_0xc444('0x14')]){this[_0xc444('0x15')]+=0x1;}if(this['Agents'][_0x816b5e]['faxPause']){this[_0xc444('0x13')]+=0x1;}}this[_0xc444('0x16')]=this[_0xc444('0x15')]-this[_0xc444('0x13')];this[_0xc444('0x16')]=this[_0xc444('0x16')]>=0x0?this[_0xc444('0x16')]:0x0;var _0x39dc0d={'id':this['id'],'available':this[_0xc444('0x16')],'loggedIn':this[_0xc444('0x15')],'name':this['name'],'paused':this[_0xc444('0x13')],'waiting':this[_0xc444('0xd')]};var _0x3afb3f=md5(JSON[_0xc444('0x17')](_0x39dc0d));if(this[_0xc444('0x1')]!==_0x3afb3f){this[_0xc444('0x1')]=_0x3afb3f;io['to'](util[_0xc444('0x18')](_0xc444('0x19'),_0x39dc0d[_0xc444('0x7')]))[_0xc444('0x1a')](_0xc444('0x1b'),_0x39dc0d);}};module[_0xc444('0x1c')]=FaxQueue;