Built motion from commit 97153652.|2.6.26
[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 _0x0c57=['localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRealtime','mapAgentsId','_rr','prototype','loggedIn','length','mailPause','paused','available','stringify','format','mail:queue:%s','emit','exports','md5','util','ioredis','../../../config/environment','redis'];(function(_0x817d9b,_0x3c37e3){var _0x2752e1=function(_0x2b434e){while(--_0x2b434e){_0x817d9b['push'](_0x817d9b['shift']());}};_0x2752e1(++_0x3c37e3);}(_0x0c57,0x190));var _0x70c5=function(_0x2a9b35,_0x27e2cd){_0x2a9b35=_0x2a9b35-0x0;var _0x1253ec=_0x0c57[_0x2a9b35];return _0x1253ec;};'use strict';var _=require('lodash');var md5=require(_0x70c5('0x0'));var util=require(_0x70c5('0x1'));var Redis=require(_0x70c5('0x2'));var config=require(_0x70c5('0x3'));config[_0x70c5('0x4')]=_['defaults'](config[_0x70c5('0x4')],{'host':_0x70c5('0x5'),'port':0x18eb});var io=require(_0x70c5('0x6'))(new Redis(config[_0x70c5('0x4')]));function MailQueue(_0x4ad029){this['id']=_0x4ad029['id']||0x0;this[_0x70c5('0x7')]=_0x4ad029[_0x70c5('0x7')]||'';this[_0x70c5('0x8')]=_0x4ad029[_0x70c5('0x8')]||0xa;this[_0x70c5('0x9')]=_0x4ad029['strategy']||_0x70c5('0xa');this[_0x70c5('0xb')]=_0x4ad029['Agents'];this['mapAgentsId']={};this[_0x70c5('0xc')]=0x0;this[_0x70c5('0x0')]='';this['updateRouting']();this[_0x70c5('0xd')]();}MailQueue['prototype']['updateRouting']=function(){var _0x381513=this[_0x70c5('0xe')][_0x70c5('0xf')];this['mapAgentsId']=_['map'](this[_0x70c5('0xb')],'id');this['mapAgentsId']['_rr']=_0x381513;};MailQueue[_0x70c5('0x10')][_0x70c5('0xd')]=function(){this[_0x70c5('0x11')]=0x0;this['paused']=0x0;for(var _0xed0f69=0x0;_0xed0f69<this[_0x70c5('0xb')][_0x70c5('0x12')];_0xed0f69+=0x1){if(this[_0x70c5('0xb')][_0xed0f69]['online']){this[_0x70c5('0x11')]+=0x1;}if(this['Agents'][_0xed0f69][_0x70c5('0x13')]){this['paused']+=0x1;}}this['available']=this[_0x70c5('0x11')]-this[_0x70c5('0x14')];this[_0x70c5('0x15')]=this[_0x70c5('0x15')]>=0x0?this[_0x70c5('0x15')]:0x0;var _0xfd28fe={'id':this['id'],'available':this['available'],'loggedIn':this[_0x70c5('0x11')],'name':this[_0x70c5('0x7')],'paused':this[_0x70c5('0x14')],'waiting':this[_0x70c5('0xc')]};var _0x21ccfe=md5(JSON[_0x70c5('0x16')](_0xfd28fe));if(this[_0x70c5('0x0')]!==_0x21ccfe){this[_0x70c5('0x0')]=_0x21ccfe;io['to'](util[_0x70c5('0x17')](_0x70c5('0x18'),_0xfd28fe[_0x70c5('0x7')]))[_0x70c5('0x19')]('mail_queue:save',_0xfd28fe);}};module[_0x70c5('0x1a')]=MailQueue;