Built motion from commit da617fac.|2.6.6
[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 _0xb332=['map','loggedIn','length','online','smsPause','paused','available','stringify','md5','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','util','ioredis','redis','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr'];(function(_0x424057,_0x3e660c){var _0x150fba=function(_0x3aed67){while(--_0x3aed67){_0x424057['push'](_0x424057['shift']());}};_0x150fba(++_0x3e660c);}(_0xb332,0xd9));var _0x2b33=function(_0x4df6f9,_0x44bd65){_0x4df6f9=_0x4df6f9-0x0;var _0x4b1a73=_0xb332[_0x4df6f9];return _0x4b1a73;};'use strict';var _=require(_0x2b33('0x0'));var md5=require('md5');var util=require(_0x2b33('0x1'));var Redis=require(_0x2b33('0x2'));var config=require('../../../config/environment');config[_0x2b33('0x3')]=_['defaults'](config[_0x2b33('0x3')],{'host':'localhost','port':0x18eb});var io=require(_0x2b33('0x4'))(new Redis(config['redis']));function SmsQueue(_0xf9b9c2){this['id']=_0xf9b9c2['id']||0x0;this[_0x2b33('0x5')]=_0xf9b9c2[_0x2b33('0x5')]||'';this[_0x2b33('0x6')]=_0xf9b9c2['timeout']||0xa;this['strategy']=_0xf9b9c2[_0x2b33('0x7')]||'beepall';this[_0x2b33('0x8')]=_0xf9b9c2[_0x2b33('0x8')];this[_0x2b33('0x9')]={};this[_0x2b33('0xa')]=0x0;this['md5']='';this[_0x2b33('0xb')]();this[_0x2b33('0xc')]();}SmsQueue[_0x2b33('0xd')][_0x2b33('0xb')]=function(){var _0x1989f3=this[_0x2b33('0x9')][_0x2b33('0xe')];this[_0x2b33('0x9')]=_[_0x2b33('0xf')](this[_0x2b33('0x8')],'id');this[_0x2b33('0x9')]['_rr']=_0x1989f3;};SmsQueue[_0x2b33('0xd')][_0x2b33('0xc')]=function(){this[_0x2b33('0x10')]=0x0;this['paused']=0x0;for(var _0x173c75=0x0;_0x173c75<this['Agents'][_0x2b33('0x11')];_0x173c75+=0x1){if(this[_0x2b33('0x8')][_0x173c75][_0x2b33('0x12')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x173c75][_0x2b33('0x13')]){this[_0x2b33('0x14')]+=0x1;}}this[_0x2b33('0x15')]=this[_0x2b33('0x10')]-this[_0x2b33('0x14')];this['available']=this['available']>=0x0?this['available']:0x0;var _0x4041bd={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x2b33('0x5')],'paused':this[_0x2b33('0x14')],'waiting':this[_0x2b33('0xa')]};var _0x539c5f=md5(JSON[_0x2b33('0x16')](_0x4041bd));if(this['md5']!==_0x539c5f){this[_0x2b33('0x17')]=_0x539c5f;io['to'](util[_0x2b33('0x18')](_0x2b33('0x19'),_0x4041bd[_0x2b33('0x5')]))[_0x2b33('0x1a')](_0x2b33('0x1b'),_0x4041bd);}};module[_0x2b33('0x1c')]=SmsQueue;