Built motion from commit 10af8726.|2.6.34
[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 _0xdc70=['../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','updateRouting','updateRealtime','prototype','mapAgentsId','_rr','map','loggedIn','paused','faxPause','available','format','fax:queue:%s','emit','exports','md5','ioredis'];(function(_0x33da8e,_0x48beb9){var _0x216c51=function(_0x50eab2){while(--_0x50eab2){_0x33da8e['push'](_0x33da8e['shift']());}};_0x216c51(++_0x48beb9);}(_0xdc70,0x175));var _0x0dc7=function(_0x49192e,_0x4739a3){_0x49192e=_0x49192e-0x0;var _0x4ba592=_0xdc70[_0x49192e];return _0x4ba592;};'use strict';var _=require('lodash');var md5=require(_0x0dc7('0x0'));var util=require('util');var Redis=require(_0x0dc7('0x1'));var config=require(_0x0dc7('0x2'));config['redis']=_['defaults'](config[_0x0dc7('0x3')],{'host':_0x0dc7('0x4'),'port':0x18eb});var io=require(_0x0dc7('0x5'))(new Redis(config['redis']));function FaxQueue(_0x19232c){this['id']=_0x19232c['id']||0x0;this['name']=_0x19232c[_0x0dc7('0x6')]||'';this[_0x0dc7('0x7')]=_0x19232c[_0x0dc7('0x7')]||0xa;this['strategy']=_0x19232c[_0x0dc7('0x8')]||_0x0dc7('0x9');this[_0x0dc7('0xa')]=_0x19232c[_0x0dc7('0xa')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x0dc7('0x0')]='';this[_0x0dc7('0xb')]();this[_0x0dc7('0xc')]();}FaxQueue[_0x0dc7('0xd')]['updateRouting']=function(){var _0x311376=this[_0x0dc7('0xe')][_0x0dc7('0xf')];this[_0x0dc7('0xe')]=_[_0x0dc7('0x10')](this[_0x0dc7('0xa')],'id');this[_0x0dc7('0xe')][_0x0dc7('0xf')]=_0x311376;};FaxQueue[_0x0dc7('0xd')][_0x0dc7('0xc')]=function(){this[_0x0dc7('0x11')]=0x0;this[_0x0dc7('0x12')]=0x0;for(var _0x37a011=0x0;_0x37a011<this[_0x0dc7('0xa')]['length'];_0x37a011+=0x1){if(this['Agents'][_0x37a011]['online']){this[_0x0dc7('0x11')]+=0x1;}if(this[_0x0dc7('0xa')][_0x37a011][_0x0dc7('0x13')]){this['paused']+=0x1;}}this[_0x0dc7('0x14')]=this[_0x0dc7('0x11')]-this['paused'];this[_0x0dc7('0x14')]=this[_0x0dc7('0x14')]>=0x0?this[_0x0dc7('0x14')]:0x0;var _0xe8a40f={'id':this['id'],'available':this[_0x0dc7('0x14')],'loggedIn':this[_0x0dc7('0x11')],'name':this[_0x0dc7('0x6')],'paused':this['paused'],'waiting':this['waiting']};var _0x505bc6=md5(JSON['stringify'](_0xe8a40f));if(this[_0x0dc7('0x0')]!==_0x505bc6){this[_0x0dc7('0x0')]=_0x505bc6;io['to'](util[_0x0dc7('0x15')](_0x0dc7('0x16'),_0xe8a40f[_0x0dc7('0x6')]))[_0x0dc7('0x17')]('fax_queue:save',_0xe8a40f);}};module[_0x0dc7('0x18')]=FaxQueue;