Built motion from commit 97153652.|2.6.26
[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 _0xf408=['validate','length','error','[%s][GOTOIF]\x20%s','map','message','condition','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stop','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','replace'];(function(_0x150fa2,_0x156632){var _0x88e6ba=function(_0x23536e){while(--_0x23536e){_0x150fa2['push'](_0x150fa2['shift']());}};_0x88e6ba(++_0x156632);}(_0xf408,0x90));var _0x8f40=function(_0x14490c,_0x50e8ab){_0x14490c=_0x14490c-0x0;var _0x2f6825=_0xf408[_0x14490c];return _0x2f6825;};'use strict';var schema=require('validate');var _=require(_0x8f40('0x0'));var htmlToText=require(_0x8f40('0x1'));var utils=require(_0x8f40('0x2'));var logger=require(_0x8f40('0x3'))(_0x8f40('0x4'));var gotoif=schema({'condition':{'type':_0x8f40('0x5'),'required':!![],'message':_0x8f40('0x6')},'priorityTrue':{'type':'number','message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x8f40('0x7'),'message':_0x8f40('0x8')}});exports['consequence']=function(_0x1296eb,_0x425413){return function(_0x304c5a){try{var _0x4b3fe8={'condition':htmlToText[_0x8f40('0x9')](utils[_0x8f40('0xa')](_0x425413[0x0],this),{'wordwrap':![]})[_0x8f40('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x425413[0x1],'priorityFalse':_0x425413[0x2]};var _0xa68727=gotoif[_0x8f40('0xc')](_0x4b3fe8,{'typecast':!![]});if(_0xa68727[_0x8f40('0xd')]){logger[_0x8f40('0xe')](_0x8f40('0xf'),_0x1296eb,_[_0x8f40('0x10')](_0xa68727,_0x8f40('0x11'))['join'](',\x20'));_0x304c5a['stop']();}else{try{var _0x392e5c=eval('('+_0x4b3fe8[_0x8f40('0x12')]+')');var _0x387ff4=_0x392e5c?_0x4b3fe8['priorityTrue']:_0x4b3fe8['priorityFalse'];logger[_0x8f40('0x13')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x1296eb,_0x4b3fe8['condition'],_0x392e5c,_0x387ff4||_0x8f40('0x14'));if(_0x387ff4){var _0x259586=_[_0x8f40('0x15')](_0x304c5a[_0x8f40('0x16')](),{'p':_0x387ff4});if(_0x259586>=0x0){logger[_0x8f40('0x13')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x1296eb,_0x387ff4||_0x8f40('0x14'),_0x259586);_0x304c5a[_0x8f40('0x14')](_0x259586);}else{logger[_0x8f40('0x13')](_0x8f40('0x17'),_0x1296eb,_0x387ff4||'next');_0x304c5a['stop']();}}else{_0x304c5a[_0x8f40('0x14')]();}}catch(_0x138610){logger[_0x8f40('0xe')](_0x8f40('0x18'),_0x1296eb,_0x138610[_0x8f40('0x11')]);_0x304c5a[_0x8f40('0x19')]();}}}catch(_0x4df99c){logger[_0x8f40('0xe')](_0x8f40('0xf'),_0x1296eb,JSON['stringify'](_0x4df99c));_0x304c5a[_0x8f40('0x19')]();}};};