75e19a8f9bd6a6fe420db0839813deed3691e91e
[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 _0x41db=['stringify','validate','lodash','./utils','../../../../config/logger','string','number','priority\x20true\x20is\x20a\x20number','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','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'];(function(_0x532d04,_0x20030d){var _0x561416=function(_0x52f69a){while(--_0x52f69a){_0x532d04['push'](_0x532d04['shift']());}};_0x561416(++_0x20030d);}(_0x41db,0x17b));var _0xb41d=function(_0x3b9803,_0x79ad73){_0x3b9803=_0x3b9803-0x0;var _0x1411e9=_0x41db[_0x3b9803];return _0x1411e9;};'use strict';var schema=require(_0xb41d('0x0'));var _=require(_0xb41d('0x1'));var htmlToText=require('html-to-text');var utils=require(_0xb41d('0x2'));var logger=require(_0xb41d('0x3'))('routing');var gotoif=schema({'condition':{'type':_0xb41d('0x4'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0xb41d('0x5'),'message':_0xb41d('0x6')},'priorityFalse':{'type':_0xb41d('0x5'),'message':'priority\x20false\x20is\x20a\x20number'}});exports['consequence']=function(_0x4e2c37,_0x33c4cc){return function(_0x5b2f05){try{var _0x20ecb2={'condition':htmlToText[_0xb41d('0x7')](utils[_0xb41d('0x8')](_0x33c4cc[0x0],this),{'wordwrap':![]})[_0xb41d('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x33c4cc[0x1],'priorityFalse':_0x33c4cc[0x2]};var _0x550fcb=gotoif[_0xb41d('0x0')](_0x20ecb2,{'typecast':!![]});if(_0x550fcb[_0xb41d('0xa')]){logger[_0xb41d('0xb')](_0xb41d('0xc'),_0x4e2c37,_['map'](_0x550fcb,'message')[_0xb41d('0xd')](',\x20'));_0x5b2f05[_0xb41d('0xe')]();}else{try{var _0x3b2007=eval('('+_0x20ecb2[_0xb41d('0xf')]+')');var _0x2f818e=_0x3b2007?_0x20ecb2[_0xb41d('0x10')]:_0x20ecb2[_0xb41d('0x11')];logger[_0xb41d('0x12')](_0xb41d('0x13'),_0x4e2c37,_0x20ecb2[_0xb41d('0xf')],_0x3b2007,_0x2f818e||_0xb41d('0x14'));if(_0x2f818e){var _0x11180b=_[_0xb41d('0x15')](_0x5b2f05['rules'](),{'p':_0x2f818e});if(_0x11180b>=0x0){logger['info'](_0xb41d('0x16'),_0x4e2c37,_0x2f818e||_0xb41d('0x14'),_0x11180b);_0x5b2f05[_0xb41d('0x14')](_0x11180b);}else{logger[_0xb41d('0x12')](_0xb41d('0x17'),_0x4e2c37,_0x2f818e||_0xb41d('0x14'));_0x5b2f05[_0xb41d('0xe')]();}}else{_0x5b2f05[_0xb41d('0x14')]();}}catch(_0x4bc54c){logger[_0xb41d('0xb')](_0xb41d('0x18'),_0x4e2c37,_0x4bc54c[_0xb41d('0x19')]);_0x5b2f05[_0xb41d('0xe')]();}}}catch(_0x93f18d){logger[_0xb41d('0xb')](_0xb41d('0xc'),_0x4e2c37,JSON[_0xb41d('0x1a')](_0x93f18d));_0x5b2f05[_0xb41d('0xe')]();}};};