Built motion from commit 85328c08.|2.5.50
[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 _0xfc1e=['redis','defaults','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRealtime','prototype','updateRouting','_rr','map','loggedIn','paused','length','online','smsPause','available','sms:queue:%s','emit','sms_queue:save','ioredis','../../../config/environment'];(function(_0x374ccf,_0xa945c4){var _0x443cde=function(_0x27ff10){while(--_0x27ff10){_0x374ccf['push'](_0x374ccf['shift']());}};_0x443cde(++_0xa945c4);}(_0xfc1e,0x1c9));var _0xefc1=function(_0x1cd47d,_0x55bc75){_0x1cd47d=_0x1cd47d-0x0;var _0x29d52f=_0xfc1e[_0x1cd47d];return _0x29d52f;};'use strict';var _=require('lodash');var md5=require('md5');var util=require('util');var Redis=require(_0xefc1('0x0'));var config=require(_0xefc1('0x1'));config[_0xefc1('0x2')]=_[_0xefc1('0x3')](config[_0xefc1('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0xefc1('0x4'))(new Redis(config[_0xefc1('0x2')]));function SmsQueue(_0x489ead){this['id']=_0x489ead['id']||0x0;this['name']=_0x489ead[_0xefc1('0x5')]||'';this[_0xefc1('0x6')]=_0x489ead[_0xefc1('0x6')]||0xa;this[_0xefc1('0x7')]=_0x489ead[_0xefc1('0x7')]||_0xefc1('0x8');this[_0xefc1('0x9')]=_0x489ead[_0xefc1('0x9')];this[_0xefc1('0xa')]={};this[_0xefc1('0xb')]=0x0;this[_0xefc1('0xc')]='';this['updateRouting']();this[_0xefc1('0xd')]();}SmsQueue[_0xefc1('0xe')][_0xefc1('0xf')]=function(){var _0x1f4846=this[_0xefc1('0xa')][_0xefc1('0x10')];this[_0xefc1('0xa')]=_[_0xefc1('0x11')](this[_0xefc1('0x9')],'id');this[_0xefc1('0xa')][_0xefc1('0x10')]=_0x1f4846;};SmsQueue['prototype'][_0xefc1('0xd')]=function(){this[_0xefc1('0x12')]=0x0;this[_0xefc1('0x13')]=0x0;for(var _0x36633f=0x0;_0x36633f<this[_0xefc1('0x9')][_0xefc1('0x14')];_0x36633f+=0x1){if(this[_0xefc1('0x9')][_0x36633f][_0xefc1('0x15')]){this['loggedIn']+=0x1;}if(this[_0xefc1('0x9')][_0x36633f][_0xefc1('0x16')]){this[_0xefc1('0x13')]+=0x1;}}this['available']=this[_0xefc1('0x12')]-this[_0xefc1('0x13')];this[_0xefc1('0x17')]=this[_0xefc1('0x17')]>=0x0?this[_0xefc1('0x17')]:0x0;var _0x38923c={'id':this['id'],'available':this[_0xefc1('0x17')],'loggedIn':this[_0xefc1('0x12')],'name':this['name'],'paused':this[_0xefc1('0x13')],'waiting':this[_0xefc1('0xb')]};var _0x2670a9=md5(JSON['stringify'](_0x38923c));if(this['md5']!==_0x2670a9){this[_0xefc1('0xc')]=_0x2670a9;io['to'](util['format'](_0xefc1('0x18'),_0x38923c['name']))[_0xefc1('0x19')](_0xefc1('0x1a'),_0x38923c);}};module['exports']=SmsQueue;