Built motion from commit (unavailable).|2.3.4
[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 _0x55f8=['map','join','stop','condition','priorityTrue','priorityFalse','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number','number','consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s'];(function(_0x3da8f7,_0x30b82a){var _0x4a6ed1=function(_0x1a51ac){while(--_0x1a51ac){_0x3da8f7['push'](_0x3da8f7['shift']());}};_0x4a6ed1(++_0x30b82a);}(_0x55f8,0x194));var _0x855f=function(_0x1471ce,_0x30b3da){_0x1471ce=_0x1471ce-0x0;var _0x12dae8=_0x55f8[_0x1471ce];return _0x12dae8;};'use strict';var schema=require(_0x855f('0x0'));var _=require(_0x855f('0x1'));var htmlToText=require(_0x855f('0x2'));var utils=require(_0x855f('0x3'));var logger=require(_0x855f('0x4'))('routing');var gotoif=schema({'condition':{'type':_0x855f('0x5'),'required':!![],'message':_0x855f('0x6')},'priorityTrue':{'type':'number','message':_0x855f('0x7')},'priorityFalse':{'type':_0x855f('0x8'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x855f('0x9')]=function(_0x2fa73e,_0x91dc13){return function(_0x48790f){try{var _0xc5c794={'condition':htmlToText[_0x855f('0xa')](utils[_0x855f('0xb')](_0x91dc13[0x0],this),{'wordwrap':![]})[_0x855f('0xc')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x91dc13[0x1],'priorityFalse':_0x91dc13[0x2]};var _0x4188da=gotoif['validate'](_0xc5c794,{'typecast':!![]});if(_0x4188da[_0x855f('0xd')]){logger[_0x855f('0xe')](_0x855f('0xf'),_0x2fa73e,_[_0x855f('0x10')](_0x4188da,'message')[_0x855f('0x11')](',\x20'));_0x48790f[_0x855f('0x12')]();}else{try{var _0xba479f=eval('('+_0xc5c794[_0x855f('0x13')]+')');var _0x24c8ff=_0xba479f?_0xc5c794[_0x855f('0x14')]:_0xc5c794[_0x855f('0x15')];logger[_0x855f('0x16')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x2fa73e,_0xc5c794['condition'],_0xba479f,_0x24c8ff||_0x855f('0x17'));if(_0x24c8ff){var _0x251b1c=_[_0x855f('0x18')](_0x48790f[_0x855f('0x19')](),{'p':_0x24c8ff});if(_0x251b1c>=0x0){logger[_0x855f('0x16')](_0x855f('0x1a'),_0x2fa73e,_0x24c8ff||_0x855f('0x17'),_0x251b1c);_0x48790f[_0x855f('0x17')](_0x251b1c);}else{logger[_0x855f('0x16')]('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x2fa73e,_0x24c8ff||_0x855f('0x17'));_0x48790f[_0x855f('0x12')]();}}else{_0x48790f[_0x855f('0x17')]();}}catch(_0x238a54){logger[_0x855f('0xe')](_0x855f('0x1b'),_0x2fa73e,_0x238a54[_0x855f('0x1c')]);_0x48790f[_0x855f('0x12')]();}}}catch(_0x572dbe){logger['error'](_0x855f('0xf'),_0x2fa73e,JSON[_0x855f('0x1d')](_0x572dbe));_0x48790f['stop']();}};};