Built motion from commit d5e4af8c.|2.6.23
[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 _0xb2b3=['waiting','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','paused','length','online','available','stringify','format','sms:queue:%s','emit','sms_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId'];(function(_0x49c351,_0x104b09){var _0x1fb07c=function(_0x3eca6a){while(--_0x3eca6a){_0x49c351['push'](_0x49c351['shift']());}};_0x1fb07c(++_0x104b09);}(_0xb2b3,0x71));var _0x3b2b=function(_0x30b29c,_0x10f252){_0x30b29c=_0x30b29c-0x0;var _0x1e05f7=_0xb2b3[_0x30b29c];return _0x1e05f7;};'use strict';var _=require(_0x3b2b('0x0'));var md5=require(_0x3b2b('0x1'));var util=require(_0x3b2b('0x2'));var Redis=require(_0x3b2b('0x3'));var config=require(_0x3b2b('0x4'));config[_0x3b2b('0x5')]=_[_0x3b2b('0x6')](config['redis'],{'host':_0x3b2b('0x7'),'port':0x18eb});var io=require(_0x3b2b('0x8'))(new Redis(config[_0x3b2b('0x5')]));function SmsQueue(_0x45e179){this['id']=_0x45e179['id']||0x0;this[_0x3b2b('0x9')]=_0x45e179[_0x3b2b('0x9')]||'';this[_0x3b2b('0xa')]=_0x45e179[_0x3b2b('0xa')]||0xa;this[_0x3b2b('0xb')]=_0x45e179[_0x3b2b('0xb')]||_0x3b2b('0xc');this[_0x3b2b('0xd')]=_0x45e179['Agents'];this[_0x3b2b('0xe')]={};this[_0x3b2b('0xf')]=0x0;this[_0x3b2b('0x1')]='';this[_0x3b2b('0x10')]();this[_0x3b2b('0x11')]();}SmsQueue[_0x3b2b('0x12')]['updateRouting']=function(){var _0x492f5f=this[_0x3b2b('0xe')][_0x3b2b('0x13')];this[_0x3b2b('0xe')]=_[_0x3b2b('0x14')](this['Agents'],'id');this[_0x3b2b('0xe')][_0x3b2b('0x13')]=_0x492f5f;};SmsQueue[_0x3b2b('0x12')][_0x3b2b('0x11')]=function(){this[_0x3b2b('0x15')]=0x0;this[_0x3b2b('0x16')]=0x0;for(var _0x52b63f=0x0;_0x52b63f<this[_0x3b2b('0xd')][_0x3b2b('0x17')];_0x52b63f+=0x1){if(this['Agents'][_0x52b63f][_0x3b2b('0x18')]){this[_0x3b2b('0x15')]+=0x1;}if(this[_0x3b2b('0xd')][_0x52b63f]['smsPause']){this[_0x3b2b('0x16')]+=0x1;}}this['available']=this[_0x3b2b('0x15')]-this[_0x3b2b('0x16')];this['available']=this['available']>=0x0?this[_0x3b2b('0x19')]:0x0;var _0x52bba5={'id':this['id'],'available':this[_0x3b2b('0x19')],'loggedIn':this[_0x3b2b('0x15')],'name':this['name'],'paused':this[_0x3b2b('0x16')],'waiting':this['waiting']};var _0x26f83=md5(JSON[_0x3b2b('0x1a')](_0x52bba5));if(this['md5']!==_0x26f83){this['md5']=_0x26f83;io['to'](util[_0x3b2b('0x1b')](_0x3b2b('0x1c'),_0x52bba5[_0x3b2b('0x9')]))[_0x3b2b('0x1d')](_0x3b2b('0x1e'),_0x52bba5);}};module[_0x3b2b('0x1f')]=SmsQueue;