Built motion from commit b5996064.|2.6.21
[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 _0x156f=['loggedIn','paused','length','online','mailPause','available','name','waiting','stringify','format','mail_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','timeout','strategy','Agents','mapAgentsId','updateRouting','updateRealtime','_rr'];(function(_0x2582af,_0x3409f7){var _0x38c9c6=function(_0x2695e4){while(--_0x2695e4){_0x2582af['push'](_0x2582af['shift']());}};_0x38c9c6(++_0x3409f7);}(_0x156f,0xf6));var _0xf156=function(_0x4d4e50,_0x394d0e){_0x4d4e50=_0x4d4e50-0x0;var _0x4db4a5=_0x156f[_0x4d4e50];return _0x4db4a5;};'use strict';var _=require(_0xf156('0x0'));var md5=require(_0xf156('0x1'));var util=require(_0xf156('0x2'));var Redis=require(_0xf156('0x3'));var config=require(_0xf156('0x4'));config[_0xf156('0x5')]=_[_0xf156('0x6')](config[_0xf156('0x5')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf156('0x5')]));function MailQueue(_0x7a14ba){this['id']=_0x7a14ba['id']||0x0;this['name']=_0x7a14ba['name']||'';this[_0xf156('0x7')]=_0x7a14ba[_0xf156('0x7')]||0xa;this[_0xf156('0x8')]=_0x7a14ba['strategy']||'beepall';this['Agents']=_0x7a14ba[_0xf156('0x9')];this[_0xf156('0xa')]={};this['waiting']=0x0;this[_0xf156('0x1')]='';this[_0xf156('0xb')]();this[_0xf156('0xc')]();}MailQueue['prototype']['updateRouting']=function(){var _0x3e54d5=this[_0xf156('0xa')][_0xf156('0xd')];this[_0xf156('0xa')]=_['map'](this[_0xf156('0x9')],'id');this[_0xf156('0xa')][_0xf156('0xd')]=_0x3e54d5;};MailQueue['prototype']['updateRealtime']=function(){this[_0xf156('0xe')]=0x0;this[_0xf156('0xf')]=0x0;for(var _0x16158b=0x0;_0x16158b<this[_0xf156('0x9')][_0xf156('0x10')];_0x16158b+=0x1){if(this[_0xf156('0x9')][_0x16158b][_0xf156('0x11')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x16158b][_0xf156('0x12')]){this[_0xf156('0xf')]+=0x1;}}this[_0xf156('0x13')]=this[_0xf156('0xe')]-this[_0xf156('0xf')];this[_0xf156('0x13')]=this['available']>=0x0?this[_0xf156('0x13')]:0x0;var _0x513984={'id':this['id'],'available':this['available'],'loggedIn':this[_0xf156('0xe')],'name':this[_0xf156('0x14')],'paused':this[_0xf156('0xf')],'waiting':this[_0xf156('0x15')]};var _0x533757=md5(JSON[_0xf156('0x16')](_0x513984));if(this['md5']!==_0x533757){this['md5']=_0x533757;io['to'](util[_0xf156('0x17')]('mail:queue:%s',_0x513984[_0xf156('0x14')]))['emit'](_0xf156('0x18'),_0x513984);}};module[_0xf156('0x19')]=MailQueue;