Built motion from commit d6d69adf.|2.6.33
[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 _0xadb1=['waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','online','mailPause','available','format','mail:queue:%s','emit','mail_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents','mapAgentsId'];(function(_0x29234f,_0xa4b3b0){var _0x119a23=function(_0x2262e5){while(--_0x2262e5){_0x29234f['push'](_0x29234f['shift']());}};_0x119a23(++_0xa4b3b0);}(_0xadb1,0x67));var _0x1adb=function(_0x43ae5c,_0xecb40e){_0x43ae5c=_0x43ae5c-0x0;var _0x4b5f96=_0xadb1[_0x43ae5c];return _0x4b5f96;};'use strict';var _=require('lodash');var md5=require(_0x1adb('0x0'));var util=require(_0x1adb('0x1'));var Redis=require(_0x1adb('0x2'));var config=require(_0x1adb('0x3'));config[_0x1adb('0x4')]=_[_0x1adb('0x5')](config[_0x1adb('0x4')],{'host':_0x1adb('0x6'),'port':0x18eb});var io=require(_0x1adb('0x7'))(new Redis(config[_0x1adb('0x4')]));function MailQueue(_0x5a2070){this['id']=_0x5a2070['id']||0x0;this[_0x1adb('0x8')]=_0x5a2070['name']||'';this['timeout']=_0x5a2070['timeout']||0xa;this[_0x1adb('0x9')]=_0x5a2070[_0x1adb('0x9')]||_0x1adb('0xa');this['Agents']=_0x5a2070[_0x1adb('0xb')];this[_0x1adb('0xc')]={};this[_0x1adb('0xd')]=0x0;this['md5']='';this[_0x1adb('0xe')]();this[_0x1adb('0xf')]();}MailQueue[_0x1adb('0x10')]['updateRouting']=function(){var _0x48cbaa=this['mapAgentsId'][_0x1adb('0x11')];this[_0x1adb('0xc')]=_[_0x1adb('0x12')](this[_0x1adb('0xb')],'id');this[_0x1adb('0xc')][_0x1adb('0x11')]=_0x48cbaa;};MailQueue[_0x1adb('0x10')]['updateRealtime']=function(){this[_0x1adb('0x13')]=0x0;this[_0x1adb('0x14')]=0x0;for(var _0x65cd59=0x0;_0x65cd59<this[_0x1adb('0xb')]['length'];_0x65cd59+=0x1){if(this[_0x1adb('0xb')][_0x65cd59][_0x1adb('0x15')]){this[_0x1adb('0x13')]+=0x1;}if(this['Agents'][_0x65cd59][_0x1adb('0x16')]){this['paused']+=0x1;}}this[_0x1adb('0x17')]=this['loggedIn']-this[_0x1adb('0x14')];this[_0x1adb('0x17')]=this[_0x1adb('0x17')]>=0x0?this[_0x1adb('0x17')]:0x0;var _0x52e733={'id':this['id'],'available':this[_0x1adb('0x17')],'loggedIn':this[_0x1adb('0x13')],'name':this[_0x1adb('0x8')],'paused':this['paused'],'waiting':this[_0x1adb('0xd')]};var _0x1467bd=md5(JSON['stringify'](_0x52e733));if(this['md5']!==_0x1467bd){this[_0x1adb('0x0')]=_0x1467bd;io['to'](util[_0x1adb('0x18')](_0x1adb('0x19'),_0x52e733[_0x1adb('0x8')]))[_0x1adb('0x1a')](_0x1adb('0x1b'),_0x52e733);}};module[_0x1adb('0x1c')]=MailQueue;