Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
index 23460d1..5cb3382 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x222f=['../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','FreshdeskField','rawAttributes','fieldName','key','model','query','keys','attributes','intersection','fields','nolimit','sort','where','filters','filter','merge','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x5bf2b3,_0xfcd364){var _0x5e8a9b=function(_0x43546b){while(--_0x43546b){_0x5bf2b3['push'](_0x5bf2b3['shift']());}};_0x5e8a9b(++_0xfcd364);}(_0x222f,0x1a4));var _0xf222=function(_0x342ca3,_0x31db47){_0x342ca3=_0x342ca3-0x0;var _0x580f2d=_0x222f[_0x342ca3];return _0x580f2d;};'use strict';var emlformat=require(_0xf222('0x0'));var rimraf=require(_0xf222('0x1'));var zipdir=require(_0xf222('0x2'));var jsonpatch=require(_0xf222('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf222('0x4'));var Mustache=require(_0xf222('0x5'));var util=require(_0xf222('0x6'));var path=require(_0xf222('0x7'));var sox=require('sox');var csv=require(_0xf222('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf222('0x9'));var _=require(_0xf222('0xa'));var squel=require('squel');var crypto=require(_0xf222('0xb'));var jsforce=require(_0xf222('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xf222('0x8'));var querystring=require(_0xf222('0xd'));var Papa=require(_0xf222('0xe'));var Redis=require(_0xf222('0xf'));var authService=require(_0xf222('0x10'));var qs=require(_0xf222('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf222('0x12'));var logger=require(_0xf222('0x13'))(_0xf222('0x14'));var utils=require(_0xf222('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf222('0x16'));var db=require(_0xf222('0x17'))['db'];function respondWithStatusCode(_0x2a6965,_0x3d3d29){_0x3d3d29=_0x3d3d29||0xcc;return function(_0x12f968){if(_0x12f968){return _0x2a6965[_0xf222('0x18')](_0x3d3d29);}return _0x2a6965[_0xf222('0x19')](_0x3d3d29)[_0xf222('0x1a')]();};}function respondWithResult(_0x52a003,_0x5b8f97){_0x5b8f97=_0x5b8f97||0xc8;return function(_0x1feb86){if(_0x1feb86){return _0x52a003[_0xf222('0x19')](_0x5b8f97)['json'](_0x1feb86);}};}function respondWithFilteredResult(_0x39be58,_0x43d35b){return function(_0x464f3e){if(_0x464f3e){var _0x4392a0=typeof _0x43d35b[_0xf222('0x1b')]===_0xf222('0x1c')&&typeof _0x43d35b[_0xf222('0x1d')]==='undefined';var _0x1efa9f=_0x464f3e[_0xf222('0x1e')];var _0x8783ab=_0x4392a0?0x0:_0x43d35b[_0xf222('0x1b')];var _0x12a2e4=_0x4392a0?_0x464f3e[_0xf222('0x1e')]:_0x43d35b[_0xf222('0x1b')]+_0x43d35b['limit'];var _0xf26a16;if(_0x12a2e4>=_0x1efa9f){_0x12a2e4=_0x1efa9f;_0xf26a16=0xc8;}else{_0xf26a16=0xce;}_0x39be58[_0xf222('0x19')](_0xf26a16);return _0x39be58[_0xf222('0x1f')](_0xf222('0x20'),_0x8783ab+'-'+_0x12a2e4+'/'+_0x1efa9f)['json'](_0x464f3e);}return null;};}function patchUpdates(_0x5cd899){return function(_0x398ff4){try{jsonpatch[_0xf222('0x21')](_0x398ff4,_0x5cd899,!![]);}catch(_0x201cf0){return BPromise[_0xf222('0x22')](_0x201cf0);}return _0x398ff4[_0xf222('0x23')]();};}function saveUpdates(_0x151a89,_0x51b872){return function(_0x176b20){if(_0x176b20){return _0x176b20[_0xf222('0x24')](_0x151a89)[_0xf222('0x25')](function(_0x12d443){return _0x12d443;});}return null;};}function removeEntity(_0x2c48ce,_0x2d18ab){return function(_0x4616de){if(_0x4616de){return _0x4616de[_0xf222('0x26')]()['then'](function(){_0x2c48ce[_0xf222('0x19')](0xcc)[_0xf222('0x1a')]();});}};}function handleEntityNotFound(_0x1883c1,_0x3fce26){return function(_0x4305e0){if(!_0x4305e0){_0x1883c1[_0xf222('0x18')](0x194);}return _0x4305e0;};}function handleError(_0x42616e,_0x263dc2){_0x263dc2=_0x263dc2||0x1f4;return function(_0x15bf4e){logger[_0xf222('0x27')](_0x15bf4e[_0xf222('0x28')]);if(_0x15bf4e['name']){delete _0x15bf4e[_0xf222('0x29')];}_0x42616e[_0xf222('0x19')](_0x263dc2)[_0xf222('0x2a')](_0x15bf4e);};}exports[_0xf222('0x2b')]=function(_0xe41039,_0x40a715){var _0x3789e0={},_0x1b928b={},_0x1e87ec={'count':0x0,'rows':[]};var _0x59721a=_[_0xf222('0x2c')](db[_0xf222('0x2d')][_0xf222('0x2e')],function(_0x53a382){return{'name':_0x53a382[_0xf222('0x2f')],'type':_0x53a382['type'][_0xf222('0x30')]};});_0x1b928b[_0xf222('0x31')]=_[_0xf222('0x2c')](_0x59721a,_0xf222('0x29'));_0x1b928b[_0xf222('0x32')]=_[_0xf222('0x33')](_0xe41039[_0xf222('0x32')]);_0x1b928b['filters']=_['intersection'](_0x1b928b[_0xf222('0x31')],_0x1b928b[_0xf222('0x32')]);_0x3789e0[_0xf222('0x34')]=_[_0xf222('0x35')](_0x1b928b[_0xf222('0x31')],qs[_0xf222('0x36')](_0xe41039['query'][_0xf222('0x36')]));_0x3789e0[_0xf222('0x34')]=_0x3789e0[_0xf222('0x34')]['length']?_0x3789e0[_0xf222('0x34')]:_0x1b928b[_0xf222('0x31')];if(!_0xe41039[_0xf222('0x32')]['hasOwnProperty'](_0xf222('0x37'))){_0x3789e0[_0xf222('0x1d')]=qs[_0xf222('0x1d')](_0xe41039['query'][_0xf222('0x1d')]);_0x3789e0[_0xf222('0x1b')]=qs[_0xf222('0x1b')](_0xe41039[_0xf222('0x32')][_0xf222('0x1b')]);}_0x3789e0['order']=qs[_0xf222('0x38')](_0xe41039['query'][_0xf222('0x38')]);_0x3789e0[_0xf222('0x39')]=qs[_0xf222('0x3a')](_['pick'](_0xe41039[_0xf222('0x32')],_0x1b928b[_0xf222('0x3a')]),_0x59721a);if(_0xe41039['query'][_0xf222('0x3b')]){_0x3789e0['where']=_[_0xf222('0x3c')](_0x3789e0[_0xf222('0x39')],{'$or':_[_0xf222('0x2c')](_0x59721a,function(_0x5c8b04){if(_0x5c8b04[_0xf222('0x3d')]!==_0xf222('0x3e')){var _0x2c1e49={};_0x2c1e49[_0x5c8b04[_0xf222('0x29')]]={'$like':'%'+_0xe41039[_0xf222('0x32')][_0xf222('0x3b')]+'%'};return _0x2c1e49;}})});}_0x3789e0=_['merge']({},_0x3789e0,_0xe41039[_0xf222('0x3f')]);var _0x24e8a5={'where':_0x3789e0['where']};return db['FreshdeskField'][_0xf222('0x1e')](_0x24e8a5)['then'](function(_0x2b20d3){_0x1e87ec[_0xf222('0x1e')]=_0x2b20d3;if(_0xe41039[_0xf222('0x32')][_0xf222('0x40')]){_0x3789e0['include']=[{'all':!![]}];}return db['FreshdeskField'][_0xf222('0x41')](_0x3789e0);})['then'](function(_0x522a9e){_0x1e87ec[_0xf222('0x42')]=_0x522a9e;return _0x1e87ec;})[_0xf222('0x25')](respondWithFilteredResult(_0x40a715,_0x3789e0))[_0xf222('0x43')](handleError(_0x40a715,null));};exports[_0xf222('0x44')]=function(_0x10f065,_0x2af478){var _0x5c60e6={'raw':!![],'where':{'id':_0x10f065[_0xf222('0x45')]['id']}},_0xf829ae={};_0xf829ae['model']=_[_0xf222('0x33')](db[_0xf222('0x2d')]['rawAttributes']);_0xf829ae[_0xf222('0x32')]=_['keys'](_0x10f065[_0xf222('0x32')]);_0xf829ae[_0xf222('0x3a')]=_[_0xf222('0x35')](_0xf829ae[_0xf222('0x31')],_0xf829ae[_0xf222('0x32')]);_0x5c60e6[_0xf222('0x34')]=_[_0xf222('0x35')](_0xf829ae[_0xf222('0x31')],qs[_0xf222('0x36')](_0x10f065[_0xf222('0x32')][_0xf222('0x36')]));_0x5c60e6['attributes']=_0x5c60e6['attributes']['length']?_0x5c60e6[_0xf222('0x34')]:_0xf829ae[_0xf222('0x31')];if(_0x10f065[_0xf222('0x32')][_0xf222('0x40')]){_0x5c60e6['include']=[{'all':!![]}];}_0x5c60e6=_[_0xf222('0x3c')]({},_0x5c60e6,_0x10f065[_0xf222('0x3f')]);return db[_0xf222('0x2d')][_0xf222('0x46')](_0x5c60e6)['then'](handleEntityNotFound(_0x2af478,null))[_0xf222('0x25')](respondWithResult(_0x2af478,null))[_0xf222('0x43')](handleError(_0x2af478,null));};exports[_0xf222('0x47')]=function(_0x37b393,_0x1d60e5){return db[_0xf222('0x2d')][_0xf222('0x47')](_0x37b393[_0xf222('0x48')],{})[_0xf222('0x25')](respondWithResult(_0x1d60e5,0xc9))[_0xf222('0x43')](handleError(_0x1d60e5,null));};exports['update']=function(_0x5d0d70,_0x193762){if(_0x5d0d70['body']['id']){delete _0x5d0d70[_0xf222('0x48')]['id'];}return db['FreshdeskField'][_0xf222('0x46')]({'where':{'id':_0x5d0d70['params']['id']}})[_0xf222('0x25')](handleEntityNotFound(_0x193762,null))[_0xf222('0x25')](saveUpdates(_0x5d0d70[_0xf222('0x48')],null))[_0xf222('0x25')](respondWithResult(_0x193762,null))['catch'](handleError(_0x193762,null));};exports[_0xf222('0x26')]=function(_0x34fd50,_0x380642){return db[_0xf222('0x2d')][_0xf222('0x46')]({'where':{'id':_0x34fd50[_0xf222('0x45')]['id']}})[_0xf222('0x25')](handleEntityNotFound(_0x380642,null))[_0xf222('0x25')](removeEntity(_0x380642,null))[_0xf222('0x43')](handleError(_0x380642,null));};
\ No newline at end of file
+var _0xb469=['undefined','count','limit','set','Content-Range','apply','update','then','error','stack','name','index','map','FreshdeskField','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','offset','order','sort','pick','filter','where','merge','VIRTUAL','include','rows','catch','params','includeAll','options','find','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json'];(function(_0x38c652,_0x1ea1b7){var _0x218a37=function(_0x5dcb2a){while(--_0x5dcb2a){_0x38c652['push'](_0x38c652['shift']());}};_0x218a37(++_0x1ea1b7);}(_0xb469,0x13b));var _0x9b46=function(_0x1dabcf,_0x19161a){_0x1dabcf=_0x1dabcf-0x0;var _0x2c98a7=_0xb469[_0x1dabcf];return _0x2c98a7;};'use strict';var emlformat=require(_0x9b46('0x0'));var rimraf=require(_0x9b46('0x1'));var zipdir=require(_0x9b46('0x2'));var jsonpatch=require(_0x9b46('0x3'));var rp=require(_0x9b46('0x4'));var moment=require(_0x9b46('0x5'));var BPromise=require(_0x9b46('0x6'));var Mustache=require('mustache');var util=require(_0x9b46('0x7'));var path=require(_0x9b46('0x8'));var sox=require('sox');var csv=require(_0x9b46('0x9'));var ejs=require(_0x9b46('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9b46('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x9b46('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x9b46('0x9'));var querystring=require(_0x9b46('0xd'));var Papa=require(_0x9b46('0xe'));var Redis=require('ioredis');var authService=require(_0x9b46('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x9b46('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9b46('0x11'))('api');var utils=require(_0x9b46('0x12'));var config=require(_0x9b46('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x9b46('0x14'))['db'];function respondWithStatusCode(_0x417df5,_0x5b65c2){_0x5b65c2=_0x5b65c2||0xcc;return function(_0x14362a){if(_0x14362a){return _0x417df5[_0x9b46('0x15')](_0x5b65c2);}return _0x417df5[_0x9b46('0x16')](_0x5b65c2)[_0x9b46('0x17')]();};}function respondWithResult(_0xa8f4ac,_0x35c5c1){_0x35c5c1=_0x35c5c1||0xc8;return function(_0x2136bc){if(_0x2136bc){return _0xa8f4ac[_0x9b46('0x16')](_0x35c5c1)[_0x9b46('0x18')](_0x2136bc);}};}function respondWithFilteredResult(_0x178293,_0xbc1ba6){return function(_0x135cc2){if(_0x135cc2){var _0x1e6911=typeof _0xbc1ba6['offset']==='undefined'&&typeof _0xbc1ba6['limit']===_0x9b46('0x19');var _0x5a380c=_0x135cc2[_0x9b46('0x1a')];var _0x5c5cc9=_0x1e6911?0x0:_0xbc1ba6['offset'];var _0x3d9efa=_0x1e6911?_0x135cc2['count']:_0xbc1ba6['offset']+_0xbc1ba6[_0x9b46('0x1b')];var _0x3a15cc;if(_0x3d9efa>=_0x5a380c){_0x3d9efa=_0x5a380c;_0x3a15cc=0xc8;}else{_0x3a15cc=0xce;}_0x178293['status'](_0x3a15cc);return _0x178293[_0x9b46('0x1c')](_0x9b46('0x1d'),_0x5c5cc9+'-'+_0x3d9efa+'/'+_0x5a380c)['json'](_0x135cc2);}return null;};}function patchUpdates(_0x55aece){return function(_0xbec2ea){try{jsonpatch[_0x9b46('0x1e')](_0xbec2ea,_0x55aece,!![]);}catch(_0x204098){return BPromise['reject'](_0x204098);}return _0xbec2ea['save']();};}function saveUpdates(_0x2b3440,_0x51d2ca){return function(_0x21dacb){if(_0x21dacb){return _0x21dacb[_0x9b46('0x1f')](_0x2b3440)['then'](function(_0xadff19){return _0xadff19;});}return null;};}function removeEntity(_0x5182b1,_0x141cb6){return function(_0x2b6f72){if(_0x2b6f72){return _0x2b6f72['destroy']()[_0x9b46('0x20')](function(){_0x5182b1[_0x9b46('0x16')](0xcc)[_0x9b46('0x17')]();});}};}function handleEntityNotFound(_0x319930,_0x33ea06){return function(_0x3e4899){if(!_0x3e4899){_0x319930[_0x9b46('0x15')](0x194);}return _0x3e4899;};}function handleError(_0x5dc377,_0xdd756c){_0xdd756c=_0xdd756c||0x1f4;return function(_0x3ac37e){logger[_0x9b46('0x21')](_0x3ac37e[_0x9b46('0x22')]);if(_0x3ac37e[_0x9b46('0x23')]){delete _0x3ac37e[_0x9b46('0x23')];}_0x5dc377[_0x9b46('0x16')](_0xdd756c)['send'](_0x3ac37e);};}exports[_0x9b46('0x24')]=function(_0xee519e,_0x3630bf){var _0x376ccc={},_0x28b289={},_0x869993={'count':0x0,'rows':[]};var _0xc062ec=_[_0x9b46('0x25')](db[_0x9b46('0x26')][_0x9b46('0x27')],function(_0x2e1c51){return{'name':_0x2e1c51['fieldName'],'type':_0x2e1c51[_0x9b46('0x28')][_0x9b46('0x29')]};});_0x28b289[_0x9b46('0x2a')]=_[_0x9b46('0x25')](_0xc062ec,_0x9b46('0x23'));_0x28b289[_0x9b46('0x2b')]=_[_0x9b46('0x2c')](_0xee519e[_0x9b46('0x2b')]);_0x28b289[_0x9b46('0x2d')]=_[_0x9b46('0x2e')](_0x28b289[_0x9b46('0x2a')],_0x28b289['query']);_0x376ccc[_0x9b46('0x2f')]=_['intersection'](_0x28b289[_0x9b46('0x2a')],qs[_0x9b46('0x30')](_0xee519e[_0x9b46('0x2b')]['fields']));_0x376ccc[_0x9b46('0x2f')]=_0x376ccc[_0x9b46('0x2f')][_0x9b46('0x31')]?_0x376ccc[_0x9b46('0x2f')]:_0x28b289[_0x9b46('0x2a')];if(!_0xee519e['query']['hasOwnProperty'](_0x9b46('0x32'))){_0x376ccc[_0x9b46('0x1b')]=qs[_0x9b46('0x1b')](_0xee519e[_0x9b46('0x2b')]['limit']);_0x376ccc[_0x9b46('0x33')]=qs['offset'](_0xee519e[_0x9b46('0x2b')][_0x9b46('0x33')]);}_0x376ccc[_0x9b46('0x34')]=qs[_0x9b46('0x35')](_0xee519e['query'][_0x9b46('0x35')]);_0x376ccc['where']=qs[_0x9b46('0x2d')](_[_0x9b46('0x36')](_0xee519e[_0x9b46('0x2b')],_0x28b289[_0x9b46('0x2d')]),_0xc062ec);if(_0xee519e[_0x9b46('0x2b')][_0x9b46('0x37')]){_0x376ccc[_0x9b46('0x38')]=_[_0x9b46('0x39')](_0x376ccc[_0x9b46('0x38')],{'$or':_[_0x9b46('0x25')](_0xc062ec,function(_0x1c4147){if(_0x1c4147['type']!==_0x9b46('0x3a')){var _0x5aac02={};_0x5aac02[_0x1c4147[_0x9b46('0x23')]]={'$like':'%'+_0xee519e[_0x9b46('0x2b')]['filter']+'%'};return _0x5aac02;}})});}_0x376ccc=_[_0x9b46('0x39')]({},_0x376ccc,_0xee519e['options']);var _0x416538={'where':_0x376ccc['where']};return db[_0x9b46('0x26')][_0x9b46('0x1a')](_0x416538)[_0x9b46('0x20')](function(_0x22ab5d){_0x869993[_0x9b46('0x1a')]=_0x22ab5d;if(_0xee519e['query']['includeAll']){_0x376ccc[_0x9b46('0x3b')]=[{'all':!![]}];}return db['FreshdeskField']['findAll'](_0x376ccc);})['then'](function(_0x4e1911){_0x869993[_0x9b46('0x3c')]=_0x4e1911;return _0x869993;})['then'](respondWithFilteredResult(_0x3630bf,_0x376ccc))[_0x9b46('0x3d')](handleError(_0x3630bf,null));};exports['show']=function(_0x3fa46c,_0xe807bf){var _0x2e92aa={'raw':!![],'where':{'id':_0x3fa46c[_0x9b46('0x3e')]['id']}},_0xa14b={};_0xa14b[_0x9b46('0x2a')]=_[_0x9b46('0x2c')](db[_0x9b46('0x26')][_0x9b46('0x27')]);_0xa14b['query']=_[_0x9b46('0x2c')](_0x3fa46c[_0x9b46('0x2b')]);_0xa14b[_0x9b46('0x2d')]=_[_0x9b46('0x2e')](_0xa14b[_0x9b46('0x2a')],_0xa14b[_0x9b46('0x2b')]);_0x2e92aa[_0x9b46('0x2f')]=_[_0x9b46('0x2e')](_0xa14b[_0x9b46('0x2a')],qs[_0x9b46('0x30')](_0x3fa46c[_0x9b46('0x2b')][_0x9b46('0x30')]));_0x2e92aa[_0x9b46('0x2f')]=_0x2e92aa[_0x9b46('0x2f')]['length']?_0x2e92aa['attributes']:_0xa14b[_0x9b46('0x2a')];if(_0x3fa46c[_0x9b46('0x2b')][_0x9b46('0x3f')]){_0x2e92aa['include']=[{'all':!![]}];}_0x2e92aa=_['merge']({},_0x2e92aa,_0x3fa46c[_0x9b46('0x40')]);return db[_0x9b46('0x26')][_0x9b46('0x41')](_0x2e92aa)[_0x9b46('0x20')](handleEntityNotFound(_0xe807bf,null))[_0x9b46('0x20')](respondWithResult(_0xe807bf,null))[_0x9b46('0x3d')](handleError(_0xe807bf,null));};exports['create']=function(_0x6d1e73,_0x32e34d){return db[_0x9b46('0x26')]['create'](_0x6d1e73[_0x9b46('0x42')],{})['then'](respondWithResult(_0x32e34d,0xc9))[_0x9b46('0x3d')](handleError(_0x32e34d,null));};exports[_0x9b46('0x1f')]=function(_0x16e6d8,_0x566bad){if(_0x16e6d8[_0x9b46('0x42')]['id']){delete _0x16e6d8[_0x9b46('0x42')]['id'];}return db[_0x9b46('0x26')][_0x9b46('0x41')]({'where':{'id':_0x16e6d8[_0x9b46('0x3e')]['id']}})[_0x9b46('0x20')](handleEntityNotFound(_0x566bad,null))['then'](saveUpdates(_0x16e6d8[_0x9b46('0x42')],null))[_0x9b46('0x20')](respondWithResult(_0x566bad,null))[_0x9b46('0x3d')](handleError(_0x566bad,null));};exports[_0x9b46('0x43')]=function(_0x362311,_0x36a492){return db['FreshdeskField'][_0x9b46('0x41')]({'where':{'id':_0x362311['params']['id']}})[_0x9b46('0x20')](handleEntityNotFound(_0x36a492,null))[_0x9b46('0x20')](removeEntity(_0x36a492,null))[_0x9b46('0x3d')](handleError(_0x36a492,null));};
\ No newline at end of file