Built motion from commit (unavailable).|2.5.4
[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 _0xd527=['md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','_rr','prototype','online','loggedIn','mailPause','available','paused','name','waiting','stringify','format','emit','exports'];(function(_0x4d62ae,_0x1509f5){var _0x54d4b7=function(_0x492d51){while(--_0x492d51){_0x4d62ae['push'](_0x4d62ae['shift']());}};_0x54d4b7(++_0x1509f5);}(_0xd527,0x195));var _0x7d52=function(_0x5ef55a,_0x2a03b1){_0x5ef55a=_0x5ef55a-0x0;var _0x20ae40=_0xd527[_0x5ef55a];return _0x20ae40;};'use strict';var _=require('lodash');var md5=require(_0x7d52('0x0'));var util=require(_0x7d52('0x1'));var Redis=require(_0x7d52('0x2'));var config=require(_0x7d52('0x3'));config[_0x7d52('0x4')]=_[_0x7d52('0x5')](config[_0x7d52('0x4')],{'host':_0x7d52('0x6'),'port':0x18eb});var io=require(_0x7d52('0x7'))(new Redis(config[_0x7d52('0x4')]));function MailQueue(_0x1fdfc3){this['id']=_0x1fdfc3['id']||0x0;this['name']=_0x1fdfc3['name']||'';this['timeout']=_0x1fdfc3['timeout']||0xa;this[_0x7d52('0x8')]=_0x1fdfc3[_0x7d52('0x8')]||_0x7d52('0x9');this[_0x7d52('0xa')]=_0x1fdfc3['Agents'];this[_0x7d52('0xb')]={};this['waiting']=0x0;this[_0x7d52('0x0')]='';this[_0x7d52('0xc')]();this[_0x7d52('0xd')]();}MailQueue['prototype'][_0x7d52('0xc')]=function(){var _0x1144be=this[_0x7d52('0xb')][_0x7d52('0xe')];this['mapAgentsId']=_['map'](this['Agents'],'id');this[_0x7d52('0xb')][_0x7d52('0xe')]=_0x1144be;};MailQueue[_0x7d52('0xf')]['updateRealtime']=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x4b1e27=0x0;_0x4b1e27<this['Agents']['length'];_0x4b1e27+=0x1){if(this[_0x7d52('0xa')][_0x4b1e27][_0x7d52('0x10')]){this[_0x7d52('0x11')]+=0x1;}if(this[_0x7d52('0xa')][_0x4b1e27][_0x7d52('0x12')]){this['paused']+=0x1;}}this[_0x7d52('0x13')]=this[_0x7d52('0x11')]-this[_0x7d52('0x14')];this[_0x7d52('0x13')]=this[_0x7d52('0x13')]>=0x0?this['available']:0x0;var _0x51b1df={'id':this['id'],'available':this[_0x7d52('0x13')],'loggedIn':this[_0x7d52('0x11')],'name':this[_0x7d52('0x15')],'paused':this[_0x7d52('0x14')],'waiting':this[_0x7d52('0x16')]};var _0xb05603=md5(JSON[_0x7d52('0x17')](_0x51b1df));if(this[_0x7d52('0x0')]!==_0xb05603){this[_0x7d52('0x0')]=_0xb05603;io['to'](util[_0x7d52('0x18')]('mail:queue:%s',_0x51b1df['name']))[_0x7d52('0x19')]('mail_queue:save',_0x51b1df);}};module[_0x7d52('0x1a')]=MailQueue;