c9983337d5d256c006de0f6633538c056739de35
[motion2.git] / server / services / routing / server / applications / gotoif.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 _0xfe12=['../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','length','error','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','message','[%s][GOTOIF]\x20%s','stringify','validate','lodash','./utils'];(function(_0x4f68ea,_0x4f873a){var _0x3da13b=function(_0x114456){while(--_0x114456){_0x4f68ea['push'](_0x4f68ea['shift']());}};_0x3da13b(++_0x4f873a);}(_0xfe12,0x93));var _0x2fe1=function(_0x10f6e8,_0x351db6){_0x10f6e8=_0x10f6e8-0x0;var _0x35bb3c=_0xfe12[_0x10f6e8];return _0x35bb3c;};'use strict';var schema=require(_0x2fe1('0x0'));var _=require(_0x2fe1('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x2fe1('0x2'));var logger=require(_0x2fe1('0x3'))(_0x2fe1('0x4'));var gotoif=schema({'condition':{'type':_0x2fe1('0x5'),'required':!![],'message':_0x2fe1('0x6')},'priorityTrue':{'type':_0x2fe1('0x7'),'message':_0x2fe1('0x8')},'priorityFalse':{'type':_0x2fe1('0x7'),'message':_0x2fe1('0x9')}});exports[_0x2fe1('0xa')]=function(_0x39f961,_0x5d9cd8){return function(_0x20ab37){try{var _0x2ed186={'condition':htmlToText[_0x2fe1('0xb')](utils[_0x2fe1('0xc')](_0x5d9cd8[0x0],this),{'wordwrap':![]})[_0x2fe1('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x5d9cd8[0x1],'priorityFalse':_0x5d9cd8[0x2]};var _0x32b43d=gotoif[_0x2fe1('0x0')](_0x2ed186,{'typecast':!![]});if(_0x32b43d[_0x2fe1('0xe')]){logger[_0x2fe1('0xf')]('[%s][GOTOIF]\x20%s',_0x39f961,_['map'](_0x32b43d,'message')[_0x2fe1('0x10')](',\x20'));_0x20ab37[_0x2fe1('0x11')]();}else{try{var _0x193f45=eval('('+_0x2ed186[_0x2fe1('0x12')]+')');var _0x53d81f=_0x193f45?_0x2ed186[_0x2fe1('0x13')]:_0x2ed186[_0x2fe1('0x14')];logger[_0x2fe1('0x15')](_0x2fe1('0x16'),_0x39f961,_0x2ed186[_0x2fe1('0x12')],_0x193f45,_0x53d81f||'next');if(_0x53d81f){var _0x544aa0=_[_0x2fe1('0x17')](_0x20ab37['rules'](),{'p':_0x53d81f});if(_0x544aa0>=0x0){logger[_0x2fe1('0x15')](_0x2fe1('0x18'),_0x39f961,_0x53d81f||'next',_0x544aa0);_0x20ab37[_0x2fe1('0x19')](_0x544aa0);}else{logger['info'](_0x2fe1('0x1a'),_0x39f961,_0x53d81f||_0x2fe1('0x19'));_0x20ab37['stop']();}}else{_0x20ab37[_0x2fe1('0x19')]();}}catch(_0x2c6fe4){logger['error']('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x39f961,_0x2c6fe4[_0x2fe1('0x1b')]);_0x20ab37[_0x2fe1('0x11')]();}}}catch(_0x1fe509){logger[_0x2fe1('0xf')](_0x2fe1('0x1c'),_0x39f961,JSON[_0x2fe1('0x1d')](_0x1fe509));_0x20ab37[_0x2fe1('0x11')]();}};};