5d9fce1ad61f9d1f2d735fd01adb5d536bfdcf6b
[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 _0xdafb=['I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','notification:%s','save','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','BUSY','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','localhost','socket.io-emitter','redis','emit','format','user:%s','name','split','\x20interaction','account','notificationSound','notificationShake','body','queue','getMustacheRender','notificationTemplate','msg'];(function(_0x17406e,_0x1049fd){var _0x2bfc5a=function(_0x2aae05){while(--_0x2aae05){_0x17406e['push'](_0x17406e['shift']());}};_0x2bfc5a(++_0x1049fd);}(_0xdafb,0x1a9));var _0xbdaf=function(_0x57d44f,_0x128a06){_0x57d44f=_0x57d44f-0x0;var _0x192f63=_0xdafb[_0x57d44f];return _0x192f63;};'use strict';var _=require(_0xbdaf('0x0'));var util=require(_0xbdaf('0x1'));var utils=require(_0xbdaf('0x2'));var Mustache=require(_0xbdaf('0x3'));var Redis=require(_0xbdaf('0x4'));var config=require(_0xbdaf('0x5'));var logger=require(_0xbdaf('0x6'))(_0xbdaf('0x7'));config['redis']=_['defaults'](config['redis'],{'host':_0xbdaf('0x8'),'port':0x18eb});var io=require(_0xbdaf('0x9'))(new Redis(config[_0xbdaf('0xa')]));function emit(_0x43f837,_0x480667,_0x171a1b){io['to'](_0x43f837)[_0xbdaf('0xb')](_0x480667,_0x171a1b);}function sendNotification(_0x115b1b,_0x549a51,_0x57c52b,_0x20e3ff,_0x30774f,_0x31fea2){io['to'](util[_0xbdaf('0xc')](_0xbdaf('0xd'),_0x20e3ff[_0xbdaf('0xe')]))[_0xbdaf('0xb')]('user:save',_0x20e3ff);var _0x2fe1ab=_0x31fea2||{};var _0x596e64=_0x57c52b[_0xbdaf('0xf')]('.');var _0x1aca26={'uniqueid':_0x549a51,'channel':_0x596e64[0x0],'id':_0x596e64[0x1],'title':_0x596e64[0x0]+_0xbdaf('0x10'),'interactionId':_0x596e64[0x2],'queue':_0x30774f?_0x30774f[_0xbdaf('0xe')]:null,'sound':_0x2fe1ab[_0xbdaf('0x11')][_0xbdaf('0x12')],'shake':_0x2fe1ab[_0xbdaf('0x11')][_0xbdaf('0x13')]};try{if(!_0x2fe1ab['body']){_0x2fe1ab[_0xbdaf('0x14')]={};}if(_0x30774f){_0x2fe1ab['body']['queue']=_0x30774f;}else if(_0x2fe1ab['body'][_0xbdaf('0x15')]){delete _0x2fe1ab[_0xbdaf('0x14')][_0xbdaf('0x15')];}_0x1aca26['msg']=utils[_0xbdaf('0x16')](_0x2fe1ab['account'][_0xbdaf('0x17')],_0x2fe1ab);}catch(_0x415332){_0x1aca26[_0xbdaf('0x18')]=_0xbdaf('0x19');logger[_0xbdaf('0x1a')](util[_0xbdaf('0xc')](_0xbdaf('0x1b'),_0x549a51,_0x415332[_0xbdaf('0x1c')]));}io['to'](util[_0xbdaf('0xc')](_0xbdaf('0xd'),_0x20e3ff[_0xbdaf('0xe')]))[_0xbdaf('0xb')](util[_0xbdaf('0xc')](_0xbdaf('0x1d'),_0x115b1b?_0xbdaf('0x1e'):_0xbdaf('0x1f')),_0x1aca26);}function writeLog(_0x5dc382,_0x2aafea,_0x21ed88){return logger[_0xbdaf('0x20')](util[_0xbdaf('0xc')](_0xbdaf('0x21'),_0x5dc382,_0x2aafea[_0xbdaf('0xe')],_0x21ed88));}exports[_0xbdaf('0x22')]=function(_0x4b7d74,_0x25ce4a,_0x545ab2,_0x3a3ce8){if(_0x25ce4a['busy']){writeLog(_0x4b7d74,_0x25ce4a,_0xbdaf('0x23'));return![];}if(!_0x25ce4a['online']){writeLog(_0x4b7d74,_0x25ce4a,_0xbdaf('0x24'));return![];}if(_0x25ce4a[_0x545ab2+_0xbdaf('0x25')]){writeLog(_0x4b7d74,_0x25ce4a,'PAUSE');return![];}if(_0x3a3ce8&&_0x25ce4a[_0xbdaf('0x26')](_0x545ab2+_0xbdaf('0x27'))&&_0x25ce4a[_0xbdaf('0x26')](_0x545ab2+_0xbdaf('0x28'))){if(_0x25ce4a[_0x545ab2+_0xbdaf('0x27')]>0x0&&_0x25ce4a[_0x545ab2+'CurrentCapacity']>=_0x25ce4a[_0x545ab2+'Capacity']){writeLog(_0x4b7d74,_0x25ce4a,_0x545ab2[_0xbdaf('0x29')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports[_0xbdaf('0x2a')]=function(_0x802578,_0x225162,_0x1cefc2,_0x50ea52,_0xba7944){return sendNotification(!![],_0x802578,_0x225162,_0x1cefc2,_0x50ea52,_0xba7944);};exports[_0xbdaf('0x2b')]=function(_0x56c850,_0x63583b,_0x23f7b7,_0x532076,_0x4bded4){return sendNotification(![],_0x56c850,_0x63583b,_0x23f7b7,_0x532076,_0x4bded4);};exports[_0xbdaf('0x2c')]=writeLog;