Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / services / routing / model / mailQueue.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 _0xe070=['_rr','mapAgentsId','map','loggedIn','paused','length','online','mailPause','available','stringify','md5','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','prototype'];(function(_0xe98e1e,_0x39c885){var _0x5630fa=function(_0x102de6){while(--_0x102de6){_0xe98e1e['push'](_0xe98e1e['shift']());}};_0x5630fa(++_0x39c885);}(_0xe070,0x1f0));var _0x0e07=function(_0x1f1170,_0x3b5783){_0x1f1170=_0x1f1170-0x0;var _0x127b7b=_0xe070[_0x1f1170];return _0x127b7b;};'use strict';var _=require(_0x0e07('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x0e07('0x1'));var config=require(_0x0e07('0x2'));config[_0x0e07('0x3')]=_[_0x0e07('0x4')](config['redis'],{'host':_0x0e07('0x5'),'port':0x18eb});var io=require(_0x0e07('0x6'))(new Redis(config['redis']));function MailQueue(_0x5e07f0){this['id']=_0x5e07f0['id']||0x0;this[_0x0e07('0x7')]=_0x5e07f0[_0x0e07('0x7')]||'';this[_0x0e07('0x8')]=_0x5e07f0[_0x0e07('0x8')]||0xa;this['strategy']=_0x5e07f0[_0x0e07('0x9')]||_0x0e07('0xa');this[_0x0e07('0xb')]=_0x5e07f0[_0x0e07('0xb')];this['mapAgentsId']={};this[_0x0e07('0xc')]=0x0;this['md5']='';this[_0x0e07('0xd')]();this[_0x0e07('0xe')]();}MailQueue[_0x0e07('0xf')][_0x0e07('0xd')]=function(){var _0x4b3287=this['mapAgentsId'][_0x0e07('0x10')];this[_0x0e07('0x11')]=_[_0x0e07('0x12')](this[_0x0e07('0xb')],'id');this['mapAgentsId'][_0x0e07('0x10')]=_0x4b3287;};MailQueue[_0x0e07('0xf')][_0x0e07('0xe')]=function(){this[_0x0e07('0x13')]=0x0;this[_0x0e07('0x14')]=0x0;for(var _0x25c702=0x0;_0x25c702<this[_0x0e07('0xb')][_0x0e07('0x15')];_0x25c702+=0x1){if(this['Agents'][_0x25c702][_0x0e07('0x16')]){this[_0x0e07('0x13')]+=0x1;}if(this[_0x0e07('0xb')][_0x25c702][_0x0e07('0x17')]){this[_0x0e07('0x14')]+=0x1;}}this[_0x0e07('0x18')]=this[_0x0e07('0x13')]-this[_0x0e07('0x14')];this[_0x0e07('0x18')]=this[_0x0e07('0x18')]>=0x0?this['available']:0x0;var _0x36cdf9={'id':this['id'],'available':this[_0x0e07('0x18')],'loggedIn':this[_0x0e07('0x13')],'name':this['name'],'paused':this[_0x0e07('0x14')],'waiting':this[_0x0e07('0xc')]};var _0x1f9de3=md5(JSON[_0x0e07('0x19')](_0x36cdf9));if(this['md5']!==_0x1f9de3){this[_0x0e07('0x1a')]=_0x1f9de3;io['to'](util[_0x0e07('0x1b')](_0x0e07('0x1c'),_0x36cdf9[_0x0e07('0x7')]))[_0x0e07('0x1d')](_0x0e07('0x1e'),_0x36cdf9);}};module[_0x0e07('0x1f')]=MailQueue;