3ccc2e8f8ef6b111d6ca909355424a82ae285583
[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 _0x890b=['mapAgentsId','waiting','updateRealtime','prototype','_rr','map','Agents','paused','length','online','mailPause','available','loggedIn','stringify','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall'];(function(_0x513a90,_0x2f7107){var _0x2cf336=function(_0x2f899b){while(--_0x2f899b){_0x513a90['push'](_0x513a90['shift']());}};_0x2cf336(++_0x2f7107);}(_0x890b,0x8f));var _0xb890=function(_0x19a550,_0x30df50){_0x19a550=_0x19a550-0x0;var _0x18ecef=_0x890b[_0x19a550];return _0x18ecef;};'use strict';var _=require(_0xb890('0x0'));var md5=require(_0xb890('0x1'));var util=require(_0xb890('0x2'));var Redis=require('ioredis');var config=require(_0xb890('0x3'));config[_0xb890('0x4')]=_[_0xb890('0x5')](config[_0xb890('0x4')],{'host':_0xb890('0x6'),'port':0x18eb});var io=require(_0xb890('0x7'))(new Redis(config[_0xb890('0x4')]));function MailQueue(_0x335f26){this['id']=_0x335f26['id']||0x0;this[_0xb890('0x8')]=_0x335f26[_0xb890('0x8')]||'';this[_0xb890('0x9')]=_0x335f26[_0xb890('0x9')]||0xa;this['strategy']=_0x335f26[_0xb890('0xa')]||_0xb890('0xb');this['Agents']=_0x335f26['Agents'];this[_0xb890('0xc')]={};this[_0xb890('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0xb890('0xe')]();}MailQueue[_0xb890('0xf')]['updateRouting']=function(){var _0x416289=this[_0xb890('0xc')][_0xb890('0x10')];this['mapAgentsId']=_[_0xb890('0x11')](this[_0xb890('0x12')],'id');this['mapAgentsId'][_0xb890('0x10')]=_0x416289;};MailQueue[_0xb890('0xf')][_0xb890('0xe')]=function(){this['loggedIn']=0x0;this[_0xb890('0x13')]=0x0;for(var _0x298567=0x0;_0x298567<this[_0xb890('0x12')][_0xb890('0x14')];_0x298567+=0x1){if(this[_0xb890('0x12')][_0x298567][_0xb890('0x15')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x298567][_0xb890('0x16')]){this[_0xb890('0x13')]+=0x1;}}this[_0xb890('0x17')]=this['loggedIn']-this[_0xb890('0x13')];this[_0xb890('0x17')]=this['available']>=0x0?this['available']:0x0;var _0x314b1d={'id':this['id'],'available':this[_0xb890('0x17')],'loggedIn':this[_0xb890('0x18')],'name':this['name'],'paused':this[_0xb890('0x13')],'waiting':this['waiting']};var _0x23d894=md5(JSON[_0xb890('0x19')](_0x314b1d));if(this[_0xb890('0x1')]!==_0x23d894){this[_0xb890('0x1')]=_0x23d894;io['to'](util[_0xb890('0x1a')](_0xb890('0x1b'),_0x314b1d[_0xb890('0x8')]))[_0xb890('0x1c')](_0xb890('0x1d'),_0x314b1d);}};module[_0xb890('0x1e')]=MailQueue;