Built motion from commit 9d1906d1.|2.5.40
[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 _0xb24a=['redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','mapAgentsId','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','paused','Agents','length','online','mailPause','available','waiting','stringify','mail:queue:%s','emit','mail_queue:save','md5','util','../../../config/environment','defaults'];(function(_0x1ce05f,_0xe4d511){var _0x493e80=function(_0x230a52){while(--_0x230a52){_0x1ce05f['push'](_0x1ce05f['shift']());}};_0x493e80(++_0xe4d511);}(_0xb24a,0x70));var _0xab24=function(_0x4b8156,_0x437af2){_0x4b8156=_0x4b8156-0x0;var _0x4a819c=_0xb24a[_0x4b8156];return _0x4a819c;};'use strict';var _=require('lodash');var md5=require(_0xab24('0x0'));var util=require(_0xab24('0x1'));var Redis=require('ioredis');var config=require(_0xab24('0x2'));config['redis']=_[_0xab24('0x3')](config[_0xab24('0x4')],{'host':_0xab24('0x5'),'port':0x18eb});var io=require(_0xab24('0x6'))(new Redis(config[_0xab24('0x4')]));function MailQueue(_0x2ac875){this['id']=_0x2ac875['id']||0x0;this[_0xab24('0x7')]=_0x2ac875['name']||'';this[_0xab24('0x8')]=_0x2ac875[_0xab24('0x8')]||0xa;this[_0xab24('0x9')]=_0x2ac875[_0xab24('0x9')]||_0xab24('0xa');this['Agents']=_0x2ac875['Agents'];this[_0xab24('0xb')]={};this['waiting']=0x0;this['md5']='';this[_0xab24('0xc')]();this[_0xab24('0xd')]();}MailQueue[_0xab24('0xe')][_0xab24('0xc')]=function(){var _0x1dc33f=this[_0xab24('0xb')]['_rr'];this['mapAgentsId']=_[_0xab24('0xf')](this['Agents'],'id');this['mapAgentsId'][_0xab24('0x10')]=_0x1dc33f;};MailQueue[_0xab24('0xe')][_0xab24('0xd')]=function(){this[_0xab24('0x11')]=0x0;this[_0xab24('0x12')]=0x0;for(var _0x31f0ac=0x0;_0x31f0ac<this[_0xab24('0x13')][_0xab24('0x14')];_0x31f0ac+=0x1){if(this[_0xab24('0x13')][_0x31f0ac][_0xab24('0x15')]){this[_0xab24('0x11')]+=0x1;}if(this[_0xab24('0x13')][_0x31f0ac][_0xab24('0x16')]){this[_0xab24('0x12')]+=0x1;}}this['available']=this[_0xab24('0x11')]-this[_0xab24('0x12')];this['available']=this[_0xab24('0x17')]>=0x0?this['available']:0x0;var _0x3ece7c={'id':this['id'],'available':this[_0xab24('0x17')],'loggedIn':this['loggedIn'],'name':this[_0xab24('0x7')],'paused':this[_0xab24('0x12')],'waiting':this[_0xab24('0x18')]};var _0x298683=md5(JSON[_0xab24('0x19')](_0x3ece7c));if(this[_0xab24('0x0')]!==_0x298683){this['md5']=_0x298683;io['to'](util['format'](_0xab24('0x1a'),_0x3ece7c[_0xab24('0x7')]))[_0xab24('0x1b')](_0xab24('0x1c'),_0x3ece7c);}};module['exports']=MailQueue;