Built motion from commit f7863d46.|2.5.41
[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 _0x0eaa=['updateRealtime','loggedIn','length','smsPause','paused','available','stringify','format','sms:queue:%s','sms_queue:save','exports','lodash','md5','../../../config/environment','redis','localhost','socket.io-emitter','name','strategy','Agents','mapAgentsId','waiting','updateRouting','prototype','map','_rr'];(function(_0x416c4b,_0x3600bf){var _0x52d2ec=function(_0x3d09bf){while(--_0x3d09bf){_0x416c4b['push'](_0x416c4b['shift']());}};_0x52d2ec(++_0x3600bf);}(_0x0eaa,0x1c5));var _0xa0ea=function(_0x203de2,_0x36b188){_0x203de2=_0x203de2-0x0;var _0x4ade6d=_0x0eaa[_0x203de2];return _0x4ade6d;};'use strict';var _=require(_0xa0ea('0x0'));var md5=require(_0xa0ea('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xa0ea('0x2'));config[_0xa0ea('0x3')]=_['defaults'](config[_0xa0ea('0x3')],{'host':_0xa0ea('0x4'),'port':0x18eb});var io=require(_0xa0ea('0x5'))(new Redis(config[_0xa0ea('0x3')]));function SmsQueue(_0x1d27f8){this['id']=_0x1d27f8['id']||0x0;this['name']=_0x1d27f8[_0xa0ea('0x6')]||'';this['timeout']=_0x1d27f8['timeout']||0xa;this[_0xa0ea('0x7')]=_0x1d27f8[_0xa0ea('0x7')]||'beepall';this['Agents']=_0x1d27f8[_0xa0ea('0x8')];this[_0xa0ea('0x9')]={};this[_0xa0ea('0xa')]=0x0;this[_0xa0ea('0x1')]='';this[_0xa0ea('0xb')]();this['updateRealtime']();}SmsQueue[_0xa0ea('0xc')][_0xa0ea('0xb')]=function(){var _0x33572c=this[_0xa0ea('0x9')]['_rr'];this[_0xa0ea('0x9')]=_[_0xa0ea('0xd')](this[_0xa0ea('0x8')],'id');this[_0xa0ea('0x9')][_0xa0ea('0xe')]=_0x33572c;};SmsQueue['prototype'][_0xa0ea('0xf')]=function(){this[_0xa0ea('0x10')]=0x0;this['paused']=0x0;for(var _0x3970e5=0x0;_0x3970e5<this[_0xa0ea('0x8')][_0xa0ea('0x11')];_0x3970e5+=0x1){if(this[_0xa0ea('0x8')][_0x3970e5]['online']){this[_0xa0ea('0x10')]+=0x1;}if(this[_0xa0ea('0x8')][_0x3970e5][_0xa0ea('0x12')]){this[_0xa0ea('0x13')]+=0x1;}}this[_0xa0ea('0x14')]=this[_0xa0ea('0x10')]-this[_0xa0ea('0x13')];this[_0xa0ea('0x14')]=this[_0xa0ea('0x14')]>=0x0?this[_0xa0ea('0x14')]:0x0;var _0x581f59={'id':this['id'],'available':this['available'],'loggedIn':this[_0xa0ea('0x10')],'name':this[_0xa0ea('0x6')],'paused':this[_0xa0ea('0x13')],'waiting':this[_0xa0ea('0xa')]};var _0x1f194d=md5(JSON[_0xa0ea('0x15')](_0x581f59));if(this[_0xa0ea('0x1')]!==_0x1f194d){this['md5']=_0x1f194d;io['to'](util[_0xa0ea('0x16')](_0xa0ea('0x17'),_0x581f59[_0xa0ea('0x6')]))['emit'](_0xa0ea('0x18'),_0x581f59);}};module[_0xa0ea('0x19')]=SmsQueue;