Built motion from commit (unavailable).|2.5.23
[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 _0xc152=['fromString','getMustacheRender','replace','length','error','[%s][GOTOIF]\x20%s','map','message','join','stop','priorityTrue','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','condition','next','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','number','priority\x20false\x20is\x20a\x20number','consequence'];(function(_0x29a80c,_0x56d71c){var _0x3e4bc1=function(_0x4d0169){while(--_0x4d0169){_0x29a80c['push'](_0x29a80c['shift']());}};_0x3e4bc1(++_0x56d71c);}(_0xc152,0x94));var _0x2c15=function(_0x3f681b,_0x51fe86){_0x3f681b=_0x3f681b-0x0;var _0x2d4d24=_0xc152[_0x3f681b];return _0x2d4d24;};'use strict';var schema=require(_0x2c15('0x0'));var _=require(_0x2c15('0x1'));var htmlToText=require(_0x2c15('0x2'));var utils=require(_0x2c15('0x3'));var logger=require(_0x2c15('0x4'))('routing');var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x2c15('0x5'),'message':'priority\x20true\x20is\x20a\x20number'},'priorityFalse':{'type':_0x2c15('0x5'),'message':_0x2c15('0x6')}});exports[_0x2c15('0x7')]=function(_0x56f78c,_0x439ddc){return function(_0x5bd8c8){try{var _0x4f564d={'condition':htmlToText[_0x2c15('0x8')](utils[_0x2c15('0x9')](_0x439ddc[0x0],this),{'wordwrap':![]})[_0x2c15('0xa')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x439ddc[0x1],'priorityFalse':_0x439ddc[0x2]};var _0x5c99f7=gotoif[_0x2c15('0x0')](_0x4f564d,{'typecast':!![]});if(_0x5c99f7[_0x2c15('0xb')]){logger[_0x2c15('0xc')](_0x2c15('0xd'),_0x56f78c,_[_0x2c15('0xe')](_0x5c99f7,_0x2c15('0xf'))[_0x2c15('0x10')](',\x20'));_0x5bd8c8[_0x2c15('0x11')]();}else{try{var _0x2b657c=eval('('+_0x4f564d['condition']+')');var _0x15397c=_0x2b657c?_0x4f564d[_0x2c15('0x12')]:_0x4f564d['priorityFalse'];logger[_0x2c15('0x13')](_0x2c15('0x14'),_0x56f78c,_0x4f564d[_0x2c15('0x15')],_0x2b657c,_0x15397c||_0x2c15('0x16'));if(_0x15397c){var _0x1f4f43=_['findIndex'](_0x5bd8c8['rules'](),{'p':_0x15397c});if(_0x1f4f43>=0x0){logger[_0x2c15('0x13')](_0x2c15('0x17'),_0x56f78c,_0x15397c||_0x2c15('0x16'),_0x1f4f43);_0x5bd8c8[_0x2c15('0x16')](_0x1f4f43);}else{logger[_0x2c15('0x13')](_0x2c15('0x18'),_0x56f78c,_0x15397c||'next');_0x5bd8c8['stop']();}}else{_0x5bd8c8[_0x2c15('0x16')]();}}catch(_0x3a0e0f){logger[_0x2c15('0xc')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x56f78c,_0x3a0e0f[_0x2c15('0xf')]);_0x5bd8c8[_0x2c15('0x11')]();}}}catch(_0x1639c2){logger[_0x2c15('0xc')](_0x2c15('0xd'),_0x56f78c,JSON[_0x2c15('0x19')](_0x1639c2));_0x5bd8c8[_0x2c15('0x11')]();}};};