Built motion from commit (unavailable).|2.5.31
[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 _0xa963=['consequence','fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','stop','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number'];(function(_0x43276b,_0x1c50ae){var _0x551b9b=function(_0x487658){while(--_0x487658){_0x43276b['push'](_0x43276b['shift']());}};_0x551b9b(++_0x1c50ae);}(_0xa963,0x16f));var _0x3a96=function(_0x1a681a,_0x45302b){_0x1a681a=_0x1a681a-0x0;var _0xfae1c8=_0xa963[_0x1a681a];return _0xfae1c8;};'use strict';var schema=require(_0x3a96('0x0'));var _=require(_0x3a96('0x1'));var htmlToText=require(_0x3a96('0x2'));var utils=require(_0x3a96('0x3'));var logger=require(_0x3a96('0x4'))(_0x3a96('0x5'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0x3a96('0x6')},'priorityTrue':{'type':_0x3a96('0x7'),'message':_0x3a96('0x8')},'priorityFalse':{'type':_0x3a96('0x7'),'message':_0x3a96('0x9')}});exports[_0x3a96('0xa')]=function(_0x26af6f,_0x53fccb){return function(_0x292410){try{var _0x177b9a={'condition':htmlToText[_0x3a96('0xb')](utils[_0x3a96('0xc')](_0x53fccb[0x0],this),{'wordwrap':![]})[_0x3a96('0xd')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x53fccb[0x1],'priorityFalse':_0x53fccb[0x2]};var _0x25516d=gotoif[_0x3a96('0x0')](_0x177b9a,{'typecast':!![]});if(_0x25516d[_0x3a96('0xe')]){logger[_0x3a96('0xf')](_0x3a96('0x10'),_0x26af6f,_[_0x3a96('0x11')](_0x25516d,'message')['join'](',\x20'));_0x292410[_0x3a96('0x12')]();}else{try{var _0x1a2b3c=eval('('+_0x177b9a['condition']+')');var _0x586462=_0x1a2b3c?_0x177b9a[_0x3a96('0x13')]:_0x177b9a[_0x3a96('0x14')];logger[_0x3a96('0x15')](_0x3a96('0x16'),_0x26af6f,_0x177b9a[_0x3a96('0x17')],_0x1a2b3c,_0x586462||_0x3a96('0x18'));if(_0x586462){var _0x1636b3=_[_0x3a96('0x19')](_0x292410['rules'](),{'p':_0x586462});if(_0x1636b3>=0x0){logger[_0x3a96('0x15')]('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x26af6f,_0x586462||_0x3a96('0x18'),_0x1636b3);_0x292410['next'](_0x1636b3);}else{logger['info'](_0x3a96('0x1a'),_0x26af6f,_0x586462||_0x3a96('0x18'));_0x292410['stop']();}}else{_0x292410[_0x3a96('0x18')]();}}catch(_0x57de23){logger[_0x3a96('0xf')](_0x3a96('0x1b'),_0x26af6f,_0x57de23['message']);_0x292410[_0x3a96('0x12')]();}}}catch(_0x4f1698){logger[_0x3a96('0xf')](_0x3a96('0x10'),_0x26af6f,JSON[_0x3a96('0x1c')](_0x4f1698));_0x292410['stop']();}};};