Built motion from commit (unavailable).|2.5.30
[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 _0xa503=['../../../../../config/environment','../../../../../config/logger','defaults','redis','emit','format','user:%s','name','user:save','account','notificationSound','body','queue','getMustacheRender','msg','error','[%s][QUEUE]\x20%s','message','notification:%s','save','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','BUSY','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','writeLog','lodash','util','../utils','mustache','ioredis'];(function(_0x103eb8,_0x310eb3){var _0x19155d=function(_0xd552ec){while(--_0xd552ec){_0x103eb8['push'](_0x103eb8['shift']());}};_0x19155d(++_0x310eb3);}(_0xa503,0x143));var _0x3a50=function(_0x274242,_0x18d7b2){_0x274242=_0x274242-0x0;var _0x148bab=_0xa503[_0x274242];return _0x148bab;};'use strict';var _=require(_0x3a50('0x0'));var util=require(_0x3a50('0x1'));var utils=require(_0x3a50('0x2'));var Mustache=require(_0x3a50('0x3'));var Redis=require(_0x3a50('0x4'));var config=require(_0x3a50('0x5'));var logger=require(_0x3a50('0x6'))('routing');config['redis']=_[_0x3a50('0x7')](config[_0x3a50('0x8')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x3a50('0x8')]));function emit(_0x3ad392,_0x44bd93,_0x307280){io['to'](_0x3ad392)[_0x3a50('0x9')](_0x44bd93,_0x307280);}function sendNotification(_0x1cd114,_0x58b86e,_0x2ed3f7,_0x1c2d44,_0x43491b,_0xae7b4b){io['to'](util[_0x3a50('0xa')](_0x3a50('0xb'),_0x1c2d44[_0x3a50('0xc')]))['emit'](_0x3a50('0xd'),_0x1c2d44);var _0x15440c=_0xae7b4b||{};var _0x1c5a82=_0x2ed3f7['split']('.');var _0x1bfd3f={'uniqueid':_0x58b86e,'channel':_0x1c5a82[0x0],'id':_0x1c5a82[0x1],'title':_0x1c5a82[0x0]+'\x20interaction','interactionId':_0x1c5a82[0x2],'queue':_0x43491b?_0x43491b[_0x3a50('0xc')]:null,'sound':_0x15440c[_0x3a50('0xe')][_0x3a50('0xf')],'shake':_0x15440c[_0x3a50('0xe')]['notificationShake']};try{if(!_0x15440c[_0x3a50('0x10')]){_0x15440c['body']={};}if(_0x43491b){_0x15440c[_0x3a50('0x10')][_0x3a50('0x11')]=_0x43491b;}else if(_0x15440c[_0x3a50('0x10')][_0x3a50('0x11')]){delete _0x15440c['body'][_0x3a50('0x11')];}_0x1bfd3f['msg']=utils[_0x3a50('0x12')](_0x15440c[_0x3a50('0xe')]['notificationTemplate'],_0x15440c);}catch(_0x549b70){_0x1bfd3f[_0x3a50('0x13')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0x3a50('0x14')](util[_0x3a50('0xa')](_0x3a50('0x15'),_0x58b86e,_0x549b70[_0x3a50('0x16')]));}io['to'](util['format'](_0x3a50('0xb'),_0x1c2d44['name']))[_0x3a50('0x9')](util[_0x3a50('0xa')](_0x3a50('0x17'),_0x1cd114?_0x3a50('0x18'):_0x3a50('0x19')),_0x1bfd3f);}function writeLog(_0x231a24,_0x1eeeec,_0x42c445){return logger[_0x3a50('0x1a')](util[_0x3a50('0xa')](_0x3a50('0x1b'),_0x231a24,_0x1eeeec['name'],_0x42c445));}exports[_0x3a50('0x1c')]=function(_0x1c0754,_0x558426,_0x219f34,_0x33333f){if(_0x558426['busy']){writeLog(_0x1c0754,_0x558426,_0x3a50('0x1d'));return![];}if(!_0x558426[_0x3a50('0x1e')]){writeLog(_0x1c0754,_0x558426,_0x3a50('0x1f'));return![];}if(_0x558426[_0x219f34+_0x3a50('0x20')]){writeLog(_0x1c0754,_0x558426,_0x3a50('0x21'));return![];}if(_0x33333f&&_0x558426[_0x3a50('0x22')](_0x219f34+_0x3a50('0x23'))&&_0x558426[_0x3a50('0x22')](_0x219f34+_0x3a50('0x24'))){if(_0x558426[_0x219f34+_0x3a50('0x23')]>0x0&&_0x558426[_0x219f34+_0x3a50('0x24')]>=_0x558426[_0x219f34+_0x3a50('0x23')]){writeLog(_0x1c0754,_0x558426,_0x219f34[_0x3a50('0x25')]()+_0x3a50('0x26'));return![];}}return!![];};exports[_0x3a50('0x27')]=function(_0xca5e99,_0x44bc6f,_0x253b13,_0x232efd,_0x4dc6c8){return sendNotification(!![],_0xca5e99,_0x44bc6f,_0x253b13,_0x232efd,_0x4dc6c8);};exports['hideNotification']=function(_0x41ab10,_0x18336e,_0x1a7ceb,_0x55d6d3,_0x5162ae){return sendNotification(![],_0x41ab10,_0x18336e,_0x1a7ceb,_0x55d6d3,_0x5162ae);};exports[_0x3a50('0x28')]=writeLog;