Built motion from commit b0a9a629.|2.6.33
[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 _0x22a6=['[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','consequence','getMustacheRender','replace','length','[%s][GOTOIF]\x20%s','message','join','stop','condition','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found'];(function(_0x3b31b4,_0x3c8483){var _0x117f7f=function(_0xe98958){while(--_0xe98958){_0x3b31b4['push'](_0x3b31b4['shift']());}};_0x117f7f(++_0x3c8483);}(_0x22a6,0x1f0));var _0x622a=function(_0x31b5a5,_0x44376a){_0x31b5a5=_0x31b5a5-0x0;var _0x364cc9=_0x22a6[_0x31b5a5];return _0x364cc9;};'use strict';var schema=require(_0x622a('0x0'));var _=require(_0x622a('0x1'));var htmlToText=require(_0x622a('0x2'));var utils=require(_0x622a('0x3'));var logger=require(_0x622a('0x4'))('routing');var gotoif=schema({'condition':{'type':_0x622a('0x5'),'required':!![],'message':_0x622a('0x6')},'priorityTrue':{'type':_0x622a('0x7'),'message':_0x622a('0x8')},'priorityFalse':{'type':_0x622a('0x7'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x622a('0x9')]=function(_0x449455,_0xae810a){return function(_0x5352de){try{var _0x286e60={'condition':htmlToText['fromString'](utils[_0x622a('0xa')](_0xae810a[0x0],this),{'wordwrap':![]})[_0x622a('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0xae810a[0x1],'priorityFalse':_0xae810a[0x2]};var _0x258a74=gotoif[_0x622a('0x0')](_0x286e60,{'typecast':!![]});if(_0x258a74[_0x622a('0xc')]){logger['error'](_0x622a('0xd'),_0x449455,_['map'](_0x258a74,_0x622a('0xe'))[_0x622a('0xf')](',\x20'));_0x5352de[_0x622a('0x10')]();}else{try{var _0x528981=eval('('+_0x286e60[_0x622a('0x11')]+')');var _0x5d8073=_0x528981?_0x286e60['priorityTrue']:_0x286e60[_0x622a('0x12')];logger[_0x622a('0x13')](_0x622a('0x14'),_0x449455,_0x286e60['condition'],_0x528981,_0x5d8073||_0x622a('0x15'));if(_0x5d8073){var _0x47f29d=_[_0x622a('0x16')](_0x5352de['rules'](),{'p':_0x5d8073});if(_0x47f29d>=0x0){logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x449455,_0x5d8073||_0x622a('0x15'),_0x47f29d);_0x5352de[_0x622a('0x15')](_0x47f29d);}else{logger[_0x622a('0x13')](_0x622a('0x17'),_0x449455,_0x5d8073||_0x622a('0x15'));_0x5352de[_0x622a('0x10')]();}}else{_0x5352de['next']();}}catch(_0x34c7c1){logger['error'](_0x622a('0x18'),_0x449455,_0x34c7c1['message']);_0x5352de[_0x622a('0x10')]();}}}catch(_0x3bcd70){logger['error']('[%s][GOTOIF]\x20%s',_0x449455,JSON[_0x622a('0x19')](_0x3bcd70));_0x5352de[_0x622a('0x10')]();}};};