Built motion from commit (unavailable).|2.5.21
[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 _0x2d91=['[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stop','[%s][GOTOIF]\x20%s','stringify','lodash','./utils','routing','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','validate','length','error','map','message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','rules'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x2d91,0x1bf));var _0x12d9=function(_0x1034ee,_0x12998c){_0x1034ee=_0x1034ee-0x0;var _0x2922af=_0x2d91[_0x1034ee];return _0x2922af;};'use strict';var schema=require('validate');var _=require(_0x12d9('0x0'));var htmlToText=require('html-to-text');var utils=require(_0x12d9('0x1'));var logger=require('../../../../config/logger')(_0x12d9('0x2'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0x12d9('0x3')},'priorityTrue':{'type':_0x12d9('0x4'),'message':_0x12d9('0x5')},'priorityFalse':{'type':_0x12d9('0x4'),'message':_0x12d9('0x6')}});exports[_0x12d9('0x7')]=function(_0x78fc3b,_0x1d12fb){return function(_0x374575){try{var _0x3fe167={'condition':htmlToText['fromString'](utils['getMustacheRender'](_0x1d12fb[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1d12fb[0x1],'priorityFalse':_0x1d12fb[0x2]};var _0x44a536=gotoif[_0x12d9('0x8')](_0x3fe167,{'typecast':!![]});if(_0x44a536[_0x12d9('0x9')]){logger[_0x12d9('0xa')]('[%s][GOTOIF]\x20%s',_0x78fc3b,_[_0x12d9('0xb')](_0x44a536,_0x12d9('0xc'))[_0x12d9('0xd')](',\x20'));_0x374575['stop']();}else{try{var _0x5222e3=eval('('+_0x3fe167[_0x12d9('0xe')]+')');var _0xdf8251=_0x5222e3?_0x3fe167[_0x12d9('0xf')]:_0x3fe167[_0x12d9('0x10')];logger[_0x12d9('0x11')](_0x12d9('0x12'),_0x78fc3b,_0x3fe167[_0x12d9('0xe')],_0x5222e3,_0xdf8251||_0x12d9('0x13'));if(_0xdf8251){var _0x4f277b=_['findIndex'](_0x374575[_0x12d9('0x14')](),{'p':_0xdf8251});if(_0x4f277b>=0x0){logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x78fc3b,_0xdf8251||_0x12d9('0x13'),_0x4f277b);_0x374575[_0x12d9('0x13')](_0x4f277b);}else{logger['info'](_0x12d9('0x15'),_0x78fc3b,_0xdf8251||_0x12d9('0x13'));_0x374575['stop']();}}else{_0x374575[_0x12d9('0x13')]();}}catch(_0x21785f){logger[_0x12d9('0xa')](_0x12d9('0x16'),_0x78fc3b,_0x21785f[_0x12d9('0xc')]);_0x374575[_0x12d9('0x17')]();}}}catch(_0x1f530a){logger[_0x12d9('0xa')](_0x12d9('0x18'),_0x78fc3b,JSON[_0x12d9('0x19')](_0x1f530a));_0x374575[_0x12d9('0x17')]();}};};