Built motion from commit (unavailable).|2.5.15
[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 _0x4e29=['findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','stringify','lodash','html-to-text','./utils','string','number','priority\x20true\x20is\x20a\x20number','consequence','fromString','getMustacheRender','replace','validate','length','error','[%s][GOTOIF]\x20%s','map','message','join','condition','priorityTrue','info','next'];(function(_0x4450b1,_0x214ace){var _0x399b0b=function(_0x2197df){while(--_0x2197df){_0x4450b1['push'](_0x4450b1['shift']());}};_0x399b0b(++_0x214ace);}(_0x4e29,0xf9));var _0x94e2=function(_0x11e05d,_0x3a4491){_0x11e05d=_0x11e05d-0x0;var _0x335588=_0x4e29[_0x11e05d];return _0x335588;};'use strict';var schema=require('validate');var _=require(_0x94e2('0x0'));var htmlToText=require(_0x94e2('0x1'));var utils=require(_0x94e2('0x2'));var logger=require('../../../../config/logger')('routing');var gotoif=schema({'condition':{'type':_0x94e2('0x3'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x94e2('0x4'),'message':_0x94e2('0x5')},'priorityFalse':{'type':_0x94e2('0x4'),'message':'priority\x20false\x20is\x20a\x20number'}});exports[_0x94e2('0x6')]=function(_0x36e95c,_0x1d9c19){return function(_0x4664d9){try{var _0x275f18={'condition':htmlToText[_0x94e2('0x7')](utils[_0x94e2('0x8')](_0x1d9c19[0x0],this),{'wordwrap':![]})[_0x94e2('0x9')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1d9c19[0x1],'priorityFalse':_0x1d9c19[0x2]};var _0x53d027=gotoif[_0x94e2('0xa')](_0x275f18,{'typecast':!![]});if(_0x53d027[_0x94e2('0xb')]){logger[_0x94e2('0xc')](_0x94e2('0xd'),_0x36e95c,_[_0x94e2('0xe')](_0x53d027,_0x94e2('0xf'))[_0x94e2('0x10')](',\x20'));_0x4664d9['stop']();}else{try{var _0x5e4837=eval('('+_0x275f18[_0x94e2('0x11')]+')');var _0x164824=_0x5e4837?_0x275f18[_0x94e2('0x12')]:_0x275f18['priorityFalse'];logger[_0x94e2('0x13')]('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x36e95c,_0x275f18['condition'],_0x5e4837,_0x164824||_0x94e2('0x14'));if(_0x164824){var _0x237613=_[_0x94e2('0x15')](_0x4664d9[_0x94e2('0x16')](),{'p':_0x164824});if(_0x237613>=0x0){logger[_0x94e2('0x13')](_0x94e2('0x17'),_0x36e95c,_0x164824||_0x94e2('0x14'),_0x237613);_0x4664d9[_0x94e2('0x14')](_0x237613);}else{logger['info'](_0x94e2('0x18'),_0x36e95c,_0x164824||_0x94e2('0x14'));_0x4664d9['stop']();}}else{_0x4664d9[_0x94e2('0x14')]();}}catch(_0x34ca65){logger[_0x94e2('0xc')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x36e95c,_0x34ca65[_0x94e2('0xf')]);_0x4664d9[_0x94e2('0x19')]();}}}catch(_0x235324){logger[_0x94e2('0xc')](_0x94e2('0xd'),_0x36e95c,JSON[_0x94e2('0x1a')](_0x235324));_0x4664d9[_0x94e2('0x19')]();}};};