Built motion from commit 85328c08.|2.5.50
[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 _0xa224=['info','rules','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','lodash','html-to-text','./utils','routing','priority\x20true\x20is\x20a\x20number','number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','error','[%s][GOTOIF]\x20%s','map','message','join','stop','condition','priorityTrue'];(function(_0x22ae1f,_0x51f076){var _0x512c30=function(_0x112307){while(--_0x112307){_0x22ae1f['push'](_0x22ae1f['shift']());}};_0x512c30(++_0x51f076);}(_0xa224,0x131));var _0x4a22=function(_0x5240a1,_0x4d2a47){_0x5240a1=_0x5240a1-0x0;var _0x22bd79=_0xa224[_0x5240a1];return _0x22bd79;};'use strict';var schema=require(_0x4a22('0x0'));var _=require(_0x4a22('0x1'));var htmlToText=require(_0x4a22('0x2'));var utils=require(_0x4a22('0x3'));var logger=require('../../../../config/logger')(_0x4a22('0x4'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':'number','message':_0x4a22('0x5')},'priorityFalse':{'type':_0x4a22('0x6'),'message':_0x4a22('0x7')}});exports[_0x4a22('0x8')]=function(_0x4082d2,_0xa81060){return function(_0x2322e5){try{var _0x41b3b1={'condition':htmlToText[_0x4a22('0x9')](utils[_0x4a22('0xa')](_0xa81060[0x0],this),{'wordwrap':![]})[_0x4a22('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0xa81060[0x1],'priorityFalse':_0xa81060[0x2]};var _0x9fd696=gotoif['validate'](_0x41b3b1,{'typecast':!![]});if(_0x9fd696['length']){logger[_0x4a22('0xc')](_0x4a22('0xd'),_0x4082d2,_[_0x4a22('0xe')](_0x9fd696,_0x4a22('0xf'))[_0x4a22('0x10')](',\x20'));_0x2322e5[_0x4a22('0x11')]();}else{try{var _0x5c7838=eval('('+_0x41b3b1[_0x4a22('0x12')]+')');var _0x3ced7a=_0x5c7838?_0x41b3b1[_0x4a22('0x13')]:_0x41b3b1['priorityFalse'];logger[_0x4a22('0x14')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x4082d2,_0x41b3b1[_0x4a22('0x12')],_0x5c7838,_0x3ced7a||'next');if(_0x3ced7a){var _0x5cbeb9=_['findIndex'](_0x2322e5[_0x4a22('0x15')](),{'p':_0x3ced7a});if(_0x5cbeb9>=0x0){logger[_0x4a22('0x14')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x4082d2,_0x3ced7a||_0x4a22('0x16'),_0x5cbeb9);_0x2322e5[_0x4a22('0x16')](_0x5cbeb9);}else{logger[_0x4a22('0x14')](_0x4a22('0x17'),_0x4082d2,_0x3ced7a||_0x4a22('0x16'));_0x2322e5[_0x4a22('0x11')]();}}else{_0x2322e5[_0x4a22('0x16')]();}}catch(_0x3a404f){logger[_0x4a22('0xc')](_0x4a22('0x18'),_0x4082d2,_0x3a404f[_0x4a22('0xf')]);_0x2322e5[_0x4a22('0x11')]();}}}catch(_0x356478){logger[_0x4a22('0xc')]('[%s][GOTOIF]\x20%s',_0x4082d2,JSON['stringify'](_0x356478));_0x2322e5[_0x4a22('0x11')]();}};};