Built motion from commit 00bf23f6.|2.6.16
[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 _0xc78a=['../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','md5','updateRealtime','prototype','updateRouting','mapAgentsId','_rr','map','loggedIn','paused','length','available','format','mail:queue:%s','mail_queue:save','lodash','util','ioredis'];(function(_0x2ceedb,_0x3d4af3){var _0x1eef5c=function(_0xee38c1){while(--_0xee38c1){_0x2ceedb['push'](_0x2ceedb['shift']());}};_0x1eef5c(++_0x3d4af3);}(_0xc78a,0x169));var _0xac78=function(_0x1e896c,_0x3f9948){_0x1e896c=_0x1e896c-0x0;var _0xd149d9=_0xc78a[_0x1e896c];return _0xd149d9;};'use strict';var _=require(_0xac78('0x0'));var md5=require('md5');var util=require(_0xac78('0x1'));var Redis=require(_0xac78('0x2'));var config=require(_0xac78('0x3'));config[_0xac78('0x4')]=_[_0xac78('0x5')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0xac78('0x6'))(new Redis(config[_0xac78('0x4')]));function MailQueue(_0x4df963){this['id']=_0x4df963['id']||0x0;this[_0xac78('0x7')]=_0x4df963[_0xac78('0x7')]||'';this[_0xac78('0x8')]=_0x4df963[_0xac78('0x8')]||0xa;this[_0xac78('0x9')]=_0x4df963[_0xac78('0x9')]||_0xac78('0xa');this[_0xac78('0xb')]=_0x4df963['Agents'];this['mapAgentsId']={};this['waiting']=0x0;this[_0xac78('0xc')]='';this['updateRouting']();this[_0xac78('0xd')]();}MailQueue[_0xac78('0xe')][_0xac78('0xf')]=function(){var _0x4543a7=this[_0xac78('0x10')][_0xac78('0x11')];this[_0xac78('0x10')]=_[_0xac78('0x12')](this[_0xac78('0xb')],'id');this['mapAgentsId'][_0xac78('0x11')]=_0x4543a7;};MailQueue[_0xac78('0xe')][_0xac78('0xd')]=function(){this[_0xac78('0x13')]=0x0;this[_0xac78('0x14')]=0x0;for(var _0x44ac2a=0x0;_0x44ac2a<this[_0xac78('0xb')][_0xac78('0x15')];_0x44ac2a+=0x1){if(this[_0xac78('0xb')][_0x44ac2a]['online']){this['loggedIn']+=0x1;}if(this['Agents'][_0x44ac2a]['mailPause']){this['paused']+=0x1;}}this[_0xac78('0x16')]=this[_0xac78('0x13')]-this[_0xac78('0x14')];this[_0xac78('0x16')]=this[_0xac78('0x16')]>=0x0?this[_0xac78('0x16')]:0x0;var _0x276824={'id':this['id'],'available':this[_0xac78('0x16')],'loggedIn':this[_0xac78('0x13')],'name':this[_0xac78('0x7')],'paused':this['paused'],'waiting':this['waiting']};var _0x43741e=md5(JSON['stringify'](_0x276824));if(this[_0xac78('0xc')]!==_0x43741e){this['md5']=_0x43741e;io['to'](util[_0xac78('0x17')](_0xac78('0x18'),_0x276824[_0xac78('0x7')]))['emit'](_0xac78('0x19'),_0x276824);}};module['exports']=MailQueue;