Built motion from commit 9d0783e6.|2.6.13
[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 _0x21c8=['priorityTrue','priorityFalse','info','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20false\x20is\x20a\x20number','consequence','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','stop','condition'];(function(_0x2c714a,_0x18a92f){var _0x227672=function(_0xa34bf9){while(--_0xa34bf9){_0x2c714a['push'](_0x2c714a['shift']());}};_0x227672(++_0x18a92f);}(_0x21c8,0x165));var _0x821c=function(_0x21e6f1,_0x4d5eb5){_0x21e6f1=_0x21e6f1-0x0;var _0x44a394=_0x21c8[_0x21e6f1];return _0x44a394;};'use strict';var schema=require(_0x821c('0x0'));var _=require(_0x821c('0x1'));var htmlToText=require(_0x821c('0x2'));var utils=require(_0x821c('0x3'));var logger=require(_0x821c('0x4'))(_0x821c('0x5'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0x821c('0x6')},'priorityTrue':{'type':_0x821c('0x7'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':'number','message':_0x821c('0x8')}});exports[_0x821c('0x9')]=function(_0x2a3265,_0x579397){return function(_0x5289c9){try{var _0xbeb5fc={'condition':htmlToText['fromString'](utils[_0x821c('0xa')](_0x579397[0x0],this),{'wordwrap':![]})[_0x821c('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x579397[0x1],'priorityFalse':_0x579397[0x2]};var _0x82cc09=gotoif['validate'](_0xbeb5fc,{'typecast':!![]});if(_0x82cc09[_0x821c('0xc')]){logger[_0x821c('0xd')](_0x821c('0xe'),_0x2a3265,_[_0x821c('0xf')](_0x82cc09,_0x821c('0x10'))[_0x821c('0x11')](',\x20'));_0x5289c9[_0x821c('0x12')]();}else{try{var _0x3e350b=eval('('+_0xbeb5fc[_0x821c('0x13')]+')');var _0x30abe5=_0x3e350b?_0xbeb5fc[_0x821c('0x14')]:_0xbeb5fc[_0x821c('0x15')];logger[_0x821c('0x16')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x2a3265,_0xbeb5fc[_0x821c('0x13')],_0x3e350b,_0x30abe5||_0x821c('0x17'));if(_0x30abe5){var _0x29958a=_[_0x821c('0x18')](_0x5289c9[_0x821c('0x19')](),{'p':_0x30abe5});if(_0x29958a>=0x0){logger['info'](_0x821c('0x1a'),_0x2a3265,_0x30abe5||_0x821c('0x17'),_0x29958a);_0x5289c9[_0x821c('0x17')](_0x29958a);}else{logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x2a3265,_0x30abe5||_0x821c('0x17'));_0x5289c9[_0x821c('0x12')]();}}else{_0x5289c9[_0x821c('0x17')]();}}catch(_0xb6543b){logger[_0x821c('0xd')](_0x821c('0x1b'),_0x2a3265,_0xb6543b[_0x821c('0x10')]);_0x5289c9[_0x821c('0x12')]();}}}catch(_0x5e3ce2){logger[_0x821c('0xd')](_0x821c('0xe'),_0x2a3265,JSON[_0x821c('0x1c')](_0x5e3ce2));_0x5289c9[_0x821c('0x12')]();}};};