Built motion from commit (unavailable).|2.3.95
[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 _0xcdb7=['[%s][GOTOIF]\x20%s','map','join','stop','condition','priorityFalse','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','info','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','error','[%s][GOTOIF]\x20eval\x20error:\x20%s','message','stringify','html-to-text','./utils','routing','priority\x20true\x20is\x20a\x20number','number','getMustacheRender','replace','validate','length'];(function(_0x46d0c9,_0x526bfa){var _0x174506=function(_0x654bc6){while(--_0x654bc6){_0x46d0c9['push'](_0x46d0c9['shift']());}};_0x174506(++_0x526bfa);}(_0xcdb7,0x1d2));var _0x7cdb=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0xcdb7[_0x501510];return _0x1e6ee5;};'use strict';var schema=require('validate');var _=require('lodash');var htmlToText=require(_0x7cdb('0x0'));var utils=require(_0x7cdb('0x1'));var logger=require('../../../../config/logger')(_0x7cdb('0x2'));var gotoif=schema({'condition':{'type':'string','required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':'number','message':_0x7cdb('0x3')},'priorityFalse':{'type':_0x7cdb('0x4'),'message':'priority\x20false\x20is\x20a\x20number'}});exports['consequence']=function(_0xd19ec7,_0x49649a){return function(_0x41863e){try{var _0x537687={'condition':htmlToText['fromString'](utils[_0x7cdb('0x5')](_0x49649a[0x0],this),{'wordwrap':![]})[_0x7cdb('0x6')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x49649a[0x1],'priorityFalse':_0x49649a[0x2]};var _0x2783b5=gotoif[_0x7cdb('0x7')](_0x537687,{'typecast':!![]});if(_0x2783b5[_0x7cdb('0x8')]){logger['error'](_0x7cdb('0x9'),_0xd19ec7,_[_0x7cdb('0xa')](_0x2783b5,'message')[_0x7cdb('0xb')](',\x20'));_0x41863e[_0x7cdb('0xc')]();}else{try{var _0x579a67=eval('('+_0x537687[_0x7cdb('0xd')]+')');var _0x1db57e=_0x579a67?_0x537687['priorityTrue']:_0x537687[_0x7cdb('0xe')];logger['info'](_0x7cdb('0xf'),_0xd19ec7,_0x537687[_0x7cdb('0xd')],_0x579a67,_0x1db57e||_0x7cdb('0x10'));if(_0x1db57e){var _0x571779=_['findIndex'](_0x41863e[_0x7cdb('0x11')](),{'p':_0x1db57e});if(_0x571779>=0x0){logger['info'](_0x7cdb('0x12'),_0xd19ec7,_0x1db57e||_0x7cdb('0x10'),_0x571779);_0x41863e[_0x7cdb('0x10')](_0x571779);}else{logger[_0x7cdb('0x13')](_0x7cdb('0x14'),_0xd19ec7,_0x1db57e||_0x7cdb('0x10'));_0x41863e[_0x7cdb('0xc')]();}}else{_0x41863e['next']();}}catch(_0x1d8076){logger[_0x7cdb('0x15')](_0x7cdb('0x16'),_0xd19ec7,_0x1d8076[_0x7cdb('0x17')]);_0x41863e[_0x7cdb('0xc')]();}}}catch(_0x560527){logger[_0x7cdb('0x15')](_0x7cdb('0x9'),_0xd19ec7,JSON[_0x7cdb('0x18')](_0x560527));_0x41863e['stop']();}};};