Built motion from commit fe909640.|2.6.8
[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 _0x0c4e=['error','[%s][GOTOIF]\x20%s','map','message','join','stop','condition','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','info','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stringify','validate','lodash','html-to-text','../../../../config/logger','routing','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','replace','length'];(function(_0x33f6cd,_0x47b58f){var _0x4f997e=function(_0x3d64de){while(--_0x3d64de){_0x33f6cd['push'](_0x33f6cd['shift']());}};_0x4f997e(++_0x47b58f);}(_0x0c4e,0x155));var _0xe0c4=function(_0x1765c7,_0x5b4e2b){_0x1765c7=_0x1765c7-0x0;var _0x5de897=_0x0c4e[_0x1765c7];return _0x5de897;};'use strict';var schema=require(_0xe0c4('0x0'));var _=require(_0xe0c4('0x1'));var htmlToText=require(_0xe0c4('0x2'));var utils=require('./utils');var logger=require(_0xe0c4('0x3'))(_0xe0c4('0x4'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0xe0c4('0x5'),'message':_0xe0c4('0x6')},'priorityFalse':{'type':'number','message':_0xe0c4('0x7')}});exports['consequence']=function(_0x30707c,_0x5235ef){return function(_0xd78000){try{var _0x2ed1d4={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x5235ef[0x0],this),{'wordwrap':![]})[_0xe0c4('0x8')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x5235ef[0x1],'priorityFalse':_0x5235ef[0x2]};var _0x553c61=gotoif[_0xe0c4('0x0')](_0x2ed1d4,{'typecast':!![]});if(_0x553c61[_0xe0c4('0x9')]){logger[_0xe0c4('0xa')](_0xe0c4('0xb'),_0x30707c,_[_0xe0c4('0xc')](_0x553c61,_0xe0c4('0xd'))[_0xe0c4('0xe')](',\x20'));_0xd78000[_0xe0c4('0xf')]();}else{try{var _0x4d2480=eval('('+_0x2ed1d4[_0xe0c4('0x10')]+')');var _0x36537f=_0x4d2480?_0x2ed1d4[_0xe0c4('0x11')]:_0x2ed1d4[_0xe0c4('0x12')];logger['info'](_0xe0c4('0x13'),_0x30707c,_0x2ed1d4[_0xe0c4('0x10')],_0x4d2480,_0x36537f||'next');if(_0x36537f){var _0x38f5b0=_[_0xe0c4('0x14')](_0xd78000[_0xe0c4('0x15')](),{'p':_0x36537f});if(_0x38f5b0>=0x0){logger['info'](_0xe0c4('0x16'),_0x30707c,_0x36537f||_0xe0c4('0x17'),_0x38f5b0);_0xd78000['next'](_0x38f5b0);}else{logger[_0xe0c4('0x18')](_0xe0c4('0x19'),_0x30707c,_0x36537f||_0xe0c4('0x17'));_0xd78000[_0xe0c4('0xf')]();}}else{_0xd78000[_0xe0c4('0x17')]();}}catch(_0x1c5dea){logger[_0xe0c4('0xa')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x30707c,_0x1c5dea['message']);_0xd78000[_0xe0c4('0xf')]();}}}catch(_0x34e414){logger['error']('[%s][GOTOIF]\x20%s',_0x30707c,JSON[_0xe0c4('0x1a')](_0x34e414));_0xd78000[_0xe0c4('0xf')]();}};};