f44876762b92cdc19a78edf85fa6984a877f11dc
[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 _0xc3ed=['name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','paused','length','loggedIn','mailPause','available','stringify','format','mail:queue:%s','emit','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter'];(function(_0x201d73,_0x2a916b){var _0x5673e1=function(_0x273898){while(--_0x273898){_0x201d73['push'](_0x201d73['shift']());}};_0x5673e1(++_0x2a916b);}(_0xc3ed,0x111));var _0xdc3e=function(_0x5265da,_0x1eac7e){_0x5265da=_0x5265da-0x0;var _0x2cd309=_0xc3ed[_0x5265da];return _0x2cd309;};'use strict';var _=require(_0xdc3e('0x0'));var md5=require(_0xdc3e('0x1'));var util=require('util');var Redis=require(_0xdc3e('0x2'));var config=require(_0xdc3e('0x3'));config[_0xdc3e('0x4')]=_[_0xdc3e('0x5')](config[_0xdc3e('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xdc3e('0x6'))(new Redis(config['redis']));function MailQueue(_0x9a9a96){this['id']=_0x9a9a96['id']||0x0;this[_0xdc3e('0x7')]=_0x9a9a96[_0xdc3e('0x7')]||'';this[_0xdc3e('0x8')]=_0x9a9a96[_0xdc3e('0x8')]||0xa;this[_0xdc3e('0x9')]=_0x9a9a96[_0xdc3e('0x9')]||_0xdc3e('0xa');this[_0xdc3e('0xb')]=_0x9a9a96[_0xdc3e('0xb')];this[_0xdc3e('0xc')]={};this[_0xdc3e('0xd')]=0x0;this[_0xdc3e('0x1')]='';this[_0xdc3e('0xe')]();this[_0xdc3e('0xf')]();}MailQueue[_0xdc3e('0x10')][_0xdc3e('0xe')]=function(){var _0x4af4b6=this[_0xdc3e('0xc')][_0xdc3e('0x11')];this[_0xdc3e('0xc')]=_['map'](this[_0xdc3e('0xb')],'id');this['mapAgentsId'][_0xdc3e('0x11')]=_0x4af4b6;};MailQueue[_0xdc3e('0x10')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0xdc3e('0x12')]=0x0;for(var _0x4f9adb=0x0;_0x4f9adb<this[_0xdc3e('0xb')][_0xdc3e('0x13')];_0x4f9adb+=0x1){if(this[_0xdc3e('0xb')][_0x4f9adb]['online']){this[_0xdc3e('0x14')]+=0x1;}if(this[_0xdc3e('0xb')][_0x4f9adb][_0xdc3e('0x15')]){this[_0xdc3e('0x12')]+=0x1;}}this['available']=this[_0xdc3e('0x14')]-this[_0xdc3e('0x12')];this[_0xdc3e('0x16')]=this[_0xdc3e('0x16')]>=0x0?this['available']:0x0;var _0x406d90={'id':this['id'],'available':this[_0xdc3e('0x16')],'loggedIn':this[_0xdc3e('0x14')],'name':this[_0xdc3e('0x7')],'paused':this[_0xdc3e('0x12')],'waiting':this[_0xdc3e('0xd')]};var _0x13bc8c=md5(JSON[_0xdc3e('0x17')](_0x406d90));if(this[_0xdc3e('0x1')]!==_0x13bc8c){this[_0xdc3e('0x1')]=_0x13bc8c;io['to'](util[_0xdc3e('0x18')](_0xdc3e('0x19'),_0x406d90[_0xdc3e('0x7')]))[_0xdc3e('0x1a')]('mail_queue:save',_0x406d90);}};module[_0xdc3e('0x1b')]=MailQueue;