Built motion from commit da24aabd.|2.6.20
[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 _0x2ee2=['timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','length','online','loggedIn','mailPause','paused','available','format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name'];(function(_0x3bb99f,_0x809eb6){var _0x1cfe1d=function(_0x1017e0){while(--_0x1017e0){_0x3bb99f['push'](_0x3bb99f['shift']());}};_0x1cfe1d(++_0x809eb6);}(_0x2ee2,0x160));var _0x22ee=function(_0x1fa760,_0x1bf063){_0x1fa760=_0x1fa760-0x0;var _0xd8eda1=_0x2ee2[_0x1fa760];return _0xd8eda1;};'use strict';var _=require(_0x22ee('0x0'));var md5=require(_0x22ee('0x1'));var util=require('util');var Redis=require(_0x22ee('0x2'));var config=require(_0x22ee('0x3'));config[_0x22ee('0x4')]=_[_0x22ee('0x5')](config[_0x22ee('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x22ee('0x6'))(new Redis(config[_0x22ee('0x4')]));function MailQueue(_0x15929b){this['id']=_0x15929b['id']||0x0;this['name']=_0x15929b[_0x22ee('0x7')]||'';this[_0x22ee('0x8')]=_0x15929b['timeout']||0xa;this[_0x22ee('0x9')]=_0x15929b[_0x22ee('0x9')]||_0x22ee('0xa');this[_0x22ee('0xb')]=_0x15929b[_0x22ee('0xb')];this[_0x22ee('0xc')]={};this[_0x22ee('0xd')]=0x0;this['md5']='';this[_0x22ee('0xe')]();this[_0x22ee('0xf')]();}MailQueue[_0x22ee('0x10')][_0x22ee('0xe')]=function(){var _0x5e29c8=this[_0x22ee('0xc')][_0x22ee('0x11')];this[_0x22ee('0xc')]=_[_0x22ee('0x12')](this[_0x22ee('0xb')],'id');this[_0x22ee('0xc')][_0x22ee('0x11')]=_0x5e29c8;};MailQueue[_0x22ee('0x10')][_0x22ee('0xf')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x4edea9=0x0;_0x4edea9<this[_0x22ee('0xb')][_0x22ee('0x13')];_0x4edea9+=0x1){if(this[_0x22ee('0xb')][_0x4edea9][_0x22ee('0x14')]){this[_0x22ee('0x15')]+=0x1;}if(this[_0x22ee('0xb')][_0x4edea9][_0x22ee('0x16')]){this[_0x22ee('0x17')]+=0x1;}}this[_0x22ee('0x18')]=this[_0x22ee('0x15')]-this['paused'];this[_0x22ee('0x18')]=this['available']>=0x0?this['available']:0x0;var _0x36fc10={'id':this['id'],'available':this[_0x22ee('0x18')],'loggedIn':this[_0x22ee('0x15')],'name':this['name'],'paused':this[_0x22ee('0x17')],'waiting':this[_0x22ee('0xd')]};var _0x7a10b1=md5(JSON['stringify'](_0x36fc10));if(this[_0x22ee('0x1')]!==_0x7a10b1){this[_0x22ee('0x1')]=_0x7a10b1;io['to'](util[_0x22ee('0x19')](_0x22ee('0x1a'),_0x36fc10[_0x22ee('0x7')]))[_0x22ee('0x1b')](_0x22ee('0x1c'),_0x36fc10);}};module[_0x22ee('0x1d')]=MailQueue;