Built motion from commit 3c2ce842.|2.6.31
[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 _0x6a24=['name','strategy','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','length','smsPause','available','waiting','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','ioredis','../../../config/environment','redis','defaults','socket.io-emitter'];(function(_0x30e4c8,_0x11b4e5){var _0x5b129d=function(_0x45cd55){while(--_0x45cd55){_0x30e4c8['push'](_0x30e4c8['shift']());}};_0x5b129d(++_0x11b4e5);}(_0x6a24,0xd1));var _0x46a2=function(_0x1e725e,_0x815936){_0x1e725e=_0x1e725e-0x0;var _0x2fdfe1=_0x6a24[_0x1e725e];return _0x2fdfe1;};'use strict';var _=require(_0x46a2('0x0'));var md5=require(_0x46a2('0x1'));var util=require('util');var Redis=require(_0x46a2('0x2'));var config=require(_0x46a2('0x3'));config[_0x46a2('0x4')]=_[_0x46a2('0x5')](config[_0x46a2('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0x46a2('0x6'))(new Redis(config[_0x46a2('0x4')]));function SmsQueue(_0x4f6948){this['id']=_0x4f6948['id']||0x0;this[_0x46a2('0x7')]=_0x4f6948[_0x46a2('0x7')]||'';this['timeout']=_0x4f6948['timeout']||0xa;this[_0x46a2('0x8')]=_0x4f6948[_0x46a2('0x8')]||'beepall';this[_0x46a2('0x9')]=_0x4f6948['Agents'];this[_0x46a2('0xa')]={};this['waiting']=0x0;this[_0x46a2('0x1')]='';this[_0x46a2('0xb')]();this[_0x46a2('0xc')]();}SmsQueue[_0x46a2('0xd')][_0x46a2('0xb')]=function(){var _0x40ef63=this[_0x46a2('0xa')][_0x46a2('0xe')];this['mapAgentsId']=_['map'](this[_0x46a2('0x9')],'id');this[_0x46a2('0xa')]['_rr']=_0x40ef63;};SmsQueue[_0x46a2('0xd')][_0x46a2('0xc')]=function(){this[_0x46a2('0xf')]=0x0;this[_0x46a2('0x10')]=0x0;for(var _0xddc328=0x0;_0xddc328<this[_0x46a2('0x9')][_0x46a2('0x11')];_0xddc328+=0x1){if(this[_0x46a2('0x9')][_0xddc328]['online']){this['loggedIn']+=0x1;}if(this[_0x46a2('0x9')][_0xddc328][_0x46a2('0x12')]){this['paused']+=0x1;}}this[_0x46a2('0x13')]=this[_0x46a2('0xf')]-this['paused'];this[_0x46a2('0x13')]=this[_0x46a2('0x13')]>=0x0?this['available']:0x0;var _0x27250b={'id':this['id'],'available':this[_0x46a2('0x13')],'loggedIn':this['loggedIn'],'name':this[_0x46a2('0x7')],'paused':this[_0x46a2('0x10')],'waiting':this[_0x46a2('0x14')]};var _0xc28d15=md5(JSON[_0x46a2('0x15')](_0x27250b));if(this[_0x46a2('0x1')]!==_0xc28d15){this[_0x46a2('0x1')]=_0xc28d15;io['to'](util[_0x46a2('0x16')](_0x46a2('0x17'),_0x27250b[_0x46a2('0x7')]))[_0x46a2('0x18')](_0x46a2('0x19'),_0x27250b);}};module[_0x46a2('0x1a')]=SmsQueue;