Built motion from commit 25580385.|2.6.2
[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 _0xadb8=['format','mail:queue:%s','emit','mail_queue:save','exports','lodash','md5','ioredis','redis','defaults','localhost','socket.io-emitter','name','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','online','mailPause','available','waiting','stringify'];(function(_0x12fc8d,_0x19ee33){var _0x3f9d04=function(_0x52e51c){while(--_0x52e51c){_0x12fc8d['push'](_0x12fc8d['shift']());}};_0x3f9d04(++_0x19ee33);}(_0xadb8,0x155));var _0x8adb=function(_0x2e2f84,_0x24e46f){_0x2e2f84=_0x2e2f84-0x0;var _0x448191=_0xadb8[_0x2e2f84];return _0x448191;};'use strict';var _=require(_0x8adb('0x0'));var md5=require(_0x8adb('0x1'));var util=require('util');var Redis=require(_0x8adb('0x2'));var config=require('../../../config/environment');config[_0x8adb('0x3')]=_[_0x8adb('0x4')](config['redis'],{'host':_0x8adb('0x5'),'port':0x18eb});var io=require(_0x8adb('0x6'))(new Redis(config['redis']));function MailQueue(_0x731a93){this['id']=_0x731a93['id']||0x0;this['name']=_0x731a93[_0x8adb('0x7')]||'';this['timeout']=_0x731a93['timeout']||0xa;this['strategy']=_0x731a93['strategy']||_0x8adb('0x8');this[_0x8adb('0x9')]=_0x731a93[_0x8adb('0x9')];this[_0x8adb('0xa')]={};this['waiting']=0x0;this[_0x8adb('0x1')]='';this[_0x8adb('0xb')]();this[_0x8adb('0xc')]();}MailQueue[_0x8adb('0xd')]['updateRouting']=function(){var _0x2e96bd=this['mapAgentsId'][_0x8adb('0xe')];this[_0x8adb('0xa')]=_[_0x8adb('0xf')](this['Agents'],'id');this['mapAgentsId'][_0x8adb('0xe')]=_0x2e96bd;};MailQueue['prototype'][_0x8adb('0xc')]=function(){this[_0x8adb('0x10')]=0x0;this[_0x8adb('0x11')]=0x0;for(var _0x53789f=0x0;_0x53789f<this[_0x8adb('0x9')]['length'];_0x53789f+=0x1){if(this[_0x8adb('0x9')][_0x53789f][_0x8adb('0x12')]){this[_0x8adb('0x10')]+=0x1;}if(this['Agents'][_0x53789f][_0x8adb('0x13')]){this[_0x8adb('0x11')]+=0x1;}}this[_0x8adb('0x14')]=this[_0x8adb('0x10')]-this[_0x8adb('0x11')];this[_0x8adb('0x14')]=this[_0x8adb('0x14')]>=0x0?this[_0x8adb('0x14')]:0x0;var _0x2bb919={'id':this['id'],'available':this[_0x8adb('0x14')],'loggedIn':this[_0x8adb('0x10')],'name':this['name'],'paused':this[_0x8adb('0x11')],'waiting':this[_0x8adb('0x15')]};var _0x31f174=md5(JSON[_0x8adb('0x16')](_0x2bb919));if(this[_0x8adb('0x1')]!==_0x31f174){this['md5']=_0x31f174;io['to'](util[_0x8adb('0x17')](_0x8adb('0x18'),_0x2bb919[_0x8adb('0x7')]))[_0x8adb('0x19')](_0x8adb('0x1a'),_0x2bb919);}};module[_0x8adb('0x1b')]=MailQueue;