0f880199480eaa35f2109c36df77af090f135208
[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 _0x9568=['priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','getMustacheRender','replace','length','error','map','join','stop','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','[%s][GOTOIF]\x20%s','stringify','validate','lodash','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number'];(function(_0x47a7d0,_0x4e182d){var _0xb9bd08=function(_0x588ee2){while(--_0x588ee2){_0x47a7d0['push'](_0x47a7d0['shift']());}};_0xb9bd08(++_0x4e182d);}(_0x9568,0xa3));var _0x8956=function(_0x1e0499,_0x2222ed){_0x1e0499=_0x1e0499-0x0;var _0x527766=_0x9568[_0x1e0499];return _0x527766;};'use strict';var schema=require(_0x8956('0x0'));var _=require(_0x8956('0x1'));var htmlToText=require('html-to-text');var utils=require('./utils');var logger=require('../../../../config/logger')('routing');var gotoif=schema({'condition':{'type':_0x8956('0x2'),'required':!![],'message':_0x8956('0x3')},'priorityTrue':{'type':_0x8956('0x4'),'message':_0x8956('0x5')},'priorityFalse':{'type':_0x8956('0x4'),'message':_0x8956('0x6')}});exports[_0x8956('0x7')]=function(_0x6dec1b,_0x2b7605){return function(_0x3bdf52){try{var _0x3b7c25={'condition':htmlToText['fromString'](utils[_0x8956('0x8')](_0x2b7605[0x0],this),{'wordwrap':![]})[_0x8956('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2b7605[0x1],'priorityFalse':_0x2b7605[0x2]};var _0x52c200=gotoif[_0x8956('0x0')](_0x3b7c25,{'typecast':!![]});if(_0x52c200[_0x8956('0xa')]){logger[_0x8956('0xb')]('[%s][GOTOIF]\x20%s',_0x6dec1b,_[_0x8956('0xc')](_0x52c200,'message')[_0x8956('0xd')](',\x20'));_0x3bdf52[_0x8956('0xe')]();}else{try{var _0x1657f8=eval('('+_0x3b7c25[_0x8956('0xf')]+')');var _0x2f06d6=_0x1657f8?_0x3b7c25[_0x8956('0x10')]:_0x3b7c25[_0x8956('0x11')];logger[_0x8956('0x12')](_0x8956('0x13'),_0x6dec1b,_0x3b7c25[_0x8956('0xf')],_0x1657f8,_0x2f06d6||_0x8956('0x14'));if(_0x2f06d6){var _0x380fbf=_[_0x8956('0x15')](_0x3bdf52['rules'](),{'p':_0x2f06d6});if(_0x380fbf>=0x0){logger[_0x8956('0x12')](_0x8956('0x16'),_0x6dec1b,_0x2f06d6||_0x8956('0x14'),_0x380fbf);_0x3bdf52[_0x8956('0x14')](_0x380fbf);}else{logger[_0x8956('0x12')](_0x8956('0x17'),_0x6dec1b,_0x2f06d6||'next');_0x3bdf52['stop']();}}else{_0x3bdf52[_0x8956('0x14')]();}}catch(_0x178449){logger[_0x8956('0xb')](_0x8956('0x18'),_0x6dec1b,_0x178449[_0x8956('0x19')]);_0x3bdf52[_0x8956('0xe')]();}}}catch(_0x2553cf){logger[_0x8956('0xb')](_0x8956('0x1a'),_0x6dec1b,JSON[_0x8956('0x1b')](_0x2553cf));_0x3bdf52['stop']();}};};