Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / services / routing / server / applications / strategy / util.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 _0xaaa2=['OFFLINE','PAUSE','hasOwnProperty','CurrentCapacity','Capacity','toUpperCase','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','routing','defaults','redis','localhost','socket.io-emitter','format','user:%s','emit','user:save','split','\x20interaction','name','account','notificationSound','notificationShake','body','queue','msg','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','busy','online'];(function(_0x5374a2,_0x4947d8){var _0x343822=function(_0x3e00a5){while(--_0x3e00a5){_0x5374a2['push'](_0x5374a2['shift']());}};_0x343822(++_0x4947d8);}(_0xaaa2,0xac));var _0x2aaa=function(_0x2a14b5,_0x5d0f7b){_0x2a14b5=_0x2a14b5-0x0;var _0x3464c1=_0xaaa2[_0x2a14b5];return _0x3464c1;};'use strict';var _=require(_0x2aaa('0x0'));var util=require(_0x2aaa('0x1'));var utils=require(_0x2aaa('0x2'));var Mustache=require(_0x2aaa('0x3'));var Redis=require(_0x2aaa('0x4'));var config=require(_0x2aaa('0x5'));var logger=require('../../../../../config/logger')(_0x2aaa('0x6'));config['redis']=_[_0x2aaa('0x7')](config[_0x2aaa('0x8')],{'host':_0x2aaa('0x9'),'port':0x18eb});var io=require(_0x2aaa('0xa'))(new Redis(config[_0x2aaa('0x8')]));function emit(_0x106af9,_0x4f51e6,_0x2f16d7){io['to'](_0x106af9)['emit'](_0x4f51e6,_0x2f16d7);}function sendNotification(_0x505fe8,_0x139ca7,_0x56fa01,_0x1ad6e9,_0x491279,_0x4f1343){io['to'](util[_0x2aaa('0xb')](_0x2aaa('0xc'),_0x1ad6e9['name']))[_0x2aaa('0xd')](_0x2aaa('0xe'),_0x1ad6e9);var _0x2e3bd2=_0x4f1343||{};var _0x501e2b=_0x56fa01[_0x2aaa('0xf')]('.');var _0x1d7162={'uniqueid':_0x139ca7,'channel':_0x501e2b[0x0],'id':_0x501e2b[0x1],'title':_0x501e2b[0x0]+_0x2aaa('0x10'),'interactionId':_0x501e2b[0x2],'queue':_0x491279?_0x491279[_0x2aaa('0x11')]:null,'sound':_0x2e3bd2[_0x2aaa('0x12')][_0x2aaa('0x13')],'shake':_0x2e3bd2[_0x2aaa('0x12')][_0x2aaa('0x14')]};try{if(!_0x2e3bd2[_0x2aaa('0x15')]){_0x2e3bd2[_0x2aaa('0x15')]={};}if(_0x491279){_0x2e3bd2[_0x2aaa('0x15')][_0x2aaa('0x16')]=_0x491279;}else if(_0x2e3bd2['body'][_0x2aaa('0x16')]){delete _0x2e3bd2['body'][_0x2aaa('0x16')];}_0x1d7162[_0x2aaa('0x17')]=utils['getMustacheRender'](_0x2e3bd2['account']['notificationTemplate'],_0x2e3bd2);}catch(_0xadf40a){_0x1d7162[_0x2aaa('0x17')]=_0x2aaa('0x18');logger[_0x2aaa('0x19')](util[_0x2aaa('0xb')](_0x2aaa('0x1a'),_0x139ca7,_0xadf40a[_0x2aaa('0x1b')]));}io['to'](util['format'](_0x2aaa('0xc'),_0x1ad6e9[_0x2aaa('0x11')]))['emit'](util[_0x2aaa('0xb')]('notification:%s',_0x505fe8?'save':_0x2aaa('0x1c')),_0x1d7162);}function writeLog(_0x5052eb,_0x2450e7,_0x3e7649){return logger[_0x2aaa('0x1d')](util[_0x2aaa('0xb')](_0x2aaa('0x1e'),_0x5052eb,_0x2450e7[_0x2aaa('0x11')],_0x3e7649));}exports['isAgentAvailable']=function(_0x333b03,_0x38b37a,_0x4836b2,_0x4d35aa){if(_0x38b37a[_0x2aaa('0x1f')]){writeLog(_0x333b03,_0x38b37a,'BUSY');return![];}if(!_0x38b37a[_0x2aaa('0x20')]){writeLog(_0x333b03,_0x38b37a,_0x2aaa('0x21'));return![];}if(_0x38b37a[_0x4836b2+'Pause']){writeLog(_0x333b03,_0x38b37a,_0x2aaa('0x22'));return![];}if(_0x4d35aa&&_0x38b37a[_0x2aaa('0x23')](_0x4836b2+'Capacity')&&_0x38b37a[_0x2aaa('0x23')](_0x4836b2+_0x2aaa('0x24'))){if(_0x38b37a[_0x4836b2+_0x2aaa('0x25')]>0x0&&_0x38b37a[_0x4836b2+'CurrentCapacity']>=_0x38b37a[_0x4836b2+_0x2aaa('0x25')]){writeLog(_0x333b03,_0x38b37a,_0x4836b2[_0x2aaa('0x26')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports['showNotification']=function(_0x3af929,_0xc9169,_0x2f9772,_0xd9891d,_0x3a6a63){return sendNotification(!![],_0x3af929,_0xc9169,_0x2f9772,_0xd9891d,_0x3a6a63);};exports[_0x2aaa('0x27')]=function(_0x2f8305,_0x166dc0,_0x12cd47,_0x19472b,_0x39788b){return sendNotification(![],_0x2f8305,_0x166dc0,_0x12cd47,_0x19472b,_0x39788b);};exports[_0x2aaa('0x28')]=writeLog;