Built motion from commit (unavailable).|2.4.18
[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 _0x7cc5=['priorityTrue','findIndex','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','info','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','message','[%s][GOTOIF]\x20%s','stringify','validate','lodash','./utils','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','getMustacheRender','map','join','stop','condition'];(function(_0x4c8e4a,_0xa800c9){var _0x3033ce=function(_0x4d0b12){while(--_0x4d0b12){_0x4c8e4a['push'](_0x4c8e4a['shift']());}};_0x3033ce(++_0xa800c9);}(_0x7cc5,0x82));var _0x57cc=function(_0x3a87e8,_0x1d8633){_0x3a87e8=_0x3a87e8-0x0;var _0x591e80=_0x7cc5[_0x3a87e8];return _0x591e80;};'use strict';var schema=require(_0x57cc('0x0'));var _=require(_0x57cc('0x1'));var htmlToText=require('html-to-text');var utils=require(_0x57cc('0x2'));var logger=require('../../../../config/logger')('routing');var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0x57cc('0x3')},'priorityTrue':{'type':_0x57cc('0x4'),'message':_0x57cc('0x5')},'priorityFalse':{'type':_0x57cc('0x4'),'message':_0x57cc('0x6')}});exports[_0x57cc('0x7')]=function(_0x555c20,_0x2c3da4){return function(_0x26082b){try{var _0xc4382b={'condition':htmlToText[_0x57cc('0x8')](utils[_0x57cc('0x9')](_0x2c3da4[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x2c3da4[0x1],'priorityFalse':_0x2c3da4[0x2]};var _0x399994=gotoif[_0x57cc('0x0')](_0xc4382b,{'typecast':!![]});if(_0x399994['length']){logger['error']('[%s][GOTOIF]\x20%s',_0x555c20,_[_0x57cc('0xa')](_0x399994,'message')[_0x57cc('0xb')](',\x20'));_0x26082b[_0x57cc('0xc')]();}else{try{var _0x2769ca=eval('('+_0xc4382b[_0x57cc('0xd')]+')');var _0x3a5a20=_0x2769ca?_0xc4382b[_0x57cc('0xe')]:_0xc4382b['priorityFalse'];logger['info']('[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s',_0x555c20,_0xc4382b['condition'],_0x2769ca,_0x3a5a20||'next');if(_0x3a5a20){var _0x42a0fa=_[_0x57cc('0xf')](_0x26082b['rules'](),{'p':_0x3a5a20});if(_0x42a0fa>=0x0){logger['info'](_0x57cc('0x10'),_0x555c20,_0x3a5a20||_0x57cc('0x11'),_0x42a0fa);_0x26082b[_0x57cc('0x11')](_0x42a0fa);}else{logger[_0x57cc('0x12')](_0x57cc('0x13'),_0x555c20,_0x3a5a20||_0x57cc('0x11'));_0x26082b['stop']();}}else{_0x26082b['next']();}}catch(_0x1bb758){logger[_0x57cc('0x14')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x555c20,_0x1bb758[_0x57cc('0x15')]);_0x26082b[_0x57cc('0xc')]();}}}catch(_0x20b2aa){logger['error'](_0x57cc('0x16'),_0x555c20,JSON[_0x57cc('0x17')](_0x20b2aa));_0x26082b[_0x57cc('0xc')]();}};};