3b412a163a83f898f33d86e39d73ccd3c9ef9b45
[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 _0xa3f0=['findIndex','rules','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','lodash','html-to-text','./utils','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','getMustacheRender','replace','validate','length','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','next'];(function(_0x2a960f,_0x5aab73){var _0x5027df=function(_0x13bf75){while(--_0x13bf75){_0x2a960f['push'](_0x2a960f['shift']());}};_0x5027df(++_0x5aab73);}(_0xa3f0,0x1e7));var _0x0a3f=function(_0xbb2e58,_0x1fe145){_0xbb2e58=_0xbb2e58-0x0;var _0x2f0d91=_0xa3f0[_0xbb2e58];return _0x2f0d91;};'use strict';var schema=require('validate');var _=require(_0x0a3f('0x0'));var htmlToText=require(_0x0a3f('0x1'));var utils=require(_0x0a3f('0x2'));var logger=require(_0x0a3f('0x3'))('routing');var gotoif=schema({'condition':{'type':_0x0a3f('0x4'),'required':!![],'message':_0x0a3f('0x5')},'priorityTrue':{'type':_0x0a3f('0x6'),'message':_0x0a3f('0x7')},'priorityFalse':{'type':'number','message':_0x0a3f('0x8')}});exports[_0x0a3f('0x9')]=function(_0x436c56,_0x2e669c){return function(_0xe91863){try{var _0x91463c={'condition':htmlToText['fromString'](utils[_0x0a3f('0xa')](_0x2e669c[0x0],this),{'wordwrap':![]})[_0x0a3f('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2e669c[0x1],'priorityFalse':_0x2e669c[0x2]};var _0x567c07=gotoif[_0x0a3f('0xc')](_0x91463c,{'typecast':!![]});if(_0x567c07[_0x0a3f('0xd')]){logger[_0x0a3f('0xe')](_0x0a3f('0xf'),_0x436c56,_[_0x0a3f('0x10')](_0x567c07,_0x0a3f('0x11'))[_0x0a3f('0x12')](',\x20'));_0xe91863[_0x0a3f('0x13')]();}else{try{var _0x2d3bf5=eval('('+_0x91463c[_0x0a3f('0x14')]+')');var _0x369072=_0x2d3bf5?_0x91463c[_0x0a3f('0x15')]:_0x91463c[_0x0a3f('0x16')];logger['info'](_0x0a3f('0x17'),_0x436c56,_0x91463c[_0x0a3f('0x14')],_0x2d3bf5,_0x369072||_0x0a3f('0x18'));if(_0x369072){var _0x21b19e=_[_0x0a3f('0x19')](_0xe91863[_0x0a3f('0x1a')](),{'p':_0x369072});if(_0x21b19e>=0x0){logger[_0x0a3f('0x1b')](_0x0a3f('0x1c'),_0x436c56,_0x369072||_0x0a3f('0x18'),_0x21b19e);_0xe91863[_0x0a3f('0x18')](_0x21b19e);}else{logger[_0x0a3f('0x1b')](_0x0a3f('0x1d'),_0x436c56,_0x369072||_0x0a3f('0x18'));_0xe91863['stop']();}}else{_0xe91863[_0x0a3f('0x18')]();}}catch(_0xb24a6a){logger[_0x0a3f('0xe')](_0x0a3f('0x1e'),_0x436c56,_0xb24a6a[_0x0a3f('0x11')]);_0xe91863[_0x0a3f('0x13')]();}}}catch(_0x327d71){logger['error'](_0x0a3f('0xf'),_0x436c56,JSON[_0x0a3f('0x1f')](_0x327d71));_0xe91863[_0x0a3f('0x13')]();}};};