Built motion from commit c738b9ac.|2.6.25
[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 _0xa3e6=['name','timeout','strategy','Agents','md5','updateRealtime','updateRouting','mapAgentsId','_rr','map','prototype','loggedIn','paused','length','online','smsPause','available','waiting','format','emit','sms_queue:save','exports','lodash','util','../../../config/environment','redis','defaults','localhost'];(function(_0x33b065,_0x2bb180){var _0x16bc95=function(_0x18cd93){while(--_0x18cd93){_0x33b065['push'](_0x33b065['shift']());}};_0x16bc95(++_0x2bb180);}(_0xa3e6,0xbe));var _0x6a3e=function(_0x3bfd98,_0xc13ab4){_0x3bfd98=_0x3bfd98-0x0;var _0x1f64d7=_0xa3e6[_0x3bfd98];return _0x1f64d7;};'use strict';var _=require(_0x6a3e('0x0'));var md5=require('md5');var util=require(_0x6a3e('0x1'));var Redis=require('ioredis');var config=require(_0x6a3e('0x2'));config[_0x6a3e('0x3')]=_[_0x6a3e('0x4')](config['redis'],{'host':_0x6a3e('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6a3e('0x3')]));function SmsQueue(_0x23599b){this['id']=_0x23599b['id']||0x0;this[_0x6a3e('0x6')]=_0x23599b[_0x6a3e('0x6')]||'';this[_0x6a3e('0x7')]=_0x23599b['timeout']||0xa;this[_0x6a3e('0x8')]=_0x23599b[_0x6a3e('0x8')]||'beepall';this['Agents']=_0x23599b[_0x6a3e('0x9')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x6a3e('0xa')]='';this['updateRouting']();this[_0x6a3e('0xb')]();}SmsQueue['prototype'][_0x6a3e('0xc')]=function(){var _0x3159db=this[_0x6a3e('0xd')][_0x6a3e('0xe')];this[_0x6a3e('0xd')]=_[_0x6a3e('0xf')](this['Agents'],'id');this[_0x6a3e('0xd')][_0x6a3e('0xe')]=_0x3159db;};SmsQueue[_0x6a3e('0x10')][_0x6a3e('0xb')]=function(){this[_0x6a3e('0x11')]=0x0;this[_0x6a3e('0x12')]=0x0;for(var _0x222f7c=0x0;_0x222f7c<this['Agents'][_0x6a3e('0x13')];_0x222f7c+=0x1){if(this[_0x6a3e('0x9')][_0x222f7c][_0x6a3e('0x14')]){this[_0x6a3e('0x11')]+=0x1;}if(this['Agents'][_0x222f7c][_0x6a3e('0x15')]){this[_0x6a3e('0x12')]+=0x1;}}this['available']=this['loggedIn']-this['paused'];this['available']=this['available']>=0x0?this[_0x6a3e('0x16')]:0x0;var _0x467e2c={'id':this['id'],'available':this[_0x6a3e('0x16')],'loggedIn':this[_0x6a3e('0x11')],'name':this[_0x6a3e('0x6')],'paused':this[_0x6a3e('0x12')],'waiting':this[_0x6a3e('0x17')]};var _0x2f2150=md5(JSON['stringify'](_0x467e2c));if(this[_0x6a3e('0xa')]!==_0x2f2150){this['md5']=_0x2f2150;io['to'](util[_0x6a3e('0x18')]('sms:queue:%s',_0x467e2c[_0x6a3e('0x6')]))[_0x6a3e('0x19')](_0x6a3e('0x1a'),_0x467e2c);}};module[_0x6a3e('0x1b')]=SmsQueue;