Built motion from commit 1ea47bf4.|2.6.34
[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 _0xd759=['condition','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','stringify','validate','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','error','[%s][GOTOIF]\x20%s','map','message'];(function(_0x4edaaa,_0x305da7){var _0x1cc080=function(_0x58cd28){while(--_0x58cd28){_0x4edaaa['push'](_0x4edaaa['shift']());}};_0x1cc080(++_0x305da7);}(_0xd759,0xd7));var _0x9d75=function(_0x1c90a7,_0x115e4d){_0x1c90a7=_0x1c90a7-0x0;var _0x408b33=_0xd759[_0x1c90a7];return _0x408b33;};'use strict';var schema=require(_0x9d75('0x0'));var _=require('lodash');var htmlToText=require(_0x9d75('0x1'));var utils=require(_0x9d75('0x2'));var logger=require(_0x9d75('0x3'))(_0x9d75('0x4'));var gotoif=schema({'condition':{'type':_0x9d75('0x5'),'required':!![],'message':_0x9d75('0x6')},'priorityTrue':{'type':_0x9d75('0x7'),'message':_0x9d75('0x8')},'priorityFalse':{'type':_0x9d75('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x9d75('0x9')]=function(_0x2cc868,_0x517a9d){return function(_0x8fb54c){try{var _0x25f67b={'condition':htmlToText[_0x9d75('0xa')](utils[_0x9d75('0xb')](_0x517a9d[0x0],this),{'wordwrap':![]})[_0x9d75('0xc')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x517a9d[0x1],'priorityFalse':_0x517a9d[0x2]};var _0x5408af=gotoif[_0x9d75('0x0')](_0x25f67b,{'typecast':!![]});if(_0x5408af['length']){logger[_0x9d75('0xd')](_0x9d75('0xe'),_0x2cc868,_[_0x9d75('0xf')](_0x5408af,_0x9d75('0x10'))['join'](',\x20'));_0x8fb54c['stop']();}else{try{var _0x35374d=eval('('+_0x25f67b[_0x9d75('0x11')]+')');var _0x4d5629=_0x35374d?_0x25f67b[_0x9d75('0x12')]:_0x25f67b[_0x9d75('0x13')];logger['info'](_0x9d75('0x14'),_0x2cc868,_0x25f67b[_0x9d75('0x11')],_0x35374d,_0x4d5629||_0x9d75('0x15'));if(_0x4d5629){var _0x57dc26=_[_0x9d75('0x16')](_0x8fb54c[_0x9d75('0x17')](),{'p':_0x4d5629});if(_0x57dc26>=0x0){logger[_0x9d75('0x18')](_0x9d75('0x19'),_0x2cc868,_0x4d5629||_0x9d75('0x15'),_0x57dc26);_0x8fb54c[_0x9d75('0x15')](_0x57dc26);}else{logger[_0x9d75('0x18')](_0x9d75('0x1a'),_0x2cc868,_0x4d5629||_0x9d75('0x15'));_0x8fb54c[_0x9d75('0x1b')]();}}else{_0x8fb54c[_0x9d75('0x15')]();}}catch(_0x54d970){logger[_0x9d75('0xd')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x2cc868,_0x54d970[_0x9d75('0x10')]);_0x8fb54c[_0x9d75('0x1b')]();}}}catch(_0x53d4cf){logger[_0x9d75('0xd')](_0x9d75('0xe'),_0x2cc868,JSON[_0x9d75('0x1c')](_0x53d4cf));_0x8fb54c['stop']();}};};