Built motion from commit e02f907f.|2.6.14
[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 _0x9df6=['some','channel','QueuesWaitingInteractions','capitalize','WaitingInteractions','saveWaitingNotification','agents','removeWaitingNotification','lodash','util','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','user:%s','name','emit','user:save','\x20interaction','account','notificationSound','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','message','format','notification:%s','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','hideNotification','checkWaitingNotifications','interaction','UserId'];(function(_0x5e8eae,_0x4f81e0){var _0xdd09cd=function(_0x28c85c){while(--_0x28c85c){_0x5e8eae['push'](_0x5e8eae['shift']());}};_0xdd09cd(++_0x4f81e0);}(_0x9df6,0x17b));var _0x69df=function(_0x43d11d,_0xccff91){_0x43d11d=_0x43d11d-0x0;var _0x38cd08=_0x9df6[_0x43d11d];return _0x38cd08;};'use strict';var _=require(_0x69df('0x0'));var util=require(_0x69df('0x1'));var utils=require('../utils');var Redis=require(_0x69df('0x2'));var config=require(_0x69df('0x3'));var logger=require(_0x69df('0x4'))(_0x69df('0x5'));config[_0x69df('0x6')]=_[_0x69df('0x7')](config[_0x69df('0x6')],{'host':_0x69df('0x8'),'port':0x18eb});var io=require(_0x69df('0x9'))(new Redis(config[_0x69df('0x6')]));function sendNotification(_0xbfbcf3,_0x53bc0d,_0x8483c8,_0x524596,_0x2a0ea8,_0x23d8bb){io['to'](util['format'](_0x69df('0xa'),_0x524596[_0x69df('0xb')]))[_0x69df('0xc')](_0x69df('0xd'),_0x524596);var _0x41b03c=_0x23d8bb||{};var _0x286e2f=_0x8483c8['split']('.');var _0x4c96e1={'uniqueid':_0x53bc0d,'channel':_0x286e2f[0x0],'id':_0x286e2f[0x1],'title':_0x286e2f[0x0]+_0x69df('0xe'),'interactionId':_0x286e2f[0x2],'queue':_0x2a0ea8?_0x2a0ea8[_0x69df('0xb')]:null,'sound':_0x41b03c[_0x69df('0xf')][_0x69df('0x10')],'shake':_0x41b03c[_0x69df('0xf')]['notificationShake']};try{if(!_0x41b03c['body']){_0x41b03c['body']={};}if(_0x2a0ea8){_0x41b03c[_0x69df('0x11')][_0x69df('0x12')]=_0x2a0ea8;}else if(_0x41b03c[_0x69df('0x11')][_0x69df('0x12')]){delete _0x41b03c[_0x69df('0x11')][_0x69df('0x12')];}_0x4c96e1[_0x69df('0x13')]=utils['getMustacheRender'](_0x41b03c[_0x69df('0xf')][_0x69df('0x14')],_0x41b03c);}catch(_0x3c1686){_0x4c96e1[_0x69df('0x13')]=_0x69df('0x15');logger['error'](util['format'](_0x69df('0x16'),_0x53bc0d,_0x3c1686[_0x69df('0x17')]));}io['to'](util['format'](_0x69df('0xa'),_0x524596[_0x69df('0xb')]))[_0x69df('0xc')](util[_0x69df('0x18')](_0x69df('0x19'),_0xbfbcf3?'save':_0x69df('0x1a')),_0x4c96e1);}function writeLog(_0x4afc17,_0x10a505,_0x1ae9c9){return logger[_0x69df('0x1b')](util['format'](_0x69df('0x1c'),_0x4afc17,_0x10a505[_0x69df('0xb')],_0x1ae9c9));}exports[_0x69df('0x1d')]=function(_0x4cbb5e,_0x912602,_0xe31be0,_0x4af49b){if(_0x912602[_0x69df('0x1e')]){writeLog(_0x4cbb5e,_0x912602,_0x69df('0x1f'));return![];}if(!_0x912602[_0x69df('0x20')]){writeLog(_0x4cbb5e,_0x912602,_0x69df('0x21'));return![];}if(_0x912602[_0xe31be0+_0x69df('0x22')]){writeLog(_0x4cbb5e,_0x912602,_0x69df('0x23'));return![];}if(_0x4af49b&&_0x912602[_0x69df('0x24')](_0xe31be0+_0x69df('0x25'))&&_0x912602[_0x69df('0x24')](_0xe31be0+_0x69df('0x26'))){if(_0x912602[_0xe31be0+_0x69df('0x25')]>0x0&&_0x912602[_0xe31be0+_0x69df('0x26')]>=_0x912602[_0xe31be0+_0x69df('0x25')]){writeLog(_0x4cbb5e,_0x912602,_0xe31be0[_0x69df('0x27')]()+_0x69df('0x28'));return![];}}return!![];};exports['showNotification']=function(_0x485b76,_0x54b7d4,_0x3579b,_0x320ecd,_0x3ebe6f){return sendNotification(!![],_0x485b76,_0x54b7d4,_0x3579b,_0x320ecd,_0x3ebe6f);};exports[_0x69df('0x29')]=function(_0x415ae9,_0xff7326,_0x9ada69,_0x38dfd2,_0x4ce076){return sendNotification(![],_0x415ae9,_0xff7326,_0x9ada69,_0x38dfd2,_0x4ce076);};exports[_0x69df('0x2a')]=function(_0x2bbe48,_0x54eda3,_0x3d1084){var _0x5d5a6a=_0x54eda3[_0x69df('0x2b')][_0x69df('0x2c')];if(!_0x5d5a6a&&_0x3d1084){_0x5d5a6a=_0x3d1084['id'];}var _0x532d55=_[_0x69df('0x2d')](_0x2bbe48[_0x54eda3[_0x69df('0x2e')]+_0x69df('0x2f')],function(_0xd81e23){var _0x5121d2=_[_0x69df('0x30')](_0x54eda3[_0x69df('0x2e')])+'InteractionId';return _0xd81e23[_0x5121d2]===_0x54eda3[_0x69df('0x2b')]['id'];});if(!_0x532d55&&_0x5d5a6a){_0x532d55=_['some'](_0x2bbe48['agents'][_0x5d5a6a][_0x54eda3[_0x69df('0x2e')]+_0x69df('0x31')],function(_0x110b78){return _0x110b78['id']===_0x54eda3[_0x69df('0x2b')]['id'];});}return _0x532d55;};exports[_0x69df('0x32')]=function(_0x348d53,_0x425cf3,_0x377fa6,_0xfb90ea){_0x348d53[_0x69df('0x33')][_0x377fa6['id']][_0xfb90ea+'WaitingInteractions'][_0x425cf3['message']['id']]={'id':_0x425cf3[_0x69df('0x2b')]['id']};};exports[_0x69df('0x34')]=function(_0x2884e5,_0xce1af7,_0x39b21b,_0x4b3bb0){delete _0x2884e5['agents'][_0x39b21b['id']][_0x4b3bb0+'WaitingInteractions'][_0xce1af7[_0x69df('0x17')]['id']];};exports['writeLog']=writeLog;