Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
index a39260a..5cb3382 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x404f=['util','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','count','offset','Content-Range','apply','reject','update','then','sendStatus','error','stack','name','send','map','FreshdeskField','rawAttributes','fieldName','type','query','keys','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','limit','order','sort','where','pick','VIRTUAL','filter','merge','options','include','findAll','rows','catch','show','params','length','includeAll','find','create','body','destroy','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache'];(function(_0x30f6a6,_0x2dd6b2){var _0x280121=function(_0xaa3131){while(--_0xaa3131){_0x30f6a6['push'](_0x30f6a6['shift']());}};_0x280121(++_0x2dd6b2);}(_0x404f,0x17b));var _0xf404=function(_0x3daccc,_0x2ef4d8){_0x3daccc=_0x3daccc-0x0;var _0x31ecb0=_0x404f[_0x3daccc];return _0x31ecb0;};'use strict';var emlformat=require(_0xf404('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf404('0x1'));var jsonpatch=require(_0xf404('0x2'));var rp=require('request-promise');var moment=require(_0xf404('0x3'));var BPromise=require(_0xf404('0x4'));var Mustache=require(_0xf404('0x5'));var util=require(_0xf404('0x6'));var path=require(_0xf404('0x7'));var sox=require(_0xf404('0x8'));var csv=require('to-csv');var ejs=require(_0xf404('0x9'));var fs=require('fs');var fs_extra=require(_0xf404('0xa'));var _=require(_0xf404('0xb'));var squel=require(_0xf404('0xc'));var crypto=require('crypto');var jsforce=require(_0xf404('0xd'));var deskjs=require(_0xf404('0xe'));var toCsv=require(_0xf404('0xf'));var querystring=require('querystring');var Papa=require(_0xf404('0x10'));var Redis=require(_0xf404('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xf404('0x12'));var as=require(_0xf404('0x13'));var hardwareService=require(_0xf404('0x14'));var logger=require(_0xf404('0x15'))(_0xf404('0x16'));var utils=require(_0xf404('0x17'));var config=require(_0xf404('0x18'));var licenseUtil=require(_0xf404('0x19'));var db=require(_0xf404('0x1a'))['db'];function respondWithStatusCode(_0xd54621,_0x4db3f2){_0x4db3f2=_0x4db3f2||0xcc;return function(_0x129ed2){if(_0x129ed2){return _0xd54621['sendStatus'](_0x4db3f2);}return _0xd54621['status'](_0x4db3f2)[_0xf404('0x1b')]();};}function respondWithResult(_0x55906d,_0x34f709){_0x34f709=_0x34f709||0xc8;return function(_0x26ae42){if(_0x26ae42){return _0x55906d[_0xf404('0x1c')](_0x34f709)[_0xf404('0x1d')](_0x26ae42);}};}function respondWithFilteredResult(_0x54beeb,_0x183e17){return function(_0x52ec23){if(_0x52ec23){var _0x532a08=_0x52ec23[_0xf404('0x1e')],_0x902fb2=_0x183e17[_0xf404('0x1f')],_0xcc71d3=_0x183e17[_0xf404('0x1f')]+_0x183e17['limit'],_0x40721e;if(_0xcc71d3>=_0x532a08){_0xcc71d3=_0x532a08;_0x40721e=0xc8;}else{_0x40721e=0xce;}_0x54beeb[_0xf404('0x1c')](_0x40721e);return _0x54beeb['set'](_0xf404('0x20'),_0x902fb2+'-'+_0xcc71d3+'/'+_0x532a08)[_0xf404('0x1d')](_0x52ec23);}return null;};}function patchUpdates(_0x177824){return function(_0x42354e){try{jsonpatch[_0xf404('0x21')](_0x42354e,_0x177824,!![]);}catch(_0x59951e){return BPromise[_0xf404('0x22')](_0x59951e);}return _0x42354e['save']();};}function saveUpdates(_0x23a401,_0xc10189){return function(_0x60e612){if(_0x60e612){return _0x60e612[_0xf404('0x23')](_0x23a401)[_0xf404('0x24')](function(_0x4b31ec){return _0x4b31ec;});}return null;};}function removeEntity(_0x2bae47,_0x4c6536){return function(_0x462927){if(_0x462927){return _0x462927['destroy']()['then'](function(){_0x2bae47['status'](0xcc)[_0xf404('0x1b')]();});}};}function handleEntityNotFound(_0x5b37dc,_0xe4ddc0){return function(_0x121365){if(!_0x121365){_0x5b37dc[_0xf404('0x25')](0x194);}return _0x121365;};}function handleError(_0x5300a1,_0xaf48d){_0xaf48d=_0xaf48d||0x1f4;return function(_0x1fe620){logger[_0xf404('0x26')](_0x1fe620[_0xf404('0x27')]);if(_0x1fe620[_0xf404('0x28')]){delete _0x1fe620[_0xf404('0x28')];}_0x5300a1[_0xf404('0x1c')](_0xaf48d)[_0xf404('0x29')](_0x1fe620);};}exports['index']=function(_0x1a16d4,_0x46fbbe){var _0x15ea06={},_0x3bae20={},_0x306ded={'count':0x0,'rows':[]};var _0x3e2ad2=_[_0xf404('0x2a')](db[_0xf404('0x2b')][_0xf404('0x2c')],function(_0x51f8a0){return{'name':_0x51f8a0[_0xf404('0x2d')],'type':_0x51f8a0[_0xf404('0x2e')]['key']};});_0x3bae20['model']=_[_0xf404('0x2a')](_0x3e2ad2,_0xf404('0x28'));_0x3bae20[_0xf404('0x2f')]=_[_0xf404('0x30')](_0x1a16d4[_0xf404('0x2f')]);_0x3bae20[_0xf404('0x31')]=_[_0xf404('0x32')](_0x3bae20[_0xf404('0x33')],_0x3bae20['query']);_0x15ea06['attributes']=_[_0xf404('0x32')](_0x3bae20[_0xf404('0x33')],qs[_0xf404('0x34')](_0x1a16d4[_0xf404('0x2f')][_0xf404('0x34')]));_0x15ea06['attributes']=_0x15ea06[_0xf404('0x35')]['length']?_0x15ea06['attributes']:_0x3bae20[_0xf404('0x33')];if(!_0x1a16d4[_0xf404('0x2f')][_0xf404('0x36')](_0xf404('0x37'))){_0x15ea06['limit']=qs[_0xf404('0x38')](_0x1a16d4['query'][_0xf404('0x38')]);_0x15ea06[_0xf404('0x1f')]=qs[_0xf404('0x1f')](_0x1a16d4['query'][_0xf404('0x1f')]);}_0x15ea06[_0xf404('0x39')]=qs[_0xf404('0x3a')](_0x1a16d4[_0xf404('0x2f')]['sort']);_0x15ea06[_0xf404('0x3b')]=qs[_0xf404('0x31')](_[_0xf404('0x3c')](_0x1a16d4[_0xf404('0x2f')],_0x3bae20[_0xf404('0x31')]),_0x3e2ad2);if(_0x1a16d4[_0xf404('0x2f')]['filter']){_0x15ea06[_0xf404('0x3b')]=_['merge'](_0x15ea06[_0xf404('0x3b')],{'$or':_[_0xf404('0x2a')](_0x3e2ad2,function(_0x107476){if(_0x107476[_0xf404('0x2e')]!==_0xf404('0x3d')){var _0x1f7cde={};_0x1f7cde[_0x107476[_0xf404('0x28')]]={'$like':'%'+_0x1a16d4[_0xf404('0x2f')][_0xf404('0x3e')]+'%'};return _0x1f7cde;}})});}_0x15ea06=_[_0xf404('0x3f')]({},_0x15ea06,_0x1a16d4[_0xf404('0x40')]);var _0x596f14={'where':_0x15ea06[_0xf404('0x3b')]};return db[_0xf404('0x2b')][_0xf404('0x1e')](_0x596f14)[_0xf404('0x24')](function(_0x1ef091){_0x306ded[_0xf404('0x1e')]=_0x1ef091;if(_0x1a16d4[_0xf404('0x2f')]['includeAll']){_0x15ea06[_0xf404('0x41')]=[{'all':!![]}];}return db[_0xf404('0x2b')][_0xf404('0x42')](_0x15ea06);})['then'](function(_0x51eb6c){_0x306ded[_0xf404('0x43')]=_0x51eb6c;return _0x306ded;})[_0xf404('0x24')](respondWithFilteredResult(_0x46fbbe,_0x15ea06))[_0xf404('0x44')](handleError(_0x46fbbe,null));};exports[_0xf404('0x45')]=function(_0x2bba4f,_0x21be27){var _0x165aa3={'raw':!![],'where':{'id':_0x2bba4f[_0xf404('0x46')]['id']}},_0xce8eec={};_0xce8eec[_0xf404('0x33')]=_['keys'](db[_0xf404('0x2b')][_0xf404('0x2c')]);_0xce8eec['query']=_['keys'](_0x2bba4f[_0xf404('0x2f')]);_0xce8eec['filters']=_[_0xf404('0x32')](_0xce8eec[_0xf404('0x33')],_0xce8eec[_0xf404('0x2f')]);_0x165aa3[_0xf404('0x35')]=_[_0xf404('0x32')](_0xce8eec[_0xf404('0x33')],qs[_0xf404('0x34')](_0x2bba4f[_0xf404('0x2f')][_0xf404('0x34')]));_0x165aa3['attributes']=_0x165aa3[_0xf404('0x35')][_0xf404('0x47')]?_0x165aa3[_0xf404('0x35')]:_0xce8eec[_0xf404('0x33')];if(_0x2bba4f[_0xf404('0x2f')][_0xf404('0x48')]){_0x165aa3[_0xf404('0x41')]=[{'all':!![]}];}_0x165aa3=_[_0xf404('0x3f')]({},_0x165aa3,_0x2bba4f[_0xf404('0x40')]);return db[_0xf404('0x2b')][_0xf404('0x49')](_0x165aa3)['then'](handleEntityNotFound(_0x21be27,null))[_0xf404('0x24')](respondWithResult(_0x21be27,null))[_0xf404('0x44')](handleError(_0x21be27,null));};exports[_0xf404('0x4a')]=function(_0x5d8c4a,_0x21d40b){return db['FreshdeskField'][_0xf404('0x4a')](_0x5d8c4a[_0xf404('0x4b')],{})[_0xf404('0x24')](respondWithResult(_0x21d40b,0xc9))[_0xf404('0x44')](handleError(_0x21d40b,null));};exports['update']=function(_0x2d2e62,_0x39d647){if(_0x2d2e62[_0xf404('0x4b')]['id']){delete _0x2d2e62[_0xf404('0x4b')]['id'];}return db[_0xf404('0x2b')][_0xf404('0x49')]({'where':{'id':_0x2d2e62[_0xf404('0x46')]['id']}})[_0xf404('0x24')](handleEntityNotFound(_0x39d647,null))['then'](saveUpdates(_0x2d2e62[_0xf404('0x4b')],null))['then'](respondWithResult(_0x39d647,null))[_0xf404('0x44')](handleError(_0x39d647,null));};exports[_0xf404('0x4c')]=function(_0x2485eb,_0x466354){return db[_0xf404('0x2b')][_0xf404('0x49')]({'where':{'id':_0x2485eb[_0xf404('0x46')]['id']}})['then'](handleEntityNotFound(_0x466354,null))[_0xf404('0x24')](removeEntity(_0x466354,null))[_0xf404('0x44')](handleError(_0x466354,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