Built motion from commit (unavailable).|2.5.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 _0x6364=['lodash','html-to-text','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','getMustacheRender','replace','validate','length','error','[%s][GOTOIF]\x20%s','map','join','condition','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify'];(function(_0x289e64,_0x5adb3c){var _0x30246c=function(_0x1bf7f6){while(--_0x1bf7f6){_0x289e64['push'](_0x289e64['shift']());}};_0x30246c(++_0x5adb3c);}(_0x6364,0xae));var _0x4636=function(_0x52bd66,_0x226b74){_0x52bd66=_0x52bd66-0x0;var _0x61f4f8=_0x6364[_0x52bd66];return _0x61f4f8;};'use strict';var schema=require('validate');var _=require(_0x4636('0x0'));var htmlToText=require(_0x4636('0x1'));var utils=require(_0x4636('0x2'));var logger=require(_0x4636('0x3'))('routing');var gotoif=schema({'condition':{'type':_0x4636('0x4'),'required':!![],'message':_0x4636('0x5')},'priorityTrue':{'type':_0x4636('0x6'),'message':_0x4636('0x7')},'priorityFalse':{'type':'number','message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x4636('0x8')]=function(_0x28f0d6,_0x43b293){return function(_0xcd23a4){try{var _0x3dae25={'condition':htmlToText['fromString'](utils[_0x4636('0x9')](_0x43b293[0x0],this),{'wordwrap':![]})[_0x4636('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x43b293[0x1],'priorityFalse':_0x43b293[0x2]};var _0x124f60=gotoif[_0x4636('0xb')](_0x3dae25,{'typecast':!![]});if(_0x124f60[_0x4636('0xc')]){logger[_0x4636('0xd')](_0x4636('0xe'),_0x28f0d6,_[_0x4636('0xf')](_0x124f60,'message')[_0x4636('0x10')](',\x20'));_0xcd23a4['stop']();}else{try{var _0x179536=eval('('+_0x3dae25[_0x4636('0x11')]+')');var _0x3021e0=_0x179536?_0x3dae25['priorityTrue']:_0x3dae25[_0x4636('0x12')];logger['info'](_0x4636('0x13'),_0x28f0d6,_0x3dae25['condition'],_0x179536,_0x3021e0||_0x4636('0x14'));if(_0x3021e0){var _0xd4d26c=_['findIndex'](_0xcd23a4[_0x4636('0x15')](),{'p':_0x3021e0});if(_0xd4d26c>=0x0){logger[_0x4636('0x16')](_0x4636('0x17'),_0x28f0d6,_0x3021e0||'next',_0xd4d26c);_0xcd23a4[_0x4636('0x14')](_0xd4d26c);}else{logger[_0x4636('0x16')](_0x4636('0x18'),_0x28f0d6,_0x3021e0||_0x4636('0x14'));_0xcd23a4[_0x4636('0x19')]();}}else{_0xcd23a4[_0x4636('0x14')]();}}catch(_0x53f6a6){logger[_0x4636('0xd')](_0x4636('0x1a'),_0x28f0d6,_0x53f6a6[_0x4636('0x1b')]);_0xcd23a4['stop']();}}}catch(_0x4fee3f){logger[_0x4636('0xd')]('[%s][GOTOIF]\x20%s',_0x28f0d6,JSON[_0x4636('0x1c')](_0x4fee3f));_0xcd23a4[_0x4636('0x19')]();}};};