803685287bb6c8066f0d61c1ca554ca3d63cf160
[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 _0x6dd3=['md5','util','redis','defaults','localhost','name','timeout','strategy','Agents','waiting','updateRouting','prototype','mapAgentsId','map','_rr','updateRealtime','loggedIn','length','online','mailPause','paused','available','format','mail:queue:%s','emit','mail_queue:save','exports','lodash'];(function(_0x574162,_0x2425ea){var _0x39c245=function(_0x46653f){while(--_0x46653f){_0x574162['push'](_0x574162['shift']());}};_0x39c245(++_0x2425ea);}(_0x6dd3,0x16b));var _0x36dd=function(_0x3f3f06,_0x581e5b){_0x3f3f06=_0x3f3f06-0x0;var _0x140feb=_0x6dd3[_0x3f3f06];return _0x140feb;};'use strict';var _=require(_0x36dd('0x0'));var md5=require(_0x36dd('0x1'));var util=require(_0x36dd('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x36dd('0x3')]=_[_0x36dd('0x4')](config[_0x36dd('0x3')],{'host':_0x36dd('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function MailQueue(_0x2ec5fe){this['id']=_0x2ec5fe['id']||0x0;this[_0x36dd('0x6')]=_0x2ec5fe[_0x36dd('0x6')]||'';this['timeout']=_0x2ec5fe[_0x36dd('0x7')]||0xa;this[_0x36dd('0x8')]=_0x2ec5fe[_0x36dd('0x8')]||'beepall';this[_0x36dd('0x9')]=_0x2ec5fe[_0x36dd('0x9')];this['mapAgentsId']={};this[_0x36dd('0xa')]=0x0;this[_0x36dd('0x1')]='';this[_0x36dd('0xb')]();this['updateRealtime']();}MailQueue[_0x36dd('0xc')]['updateRouting']=function(){var _0x54d1bd=this[_0x36dd('0xd')]['_rr'];this[_0x36dd('0xd')]=_[_0x36dd('0xe')](this['Agents'],'id');this[_0x36dd('0xd')][_0x36dd('0xf')]=_0x54d1bd;};MailQueue[_0x36dd('0xc')][_0x36dd('0x10')]=function(){this[_0x36dd('0x11')]=0x0;this['paused']=0x0;for(var _0x32230e=0x0;_0x32230e<this[_0x36dd('0x9')][_0x36dd('0x12')];_0x32230e+=0x1){if(this[_0x36dd('0x9')][_0x32230e][_0x36dd('0x13')]){this[_0x36dd('0x11')]+=0x1;}if(this[_0x36dd('0x9')][_0x32230e][_0x36dd('0x14')]){this[_0x36dd('0x15')]+=0x1;}}this[_0x36dd('0x16')]=this[_0x36dd('0x11')]-this['paused'];this[_0x36dd('0x16')]=this[_0x36dd('0x16')]>=0x0?this['available']:0x0;var _0x12fc19={'id':this['id'],'available':this[_0x36dd('0x16')],'loggedIn':this[_0x36dd('0x11')],'name':this['name'],'paused':this[_0x36dd('0x15')],'waiting':this[_0x36dd('0xa')]};var _0x149b85=md5(JSON['stringify'](_0x12fc19));if(this[_0x36dd('0x1')]!==_0x149b85){this[_0x36dd('0x1')]=_0x149b85;io['to'](util[_0x36dd('0x17')](_0x36dd('0x18'),_0x12fc19[_0x36dd('0x6')]))[_0x36dd('0x19')](_0x36dd('0x1a'),_0x12fc19);}};module[_0x36dd('0x1b')]=MailQueue;