Built motion from commit e6806ed6.|2.6.0
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
index 23460d1..ea2688d 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 _0x0102=['FreshdeskField','fieldName','key','model','query','keys','filters','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','type','options','then','findAll','rows','catch','params','rawAttributes','intersection','include','find','create','update','body','rimraf','zip-dir','fast-json-patch','request-promise','sox','to-csv','ejs','fs-extra','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','count','set','apply','reject','save','sendStatus','error','stack','name','send','index','map'];(function(_0x1308ec,_0x32c99e){var _0x1a43c8=function(_0x18ff62){while(--_0x18ff62){_0x1308ec['push'](_0x1308ec['shift']());}};_0x1a43c8(++_0x32c99e);}(_0x0102,0x186));var _0x2010=function(_0x5133b2,_0x22da17){_0x5133b2=_0x5133b2-0x0;var _0x2e46c2=_0x0102[_0x5133b2];return _0x2e46c2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x2010('0x0'));var zipdir=require(_0x2010('0x1'));var jsonpatch=require(_0x2010('0x2'));var rp=require(_0x2010('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x2010('0x4'));var csv=require(_0x2010('0x5'));var ejs=require(_0x2010('0x6'));var fs=require('fs');var fs_extra=require(_0x2010('0x7'));var _=require('lodash');var squel=require(_0x2010('0x8'));var crypto=require('crypto');var jsforce=require(_0x2010('0x9'));var deskjs=require(_0x2010('0xa'));var toCsv=require('to-csv');var querystring=require(_0x2010('0xb'));var Papa=require(_0x2010('0xc'));var Redis=require(_0x2010('0xd'));var authService=require(_0x2010('0xe'));var qs=require(_0x2010('0xf'));var as=require(_0x2010('0x10'));var hardwareService=require(_0x2010('0x11'));var logger=require(_0x2010('0x12'))(_0x2010('0x13'));var utils=require(_0x2010('0x14'));var config=require(_0x2010('0x15'));var licenseUtil=require(_0x2010('0x16'));var db=require(_0x2010('0x17'))['db'];function respondWithStatusCode(_0x3f307c,_0x3e8624){_0x3e8624=_0x3e8624||0xcc;return function(_0x388991){if(_0x388991){return _0x3f307c['sendStatus'](_0x3e8624);}return _0x3f307c['status'](_0x3e8624)[_0x2010('0x18')]();};}function respondWithResult(_0x385720,_0x2e8ec2){_0x2e8ec2=_0x2e8ec2||0xc8;return function(_0x10b587){if(_0x10b587){return _0x385720[_0x2010('0x19')](_0x2e8ec2)[_0x2010('0x1a')](_0x10b587);}};}function respondWithFilteredResult(_0x517ff4,_0x3195fa){return function(_0x136418){if(_0x136418){var _0x5ad412=typeof _0x3195fa[_0x2010('0x1b')]===_0x2010('0x1c')&&typeof _0x3195fa[_0x2010('0x1d')]===_0x2010('0x1c');var _0x2d0bf2=_0x136418[_0x2010('0x1e')];var _0x83cd35=_0x5ad412?0x0:_0x3195fa[_0x2010('0x1b')];var _0x309477=_0x5ad412?_0x136418['count']:_0x3195fa['offset']+_0x3195fa[_0x2010('0x1d')];var _0x38a15a;if(_0x309477>=_0x2d0bf2){_0x309477=_0x2d0bf2;_0x38a15a=0xc8;}else{_0x38a15a=0xce;}_0x517ff4[_0x2010('0x19')](_0x38a15a);return _0x517ff4[_0x2010('0x1f')]('Content-Range',_0x83cd35+'-'+_0x309477+'/'+_0x2d0bf2)['json'](_0x136418);}return null;};}function patchUpdates(_0x22c252){return function(_0x171e45){try{jsonpatch[_0x2010('0x20')](_0x171e45,_0x22c252,!![]);}catch(_0x26facc){return BPromise[_0x2010('0x21')](_0x26facc);}return _0x171e45[_0x2010('0x22')]();};}function saveUpdates(_0x4f621c,_0x3db13d){return function(_0x1cfa57){if(_0x1cfa57){return _0x1cfa57['update'](_0x4f621c)['then'](function(_0x50aecc){return _0x50aecc;});}return null;};}function removeEntity(_0x424453,_0x574719){return function(_0x277dcc){if(_0x277dcc){return _0x277dcc['destroy']()['then'](function(){_0x424453[_0x2010('0x19')](0xcc)[_0x2010('0x18')]();});}};}function handleEntityNotFound(_0x52b4fe,_0x99ebe0){return function(_0x4cff59){if(!_0x4cff59){_0x52b4fe[_0x2010('0x23')](0x194);}return _0x4cff59;};}function handleError(_0x27b425,_0x3929d9){_0x3929d9=_0x3929d9||0x1f4;return function(_0x3dcea4){logger[_0x2010('0x24')](_0x3dcea4[_0x2010('0x25')]);if(_0x3dcea4[_0x2010('0x26')]){delete _0x3dcea4[_0x2010('0x26')];}_0x27b425[_0x2010('0x19')](_0x3929d9)[_0x2010('0x27')](_0x3dcea4);};}exports[_0x2010('0x28')]=function(_0x2ebdbb,_0x499cbe){var _0x2a4691={},_0x52fe5e={},_0x5b52fb={'count':0x0,'rows':[]};var _0x147a5a=_[_0x2010('0x29')](db[_0x2010('0x2a')]['rawAttributes'],function(_0x554f66){return{'name':_0x554f66[_0x2010('0x2b')],'type':_0x554f66['type'][_0x2010('0x2c')]};});_0x52fe5e[_0x2010('0x2d')]=_['map'](_0x147a5a,_0x2010('0x26'));_0x52fe5e[_0x2010('0x2e')]=_[_0x2010('0x2f')](_0x2ebdbb[_0x2010('0x2e')]);_0x52fe5e[_0x2010('0x30')]=_['intersection'](_0x52fe5e[_0x2010('0x2d')],_0x52fe5e[_0x2010('0x2e')]);_0x2a4691[_0x2010('0x31')]=_['intersection'](_0x52fe5e['model'],qs[_0x2010('0x32')](_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x32')]));_0x2a4691['attributes']=_0x2a4691['attributes'][_0x2010('0x33')]?_0x2a4691[_0x2010('0x31')]:_0x52fe5e[_0x2010('0x2d')];if(!_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x34')]('nolimit')){_0x2a4691['limit']=qs['limit'](_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x1d')]);_0x2a4691[_0x2010('0x1b')]=qs['offset'](_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x1b')]);}_0x2a4691[_0x2010('0x35')]=qs[_0x2010('0x36')](_0x2ebdbb['query'][_0x2010('0x36')]);_0x2a4691[_0x2010('0x37')]=qs[_0x2010('0x30')](_['pick'](_0x2ebdbb[_0x2010('0x2e')],_0x52fe5e['filters']),_0x147a5a);if(_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x38')]){_0x2a4691[_0x2010('0x37')]=_[_0x2010('0x39')](_0x2a4691[_0x2010('0x37')],{'$or':_[_0x2010('0x29')](_0x147a5a,function(_0x53c09e){if(_0x53c09e[_0x2010('0x3a')]!=='VIRTUAL'){var _0x3e5422={};_0x3e5422[_0x53c09e[_0x2010('0x26')]]={'$like':'%'+_0x2ebdbb[_0x2010('0x2e')][_0x2010('0x38')]+'%'};return _0x3e5422;}})});}_0x2a4691=_[_0x2010('0x39')]({},_0x2a4691,_0x2ebdbb[_0x2010('0x3b')]);var _0x398f10={'where':_0x2a4691[_0x2010('0x37')]};return db[_0x2010('0x2a')][_0x2010('0x1e')](_0x398f10)[_0x2010('0x3c')](function(_0x2f37ca){_0x5b52fb[_0x2010('0x1e')]=_0x2f37ca;if(_0x2ebdbb[_0x2010('0x2e')]['includeAll']){_0x2a4691['include']=[{'all':!![]}];}return db[_0x2010('0x2a')][_0x2010('0x3d')](_0x2a4691);})[_0x2010('0x3c')](function(_0x35d631){_0x5b52fb[_0x2010('0x3e')]=_0x35d631;return _0x5b52fb;})[_0x2010('0x3c')](respondWithFilteredResult(_0x499cbe,_0x2a4691))[_0x2010('0x3f')](handleError(_0x499cbe,null));};exports['show']=function(_0x392576,_0x578645){var _0x27fd64={'raw':!![],'where':{'id':_0x392576[_0x2010('0x40')]['id']}},_0x3ff496={};_0x3ff496[_0x2010('0x2d')]=_[_0x2010('0x2f')](db['FreshdeskField'][_0x2010('0x41')]);_0x3ff496[_0x2010('0x2e')]=_[_0x2010('0x2f')](_0x392576[_0x2010('0x2e')]);_0x3ff496['filters']=_[_0x2010('0x42')](_0x3ff496['model'],_0x3ff496['query']);_0x27fd64['attributes']=_[_0x2010('0x42')](_0x3ff496[_0x2010('0x2d')],qs[_0x2010('0x32')](_0x392576[_0x2010('0x2e')][_0x2010('0x32')]));_0x27fd64[_0x2010('0x31')]=_0x27fd64['attributes'][_0x2010('0x33')]?_0x27fd64[_0x2010('0x31')]:_0x3ff496[_0x2010('0x2d')];if(_0x392576['query']['includeAll']){_0x27fd64[_0x2010('0x43')]=[{'all':!![]}];}_0x27fd64=_['merge']({},_0x27fd64,_0x392576[_0x2010('0x3b')]);return db[_0x2010('0x2a')][_0x2010('0x44')](_0x27fd64)[_0x2010('0x3c')](handleEntityNotFound(_0x578645,null))['then'](respondWithResult(_0x578645,null))[_0x2010('0x3f')](handleError(_0x578645,null));};exports[_0x2010('0x45')]=function(_0x2e2703,_0x231db7){return db[_0x2010('0x2a')][_0x2010('0x45')](_0x2e2703['body'],{})[_0x2010('0x3c')](respondWithResult(_0x231db7,0xc9))[_0x2010('0x3f')](handleError(_0x231db7,null));};exports[_0x2010('0x46')]=function(_0x4dc0cf,_0x30e5d0){if(_0x4dc0cf[_0x2010('0x47')]['id']){delete _0x4dc0cf['body']['id'];}return db[_0x2010('0x2a')][_0x2010('0x44')]({'where':{'id':_0x4dc0cf[_0x2010('0x40')]['id']}})[_0x2010('0x3c')](handleEntityNotFound(_0x30e5d0,null))[_0x2010('0x3c')](saveUpdates(_0x4dc0cf[_0x2010('0x47')],null))[_0x2010('0x3c')](respondWithResult(_0x30e5d0,null))[_0x2010('0x3f')](handleError(_0x30e5d0,null));};exports['destroy']=function(_0x5258b9,_0xc9f070){return db[_0x2010('0x2a')]['find']({'where':{'id':_0x5258b9[_0x2010('0x40')]['id']}})[_0x2010('0x3c')](handleEntityNotFound(_0xc9f070,null))[_0x2010('0x3c')](removeEntity(_0xc9f070,null))[_0x2010('0x3f')](handleError(_0xc9f070,null));};
\ No newline at end of file