a8dcd66f5603b5c7cc9a0c1af0f91eec8f453e29
[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 _0x9af2=['condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','error','map','message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s','[%s][GOTOIF]\x20%s','stringify','lodash','./utils','routing','string'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x9af2,0x1e9));var _0x29af=function(_0x5f4d35,_0x1e41b8){_0x5f4d35=_0x5f4d35-0x0;var _0x43f471=_0x9af2[_0x5f4d35];return _0x43f471;};'use strict';var schema=require('validate');var _=require(_0x29af('0x0'));var htmlToText=require('html-to-text');var utils=require(_0x29af('0x1'));var logger=require('../../../../config/logger')(_0x29af('0x2'));var gotoif=schema({'condition':{'type':_0x29af('0x3'),'required':!![],'message':_0x29af('0x4')},'priorityTrue':{'type':_0x29af('0x5'),'message':_0x29af('0x6')},'priorityFalse':{'type':_0x29af('0x5'),'message':_0x29af('0x7')}});exports[_0x29af('0x8')]=function(_0x2009b7,_0x18124d){return function(_0x328f2f){try{var _0x2c81d8={'condition':htmlToText[_0x29af('0x9')](utils[_0x29af('0xa')](_0x18124d[0x0],this),{'wordwrap':![]})[_0x29af('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x18124d[0x1],'priorityFalse':_0x18124d[0x2]};var _0x41997a=gotoif['validate'](_0x2c81d8,{'typecast':!![]});if(_0x41997a['length']){logger[_0x29af('0xc')]('[%s][GOTOIF]\x20%s',_0x2009b7,_[_0x29af('0xd')](_0x41997a,_0x29af('0xe'))[_0x29af('0xf')](',\x20'));_0x328f2f['stop']();}else{try{var _0x59cc79=eval('('+_0x2c81d8[_0x29af('0x10')]+')');var _0x39cb7a=_0x59cc79?_0x2c81d8[_0x29af('0x11')]:_0x2c81d8[_0x29af('0x12')];logger[_0x29af('0x13')](_0x29af('0x14'),_0x2009b7,_0x2c81d8[_0x29af('0x10')],_0x59cc79,_0x39cb7a||'next');if(_0x39cb7a){var _0x3bc70d=_[_0x29af('0x15')](_0x328f2f['rules'](),{'p':_0x39cb7a});if(_0x3bc70d>=0x0){logger[_0x29af('0x13')](_0x29af('0x16'),_0x2009b7,_0x39cb7a||_0x29af('0x17'),_0x3bc70d);_0x328f2f[_0x29af('0x17')](_0x3bc70d);}else{logger[_0x29af('0x13')](_0x29af('0x18'),_0x2009b7,_0x39cb7a||_0x29af('0x17'));_0x328f2f[_0x29af('0x19')]();}}else{_0x328f2f[_0x29af('0x17')]();}}catch(_0x59d3a8){logger['error'](_0x29af('0x1a'),_0x2009b7,_0x59d3a8[_0x29af('0xe')]);_0x328f2f[_0x29af('0x19')]();}}}catch(_0x23e7ce){logger[_0x29af('0xc')](_0x29af('0x1b'),_0x2009b7,JSON[_0x29af('0x1c')](_0x23e7ce));_0x328f2f[_0x29af('0x19')]();}};};