Built motion from commit d69f4380.|2.6.29
[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 _0xbd50=['smsPause','available','waiting','stringify','sms_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','updateRouting','prototype','_rr','updateRealtime','loggedIn','paused','length'];(function(_0x5ddb1c,_0x5ea4df){var _0x354adc=function(_0x2dfb1f){while(--_0x2dfb1f){_0x5ddb1c['push'](_0x5ddb1c['shift']());}};_0x354adc(++_0x5ea4df);}(_0xbd50,0x196));var _0x0bd5=function(_0x4092de,_0x24186b){_0x4092de=_0x4092de-0x0;var _0x2e8a39=_0xbd50[_0x4092de];return _0x2e8a39;};'use strict';var _=require(_0x0bd5('0x0'));var md5=require(_0x0bd5('0x1'));var util=require(_0x0bd5('0x2'));var Redis=require('ioredis');var config=require(_0x0bd5('0x3'));config[_0x0bd5('0x4')]=_[_0x0bd5('0x5')](config[_0x0bd5('0x4')],{'host':_0x0bd5('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function SmsQueue(_0x560cf1){this['id']=_0x560cf1['id']||0x0;this[_0x0bd5('0x7')]=_0x560cf1[_0x0bd5('0x7')]||'';this[_0x0bd5('0x8')]=_0x560cf1[_0x0bd5('0x8')]||0xa;this[_0x0bd5('0x9')]=_0x560cf1['strategy']||'beepall';this[_0x0bd5('0xa')]=_0x560cf1[_0x0bd5('0xa')];this[_0x0bd5('0xb')]={};this['waiting']=0x0;this[_0x0bd5('0x1')]='';this[_0x0bd5('0xc')]();this['updateRealtime']();}SmsQueue[_0x0bd5('0xd')][_0x0bd5('0xc')]=function(){var _0x4d7d17=this[_0x0bd5('0xb')][_0x0bd5('0xe')];this[_0x0bd5('0xb')]=_['map'](this[_0x0bd5('0xa')],'id');this[_0x0bd5('0xb')][_0x0bd5('0xe')]=_0x4d7d17;};SmsQueue[_0x0bd5('0xd')][_0x0bd5('0xf')]=function(){this[_0x0bd5('0x10')]=0x0;this[_0x0bd5('0x11')]=0x0;for(var _0x1e961d=0x0;_0x1e961d<this['Agents'][_0x0bd5('0x12')];_0x1e961d+=0x1){if(this[_0x0bd5('0xa')][_0x1e961d]['online']){this[_0x0bd5('0x10')]+=0x1;}if(this[_0x0bd5('0xa')][_0x1e961d][_0x0bd5('0x13')]){this[_0x0bd5('0x11')]+=0x1;}}this['available']=this[_0x0bd5('0x10')]-this[_0x0bd5('0x11')];this[_0x0bd5('0x14')]=this[_0x0bd5('0x14')]>=0x0?this[_0x0bd5('0x14')]:0x0;var _0x23be38={'id':this['id'],'available':this[_0x0bd5('0x14')],'loggedIn':this[_0x0bd5('0x10')],'name':this[_0x0bd5('0x7')],'paused':this[_0x0bd5('0x11')],'waiting':this[_0x0bd5('0x15')]};var _0x415d8f=md5(JSON[_0x0bd5('0x16')](_0x23be38));if(this[_0x0bd5('0x1')]!==_0x415d8f){this['md5']=_0x415d8f;io['to'](util['format']('sms:queue:%s',_0x23be38['name']))['emit'](_0x0bd5('0x17'),_0x23be38);}};module[_0x0bd5('0x18')]=SmsQueue;