Built motion from commit e1760111.|2.6.18
[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 _0xce31=['mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','_rr','map','updateRealtime','loggedIn','paused','length','online','mailPause','available','format'];(function(_0x17e3ae,_0x1d80c4){var _0x4cc881=function(_0x323f21){while(--_0x323f21){_0x17e3ae['push'](_0x17e3ae['shift']());}};_0x4cc881(++_0x1d80c4);}(_0xce31,0x19a));var _0x1ce3=function(_0x5d351e,_0x72599f){_0x5d351e=_0x5d351e-0x0;var _0x33ea76=_0xce31[_0x5d351e];return _0x33ea76;};'use strict';var _=require(_0x1ce3('0x0'));var md5=require(_0x1ce3('0x1'));var util=require('util');var Redis=require(_0x1ce3('0x2'));var config=require(_0x1ce3('0x3'));config[_0x1ce3('0x4')]=_['defaults'](config['redis'],{'host':_0x1ce3('0x5'),'port':0x18eb});var io=require(_0x1ce3('0x6'))(new Redis(config[_0x1ce3('0x4')]));function MailQueue(_0x2da059){this['id']=_0x2da059['id']||0x0;this[_0x1ce3('0x7')]=_0x2da059['name']||'';this[_0x1ce3('0x8')]=_0x2da059[_0x1ce3('0x8')]||0xa;this[_0x1ce3('0x9')]=_0x2da059[_0x1ce3('0x9')]||_0x1ce3('0xa');this[_0x1ce3('0xb')]=_0x2da059[_0x1ce3('0xb')];this[_0x1ce3('0xc')]={};this[_0x1ce3('0xd')]=0x0;this[_0x1ce3('0x1')]='';this[_0x1ce3('0xe')]();this['updateRealtime']();}MailQueue['prototype'][_0x1ce3('0xe')]=function(){var _0x978d83=this[_0x1ce3('0xc')][_0x1ce3('0xf')];this[_0x1ce3('0xc')]=_[_0x1ce3('0x10')](this[_0x1ce3('0xb')],'id');this[_0x1ce3('0xc')][_0x1ce3('0xf')]=_0x978d83;};MailQueue['prototype'][_0x1ce3('0x11')]=function(){this[_0x1ce3('0x12')]=0x0;this[_0x1ce3('0x13')]=0x0;for(var _0x1b7b9c=0x0;_0x1b7b9c<this[_0x1ce3('0xb')][_0x1ce3('0x14')];_0x1b7b9c+=0x1){if(this[_0x1ce3('0xb')][_0x1b7b9c][_0x1ce3('0x15')]){this[_0x1ce3('0x12')]+=0x1;}if(this[_0x1ce3('0xb')][_0x1b7b9c][_0x1ce3('0x16')]){this[_0x1ce3('0x13')]+=0x1;}}this['available']=this[_0x1ce3('0x12')]-this[_0x1ce3('0x13')];this[_0x1ce3('0x17')]=this[_0x1ce3('0x17')]>=0x0?this[_0x1ce3('0x17')]:0x0;var _0x4025ba={'id':this['id'],'available':this[_0x1ce3('0x17')],'loggedIn':this[_0x1ce3('0x12')],'name':this['name'],'paused':this[_0x1ce3('0x13')],'waiting':this[_0x1ce3('0xd')]};var _0x3569a9=md5(JSON['stringify'](_0x4025ba));if(this[_0x1ce3('0x1')]!==_0x3569a9){this[_0x1ce3('0x1')]=_0x3569a9;io['to'](util[_0x1ce3('0x18')](_0x1ce3('0x19'),_0x4025ba[_0x1ce3('0x7')]))[_0x1ce3('0x1a')](_0x1ce3('0x1b'),_0x4025ba);}};module[_0x1ce3('0x1c')]=MailQueue;