Built motion from commit db94841.|2.5.3
[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 _0xb921=['error','[%s][QUEUE]\x20%s','notification:%s','save','info','isAgentAvailable','BUSY','online','OFFLINE','Pause','hasOwnProperty','CurrentCapacity','Capacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','routing','redis','defaults','localhost','socket.io-emitter','emit','format','user:%s','name','user:save','split','account','notificationSound','notificationShake','body','queue','getMustacheRender','notificationTemplate','msg','I\x20can\x27t\x20render\x20your\x20template'];(function(_0x179c4a,_0x10eb06){var _0x5d1879=function(_0x1f1dcd){while(--_0x1f1dcd){_0x179c4a['push'](_0x179c4a['shift']());}};_0x5d1879(++_0x10eb06);}(_0xb921,0x16a));var _0x1b92=function(_0x4efb56,_0x1ef9b0){_0x4efb56=_0x4efb56-0x0;var _0x4daf4e=_0xb921[_0x4efb56];return _0x4daf4e;};'use strict';var _=require(_0x1b92('0x0'));var util=require(_0x1b92('0x1'));var utils=require(_0x1b92('0x2'));var Mustache=require(_0x1b92('0x3'));var Redis=require(_0x1b92('0x4'));var config=require('../../../../../config/environment');var logger=require('../../../../../config/logger')(_0x1b92('0x5'));config[_0x1b92('0x6')]=_[_0x1b92('0x7')](config[_0x1b92('0x6')],{'host':_0x1b92('0x8'),'port':0x18eb});var io=require(_0x1b92('0x9'))(new Redis(config[_0x1b92('0x6')]));function emit(_0x8a6282,_0x7973df,_0x352406){io['to'](_0x8a6282)[_0x1b92('0xa')](_0x7973df,_0x352406);}function sendNotification(_0x64a3ed,_0x2cf050,_0x37b876,_0x4567ab,_0x4c8e30,_0x31e314){io['to'](util[_0x1b92('0xb')](_0x1b92('0xc'),_0x4567ab[_0x1b92('0xd')]))[_0x1b92('0xa')](_0x1b92('0xe'),_0x4567ab);var _0x3deaf4=_0x31e314||{};var _0x4aee95=_0x37b876[_0x1b92('0xf')]('.');var _0x3b5e5b={'uniqueid':_0x2cf050,'channel':_0x4aee95[0x0],'id':_0x4aee95[0x1],'title':_0x4aee95[0x0]+'\x20interaction','interactionId':_0x4aee95[0x2],'queue':_0x4c8e30?_0x4c8e30[_0x1b92('0xd')]:null,'sound':_0x3deaf4[_0x1b92('0x10')][_0x1b92('0x11')],'shake':_0x3deaf4[_0x1b92('0x10')][_0x1b92('0x12')]};try{if(!_0x3deaf4[_0x1b92('0x13')]){_0x3deaf4[_0x1b92('0x13')]={};}if(_0x4c8e30){_0x3deaf4['body'][_0x1b92('0x14')]=_0x4c8e30;}else if(_0x3deaf4['body'][_0x1b92('0x14')]){delete _0x3deaf4['body'][_0x1b92('0x14')];}_0x3b5e5b['msg']=utils[_0x1b92('0x15')](_0x3deaf4[_0x1b92('0x10')][_0x1b92('0x16')],_0x3deaf4);}catch(_0x5f3ded){_0x3b5e5b[_0x1b92('0x17')]=_0x1b92('0x18');logger[_0x1b92('0x19')](util[_0x1b92('0xb')](_0x1b92('0x1a'),_0x2cf050,_0x5f3ded['message']));}io['to'](util[_0x1b92('0xb')](_0x1b92('0xc'),_0x4567ab[_0x1b92('0xd')]))['emit'](util[_0x1b92('0xb')](_0x1b92('0x1b'),_0x64a3ed?_0x1b92('0x1c'):'remove'),_0x3b5e5b);}function writeLog(_0x1d9d28,_0x5c61d0,_0x39ef4e){return logger[_0x1b92('0x1d')](util['format']('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x1d9d28,_0x5c61d0[_0x1b92('0xd')],_0x39ef4e));}exports[_0x1b92('0x1e')]=function(_0x3e3698,_0x2badce,_0x41fc82,_0x186030){if(_0x2badce['busy']){writeLog(_0x3e3698,_0x2badce,_0x1b92('0x1f'));return![];}if(!_0x2badce[_0x1b92('0x20')]){writeLog(_0x3e3698,_0x2badce,_0x1b92('0x21'));return![];}if(_0x2badce[_0x41fc82+_0x1b92('0x22')]){writeLog(_0x3e3698,_0x2badce,'PAUSE');return![];}if(_0x186030&&_0x2badce[_0x1b92('0x23')](_0x41fc82+'Capacity')&&_0x2badce[_0x1b92('0x23')](_0x41fc82+_0x1b92('0x24'))){if(_0x2badce[_0x41fc82+_0x1b92('0x25')]>0x0&&_0x2badce[_0x41fc82+_0x1b92('0x24')]>=_0x2badce[_0x41fc82+_0x1b92('0x25')]){writeLog(_0x3e3698,_0x2badce,_0x41fc82[_0x1b92('0x26')]()+_0x1b92('0x27'));return![];}}return!![];};exports[_0x1b92('0x28')]=function(_0x4edbce,_0x5d82cf,_0x54d92c,_0x229c44,_0x525d05){return sendNotification(!![],_0x4edbce,_0x5d82cf,_0x54d92c,_0x229c44,_0x525d05);};exports[_0x1b92('0x29')]=function(_0x5d006b,_0x462949,_0x4656aa,_0x26f832,_0x4f0b55){return sendNotification(![],_0x5d006b,_0x462949,_0x4656aa,_0x26f832,_0x4f0b55);};exports[_0x1b92('0x2a')]=writeLog;