Built motion from commit (unavailable).|2.5.16
[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 _0x501e=['fromString','getMustacheRender','replace','length','join','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','findIndex','rules','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','validate','lodash','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20false\x20is\x20a\x20number'];(function(_0xff7728,_0x3718cf){var _0x3414d0=function(_0x30d7d3){while(--_0x30d7d3){_0xff7728['push'](_0xff7728['shift']());}};_0x3414d0(++_0x3718cf);}(_0x501e,0x105));var _0xe501=function(_0x360770,_0x31a841){_0x360770=_0x360770-0x0;var _0xc0fe0=_0x501e[_0x360770];return _0xc0fe0;};'use strict';var schema=require(_0xe501('0x0'));var _=require(_0xe501('0x1'));var htmlToText=require('html-to-text');var utils=require(_0xe501('0x2'));var logger=require(_0xe501('0x3'))(_0xe501('0x4'));var gotoif=schema({'condition':{'type':_0xe501('0x5'),'required':!![],'message':_0xe501('0x6')},'priorityTrue':{'type':_0xe501('0x7'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':_0xe501('0x8')}});exports['consequence']=function(_0x5dc1c2,_0x1b81a6){return function(_0x3c4d42){try{var _0x566eb7={'condition':htmlToText[_0xe501('0x9')](utils[_0xe501('0xa')](_0x1b81a6[0x0],this),{'wordwrap':![]})[_0xe501('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1b81a6[0x1],'priorityFalse':_0x1b81a6[0x2]};var _0x30c1ac=gotoif[_0xe501('0x0')](_0x566eb7,{'typecast':!![]});if(_0x30c1ac[_0xe501('0xc')]){logger['error']('[%s][GOTOIF]\x20%s',_0x5dc1c2,_['map'](_0x30c1ac,'message')[_0xe501('0xd')](',\x20'));_0x3c4d42[_0xe501('0xe')]();}else{try{var _0x1cf35b=eval('('+_0x566eb7['condition']+')');var _0xdce042=_0x1cf35b?_0x566eb7[_0xe501('0xf')]:_0x566eb7[_0xe501('0x10')];logger[_0xe501('0x11')](_0xe501('0x12'),_0x5dc1c2,_0x566eb7[_0xe501('0x13')],_0x1cf35b,_0xdce042||_0xe501('0x14'));if(_0xdce042){var _0x559f0f=_[_0xe501('0x15')](_0x3c4d42[_0xe501('0x16')](),{'p':_0xdce042});if(_0x559f0f>=0x0){logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x5dc1c2,_0xdce042||_0xe501('0x14'),_0x559f0f);_0x3c4d42[_0xe501('0x14')](_0x559f0f);}else{logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x5dc1c2,_0xdce042||'next');_0x3c4d42[_0xe501('0xe')]();}}else{_0x3c4d42['next']();}}catch(_0x24dbdc){logger[_0xe501('0x17')](_0xe501('0x18'),_0x5dc1c2,_0x24dbdc[_0xe501('0x19')]);_0x3c4d42[_0xe501('0xe')]();}}}catch(_0x466cbe){logger[_0xe501('0x17')]('[%s][GOTOIF]\x20%s',_0x5dc1c2,JSON[_0xe501('0x1a')](_0x466cbe));_0x3c4d42['stop']();}};};