9676c9c2681bfd34bf18aa66357f8ae93300680e
[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 _0xb75b=['name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','online','mailPause','available','stringify','format','mail:queue:%s','emit','mail_queue:save','md5','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter'];(function(_0xf55e73,_0x3fecc5){var _0x116b99=function(_0x314e0c){while(--_0x314e0c){_0xf55e73['push'](_0xf55e73['shift']());}};_0x116b99(++_0x3fecc5);}(_0xb75b,0x1ab));var _0xbb75=function(_0x32c2e0,_0x2dd51c){_0x32c2e0=_0x32c2e0-0x0;var _0x46d0e0=_0xb75b[_0x32c2e0];return _0x46d0e0;};'use strict';var _=require('lodash');var md5=require(_0xbb75('0x0'));var util=require(_0xbb75('0x1'));var Redis=require(_0xbb75('0x2'));var config=require(_0xbb75('0x3'));config['redis']=_[_0xbb75('0x4')](config[_0xbb75('0x5')],{'host':_0xbb75('0x6'),'port':0x18eb});var io=require(_0xbb75('0x7'))(new Redis(config[_0xbb75('0x5')]));function MailQueue(_0x182107){this['id']=_0x182107['id']||0x0;this[_0xbb75('0x8')]=_0x182107[_0xbb75('0x8')]||'';this[_0xbb75('0x9')]=_0x182107['timeout']||0xa;this['strategy']=_0x182107[_0xbb75('0xa')]||_0xbb75('0xb');this[_0xbb75('0xc')]=_0x182107[_0xbb75('0xc')];this[_0xbb75('0xd')]={};this[_0xbb75('0xe')]=0x0;this[_0xbb75('0x0')]='';this[_0xbb75('0xf')]();this[_0xbb75('0x10')]();}MailQueue[_0xbb75('0x11')][_0xbb75('0xf')]=function(){var _0x804a99=this[_0xbb75('0xd')]['_rr'];this['mapAgentsId']=_['map'](this[_0xbb75('0xc')],'id');this[_0xbb75('0xd')][_0xbb75('0x12')]=_0x804a99;};MailQueue[_0xbb75('0x11')][_0xbb75('0x10')]=function(){this[_0xbb75('0x13')]=0x0;this[_0xbb75('0x14')]=0x0;for(var _0x11f6b1=0x0;_0x11f6b1<this['Agents']['length'];_0x11f6b1+=0x1){if(this[_0xbb75('0xc')][_0x11f6b1][_0xbb75('0x15')]){this['loggedIn']+=0x1;}if(this[_0xbb75('0xc')][_0x11f6b1][_0xbb75('0x16')]){this[_0xbb75('0x14')]+=0x1;}}this['available']=this[_0xbb75('0x13')]-this[_0xbb75('0x14')];this[_0xbb75('0x17')]=this[_0xbb75('0x17')]>=0x0?this[_0xbb75('0x17')]:0x0;var _0x49894e={'id':this['id'],'available':this[_0xbb75('0x17')],'loggedIn':this[_0xbb75('0x13')],'name':this['name'],'paused':this[_0xbb75('0x14')],'waiting':this['waiting']};var _0x1a9518=md5(JSON[_0xbb75('0x18')](_0x49894e));if(this['md5']!==_0x1a9518){this[_0xbb75('0x0')]=_0x1a9518;io['to'](util[_0xbb75('0x19')](_0xbb75('0x1a'),_0x49894e[_0xbb75('0x8')]))[_0xbb75('0x1b')](_0xbb75('0x1c'),_0x49894e);}};module['exports']=MailQueue;