Built motion from commit (unavailable).|2.5.22
[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 _0x5694=['stringify','validate','lodash','html-to-text','../../../../config/logger','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','fromString','getMustacheRender','length','error','join','condition','priorityTrue','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','info','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','stop','[%s][GOTOIF]\x20eval\x20error:\x20%s'];(function(_0x184b9d,_0x29740f){var _0x59384b=function(_0x44c670){while(--_0x44c670){_0x184b9d['push'](_0x184b9d['shift']());}};_0x59384b(++_0x29740f);}(_0x5694,0x1b1));var _0x4569=function(_0x1c5297,_0x3169f7){_0x1c5297=_0x1c5297-0x0;var _0x128e15=_0x5694[_0x1c5297];return _0x128e15;};'use strict';var schema=require(_0x4569('0x0'));var _=require(_0x4569('0x1'));var htmlToText=require(_0x4569('0x2'));var utils=require('./utils');var logger=require(_0x4569('0x3'))('routing');var gotoif=schema({'condition':{'type':_0x4569('0x4'),'required':!![],'message':_0x4569('0x5')},'priorityTrue':{'type':_0x4569('0x6'),'message':_0x4569('0x7')},'priorityFalse':{'type':_0x4569('0x6'),'message':_0x4569('0x8')}});exports['consequence']=function(_0x5e4d40,_0x2eb193){return function(_0x22a9dd){try{var _0x215d74={'condition':htmlToText[_0x4569('0x9')](utils[_0x4569('0xa')](_0x2eb193[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2eb193[0x1],'priorityFalse':_0x2eb193[0x2]};var _0x10eacd=gotoif['validate'](_0x215d74,{'typecast':!![]});if(_0x10eacd[_0x4569('0xb')]){logger[_0x4569('0xc')]('[%s][GOTOIF]\x20%s',_0x5e4d40,_['map'](_0x10eacd,'message')[_0x4569('0xd')](',\x20'));_0x22a9dd['stop']();}else{try{var _0x341f62=eval('('+_0x215d74[_0x4569('0xe')]+')');var _0x5af6ef=_0x341f62?_0x215d74[_0x4569('0xf')]:_0x215d74['priorityFalse'];logger['info'](_0x4569('0x10'),_0x5e4d40,_0x215d74[_0x4569('0xe')],_0x341f62,_0x5af6ef||_0x4569('0x11'));if(_0x5af6ef){var _0x1aac18=_[_0x4569('0x12')](_0x22a9dd['rules'](),{'p':_0x5af6ef});if(_0x1aac18>=0x0){logger[_0x4569('0x13')](_0x4569('0x14'),_0x5e4d40,_0x5af6ef||_0x4569('0x11'),_0x1aac18);_0x22a9dd[_0x4569('0x11')](_0x1aac18);}else{logger['info']('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x5e4d40,_0x5af6ef||_0x4569('0x11'));_0x22a9dd[_0x4569('0x15')]();}}else{_0x22a9dd['next']();}}catch(_0xb06ab4){logger[_0x4569('0xc')](_0x4569('0x16'),_0x5e4d40,_0xb06ab4['message']);_0x22a9dd['stop']();}}}catch(_0x38a71e){logger['error']('[%s][GOTOIF]\x20%s',_0x5e4d40,JSON[_0x4569('0x17')](_0x38a71e));_0x22a9dd['stop']();}};};