0779033e2f627a6334e9a9c6990b95b0cdd2009f
[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 _0xa927=['consequence','fromString','getMustacheRender','replace','validate','[%s][GOTOIF]\x20%s','map','message','join','stop','condition','priorityTrue','info','next','rules','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0xa927,0x1d3));var _0x7a92=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0xa927[_0x397e5f];return _0x5302b8;};'use strict';var schema=require('validate');var _=require(_0x7a92('0x0'));var htmlToText=require(_0x7a92('0x1'));var utils=require(_0x7a92('0x2'));var logger=require(_0x7a92('0x3'))(_0x7a92('0x4'));var gotoif=schema({'condition':{'type':_0x7a92('0x5'),'required':!![],'message':_0x7a92('0x6')},'priorityTrue':{'type':_0x7a92('0x7'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x7a92('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x7a92('0x8')]=function(_0x14f4c2,_0x2a46d){return function(_0x483a76){try{var _0x2c57d={'condition':htmlToText[_0x7a92('0x9')](utils[_0x7a92('0xa')](_0x2a46d[0x0],this),{'wordwrap':![]})[_0x7a92('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2a46d[0x1],'priorityFalse':_0x2a46d[0x2]};var _0x43802f=gotoif[_0x7a92('0xc')](_0x2c57d,{'typecast':!![]});if(_0x43802f['length']){logger['error'](_0x7a92('0xd'),_0x14f4c2,_[_0x7a92('0xe')](_0x43802f,_0x7a92('0xf'))[_0x7a92('0x10')](',\x20'));_0x483a76[_0x7a92('0x11')]();}else{try{var _0x4e2bbf=eval('('+_0x2c57d[_0x7a92('0x12')]+')');var _0x29fd93=_0x4e2bbf?_0x2c57d[_0x7a92('0x13')]:_0x2c57d['priorityFalse'];logger[_0x7a92('0x14')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x14f4c2,_0x2c57d[_0x7a92('0x12')],_0x4e2bbf,_0x29fd93||_0x7a92('0x15'));if(_0x29fd93){var _0xbdd5ef=_['findIndex'](_0x483a76[_0x7a92('0x16')](),{'p':_0x29fd93});if(_0xbdd5ef>=0x0){logger[_0x7a92('0x14')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x14f4c2,_0x29fd93||_0x7a92('0x15'),_0xbdd5ef);_0x483a76[_0x7a92('0x15')](_0xbdd5ef);}else{logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x14f4c2,_0x29fd93||_0x7a92('0x15'));_0x483a76['stop']();}}else{_0x483a76[_0x7a92('0x15')]();}}catch(_0x4bbc1a){logger[_0x7a92('0x17')](_0x7a92('0x18'),_0x14f4c2,_0x4bbc1a[_0x7a92('0xf')]);_0x483a76[_0x7a92('0x11')]();}}}catch(_0x357abb){logger[_0x7a92('0x17')]('[%s][GOTOIF]\x20%s',_0x14f4c2,JSON['stringify'](_0x357abb));_0x483a76[_0x7a92('0x11')]();}};};