Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
index 94e079f..5cb3382 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x75cf=['../../config/license/util','../../mysqldb','sendStatus','end','status','json','count','offset','Content-Range','apply','save','update','then','destroy','error','stack','name','send','index','map','FreshdeskField','rawAttributes','fieldName','type','query','keys','intersection','model','fields','attributes','length','nolimit','limit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','catch','show','params','includeAll','find','create','body','html-pdf','eml-format','zip-dir','fast-json-patch','moment','util','path','sox','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils'];(function(_0x4aa082,_0x30ed5d){var _0x89703f=function(_0x500d5a){while(--_0x500d5a){_0x4aa082['push'](_0x4aa082['shift']());}};_0x89703f(++_0x30ed5d);}(_0x75cf,0x18a));var _0xf75c=function(_0x56da19,_0x1390d5){_0x56da19=_0x56da19-0x0;var _0x5dbe49=_0x75cf[_0x56da19];return _0x5dbe49;};'use strict';var pdf=require(_0xf75c('0x0'));var emlformat=require(_0xf75c('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xf75c('0x2'));var jsonpatch=require(_0xf75c('0x3'));var rp=require('request-promise');var moment=require(_0xf75c('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xf75c('0x5'));var path=require(_0xf75c('0x6'));var sox=require(_0xf75c('0x7'));var csv=require('to-csv');var ejs=require(_0xf75c('0x8'));var fs=require('fs');var _=require(_0xf75c('0x9'));var squel=require(_0xf75c('0xa'));var crypto=require(_0xf75c('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xf75c('0xc'));var toCsv=require(_0xf75c('0xd'));var querystring=require(_0xf75c('0xe'));var Papa=require(_0xf75c('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xf75c('0x10'));var as=require(_0xf75c('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf75c('0x12'));var utils=require(_0xf75c('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xf75c('0x14'));var db=require(_0xf75c('0x15'))['db'];function respondWithStatusCode(_0x441bc6,_0x4d6b33){_0x4d6b33=_0x4d6b33||0xcc;return function(_0xdf9aa5){if(_0xdf9aa5){return _0x441bc6[_0xf75c('0x16')](_0x4d6b33);}return _0x441bc6['status'](_0x4d6b33)[_0xf75c('0x17')]();};}function respondWithResult(_0x4f2909,_0x20dec0){_0x20dec0=_0x20dec0||0xc8;return function(_0x30df09){if(_0x30df09){return _0x4f2909[_0xf75c('0x18')](_0x20dec0)[_0xf75c('0x19')](_0x30df09);}};}function respondWithFilteredResult(_0x3e753d,_0x427809){return function(_0xae2398){if(_0xae2398){var _0x4071c6=_0xae2398[_0xf75c('0x1a')],_0x11d98f=_0x427809[_0xf75c('0x1b')],_0x5a13d6=_0x427809[_0xf75c('0x1b')]+_0x427809['limit'],_0x671055;if(_0x5a13d6>=_0x4071c6){_0x5a13d6=_0x4071c6;_0x671055=0xc8;}else{_0x671055=0xce;}_0x3e753d[_0xf75c('0x18')](_0x671055);return _0x3e753d['set'](_0xf75c('0x1c'),_0x11d98f+'-'+_0x5a13d6+'/'+_0x4071c6)[_0xf75c('0x19')](_0xae2398);}return null;};}function patchUpdates(_0x43df5e){return function(_0x36de1b){try{jsonpatch[_0xf75c('0x1d')](_0x36de1b,_0x43df5e,!![]);}catch(_0xed4bc1){return BPromise['reject'](_0xed4bc1);}return _0x36de1b[_0xf75c('0x1e')]();};}function saveUpdates(_0x1c61d9,_0x57496b){return function(_0x16ca37){if(_0x16ca37){return _0x16ca37[_0xf75c('0x1f')](_0x1c61d9)[_0xf75c('0x20')](function(_0x49af47){return _0x49af47;});}return null;};}function removeEntity(_0x1dfe0b,_0x2954e8){return function(_0x13eb28){if(_0x13eb28){return _0x13eb28[_0xf75c('0x21')]()[_0xf75c('0x20')](function(){_0x1dfe0b[_0xf75c('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1ef226,_0x3119db){return function(_0xe9b56b){if(!_0xe9b56b){_0x1ef226[_0xf75c('0x16')](0x194);}return _0xe9b56b;};}function handleError(_0x13d29a,_0xa712c1){_0xa712c1=_0xa712c1||0x1f4;return function(_0x39105f){logger[_0xf75c('0x22')](_0x39105f[_0xf75c('0x23')]);if(_0x39105f[_0xf75c('0x24')]){delete _0x39105f[_0xf75c('0x24')];}_0x13d29a[_0xf75c('0x18')](_0xa712c1)[_0xf75c('0x25')](_0x39105f);};}exports[_0xf75c('0x26')]=function(_0x524c80,_0x2f0c09){var _0x5d5d42={},_0x38a3bb={},_0x1c60e2={'count':0x0,'rows':[]};var _0xbd389c=_[_0xf75c('0x27')](db[_0xf75c('0x28')][_0xf75c('0x29')],function(_0x1e8a7a){return{'name':_0x1e8a7a[_0xf75c('0x2a')],'type':_0x1e8a7a[_0xf75c('0x2b')]['key']};});_0x38a3bb['model']=_[_0xf75c('0x27')](_0xbd389c,_0xf75c('0x24'));_0x38a3bb[_0xf75c('0x2c')]=_[_0xf75c('0x2d')](_0x524c80[_0xf75c('0x2c')]);_0x38a3bb['filters']=_[_0xf75c('0x2e')](_0x38a3bb[_0xf75c('0x2f')],_0x38a3bb['query']);_0x5d5d42['attributes']=_[_0xf75c('0x2e')](_0x38a3bb[_0xf75c('0x2f')],qs[_0xf75c('0x30')](_0x524c80[_0xf75c('0x2c')][_0xf75c('0x30')]));_0x5d5d42[_0xf75c('0x31')]=_0x5d5d42['attributes'][_0xf75c('0x32')]?_0x5d5d42[_0xf75c('0x31')]:_0x38a3bb[_0xf75c('0x2f')];if(!_0x524c80[_0xf75c('0x2c')]['hasOwnProperty'](_0xf75c('0x33'))){_0x5d5d42[_0xf75c('0x34')]=qs[_0xf75c('0x34')](_0x524c80['query'][_0xf75c('0x34')]);_0x5d5d42[_0xf75c('0x1b')]=qs[_0xf75c('0x1b')](_0x524c80[_0xf75c('0x2c')][_0xf75c('0x1b')]);}_0x5d5d42[_0xf75c('0x35')]=qs[_0xf75c('0x36')](_0x524c80[_0xf75c('0x2c')][_0xf75c('0x36')]);_0x5d5d42[_0xf75c('0x37')]=qs['filters'](_[_0xf75c('0x38')](_0x524c80[_0xf75c('0x2c')],_0x38a3bb[_0xf75c('0x39')]),_0xbd389c);if(_0x524c80[_0xf75c('0x2c')][_0xf75c('0x3a')]){_0x5d5d42[_0xf75c('0x37')]=_[_0xf75c('0x3b')](_0x5d5d42[_0xf75c('0x37')],{'$or':_[_0xf75c('0x27')](_0xbd389c,function(_0x549bf5){if(_0x549bf5[_0xf75c('0x2b')]!==_0xf75c('0x3c')){var _0x125bc0={};_0x125bc0[_0x549bf5[_0xf75c('0x24')]]={'$like':'%'+_0x524c80['query'][_0xf75c('0x3a')]+'%'};return _0x125bc0;}})});}_0x5d5d42=_[_0xf75c('0x3b')]({},_0x5d5d42,_0x524c80[_0xf75c('0x3d')]);var _0x574b18={'where':_0x5d5d42[_0xf75c('0x37')]};return db[_0xf75c('0x28')]['count'](_0x574b18)['then'](function(_0x1f9553){_0x1c60e2[_0xf75c('0x1a')]=_0x1f9553;if(_0x524c80[_0xf75c('0x2c')]['includeAll']){_0x5d5d42['include']=[{'all':!![]}];}return db[_0xf75c('0x28')]['findAll'](_0x5d5d42);})[_0xf75c('0x20')](function(_0x5d00f1){_0x1c60e2['rows']=_0x5d00f1;return _0x1c60e2;})[_0xf75c('0x20')](respondWithFilteredResult(_0x2f0c09,_0x5d5d42))[_0xf75c('0x3e')](handleError(_0x2f0c09,null));};exports[_0xf75c('0x3f')]=function(_0x2d5335,_0x2d4dc6){var _0x2191cd={'raw':!![],'where':{'id':_0x2d5335[_0xf75c('0x40')]['id']}},_0x365365={};_0x365365[_0xf75c('0x2f')]=_[_0xf75c('0x2d')](db['FreshdeskField'][_0xf75c('0x29')]);_0x365365[_0xf75c('0x2c')]=_[_0xf75c('0x2d')](_0x2d5335['query']);_0x365365[_0xf75c('0x39')]=_[_0xf75c('0x2e')](_0x365365[_0xf75c('0x2f')],_0x365365[_0xf75c('0x2c')]);_0x2191cd[_0xf75c('0x31')]=_['intersection'](_0x365365[_0xf75c('0x2f')],qs['fields'](_0x2d5335[_0xf75c('0x2c')][_0xf75c('0x30')]));_0x2191cd[_0xf75c('0x31')]=_0x2191cd[_0xf75c('0x31')]['length']?_0x2191cd[_0xf75c('0x31')]:_0x365365[_0xf75c('0x2f')];if(_0x2d5335[_0xf75c('0x2c')][_0xf75c('0x41')]){_0x2191cd['include']=[{'all':!![]}];}_0x2191cd=_[_0xf75c('0x3b')]({},_0x2191cd,_0x2d5335[_0xf75c('0x3d')]);return db[_0xf75c('0x28')][_0xf75c('0x42')](_0x2191cd)[_0xf75c('0x20')](handleEntityNotFound(_0x2d4dc6,null))[_0xf75c('0x20')](respondWithResult(_0x2d4dc6,null))['catch'](handleError(_0x2d4dc6,null));};exports[_0xf75c('0x43')]=function(_0x650800,_0x59eb91){return db['FreshdeskField']['create'](_0x650800[_0xf75c('0x44')],{})[_0xf75c('0x20')](respondWithResult(_0x59eb91,0xc9))[_0xf75c('0x3e')](handleError(_0x59eb91,null));};exports[_0xf75c('0x1f')]=function(_0x5361b3,_0x56c867){if(_0x5361b3[_0xf75c('0x44')]['id']){delete _0x5361b3[_0xf75c('0x44')]['id'];}return db[_0xf75c('0x28')]['find']({'where':{'id':_0x5361b3[_0xf75c('0x40')]['id']}})['then'](handleEntityNotFound(_0x56c867,null))['then'](saveUpdates(_0x5361b3[_0xf75c('0x44')],null))[_0xf75c('0x20')](respondWithResult(_0x56c867,null))[_0xf75c('0x3e')](handleError(_0x56c867,null));};exports[_0xf75c('0x21')]=function(_0x301575,_0x54a718){return db[_0xf75c('0x28')][_0xf75c('0x42')]({'where':{'id':_0x301575['params']['id']}})[_0xf75c('0x20')](handleEntityNotFound(_0x54a718,null))['then'](removeEntity(_0x54a718,null))[_0xf75c('0x3e')](handleError(_0x54a718,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