10c73bbfc0a0662a6722df56cd3ac37d67d10109
[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 _0x8428=['lodash','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','available','waiting','stringify','format','mail:queue:%s','emit','mail_queue:save'];(function(_0x1062d7,_0x5c558c){var _0x3f6910=function(_0x46c08b){while(--_0x46c08b){_0x1062d7['push'](_0x1062d7['shift']());}};_0x3f6910(++_0x5c558c);}(_0x8428,0xa8));var _0x8842=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x8428[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x8842('0x0'));var md5=require(_0x8842('0x1'));var util=require('util');var Redis=require(_0x8842('0x2'));var config=require(_0x8842('0x3'));config[_0x8842('0x4')]=_[_0x8842('0x5')](config[_0x8842('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x8842('0x6'))(new Redis(config['redis']));function MailQueue(_0x2cf881){this['id']=_0x2cf881['id']||0x0;this[_0x8842('0x7')]=_0x2cf881[_0x8842('0x7')]||'';this[_0x8842('0x8')]=_0x2cf881[_0x8842('0x8')]||0xa;this[_0x8842('0x9')]=_0x2cf881[_0x8842('0x9')]||_0x8842('0xa');this[_0x8842('0xb')]=_0x2cf881['Agents'];this[_0x8842('0xc')]={};this['waiting']=0x0;this[_0x8842('0x1')]='';this[_0x8842('0xd')]();this[_0x8842('0xe')]();}MailQueue[_0x8842('0xf')][_0x8842('0xd')]=function(){var _0x10f825=this[_0x8842('0xc')][_0x8842('0x10')];this[_0x8842('0xc')]=_[_0x8842('0x11')](this[_0x8842('0xb')],'id');this[_0x8842('0xc')]['_rr']=_0x10f825;};MailQueue[_0x8842('0xf')][_0x8842('0xe')]=function(){this[_0x8842('0x12')]=0x0;this[_0x8842('0x13')]=0x0;for(var _0x26ae56=0x0;_0x26ae56<this[_0x8842('0xb')][_0x8842('0x14')];_0x26ae56+=0x1){if(this['Agents'][_0x26ae56]['online']){this['loggedIn']+=0x1;}if(this[_0x8842('0xb')][_0x26ae56]['mailPause']){this[_0x8842('0x13')]+=0x1;}}this[_0x8842('0x15')]=this[_0x8842('0x12')]-this[_0x8842('0x13')];this[_0x8842('0x15')]=this[_0x8842('0x15')]>=0x0?this[_0x8842('0x15')]:0x0;var _0x3f7f63={'id':this['id'],'available':this[_0x8842('0x15')],'loggedIn':this['loggedIn'],'name':this[_0x8842('0x7')],'paused':this[_0x8842('0x13')],'waiting':this[_0x8842('0x16')]};var _0x2e175f=md5(JSON[_0x8842('0x17')](_0x3f7f63));if(this[_0x8842('0x1')]!==_0x2e175f){this['md5']=_0x2e175f;io['to'](util[_0x8842('0x18')](_0x8842('0x19'),_0x3f7f63[_0x8842('0x7')]))[_0x8842('0x1a')](_0x8842('0x1b'),_0x3f7f63);}};module['exports']=MailQueue;