Built motion from commit (unavailable).|2.5.26
[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 _0xcf55=['rules','next','info','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','error','[%s][GOTOIF]\x20%s','map','message','stop','condition','priorityTrue','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','findIndex'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xcf55,0x162));var _0x5cf5=function(_0x290820,_0x3924a0){_0x290820=_0x290820-0x0;var _0x45f9db=_0xcf55[_0x290820];return _0x45f9db;};'use strict';var schema=require(_0x5cf5('0x0'));var _=require(_0x5cf5('0x1'));var htmlToText=require(_0x5cf5('0x2'));var utils=require(_0x5cf5('0x3'));var logger=require(_0x5cf5('0x4'))(_0x5cf5('0x5'));var gotoif=schema({'condition':{'type':_0x5cf5('0x6'),'required':!![],'message':_0x5cf5('0x7')},'priorityTrue':{'type':_0x5cf5('0x8'),'message':_0x5cf5('0x9')},'priorityFalse':{'type':_0x5cf5('0x8'),'message':_0x5cf5('0xa')}});exports['consequence']=function(_0x63e5c,_0x1d319a){return function(_0x3d9f29){try{var _0x103a4e={'condition':htmlToText[_0x5cf5('0xb')](utils[_0x5cf5('0xc')](_0x1d319a[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1d319a[0x1],'priorityFalse':_0x1d319a[0x2]};var _0x18b75b=gotoif[_0x5cf5('0x0')](_0x103a4e,{'typecast':!![]});if(_0x18b75b['length']){logger[_0x5cf5('0xd')](_0x5cf5('0xe'),_0x63e5c,_[_0x5cf5('0xf')](_0x18b75b,_0x5cf5('0x10'))['join'](',\x20'));_0x3d9f29[_0x5cf5('0x11')]();}else{try{var _0x3f3a75=eval('('+_0x103a4e[_0x5cf5('0x12')]+')');var _0x2d7661=_0x3f3a75?_0x103a4e[_0x5cf5('0x13')]:_0x103a4e[_0x5cf5('0x14')];logger['info'](_0x5cf5('0x15'),_0x63e5c,_0x103a4e[_0x5cf5('0x12')],_0x3f3a75,_0x2d7661||'next');if(_0x2d7661){var _0x16aacd=_[_0x5cf5('0x16')](_0x3d9f29[_0x5cf5('0x17')](),{'p':_0x2d7661});if(_0x16aacd>=0x0){logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s',_0x63e5c,_0x2d7661||_0x5cf5('0x18'),_0x16aacd);_0x3d9f29[_0x5cf5('0x18')](_0x16aacd);}else{logger[_0x5cf5('0x19')](_0x5cf5('0x1a'),_0x63e5c,_0x2d7661||'next');_0x3d9f29['stop']();}}else{_0x3d9f29[_0x5cf5('0x18')]();}}catch(_0x30a4c6){logger[_0x5cf5('0xd')](_0x5cf5('0x1b'),_0x63e5c,_0x30a4c6[_0x5cf5('0x10')]);_0x3d9f29[_0x5cf5('0x11')]();}}}catch(_0x2cd369){logger[_0x5cf5('0xd')](_0x5cf5('0xe'),_0x63e5c,JSON[_0x5cf5('0x1c')](_0x2cd369));_0x3d9f29[_0x5cf5('0x11')]();}};};