Built motion from commit (unavailable).|2.0.81
[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 _0xca08=['busy','BUSY','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','writeLog','util','mustache','../../../../../config/logger','routing','socket.io-emitter','emit','format','name','user:save','\x20interaction','account','notificationSound','body','queue','msg','getMustacheRender','notificationTemplate','error','[%s][QUEUE]\x20%s','notification:%s','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable'];(function(_0x15eb81,_0x3ae4f5){var _0x80aff2=function(_0x30a60a){while(--_0x30a60a){_0x15eb81['push'](_0x15eb81['shift']());}};_0x80aff2(++_0x3ae4f5);}(_0xca08,0x1a2));var _0x8ca0=function(_0x13f23e,_0x7336bb){_0x13f23e=_0x13f23e-0x0;var _0x36cc13=_0xca08[_0x13f23e];return _0x36cc13;};'use strict';var util=require(_0x8ca0('0x0'));var utils=require('../utils');var Mustache=require(_0x8ca0('0x1'));var logger=require(_0x8ca0('0x2'))(_0x8ca0('0x3'));var io=require(_0x8ca0('0x4'))({'host':'localhost','port':0x18eb});function emit(_0x5d99e3,_0x53b7fa,_0x1bdf57){io['to'](_0x5d99e3)[_0x8ca0('0x5')](_0x53b7fa,_0x1bdf57);}function sendNotification(_0x4ecd93,_0x1f69be,_0x225073,_0x59ab6b,_0x5efcbe,_0x332e02){io['to'](util[_0x8ca0('0x6')]('user:%s',_0x59ab6b[_0x8ca0('0x7')]))['emit'](_0x8ca0('0x8'),_0x59ab6b);var _0x91ae12=_0x332e02||{};var _0x5a30a8=_0x225073['split']('.');var _0x14f7d0={'uniqueid':_0x1f69be,'channel':_0x5a30a8[0x0],'id':_0x5a30a8[0x1],'title':_0x5a30a8[0x0]+_0x8ca0('0x9'),'interactionId':_0x5a30a8[0x2],'queue':_0x5efcbe?_0x5efcbe[_0x8ca0('0x7')]:null,'sound':_0x91ae12[_0x8ca0('0xa')][_0x8ca0('0xb')],'shake':_0x91ae12['account']['notificationShake']};try{if(!_0x91ae12['body']){_0x91ae12[_0x8ca0('0xc')]={};}if(_0x5efcbe){_0x91ae12['body']['queue']=_0x5efcbe;}else if(_0x91ae12[_0x8ca0('0xc')][_0x8ca0('0xd')]){delete _0x91ae12[_0x8ca0('0xc')][_0x8ca0('0xd')];}_0x14f7d0[_0x8ca0('0xe')]=utils[_0x8ca0('0xf')](_0x91ae12[_0x8ca0('0xa')][_0x8ca0('0x10')],_0x91ae12);}catch(_0x1c61f7){_0x14f7d0['msg']='I\x20can\x27t\x20render\x20your\x20template';logger[_0x8ca0('0x11')](util[_0x8ca0('0x6')](_0x8ca0('0x12'),_0x1f69be,_0x1c61f7['message']));}io['to'](util[_0x8ca0('0x6')]('user:%s',_0x59ab6b[_0x8ca0('0x7')]))['emit'](util[_0x8ca0('0x6')](_0x8ca0('0x13'),_0x4ecd93?'save':_0x8ca0('0x14')),_0x14f7d0);}function writeLog(_0xa2de05,_0x1b0ff7,_0x28b6b8){return logger[_0x8ca0('0x15')](util[_0x8ca0('0x6')](_0x8ca0('0x16'),_0xa2de05,_0x1b0ff7[_0x8ca0('0x7')],_0x28b6b8));}exports[_0x8ca0('0x17')]=function(_0x521bf6,_0x21820e,_0x5f8f59,_0x18b105){if(_0x21820e[_0x8ca0('0x18')]){writeLog(_0x521bf6,_0x21820e,_0x8ca0('0x19'));return![];}if(!_0x21820e['online']){writeLog(_0x521bf6,_0x21820e,'OFFLINE');return![];}if(_0x21820e[_0x5f8f59+_0x8ca0('0x1a')]){writeLog(_0x521bf6,_0x21820e,_0x8ca0('0x1b'));return![];}if(_0x18b105&&_0x21820e[_0x8ca0('0x1c')](_0x5f8f59+_0x8ca0('0x1d'))&&_0x21820e[_0x8ca0('0x1c')](_0x5f8f59+_0x8ca0('0x1e'))){if(_0x21820e[_0x5f8f59+_0x8ca0('0x1d')]>0x0&&_0x21820e[_0x5f8f59+'CurrentCapacity']>=_0x21820e[_0x5f8f59+_0x8ca0('0x1d')]){writeLog(_0x521bf6,_0x21820e,_0x5f8f59[_0x8ca0('0x1f')]()+_0x8ca0('0x20'));return![];}}return!![];};exports['showNotification']=function(_0x12b7c7,_0x64834d,_0x27c7f7,_0x3a8201,_0xfdb916){return sendNotification(!![],_0x12b7c7,_0x64834d,_0x27c7f7,_0x3a8201,_0xfdb916);};exports['hideNotification']=function(_0x572218,_0xbb1b2d,_0x380121,_0x45a575,_0xc9311e){return sendNotification(![],_0x572218,_0xbb1b2d,_0x380121,_0x45a575,_0xc9311e);};exports[_0x8ca0('0x21')]=writeLog;