Built motion from commit d9028345.|2.5.43
[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 _0xb71c=['mailPause','available','waiting','stringify','mail:queue:%s','emit','mail_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','length','online'];(function(_0x435be4,_0x468442){var _0xd58821=function(_0x583781){while(--_0x583781){_0x435be4['push'](_0x435be4['shift']());}};_0xd58821(++_0x468442);}(_0xb71c,0x78));var _0xcb71=function(_0x3bd02a,_0x4ffcb0){_0x3bd02a=_0x3bd02a-0x0;var _0x433565=_0xb71c[_0x3bd02a];return _0x433565;};'use strict';var _=require('lodash');var md5=require(_0xcb71('0x0'));var util=require(_0xcb71('0x1'));var Redis=require(_0xcb71('0x2'));var config=require(_0xcb71('0x3'));config[_0xcb71('0x4')]=_[_0xcb71('0x5')](config['redis'],{'host':_0xcb71('0x6'),'port':0x18eb});var io=require(_0xcb71('0x7'))(new Redis(config['redis']));function MailQueue(_0x1e706e){this['id']=_0x1e706e['id']||0x0;this[_0xcb71('0x8')]=_0x1e706e[_0xcb71('0x8')]||'';this[_0xcb71('0x9')]=_0x1e706e['timeout']||0xa;this['strategy']=_0x1e706e['strategy']||'beepall';this[_0xcb71('0xa')]=_0x1e706e['Agents'];this[_0xcb71('0xb')]={};this['waiting']=0x0;this[_0xcb71('0x0')]='';this[_0xcb71('0xc')]();this[_0xcb71('0xd')]();}MailQueue[_0xcb71('0xe')][_0xcb71('0xc')]=function(){var _0x39cd51=this['mapAgentsId'][_0xcb71('0xf')];this['mapAgentsId']=_['map'](this[_0xcb71('0xa')],'id');this['mapAgentsId']['_rr']=_0x39cd51;};MailQueue[_0xcb71('0xe')][_0xcb71('0xd')]=function(){this[_0xcb71('0x10')]=0x0;this[_0xcb71('0x11')]=0x0;for(var _0x4f6e1e=0x0;_0x4f6e1e<this[_0xcb71('0xa')][_0xcb71('0x12')];_0x4f6e1e+=0x1){if(this['Agents'][_0x4f6e1e][_0xcb71('0x13')]){this[_0xcb71('0x10')]+=0x1;}if(this[_0xcb71('0xa')][_0x4f6e1e][_0xcb71('0x14')]){this[_0xcb71('0x11')]+=0x1;}}this[_0xcb71('0x15')]=this[_0xcb71('0x10')]-this[_0xcb71('0x11')];this[_0xcb71('0x15')]=this['available']>=0x0?this[_0xcb71('0x15')]:0x0;var _0x2875e6={'id':this['id'],'available':this[_0xcb71('0x15')],'loggedIn':this['loggedIn'],'name':this[_0xcb71('0x8')],'paused':this[_0xcb71('0x11')],'waiting':this[_0xcb71('0x16')]};var _0x340e64=md5(JSON[_0xcb71('0x17')](_0x2875e6));if(this[_0xcb71('0x0')]!==_0x340e64){this[_0xcb71('0x0')]=_0x340e64;io['to'](util['format'](_0xcb71('0x18'),_0x2875e6[_0xcb71('0x8')]))[_0xcb71('0x19')](_0xcb71('0x1a'),_0x2875e6);}};module[_0xcb71('0x1b')]=MailQueue;