Built motion from commit da617fac.|2.6.6
[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 _0xf5ec=['mail:queue:%s','emit','mail_queue:save','exports','md5','ioredis','../../../config/environment','defaults','localhost','socket.io-emitter','redis','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','map','prototype','paused','length','mailPause','available','loggedIn','stringify'];(function(_0x273dc5,_0x268a81){var _0x46dae7=function(_0x263d62){while(--_0x263d62){_0x273dc5['push'](_0x273dc5['shift']());}};_0x46dae7(++_0x268a81);}(_0xf5ec,0x109));var _0xcf5e=function(_0x218ea3,_0x36f59c){_0x218ea3=_0x218ea3-0x0;var _0x49265e=_0xf5ec[_0x218ea3];return _0x49265e;};'use strict';var _=require('lodash');var md5=require(_0xcf5e('0x0'));var util=require('util');var Redis=require(_0xcf5e('0x1'));var config=require(_0xcf5e('0x2'));config['redis']=_[_0xcf5e('0x3')](config['redis'],{'host':_0xcf5e('0x4'),'port':0x18eb});var io=require(_0xcf5e('0x5'))(new Redis(config[_0xcf5e('0x6')]));function MailQueue(_0x340209){this['id']=_0x340209['id']||0x0;this['name']=_0x340209[_0xcf5e('0x7')]||'';this[_0xcf5e('0x8')]=_0x340209[_0xcf5e('0x8')]||0xa;this[_0xcf5e('0x9')]=_0x340209[_0xcf5e('0x9')]||_0xcf5e('0xa');this[_0xcf5e('0xb')]=_0x340209[_0xcf5e('0xb')];this[_0xcf5e('0xc')]={};this[_0xcf5e('0xd')]=0x0;this[_0xcf5e('0x0')]='';this[_0xcf5e('0xe')]();this[_0xcf5e('0xf')]();}MailQueue['prototype'][_0xcf5e('0xe')]=function(){var _0x594930=this[_0xcf5e('0xc')][_0xcf5e('0x10')];this['mapAgentsId']=_[_0xcf5e('0x11')](this['Agents'],'id');this[_0xcf5e('0xc')][_0xcf5e('0x10')]=_0x594930;};MailQueue[_0xcf5e('0x12')][_0xcf5e('0xf')]=function(){this['loggedIn']=0x0;this[_0xcf5e('0x13')]=0x0;for(var _0x282816=0x0;_0x282816<this[_0xcf5e('0xb')][_0xcf5e('0x14')];_0x282816+=0x1){if(this[_0xcf5e('0xb')][_0x282816]['online']){this['loggedIn']+=0x1;}if(this[_0xcf5e('0xb')][_0x282816][_0xcf5e('0x15')]){this[_0xcf5e('0x13')]+=0x1;}}this[_0xcf5e('0x16')]=this[_0xcf5e('0x17')]-this['paused'];this[_0xcf5e('0x16')]=this['available']>=0x0?this[_0xcf5e('0x16')]:0x0;var _0x5897e8={'id':this['id'],'available':this['available'],'loggedIn':this[_0xcf5e('0x17')],'name':this[_0xcf5e('0x7')],'paused':this[_0xcf5e('0x13')],'waiting':this[_0xcf5e('0xd')]};var _0x348bfb=md5(JSON[_0xcf5e('0x18')](_0x5897e8));if(this[_0xcf5e('0x0')]!==_0x348bfb){this[_0xcf5e('0x0')]=_0x348bfb;io['to'](util['format'](_0xcf5e('0x19'),_0x5897e8[_0xcf5e('0x7')]))[_0xcf5e('0x1a')](_0xcf5e('0x1b'),_0x5897e8);}};module[_0xcf5e('0x1c')]=MailQueue;