bde7d57de2794b1f65ef7cac59039e03e6148863
[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 _0x3cc7=['strategy','Agents','mapAgentsId','updateRouting','updateRealtime','map','loggedIn','paused','online','mailPause','available','waiting','stringify','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','localhost','redis','name','timeout'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x3cc7,0x11f));var _0x73cc=function(_0x28b0a1,_0x99bd0a){_0x28b0a1=_0x28b0a1-0x0;var _0x21470c=_0x3cc7[_0x28b0a1];return _0x21470c;};'use strict';var _=require(_0x73cc('0x0'));var md5=require(_0x73cc('0x1'));var util=require(_0x73cc('0x2'));var Redis=require(_0x73cc('0x3'));var config=require(_0x73cc('0x4'));config['redis']=_[_0x73cc('0x5')](config['redis'],{'host':_0x73cc('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x73cc('0x7')]));function MailQueue(_0x1c40e4){this['id']=_0x1c40e4['id']||0x0;this[_0x73cc('0x8')]=_0x1c40e4['name']||'';this[_0x73cc('0x9')]=_0x1c40e4[_0x73cc('0x9')]||0xa;this[_0x73cc('0xa')]=_0x1c40e4['strategy']||'beepall';this['Agents']=_0x1c40e4[_0x73cc('0xb')];this[_0x73cc('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0x73cc('0xd')]();this[_0x73cc('0xe')]();}MailQueue['prototype'][_0x73cc('0xd')]=function(){var _0x4d99bf=this['mapAgentsId']['_rr'];this[_0x73cc('0xc')]=_[_0x73cc('0xf')](this[_0x73cc('0xb')],'id');this[_0x73cc('0xc')]['_rr']=_0x4d99bf;};MailQueue['prototype']['updateRealtime']=function(){this[_0x73cc('0x10')]=0x0;this[_0x73cc('0x11')]=0x0;for(var _0x532111=0x0;_0x532111<this[_0x73cc('0xb')]['length'];_0x532111+=0x1){if(this[_0x73cc('0xb')][_0x532111][_0x73cc('0x12')]){this[_0x73cc('0x10')]+=0x1;}if(this[_0x73cc('0xb')][_0x532111][_0x73cc('0x13')]){this['paused']+=0x1;}}this[_0x73cc('0x14')]=this[_0x73cc('0x10')]-this[_0x73cc('0x11')];this[_0x73cc('0x14')]=this[_0x73cc('0x14')]>=0x0?this[_0x73cc('0x14')]:0x0;var _0x14e73a={'id':this['id'],'available':this[_0x73cc('0x14')],'loggedIn':this[_0x73cc('0x10')],'name':this['name'],'paused':this[_0x73cc('0x11')],'waiting':this[_0x73cc('0x15')]};var _0x3b3912=md5(JSON[_0x73cc('0x16')](_0x14e73a));if(this[_0x73cc('0x1')]!==_0x3b3912){this[_0x73cc('0x1')]=_0x3b3912;io['to'](util['format'](_0x73cc('0x17'),_0x14e73a['name']))[_0x73cc('0x18')](_0x73cc('0x19'),_0x14e73a);}};module[_0x73cc('0x1a')]=MailQueue;