Built motion from commit (unavailable).|2.5.20
[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 _0x0ef4=['validate','html-to-text','../../../../config/logger','routing','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','length','error','map','message','stop','condition','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','[%s][GOTOIF]\x20eval\x20error:\x20%s','stringify'];(function(_0x168a25,_0x43d7a5){var _0x1681fa=function(_0x590866){while(--_0x590866){_0x168a25['push'](_0x168a25['shift']());}};_0x1681fa(++_0x43d7a5);}(_0x0ef4,0xc8));var _0x40ef=function(_0xf79bae,_0x263b2a){_0xf79bae=_0xf79bae-0x0;var _0x5d2cb7=_0x0ef4[_0xf79bae];return _0x5d2cb7;};'use strict';var schema=require(_0x40ef('0x0'));var _=require('lodash');var htmlToText=require(_0x40ef('0x1'));var utils=require('./utils');var logger=require(_0x40ef('0x2'))(_0x40ef('0x3'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':_0x40ef('0x4')},'priorityTrue':{'type':_0x40ef('0x5'),'message':_0x40ef('0x6')},'priorityFalse':{'type':_0x40ef('0x5'),'message':_0x40ef('0x7')}});exports[_0x40ef('0x8')]=function(_0x3ba07f,_0x1c02dc){return function(_0x2de39e){try{var _0x4822b5={'condition':htmlToText[_0x40ef('0x9')](utils['getMustacheRender'](_0x1c02dc[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1c02dc[0x1],'priorityFalse':_0x1c02dc[0x2]};var _0x9736db=gotoif[_0x40ef('0x0')](_0x4822b5,{'typecast':!![]});if(_0x9736db[_0x40ef('0xa')]){logger[_0x40ef('0xb')]('[%s][GOTOIF]\x20%s',_0x3ba07f,_[_0x40ef('0xc')](_0x9736db,_0x40ef('0xd'))['join'](',\x20'));_0x2de39e[_0x40ef('0xe')]();}else{try{var _0x2db1ac=eval('('+_0x4822b5[_0x40ef('0xf')]+')');var _0x3f8345=_0x2db1ac?_0x4822b5['priorityTrue']:_0x4822b5['priorityFalse'];logger[_0x40ef('0x10')](_0x40ef('0x11'),_0x3ba07f,_0x4822b5[_0x40ef('0xf')],_0x2db1ac,_0x3f8345||_0x40ef('0x12'));if(_0x3f8345){var _0x237291=_[_0x40ef('0x13')](_0x2de39e[_0x40ef('0x14')](),{'p':_0x3f8345});if(_0x237291>=0x0){logger[_0x40ef('0x10')](_0x40ef('0x15'),_0x3ba07f,_0x3f8345||_0x40ef('0x12'),_0x237291);_0x2de39e[_0x40ef('0x12')](_0x237291);}else{logger[_0x40ef('0x10')](_0x40ef('0x16'),_0x3ba07f,_0x3f8345||_0x40ef('0x12'));_0x2de39e[_0x40ef('0xe')]();}}else{_0x2de39e[_0x40ef('0x12')]();}}catch(_0x2240d8){logger['error'](_0x40ef('0x17'),_0x3ba07f,_0x2240d8['message']);_0x2de39e[_0x40ef('0xe')]();}}}catch(_0x4cfe7d){logger[_0x40ef('0xb')]('[%s][GOTOIF]\x20%s',_0x3ba07f,JSON[_0x40ef('0x18')](_0x4cfe7d));_0x2de39e[_0x40ef('0xe')]();}};};