Built motion from commit (unavailable).|2.3.4
[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 _0xcfbc=['ioredis','redis','defaults','localhost','socket.io-emitter','name','strategy','beepall','Agents','waiting','updateRealtime','prototype','updateRouting','_rr','mapAgentsId','map','loggedIn','paused','length','smsPause','available','stringify','sms:queue:%s','emit','lodash','md5','util'];(function(_0x59a628,_0x41988e){var _0x220f4d=function(_0x2b81fa){while(--_0x2b81fa){_0x59a628['push'](_0x59a628['shift']());}};_0x220f4d(++_0x41988e);}(_0xcfbc,0x141));var _0xccfb=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xcfbc[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0xccfb('0x0'));var md5=require(_0xccfb('0x1'));var util=require(_0xccfb('0x2'));var Redis=require(_0xccfb('0x3'));var config=require('../../../config/environment');config[_0xccfb('0x4')]=_[_0xccfb('0x5')](config[_0xccfb('0x4')],{'host':_0xccfb('0x6'),'port':0x18eb});var io=require(_0xccfb('0x7'))(new Redis(config['redis']));function SmsQueue(_0x49a845){this['id']=_0x49a845['id']||0x0;this[_0xccfb('0x8')]=_0x49a845['name']||'';this['timeout']=_0x49a845['timeout']||0xa;this[_0xccfb('0x9')]=_0x49a845[_0xccfb('0x9')]||_0xccfb('0xa');this['Agents']=_0x49a845[_0xccfb('0xb')];this['mapAgentsId']={};this[_0xccfb('0xc')]=0x0;this[_0xccfb('0x1')]='';this['updateRouting']();this[_0xccfb('0xd')]();}SmsQueue[_0xccfb('0xe')][_0xccfb('0xf')]=function(){var _0x3127e8=this['mapAgentsId'][_0xccfb('0x10')];this[_0xccfb('0x11')]=_[_0xccfb('0x12')](this[_0xccfb('0xb')],'id');this[_0xccfb('0x11')][_0xccfb('0x10')]=_0x3127e8;};SmsQueue['prototype']['updateRealtime']=function(){this[_0xccfb('0x13')]=0x0;this[_0xccfb('0x14')]=0x0;for(var _0x142a14=0x0;_0x142a14<this[_0xccfb('0xb')][_0xccfb('0x15')];_0x142a14+=0x1){if(this[_0xccfb('0xb')][_0x142a14]['online']){this[_0xccfb('0x13')]+=0x1;}if(this[_0xccfb('0xb')][_0x142a14][_0xccfb('0x16')]){this[_0xccfb('0x14')]+=0x1;}}this[_0xccfb('0x17')]=this[_0xccfb('0x13')]-this[_0xccfb('0x14')];this[_0xccfb('0x17')]=this[_0xccfb('0x17')]>=0x0?this['available']:0x0;var _0x4b2802={'id':this['id'],'available':this[_0xccfb('0x17')],'loggedIn':this[_0xccfb('0x13')],'name':this[_0xccfb('0x8')],'paused':this[_0xccfb('0x14')],'waiting':this[_0xccfb('0xc')]};var _0xe839d=md5(JSON[_0xccfb('0x18')](_0x4b2802));if(this[_0xccfb('0x1')]!==_0xe839d){this[_0xccfb('0x1')]=_0xe839d;io['to'](util['format'](_0xccfb('0x19'),_0x4b2802['name']))[_0xccfb('0x1a')]('sms_queue:save',_0x4b2802);}};module['exports']=SmsQueue;