Built motion from commit (unavailable).|2.5.1
[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 _0x57ac=['fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','condition','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number','number','priority\x20false\x20is\x20a\x20number','consequence'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x57ac,0xa8));var _0xc57a=function(_0x5b1981,_0x310935){_0x5b1981=_0x5b1981-0x0;var _0x59b3e3=_0x57ac[_0x5b1981];return _0x59b3e3;};'use strict';var schema=require(_0xc57a('0x0'));var _=require(_0xc57a('0x1'));var htmlToText=require(_0xc57a('0x2'));var utils=require(_0xc57a('0x3'));var logger=require(_0xc57a('0x4'))(_0xc57a('0x5'));var gotoif=schema({'condition':{'type':_0xc57a('0x6'),'required':!![],'message':_0xc57a('0x7')},'priorityTrue':{'type':'number','message':_0xc57a('0x8')},'priorityFalse':{'type':_0xc57a('0x9'),'message':_0xc57a('0xa')}});exports[_0xc57a('0xb')]=function(_0x82cee2,_0x55c440){return function(_0x1330fb){try{var _0x51b6ec={'condition':htmlToText[_0xc57a('0xc')](utils[_0xc57a('0xd')](_0x55c440[0x0],this),{'wordwrap':![]})[_0xc57a('0xe')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x55c440[0x1],'priorityFalse':_0x55c440[0x2]};var _0x276e2b=gotoif[_0xc57a('0x0')](_0x51b6ec,{'typecast':!![]});if(_0x276e2b[_0xc57a('0xf')]){logger[_0xc57a('0x10')](_0xc57a('0x11'),_0x82cee2,_[_0xc57a('0x12')](_0x276e2b,_0xc57a('0x13'))['join'](',\x20'));_0x1330fb['stop']();}else{try{var _0x3a452a=eval('('+_0x51b6ec[_0xc57a('0x14')]+')');var _0x4c2c27=_0x3a452a?_0x51b6ec['priorityTrue']:_0x51b6ec['priorityFalse'];logger[_0xc57a('0x15')](_0xc57a('0x16'),_0x82cee2,_0x51b6ec[_0xc57a('0x14')],_0x3a452a,_0x4c2c27||_0xc57a('0x17'));if(_0x4c2c27){var _0x1b37a5=_[_0xc57a('0x18')](_0x1330fb[_0xc57a('0x19')](),{'p':_0x4c2c27});if(_0x1b37a5>=0x0){logger[_0xc57a('0x15')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x82cee2,_0x4c2c27||_0xc57a('0x17'),_0x1b37a5);_0x1330fb[_0xc57a('0x17')](_0x1b37a5);}else{logger[_0xc57a('0x15')](_0xc57a('0x1a'),_0x82cee2,_0x4c2c27||_0xc57a('0x17'));_0x1330fb[_0xc57a('0x1b')]();}}else{_0x1330fb[_0xc57a('0x17')]();}}catch(_0x228cdd){logger[_0xc57a('0x10')](_0xc57a('0x1c'),_0x82cee2,_0x228cdd[_0xc57a('0x13')]);_0x1330fb['stop']();}}}catch(_0x4e1f02){logger[_0xc57a('0x10')]('[%s][GOTOIF]\x20%s',_0x82cee2,JSON[_0xc57a('0x1d')](_0x4e1f02));_0x1330fb[_0xc57a('0x1b')]();}};};