Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / services / ami / trigger / integration / util.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 _0x943f=['test','lodash','util','getString','length','type','string','push','variable','variableName','toString','customVariable','Variable','name','toLowerCase','keyType','key','%s:\x20%s','keyContent','format','join','stripTrailingSlash','substring','validateEmail'];(function(_0x29a1d6,_0x3fdc36){var _0x979ba2=function(_0x3b6dc7){while(--_0x3b6dc7){_0x29a1d6['push'](_0x29a1d6['shift']());}};_0x979ba2(++_0x3fdc36);}(_0x943f,0xa9));var _0xf943=function(_0x161945,_0x3ccd0d){_0x161945=_0x161945-0x0;var _0x10d644=_0x943f[_0x161945];return _0x10d644;};'use strict';var _=require(_0xf943('0x0'));var util=require(_0xf943('0x1'));exports[_0xf943('0x2')]=function(_0x584980,_0x3a3269,_0x223593){var _0x309ca5=[];if(_0x584980[_0xf943('0x3')]>0x0){var _0x37f8d3=_['sortBy'](_0x584980,['id']);for(var _0x1d55b6=0x0;_0x1d55b6<_0x37f8d3['length'];_0x1d55b6++){var _0x297d8d=_0x37f8d3[_0x1d55b6];if(_0x297d8d[_0xf943('0x4')]===_0xf943('0x5')){_0x309ca5[_0xf943('0x6')](_0x297d8d['content']);}else if(_0x297d8d[_0xf943('0x4')]===_0xf943('0x7')&&_0x297d8d[_0xf943('0x8')]){_0x3a3269[_0x297d8d[_0xf943('0x8')]]&&_0x309ca5[_0xf943('0x6')](_0x3a3269[_0x297d8d[_0xf943('0x8')]][_0xf943('0x9')]());}else if(_0x297d8d[_0xf943('0x4')]===_0xf943('0xa')&&_0x297d8d[_0xf943('0xb')]&&_0x297d8d[_0xf943('0xb')][_0xf943('0xc')]){_0x3a3269[_0x297d8d['Variable'][_0xf943('0xc')][_0xf943('0xd')]()]&&_0x309ca5[_0xf943('0x6')](_0x3a3269[_0x297d8d[_0xf943('0xb')][_0xf943('0xc')][_0xf943('0xd')]()][_0xf943('0x9')]());}else if(_0x297d8d['type']==='keyValue'){if(_0x297d8d[_0xf943('0xe')]==='string'&&_0x297d8d[_0xf943('0xf')]){_0x309ca5[_0xf943('0x6')](util['format'](_0xf943('0x10'),_0x297d8d[_0xf943('0xf')],_0x297d8d[_0xf943('0x11')]));}else if(_0x297d8d['keyType']==='variable'&&_0x297d8d['variableName']&&_0x297d8d['key']){_0x3a3269[_0x297d8d[_0xf943('0x8')]]&&_0x309ca5[_0xf943('0x6')](util[_0xf943('0x12')](_0xf943('0x10'),_0x297d8d[_0xf943('0xf')],_0x3a3269[_0x297d8d[_0xf943('0x8')]]));}else if(_0x297d8d['keyType']===_0xf943('0xa')&&_0x297d8d[_0xf943('0xb')]&&_0x297d8d[_0xf943('0xb')][_0xf943('0xc')]&&_0x297d8d[_0xf943('0xf')]){_0x3a3269[_0x297d8d[_0xf943('0xb')]['name']['toLowerCase']()]&&_0x309ca5[_0xf943('0x6')](util[_0xf943('0x12')](_0xf943('0x10'),_0x297d8d[_0xf943('0xf')],_0x3a3269[_0x297d8d['Variable'][_0xf943('0xc')]['toLowerCase']()]));}}}}return _0x309ca5[_0xf943('0x13')](_0x223593);};exports[_0xf943('0x14')]=function(_0x19db6e){var _0x318ffd=_0x19db6e['slice'](-0x1);if(_0x318ffd==='/'){_0x19db6e=_0x19db6e[_0xf943('0x15')](0x0,_0x19db6e['lastIndexOf'](_0x318ffd));}return _0x19db6e;};exports[_0xf943('0x16')]=function(_0x3dc1d6){if(!_['isNil'](_0x3dc1d6)&&_0x3dc1d6!==''){var _0x82749c=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return _0x82749c[_0xf943('0x17')](String(_0x3dc1d6)[_0xf943('0xd')]());}else{return![];}};