Built motion from commit (unavailable).|2.5.4
[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 _0x0df9=['emit','format','user:%s','name','split','account','notificationSound','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','notification:%s','save','remove','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','BUSY','OFFLINE','Pause','PAUSE','Capacity','hasOwnProperty','CurrentCapacity','\x20MAXCAPACITY','showNotification','hideNotification','lodash','../utils','mustache','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter'];(function(_0x284240,_0x555b56){var _0x390667=function(_0x409454){while(--_0x409454){_0x284240['push'](_0x284240['shift']());}};_0x390667(++_0x555b56);}(_0x0df9,0x170));var _0x90df=function(_0x178a31,_0x31719e){_0x178a31=_0x178a31-0x0;var _0x177c0e=_0x0df9[_0x178a31];return _0x177c0e;};'use strict';var _=require(_0x90df('0x0'));var util=require('util');var utils=require(_0x90df('0x1'));var Mustache=require(_0x90df('0x2'));var Redis=require('ioredis');var config=require(_0x90df('0x3'));var logger=require(_0x90df('0x4'))(_0x90df('0x5'));config[_0x90df('0x6')]=_[_0x90df('0x7')](config[_0x90df('0x6')],{'host':_0x90df('0x8'),'port':0x18eb});var io=require(_0x90df('0x9'))(new Redis(config[_0x90df('0x6')]));function emit(_0x2fc700,_0x5d2e61,_0x5ccd23){io['to'](_0x2fc700)[_0x90df('0xa')](_0x5d2e61,_0x5ccd23);}function sendNotification(_0x102fca,_0x5dabe8,_0x4148cc,_0x28474b,_0x7b1260,_0x1527ad){io['to'](util[_0x90df('0xb')](_0x90df('0xc'),_0x28474b[_0x90df('0xd')]))['emit']('user:save',_0x28474b);var _0x402fa1=_0x1527ad||{};var _0x112c95=_0x4148cc[_0x90df('0xe')]('.');var _0x26bf9c={'uniqueid':_0x5dabe8,'channel':_0x112c95[0x0],'id':_0x112c95[0x1],'title':_0x112c95[0x0]+'\x20interaction','interactionId':_0x112c95[0x2],'queue':_0x7b1260?_0x7b1260[_0x90df('0xd')]:null,'sound':_0x402fa1[_0x90df('0xf')][_0x90df('0x10')],'shake':_0x402fa1[_0x90df('0xf')][_0x90df('0x11')]};try{if(!_0x402fa1['body']){_0x402fa1[_0x90df('0x12')]={};}if(_0x7b1260){_0x402fa1[_0x90df('0x12')]['queue']=_0x7b1260;}else if(_0x402fa1['body'][_0x90df('0x13')]){delete _0x402fa1[_0x90df('0x12')][_0x90df('0x13')];}_0x26bf9c[_0x90df('0x14')]=utils[_0x90df('0x15')](_0x402fa1['account'][_0x90df('0x16')],_0x402fa1);}catch(_0x161681){_0x26bf9c[_0x90df('0x14')]=_0x90df('0x17');logger[_0x90df('0x18')](util['format'](_0x90df('0x19'),_0x5dabe8,_0x161681[_0x90df('0x1a')]));}io['to'](util[_0x90df('0xb')]('user:%s',_0x28474b[_0x90df('0xd')]))[_0x90df('0xa')](util['format'](_0x90df('0x1b'),_0x102fca?_0x90df('0x1c'):_0x90df('0x1d')),_0x26bf9c);}function writeLog(_0x1ca4c1,_0x18584d,_0x4117bf){return logger['info'](util['format'](_0x90df('0x1e'),_0x1ca4c1,_0x18584d['name'],_0x4117bf));}exports[_0x90df('0x1f')]=function(_0x3e837b,_0x5d28b0,_0x50f384,_0x12dce2){if(_0x5d28b0['busy']){writeLog(_0x3e837b,_0x5d28b0,_0x90df('0x20'));return![];}if(!_0x5d28b0['online']){writeLog(_0x3e837b,_0x5d28b0,_0x90df('0x21'));return![];}if(_0x5d28b0[_0x50f384+_0x90df('0x22')]){writeLog(_0x3e837b,_0x5d28b0,_0x90df('0x23'));return![];}if(_0x12dce2&&_0x5d28b0['hasOwnProperty'](_0x50f384+_0x90df('0x24'))&&_0x5d28b0[_0x90df('0x25')](_0x50f384+_0x90df('0x26'))){if(_0x5d28b0[_0x50f384+'Capacity']>0x0&&_0x5d28b0[_0x50f384+_0x90df('0x26')]>=_0x5d28b0[_0x50f384+'Capacity']){writeLog(_0x3e837b,_0x5d28b0,_0x50f384['toUpperCase']()+_0x90df('0x27'));return![];}}return!![];};exports[_0x90df('0x28')]=function(_0x123ba9,_0x3f30d6,_0x2d14c2,_0x133ce1,_0x5f95c8){return sendNotification(!![],_0x123ba9,_0x3f30d6,_0x2d14c2,_0x133ce1,_0x5f95c8);};exports[_0x90df('0x29')]=function(_0x37cf9d,_0x4e6ea2,_0x1e2c38,_0x2ff8f4,_0x5c8479){return sendNotification(![],_0x37cf9d,_0x4e6ea2,_0x1e2c38,_0x2ff8f4,_0x5c8479);};exports['writeLog']=writeLog;