ea14eb6834b24be86a0c69c724b29f92a52ec4d5
[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 _0xcc68=['../../../config/environment','redis','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','map','_rr','length','online','loggedIn','mailPause','paused','available','stringify','format','emit','mail_queue:save','exports','md5','util','ioredis'];(function(_0x201583,_0x5e64fc){var _0x4cb47f=function(_0x1a0cb0){while(--_0x1a0cb0){_0x201583['push'](_0x201583['shift']());}};_0x4cb47f(++_0x5e64fc);}(_0xcc68,0xab));var _0x8cc6=function(_0x4a9fb1,_0x273043){_0x4a9fb1=_0x4a9fb1-0x0;var _0x348672=_0xcc68[_0x4a9fb1];return _0x348672;};'use strict';var _=require('lodash');var md5=require(_0x8cc6('0x0'));var util=require(_0x8cc6('0x1'));var Redis=require(_0x8cc6('0x2'));var config=require(_0x8cc6('0x3'));config[_0x8cc6('0x4')]=_['defaults'](config[_0x8cc6('0x4')],{'host':_0x8cc6('0x5'),'port':0x18eb});var io=require(_0x8cc6('0x6'))(new Redis(config[_0x8cc6('0x4')]));function MailQueue(_0xc1a92d){this['id']=_0xc1a92d['id']||0x0;this['name']=_0xc1a92d[_0x8cc6('0x7')]||'';this['timeout']=_0xc1a92d['timeout']||0xa;this[_0x8cc6('0x8')]=_0xc1a92d[_0x8cc6('0x8')]||_0x8cc6('0x9');this[_0x8cc6('0xa')]=_0xc1a92d[_0x8cc6('0xa')];this[_0x8cc6('0xb')]={};this[_0x8cc6('0xc')]=0x0;this['md5']='';this[_0x8cc6('0xd')]();this[_0x8cc6('0xe')]();}MailQueue[_0x8cc6('0xf')]['updateRouting']=function(){var _0x14e73d=this['mapAgentsId']['_rr'];this['mapAgentsId']=_[_0x8cc6('0x10')](this[_0x8cc6('0xa')],'id');this[_0x8cc6('0xb')][_0x8cc6('0x11')]=_0x14e73d;};MailQueue[_0x8cc6('0xf')][_0x8cc6('0xe')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x5ee046=0x0;_0x5ee046<this[_0x8cc6('0xa')][_0x8cc6('0x12')];_0x5ee046+=0x1){if(this[_0x8cc6('0xa')][_0x5ee046][_0x8cc6('0x13')]){this[_0x8cc6('0x14')]+=0x1;}if(this['Agents'][_0x5ee046][_0x8cc6('0x15')]){this[_0x8cc6('0x16')]+=0x1;}}this[_0x8cc6('0x17')]=this[_0x8cc6('0x14')]-this[_0x8cc6('0x16')];this[_0x8cc6('0x17')]=this[_0x8cc6('0x17')]>=0x0?this[_0x8cc6('0x17')]:0x0;var _0x103509={'id':this['id'],'available':this[_0x8cc6('0x17')],'loggedIn':this[_0x8cc6('0x14')],'name':this['name'],'paused':this[_0x8cc6('0x16')],'waiting':this['waiting']};var _0x28ac04=md5(JSON[_0x8cc6('0x18')](_0x103509));if(this['md5']!==_0x28ac04){this[_0x8cc6('0x0')]=_0x28ac04;io['to'](util[_0x8cc6('0x19')]('mail:queue:%s',_0x103509['name']))[_0x8cc6('0x1a')](_0x8cc6('0x1b'),_0x103509);}};module[_0x8cc6('0x1c')]=MailQueue;