290137cb542f3b00d9bf9de40b708078b7cb160a
[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 _0x5a43=['stop','stringify','validate','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','getMustacheRender','replace','error','[%s][GOTOIF]\x20%s','message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s'];(function(_0x26d7b8,_0x597018){var _0x48657d=function(_0x1bc747){while(--_0x1bc747){_0x26d7b8['push'](_0x26d7b8['shift']());}};_0x48657d(++_0x597018);}(_0x5a43,0x1de));var _0x35a4=function(_0x78f00a,_0x368cc2){_0x78f00a=_0x78f00a-0x0;var _0x46d11c=_0x5a43[_0x78f00a];return _0x46d11c;};'use strict';var schema=require(_0x35a4('0x0'));var _=require('lodash');var htmlToText=require(_0x35a4('0x1'));var utils=require(_0x35a4('0x2'));var logger=require(_0x35a4('0x3'))(_0x35a4('0x4'));var gotoif=schema({'condition':{'type':_0x35a4('0x5'),'required':!![],'message':_0x35a4('0x6')},'priorityTrue':{'type':'number','message':_0x35a4('0x7')},'priorityFalse':{'type':'number','message':_0x35a4('0x8')}});exports[_0x35a4('0x9')]=function(_0x3dd220,_0x11d783){return function(_0x379549){try{var _0x2063a5={'condition':htmlToText['fromString'](utils[_0x35a4('0xa')](_0x11d783[0x0],this),{'wordwrap':![]})[_0x35a4('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x11d783[0x1],'priorityFalse':_0x11d783[0x2]};var _0x1c394d=gotoif[_0x35a4('0x0')](_0x2063a5,{'typecast':!![]});if(_0x1c394d['length']){logger[_0x35a4('0xc')](_0x35a4('0xd'),_0x3dd220,_['map'](_0x1c394d,_0x35a4('0xe'))[_0x35a4('0xf')](',\x20'));_0x379549['stop']();}else{try{var _0x33861a=eval('('+_0x2063a5[_0x35a4('0x10')]+')');var _0x4b2931=_0x33861a?_0x2063a5[_0x35a4('0x11')]:_0x2063a5[_0x35a4('0x12')];logger[_0x35a4('0x13')](_0x35a4('0x14'),_0x3dd220,_0x2063a5['condition'],_0x33861a,_0x4b2931||_0x35a4('0x15'));if(_0x4b2931){var _0x2508f5=_['findIndex'](_0x379549[_0x35a4('0x16')](),{'p':_0x4b2931});if(_0x2508f5>=0x0){logger[_0x35a4('0x13')](_0x35a4('0x17'),_0x3dd220,_0x4b2931||_0x35a4('0x15'),_0x2508f5);_0x379549['next'](_0x2508f5);}else{logger[_0x35a4('0x13')](_0x35a4('0x18'),_0x3dd220,_0x4b2931||_0x35a4('0x15'));_0x379549['stop']();}}else{_0x379549[_0x35a4('0x15')]();}}catch(_0xf482c0){logger['error'](_0x35a4('0x19'),_0x3dd220,_0xf482c0[_0x35a4('0xe')]);_0x379549[_0x35a4('0x1a')]();}}}catch(_0x3f77da){logger['error']('[%s][GOTOIF]\x20%s',_0x3dd220,JSON[_0x35a4('0x1b')](_0x3f77da));_0x379549[_0x35a4('0x1a')]();}};};