c9a066c4f9659a3aa79cb43b63d707be4754bb17
[motion2.git] / server / services / routing / model / smsQueue.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 _0xfe57=['_rr','map','prototype','loggedIn','smsPause','paused','available','waiting','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime'];(function(_0x33feef,_0x41c9d1){var _0x4497b4=function(_0x408fd7){while(--_0x408fd7){_0x33feef['push'](_0x33feef['shift']());}};_0x4497b4(++_0x41c9d1);}(_0xfe57,0x195));var _0x7fe5=function(_0x20e7e3,_0x1529be){_0x20e7e3=_0x20e7e3-0x0;var _0x14b9de=_0xfe57[_0x20e7e3];return _0x14b9de;};'use strict';var _=require(_0x7fe5('0x0'));var md5=require(_0x7fe5('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x7fe5('0x2'));config[_0x7fe5('0x3')]=_[_0x7fe5('0x4')](config[_0x7fe5('0x3')],{'host':_0x7fe5('0x5'),'port':0x18eb});var io=require(_0x7fe5('0x6'))(new Redis(config[_0x7fe5('0x3')]));function SmsQueue(_0x444eb5){this['id']=_0x444eb5['id']||0x0;this[_0x7fe5('0x7')]=_0x444eb5[_0x7fe5('0x7')]||'';this[_0x7fe5('0x8')]=_0x444eb5[_0x7fe5('0x8')]||0xa;this[_0x7fe5('0x9')]=_0x444eb5['strategy']||_0x7fe5('0xa');this['Agents']=_0x444eb5[_0x7fe5('0xb')];this[_0x7fe5('0xc')]={};this['waiting']=0x0;this['md5']='';this[_0x7fe5('0xd')]();this[_0x7fe5('0xe')]();}SmsQueue['prototype'][_0x7fe5('0xd')]=function(){var _0x5f494d=this['mapAgentsId'][_0x7fe5('0xf')];this[_0x7fe5('0xc')]=_[_0x7fe5('0x10')](this[_0x7fe5('0xb')],'id');this['mapAgentsId'][_0x7fe5('0xf')]=_0x5f494d;};SmsQueue[_0x7fe5('0x11')]['updateRealtime']=function(){this[_0x7fe5('0x12')]=0x0;this['paused']=0x0;for(var _0x1f84b5=0x0;_0x1f84b5<this[_0x7fe5('0xb')]['length'];_0x1f84b5+=0x1){if(this[_0x7fe5('0xb')][_0x1f84b5]['online']){this[_0x7fe5('0x12')]+=0x1;}if(this[_0x7fe5('0xb')][_0x1f84b5][_0x7fe5('0x13')]){this[_0x7fe5('0x14')]+=0x1;}}this[_0x7fe5('0x15')]=this[_0x7fe5('0x12')]-this['paused'];this[_0x7fe5('0x15')]=this[_0x7fe5('0x15')]>=0x0?this[_0x7fe5('0x15')]:0x0;var _0x1be963={'id':this['id'],'available':this[_0x7fe5('0x15')],'loggedIn':this[_0x7fe5('0x12')],'name':this[_0x7fe5('0x7')],'paused':this[_0x7fe5('0x14')],'waiting':this[_0x7fe5('0x16')]};var _0x3b98cd=md5(JSON['stringify'](_0x1be963));if(this['md5']!==_0x3b98cd){this[_0x7fe5('0x1')]=_0x3b98cd;io['to'](util[_0x7fe5('0x17')](_0x7fe5('0x18'),_0x1be963[_0x7fe5('0x7')]))[_0x7fe5('0x19')](_0x7fe5('0x1a'),_0x1be963);}};module[_0x7fe5('0x1b')]=SmsQueue;