Built motion from commit 1fd437e9.|2.6.19
[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 _0x899d=['number','consequence','fromString','getMustacheRender','length','error','[%s][GOTOIF]\x20%s','map','message','stop','condition','priorityTrue','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20eval\x20error:\x20%s','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','priority\x20true\x20is\x20a\x20number'];(function(_0x192a74,_0x4bb7cd){var _0x54f523=function(_0x2daf10){while(--_0x2daf10){_0x192a74['push'](_0x192a74['shift']());}};_0x54f523(++_0x4bb7cd);}(_0x899d,0x1c2));var _0xd899=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0x899d[_0xfae23b];return _0x200640;};'use strict';var schema=require(_0xd899('0x0'));var _=require(_0xd899('0x1'));var htmlToText=require(_0xd899('0x2'));var utils=require(_0xd899('0x3'));var logger=require(_0xd899('0x4'))(_0xd899('0x5'));var gotoif=schema({'condition':{'type':_0xd899('0x6'),'required':!![],'message':_0xd899('0x7')},'priorityTrue':{'type':'number','message':_0xd899('0x8')},'priorityFalse':{'type':_0xd899('0x9'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0xd899('0xa')]=function(_0x2e396e,_0x4dc778){return function(_0x44dc4e){try{var _0x383557={'condition':htmlToText[_0xd899('0xb')](utils[_0xd899('0xc')](_0x4dc778[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x4dc778[0x1],'priorityFalse':_0x4dc778[0x2]};var _0x263220=gotoif[_0xd899('0x0')](_0x383557,{'typecast':!![]});if(_0x263220[_0xd899('0xd')]){logger[_0xd899('0xe')](_0xd899('0xf'),_0x2e396e,_[_0xd899('0x10')](_0x263220,_0xd899('0x11'))['join'](',\x20'));_0x44dc4e[_0xd899('0x12')]();}else{try{var _0x214446=eval('('+_0x383557[_0xd899('0x13')]+')');var _0x37735e=_0x214446?_0x383557[_0xd899('0x14')]:_0x383557['priorityFalse'];logger[_0xd899('0x15')](_0xd899('0x16'),_0x2e396e,_0x383557['condition'],_0x214446,_0x37735e||_0xd899('0x17'));if(_0x37735e){var _0xe7ad3d=_[_0xd899('0x18')](_0x44dc4e[_0xd899('0x19')](),{'p':_0x37735e});if(_0xe7ad3d>=0x0){logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x2e396e,_0x37735e||'next',_0xe7ad3d);_0x44dc4e[_0xd899('0x17')](_0xe7ad3d);}else{logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x2e396e,_0x37735e||_0xd899('0x17'));_0x44dc4e[_0xd899('0x12')]();}}else{_0x44dc4e[_0xd899('0x17')]();}}catch(_0x49480d){logger[_0xd899('0xe')](_0xd899('0x1a'),_0x2e396e,_0x49480d[_0xd899('0x11')]);_0x44dc4e['stop']();}}}catch(_0x46e77d){logger[_0xd899('0xe')](_0xd899('0xf'),_0x2e396e,JSON['stringify'](_0x46e77d));_0x44dc4e['stop']();}};};