Built motion from commit 67e5df37.|2.0.66
[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 _0xdce8=['body','queue','notificationTemplate','msg','error','format','[%s][QUEUE]\x20%s','message','save','remove','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','Pause','hasOwnProperty','Capacity','toUpperCase','showNotification','hideNotification','writeLog','../utils','mustache','../../../../../config/logger','socket.io-emitter','emit','user:%s','name','split','account','notificationSound','notificationShake'];(function(_0x30149e,_0x16e7a5){var _0x4a1876=function(_0x3d1dfc){while(--_0x3d1dfc){_0x30149e['push'](_0x30149e['shift']());}};_0x4a1876(++_0x16e7a5);}(_0xdce8,0x149));var _0x8dce=function(_0x54e20e,_0x3d3f40){_0x54e20e=_0x54e20e-0x0;var _0x13d1c4=_0xdce8[_0x54e20e];return _0x13d1c4;};'use strict';var util=require('util');var utils=require(_0x8dce('0x0'));var Mustache=require(_0x8dce('0x1'));var logger=require(_0x8dce('0x2'))('routing');var io=require(_0x8dce('0x3'))({'host':'localhost','port':0x18eb});function emit(_0x469fd0,_0xaf8919,_0x4bf371){io['to'](_0x469fd0)[_0x8dce('0x4')](_0xaf8919,_0x4bf371);}function sendNotification(_0x533af6,_0x4630cb,_0x4e8e6f,_0x153f94,_0x190d72,_0x45af49){io['to'](util['format'](_0x8dce('0x5'),_0x153f94[_0x8dce('0x6')]))['emit']('user:save',_0x153f94);var _0x3565c8=_0x45af49||{};var _0x587d58=_0x4e8e6f[_0x8dce('0x7')]('.');var _0x3a4900={'uniqueid':_0x4630cb,'channel':_0x587d58[0x0],'id':_0x587d58[0x1],'title':_0x587d58[0x0]+'\x20interaction','interactionId':_0x587d58[0x2],'queue':_0x190d72?_0x190d72['name']:null,'sound':_0x3565c8[_0x8dce('0x8')][_0x8dce('0x9')],'shake':_0x3565c8[_0x8dce('0x8')][_0x8dce('0xa')]};try{if(!_0x3565c8[_0x8dce('0xb')]){_0x3565c8['body']={};}if(_0x190d72){_0x3565c8[_0x8dce('0xb')][_0x8dce('0xc')]=_0x190d72;}else if(_0x3565c8['body']['queue']){delete _0x3565c8[_0x8dce('0xb')]['queue'];}_0x3a4900['msg']=utils['getMustacheRender'](_0x3565c8[_0x8dce('0x8')][_0x8dce('0xd')],_0x3565c8);}catch(_0x14c446){_0x3a4900[_0x8dce('0xe')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0x8dce('0xf')](util[_0x8dce('0x10')](_0x8dce('0x11'),_0x4630cb,_0x14c446[_0x8dce('0x12')]));}io['to'](util[_0x8dce('0x10')](_0x8dce('0x5'),_0x153f94[_0x8dce('0x6')]))['emit'](util[_0x8dce('0x10')]('notification:%s',_0x533af6?_0x8dce('0x13'):_0x8dce('0x14')),_0x3a4900);}function writeLog(_0x2798d5,_0x5080ff,_0xad45ac){return logger[_0x8dce('0x15')](util['format'](_0x8dce('0x16'),_0x2798d5,_0x5080ff[_0x8dce('0x6')],_0xad45ac));}exports[_0x8dce('0x17')]=function(_0x137a04,_0x1a081a,_0x1f495c,_0x258160){if(_0x1a081a[_0x8dce('0x18')]){writeLog(_0x137a04,_0x1a081a,_0x8dce('0x19'));return![];}if(!_0x1a081a[_0x8dce('0x1a')]){writeLog(_0x137a04,_0x1a081a,'OFFLINE');return![];}if(_0x1a081a[_0x1f495c+_0x8dce('0x1b')]){writeLog(_0x137a04,_0x1a081a,'PAUSE');return![];}if(_0x258160&&_0x1a081a[_0x8dce('0x1c')](_0x1f495c+'Capacity')&&_0x1a081a[_0x8dce('0x1c')](_0x1f495c+'CurrentCapacity')){if(_0x1a081a[_0x1f495c+'Capacity']>0x0&&_0x1a081a[_0x1f495c+'CurrentCapacity']>=_0x1a081a[_0x1f495c+_0x8dce('0x1d')]){writeLog(_0x137a04,_0x1a081a,_0x1f495c[_0x8dce('0x1e')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports[_0x8dce('0x1f')]=function(_0x1dc523,_0x248fd6,_0x3174ef,_0xb2af0,_0x5cbb27){return sendNotification(!![],_0x1dc523,_0x248fd6,_0x3174ef,_0xb2af0,_0x5cbb27);};exports[_0x8dce('0x20')]=function(_0x3371ac,_0x19a441,_0x3cee95,_0x4fd54e,_0x5f1471){return sendNotification(![],_0x3371ac,_0x19a441,_0x3cee95,_0x4fd54e,_0x5f1471);};exports[_0x8dce('0x21')]=writeLog;