Built motion from commit (unavailable).|2.5.1
[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 _0xf485=['split','\x20interaction','notificationShake','body','queue','account','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','emit','notification:%s','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','busy','online','OFFLINE','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','routing','redis','socket.io-emitter','format','user:%s','name','user:save'];(function(_0xbc06f9,_0xa90d4c){var _0x1668b0=function(_0x5aab57){while(--_0x5aab57){_0xbc06f9['push'](_0xbc06f9['shift']());}};_0x1668b0(++_0xa90d4c);}(_0xf485,0xd1));var _0x5f48=function(_0x517123,_0x2353ca){_0x517123=_0x517123-0x0;var _0x1e3e0d=_0xf485[_0x517123];return _0x1e3e0d;};'use strict';var _=require(_0x5f48('0x0'));var util=require(_0x5f48('0x1'));var utils=require(_0x5f48('0x2'));var Mustache=require(_0x5f48('0x3'));var Redis=require(_0x5f48('0x4'));var config=require(_0x5f48('0x5'));var logger=require('../../../../../config/logger')(_0x5f48('0x6'));config[_0x5f48('0x7')]=_['defaults'](config[_0x5f48('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x5f48('0x8'))(new Redis(config['redis']));function emit(_0xb2021,_0x126cb7,_0x3c6f45){io['to'](_0xb2021)['emit'](_0x126cb7,_0x3c6f45);}function sendNotification(_0x3fb7e5,_0x1d722c,_0x205bce,_0x5019de,_0x24aead,_0x2b51a2){io['to'](util[_0x5f48('0x9')](_0x5f48('0xa'),_0x5019de[_0x5f48('0xb')]))['emit'](_0x5f48('0xc'),_0x5019de);var _0x2a650e=_0x2b51a2||{};var _0x37f13b=_0x205bce[_0x5f48('0xd')]('.');var _0xd825ba={'uniqueid':_0x1d722c,'channel':_0x37f13b[0x0],'id':_0x37f13b[0x1],'title':_0x37f13b[0x0]+_0x5f48('0xe'),'interactionId':_0x37f13b[0x2],'queue':_0x24aead?_0x24aead[_0x5f48('0xb')]:null,'sound':_0x2a650e['account']['notificationSound'],'shake':_0x2a650e['account'][_0x5f48('0xf')]};try{if(!_0x2a650e[_0x5f48('0x10')]){_0x2a650e['body']={};}if(_0x24aead){_0x2a650e['body'][_0x5f48('0x11')]=_0x24aead;}else if(_0x2a650e['body'][_0x5f48('0x11')]){delete _0x2a650e['body']['queue'];}_0xd825ba['msg']=utils['getMustacheRender'](_0x2a650e[_0x5f48('0x12')]['notificationTemplate'],_0x2a650e);}catch(_0x24ce1b){_0xd825ba['msg']=_0x5f48('0x13');logger[_0x5f48('0x14')](util['format'](_0x5f48('0x15'),_0x1d722c,_0x24ce1b[_0x5f48('0x16')]));}io['to'](util[_0x5f48('0x9')]('user:%s',_0x5019de[_0x5f48('0xb')]))[_0x5f48('0x17')](util[_0x5f48('0x9')](_0x5f48('0x18'),_0x3fb7e5?'save':_0x5f48('0x19')),_0xd825ba);}function writeLog(_0x4918d0,_0xa573de,_0x23ca24){return logger[_0x5f48('0x1a')](util['format'](_0x5f48('0x1b'),_0x4918d0,_0xa573de[_0x5f48('0xb')],_0x23ca24));}exports['isAgentAvailable']=function(_0x4b4757,_0x46e767,_0x39b007,_0x131a79){if(_0x46e767[_0x5f48('0x1c')]){writeLog(_0x4b4757,_0x46e767,'BUSY');return![];}if(!_0x46e767[_0x5f48('0x1d')]){writeLog(_0x4b4757,_0x46e767,_0x5f48('0x1e'));return![];}if(_0x46e767[_0x39b007+'Pause']){writeLog(_0x4b4757,_0x46e767,_0x5f48('0x1f'));return![];}if(_0x131a79&&_0x46e767[_0x5f48('0x20')](_0x39b007+_0x5f48('0x21'))&&_0x46e767[_0x5f48('0x20')](_0x39b007+_0x5f48('0x22'))){if(_0x46e767[_0x39b007+'Capacity']>0x0&&_0x46e767[_0x39b007+_0x5f48('0x22')]>=_0x46e767[_0x39b007+_0x5f48('0x21')]){writeLog(_0x4b4757,_0x46e767,_0x39b007[_0x5f48('0x23')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports['showNotification']=function(_0xdd8a6d,_0x1b6a79,_0x1132fb,_0x12823a,_0x477b9d){return sendNotification(!![],_0xdd8a6d,_0x1b6a79,_0x1132fb,_0x12823a,_0x477b9d);};exports['hideNotification']=function(_0x4631b8,_0x348f3d,_0x2f4a73,_0x1ad1d2,_0x13ffc3){return sendNotification(![],_0x4631b8,_0x348f3d,_0x2f4a73,_0x1ad1d2,_0x13ffc3);};exports[_0x5f48('0x24')]=writeLog;