Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
index fd4d45b..d1eafb6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x495c=['save','update','then','destroy','sendStatus','error','stack','name','map','rawAttributes','fieldName','type','key','model','keys','filters','intersection','fields','query','attributes','nolimit','sort','where','pick','filter','merge','VIRTUAL','FreshdeskField','count','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','eml-format','rimraf','request-promise','moment','bluebird','mustache','path','sox','ejs','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','status','end','offset','limit','set','Content-Range','json','apply','reject'];(function(_0x26cac,_0x4e0ff1){var _0x5ea95e=function(_0x36e7e0){while(--_0x36e7e0){_0x26cac['push'](_0x26cac['shift']());}};_0x5ea95e(++_0x4e0ff1);}(_0x495c,0x1d2));var _0xc495=function(_0x4307ac,_0x484d9d){_0x4307ac=_0x4307ac-0x0;var _0x204b0b=_0x495c[_0x4307ac];return _0x204b0b;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xc495('0x0'));var rimraf=require(_0xc495('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xc495('0x2'));var moment=require(_0xc495('0x3'));var BPromise=require(_0xc495('0x4'));var Mustache=require(_0xc495('0x5'));var util=require('util');var path=require(_0xc495('0x6'));var sox=require(_0xc495('0x7'));var csv=require('to-csv');var ejs=require(_0xc495('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xc495('0x9'));var crypto=require(_0xc495('0xa'));var jsforce=require(_0xc495('0xb'));var deskjs=require(_0xc495('0xc'));var toCsv=require(_0xc495('0xd'));var querystring=require(_0xc495('0xe'));var Papa=require(_0xc495('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xc495('0x10'));var as=require(_0xc495('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xc495('0x12'));var utils=require(_0xc495('0x13'));var config=require(_0xc495('0x14'));var licenseUtil=require(_0xc495('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2f0d96,_0xf9858a){_0xf9858a=_0xf9858a||0xcc;return function(_0x32602f){if(_0x32602f){return _0x2f0d96['sendStatus'](_0xf9858a);}return _0x2f0d96[_0xc495('0x16')](_0xf9858a)[_0xc495('0x17')]();};}function respondWithResult(_0x3e8bbf,_0x3ad11a){_0x3ad11a=_0x3ad11a||0xc8;return function(_0x404a25){if(_0x404a25){return _0x3e8bbf[_0xc495('0x16')](_0x3ad11a)['json'](_0x404a25);}};}function respondWithFilteredResult(_0xd92ef9,_0x395561){return function(_0x1c3b75){if(_0x1c3b75){var _0x7e44ef=_0x1c3b75['count'],_0x33d4f1=_0x395561[_0xc495('0x18')],_0x44efcd=_0x395561[_0xc495('0x18')]+_0x395561[_0xc495('0x19')],_0x271ff9;if(_0x44efcd>=_0x7e44ef){_0x44efcd=_0x7e44ef;_0x271ff9=0xc8;}else{_0x271ff9=0xce;}_0xd92ef9[_0xc495('0x16')](_0x271ff9);return _0xd92ef9[_0xc495('0x1a')](_0xc495('0x1b'),_0x33d4f1+'-'+_0x44efcd+'/'+_0x7e44ef)[_0xc495('0x1c')](_0x1c3b75);}return null;};}function patchUpdates(_0x593977){return function(_0x535cc3){try{jsonpatch[_0xc495('0x1d')](_0x535cc3,_0x593977,!![]);}catch(_0x1ae1d7){return BPromise[_0xc495('0x1e')](_0x1ae1d7);}return _0x535cc3[_0xc495('0x1f')]();};}function saveUpdates(_0x3cee5f,_0x2aca7f){return function(_0x45d7f2){if(_0x45d7f2){return _0x45d7f2[_0xc495('0x20')](_0x3cee5f)[_0xc495('0x21')](function(_0x21ab88){return _0x21ab88;});}return null;};}function removeEntity(_0x1da419,_0x32fe11){return function(_0x122471){if(_0x122471){return _0x122471[_0xc495('0x22')]()[_0xc495('0x21')](function(){_0x1da419[_0xc495('0x16')](0xcc)[_0xc495('0x17')]();});}};}function handleEntityNotFound(_0x833cfc,_0x29142d){return function(_0x293a97){if(!_0x293a97){_0x833cfc[_0xc495('0x23')](0x194);}return _0x293a97;};}function handleError(_0x495faf,_0x5b854d){_0x5b854d=_0x5b854d||0x1f4;return function(_0x394037){logger[_0xc495('0x24')](_0x394037[_0xc495('0x25')]);if(_0x394037[_0xc495('0x26')]){delete _0x394037['name'];}_0x495faf['status'](_0x5b854d)['send'](_0x394037);};}exports['index']=function(_0x564a7a,_0x4aa182){var _0x25e50a={},_0x19138d={},_0x467c0b={'count':0x0,'rows':[]};var _0x4b5cfc=_[_0xc495('0x27')](db['FreshdeskField'][_0xc495('0x28')],function(_0x49e42d){return{'name':_0x49e42d[_0xc495('0x29')],'type':_0x49e42d[_0xc495('0x2a')][_0xc495('0x2b')]};});_0x19138d[_0xc495('0x2c')]=_['map'](_0x4b5cfc,_0xc495('0x26'));_0x19138d['query']=_[_0xc495('0x2d')](_0x564a7a['query']);_0x19138d[_0xc495('0x2e')]=_['intersection'](_0x19138d[_0xc495('0x2c')],_0x19138d['query']);_0x25e50a['attributes']=_[_0xc495('0x2f')](_0x19138d[_0xc495('0x2c')],qs[_0xc495('0x30')](_0x564a7a[_0xc495('0x31')]['fields']));_0x25e50a['attributes']=_0x25e50a[_0xc495('0x32')]['length']?_0x25e50a[_0xc495('0x32')]:_0x19138d[_0xc495('0x2c')];if(!_0x564a7a[_0xc495('0x31')]['hasOwnProperty'](_0xc495('0x33'))){_0x25e50a[_0xc495('0x19')]=qs['limit'](_0x564a7a[_0xc495('0x31')]['limit']);_0x25e50a[_0xc495('0x18')]=qs[_0xc495('0x18')](_0x564a7a[_0xc495('0x31')][_0xc495('0x18')]);}_0x25e50a['order']=qs[_0xc495('0x34')](_0x564a7a[_0xc495('0x31')]['sort']);_0x25e50a[_0xc495('0x35')]=qs['filters'](_[_0xc495('0x36')](_0x564a7a[_0xc495('0x31')],_0x19138d['filters']),_0x4b5cfc);if(_0x564a7a['query'][_0xc495('0x37')]){_0x25e50a['where']=_[_0xc495('0x38')](_0x25e50a[_0xc495('0x35')],{'$or':_['map'](_0x4b5cfc,function(_0x30958c){if(_0x30958c[_0xc495('0x2a')]!==_0xc495('0x39')){var _0x3cc626={};_0x3cc626[_0x30958c['name']]={'$like':'%'+_0x564a7a['query'][_0xc495('0x37')]+'%'};return _0x3cc626;}})});}_0x25e50a=_[_0xc495('0x38')]({},_0x25e50a,_0x564a7a['options']);var _0x3e8a22={'where':_0x25e50a['where']};return db[_0xc495('0x3a')][_0xc495('0x3b')](_0x3e8a22)['then'](function(_0x326368){_0x467c0b['count']=_0x326368;if(_0x564a7a[_0xc495('0x31')][_0xc495('0x3c')]){_0x25e50a[_0xc495('0x3d')]=[{'all':!![]}];}return db[_0xc495('0x3a')][_0xc495('0x3e')](_0x25e50a);})[_0xc495('0x21')](function(_0x494182){_0x467c0b[_0xc495('0x3f')]=_0x494182;return _0x467c0b;})['then'](respondWithFilteredResult(_0x4aa182,_0x25e50a))[_0xc495('0x40')](handleError(_0x4aa182,null));};exports[_0xc495('0x41')]=function(_0x21c30c,_0x2b84b0){var _0x1397ec={'raw':!![],'where':{'id':_0x21c30c[_0xc495('0x42')]['id']}},_0x27e36c={};_0x27e36c['model']=_[_0xc495('0x2d')](db[_0xc495('0x3a')][_0xc495('0x28')]);_0x27e36c[_0xc495('0x31')]=_[_0xc495('0x2d')](_0x21c30c[_0xc495('0x31')]);_0x27e36c[_0xc495('0x2e')]=_[_0xc495('0x2f')](_0x27e36c[_0xc495('0x2c')],_0x27e36c['query']);_0x1397ec['attributes']=_['intersection'](_0x27e36c[_0xc495('0x2c')],qs[_0xc495('0x30')](_0x21c30c['query'][_0xc495('0x30')]));_0x1397ec[_0xc495('0x32')]=_0x1397ec[_0xc495('0x32')]['length']?_0x1397ec[_0xc495('0x32')]:_0x27e36c[_0xc495('0x2c')];if(_0x21c30c[_0xc495('0x31')]['includeAll']){_0x1397ec[_0xc495('0x3d')]=[{'all':!![]}];}_0x1397ec=_[_0xc495('0x38')]({},_0x1397ec,_0x21c30c[_0xc495('0x43')]);return db[_0xc495('0x3a')][_0xc495('0x44')](_0x1397ec)[_0xc495('0x21')](handleEntityNotFound(_0x2b84b0,null))[_0xc495('0x21')](respondWithResult(_0x2b84b0,null))['catch'](handleError(_0x2b84b0,null));};exports[_0xc495('0x45')]=function(_0x57742e,_0x530a23){return db[_0xc495('0x3a')][_0xc495('0x45')](_0x57742e[_0xc495('0x46')],{})[_0xc495('0x21')](respondWithResult(_0x530a23,0xc9))['catch'](handleError(_0x530a23,null));};exports['update']=function(_0x2d437a,_0x4e1bc3){if(_0x2d437a[_0xc495('0x46')]['id']){delete _0x2d437a[_0xc495('0x46')]['id'];}return db[_0xc495('0x3a')][_0xc495('0x44')]({'where':{'id':_0x2d437a['params']['id']}})[_0xc495('0x21')](handleEntityNotFound(_0x4e1bc3,null))[_0xc495('0x21')](saveUpdates(_0x2d437a[_0xc495('0x46')],null))['then'](respondWithResult(_0x4e1bc3,null))[_0xc495('0x40')](handleError(_0x4e1bc3,null));};exports['destroy']=function(_0x2ca9f1,_0x281f60){return db[_0xc495('0x3a')][_0xc495('0x44')]({'where':{'id':_0x2ca9f1['params']['id']}})[_0xc495('0x21')](handleEntityNotFound(_0x281f60,null))['then'](removeEntity(_0x281f60,null))[_0xc495('0x40')](handleError(_0x281f60,null));};
\ No newline at end of file
+var _0x593e=['../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','then','error','stack','name','send','map','FreshdeskField','fieldName','type','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filters','merge','VIRTUAL','filter','includeAll','include','rows','catch','show','params','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch'];(function(_0x5151e8,_0x4cc286){var _0x39a3bd=function(_0x2fb213){while(--_0x2fb213){_0x5151e8['push'](_0x5151e8['shift']());}};_0x39a3bd(++_0x4cc286);}(_0x593e,0xcb));var _0xe593=function(_0x14e5a4,_0x46699d){_0x14e5a4=_0x14e5a4-0x0;var _0x859da8=_0x593e[_0x14e5a4];return _0x859da8;};'use strict';var emlformat=require(_0xe593('0x0'));var rimraf=require(_0xe593('0x1'));var zipdir=require(_0xe593('0x2'));var jsonpatch=require(_0xe593('0x3'));var rp=require(_0xe593('0x4'));var moment=require(_0xe593('0x5'));var BPromise=require(_0xe593('0x6'));var Mustache=require(_0xe593('0x7'));var util=require('util');var path=require(_0xe593('0x8'));var sox=require(_0xe593('0x9'));var csv=require(_0xe593('0xa'));var ejs=require(_0xe593('0xb'));var fs=require('fs');var fs_extra=require(_0xe593('0xc'));var _=require(_0xe593('0xd'));var squel=require(_0xe593('0xe'));var crypto=require(_0xe593('0xf'));var jsforce=require(_0xe593('0x10'));var deskjs=require(_0xe593('0x11'));var toCsv=require('to-csv');var querystring=require(_0xe593('0x12'));var Papa=require(_0xe593('0x13'));var Redis=require(_0xe593('0x14'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xe593('0x15'));var hardwareService=require(_0xe593('0x16'));var logger=require(_0xe593('0x17'))('api');var utils=require(_0xe593('0x18'));var config=require(_0xe593('0x19'));var licenseUtil=require(_0xe593('0x1a'));var db=require(_0xe593('0x1b'))['db'];function respondWithStatusCode(_0x8ee313,_0x31dad0){_0x31dad0=_0x31dad0||0xcc;return function(_0x24c9fd){if(_0x24c9fd){return _0x8ee313[_0xe593('0x1c')](_0x31dad0);}return _0x8ee313[_0xe593('0x1d')](_0x31dad0)[_0xe593('0x1e')]();};}function respondWithResult(_0x499819,_0x2907e4){_0x2907e4=_0x2907e4||0xc8;return function(_0x1de391){if(_0x1de391){return _0x499819['status'](_0x2907e4)[_0xe593('0x1f')](_0x1de391);}};}function respondWithFilteredResult(_0x44837b,_0x5d4c6a){return function(_0x2ae9b6){if(_0x2ae9b6){var _0x40416c=typeof _0x5d4c6a[_0xe593('0x20')]===_0xe593('0x21')&&typeof _0x5d4c6a[_0xe593('0x22')]===_0xe593('0x21');var _0x48f3b4=_0x2ae9b6[_0xe593('0x23')];var _0x470d07=_0x40416c?0x0:_0x5d4c6a['offset'];var _0xd1020e=_0x40416c?_0x2ae9b6[_0xe593('0x23')]:_0x5d4c6a['offset']+_0x5d4c6a[_0xe593('0x22')];var _0x3dba1b;if(_0xd1020e>=_0x48f3b4){_0xd1020e=_0x48f3b4;_0x3dba1b=0xc8;}else{_0x3dba1b=0xce;}_0x44837b[_0xe593('0x1d')](_0x3dba1b);return _0x44837b[_0xe593('0x24')](_0xe593('0x25'),_0x470d07+'-'+_0xd1020e+'/'+_0x48f3b4)[_0xe593('0x1f')](_0x2ae9b6);}return null;};}function patchUpdates(_0x3d2a51){return function(_0x4ea53f){try{jsonpatch['apply'](_0x4ea53f,_0x3d2a51,!![]);}catch(_0x1634d4){return BPromise['reject'](_0x1634d4);}return _0x4ea53f['save']();};}function saveUpdates(_0x1bb8e8,_0x3c65b5){return function(_0x57379d){if(_0x57379d){return _0x57379d[_0xe593('0x26')](_0x1bb8e8)['then'](function(_0x1672bf){return _0x1672bf;});}return null;};}function removeEntity(_0x2c191f,_0x185cea){return function(_0x44d997){if(_0x44d997){return _0x44d997[_0xe593('0x27')]()[_0xe593('0x28')](function(){_0x2c191f[_0xe593('0x1d')](0xcc)[_0xe593('0x1e')]();});}};}function handleEntityNotFound(_0x4fc483,_0x47aea){return function(_0x347d7d){if(!_0x347d7d){_0x4fc483['sendStatus'](0x194);}return _0x347d7d;};}function handleError(_0x59bd4c,_0xf8d492){_0xf8d492=_0xf8d492||0x1f4;return function(_0x25238f){logger[_0xe593('0x29')](_0x25238f[_0xe593('0x2a')]);if(_0x25238f[_0xe593('0x2b')]){delete _0x25238f[_0xe593('0x2b')];}_0x59bd4c['status'](_0xf8d492)[_0xe593('0x2c')](_0x25238f);};}exports['index']=function(_0x1dacf6,_0xda61a7){var _0x4a2eaa={},_0x337ee0={},_0x561a01={'count':0x0,'rows':[]};var _0x44a68c=_[_0xe593('0x2d')](db[_0xe593('0x2e')]['rawAttributes'],function(_0x1ae8d9){return{'name':_0x1ae8d9[_0xe593('0x2f')],'type':_0x1ae8d9[_0xe593('0x30')][_0xe593('0x31')]};});_0x337ee0[_0xe593('0x32')]=_[_0xe593('0x2d')](_0x44a68c,_0xe593('0x2b'));_0x337ee0['query']=_[_0xe593('0x33')](_0x1dacf6[_0xe593('0x34')]);_0x337ee0['filters']=_[_0xe593('0x35')](_0x337ee0['model'],_0x337ee0[_0xe593('0x34')]);_0x4a2eaa[_0xe593('0x36')]=_[_0xe593('0x35')](_0x337ee0[_0xe593('0x32')],qs[_0xe593('0x37')](_0x1dacf6[_0xe593('0x34')][_0xe593('0x37')]));_0x4a2eaa[_0xe593('0x36')]=_0x4a2eaa[_0xe593('0x36')][_0xe593('0x38')]?_0x4a2eaa['attributes']:_0x337ee0[_0xe593('0x32')];if(!_0x1dacf6[_0xe593('0x34')][_0xe593('0x39')]('nolimit')){_0x4a2eaa['limit']=qs[_0xe593('0x22')](_0x1dacf6['query'][_0xe593('0x22')]);_0x4a2eaa[_0xe593('0x20')]=qs[_0xe593('0x20')](_0x1dacf6[_0xe593('0x34')][_0xe593('0x20')]);}_0x4a2eaa[_0xe593('0x3a')]=qs[_0xe593('0x3b')](_0x1dacf6['query']['sort']);_0x4a2eaa[_0xe593('0x3c')]=qs['filters'](_[_0xe593('0x3d')](_0x1dacf6['query'],_0x337ee0[_0xe593('0x3e')]),_0x44a68c);if(_0x1dacf6['query']['filter']){_0x4a2eaa[_0xe593('0x3c')]=_[_0xe593('0x3f')](_0x4a2eaa[_0xe593('0x3c')],{'$or':_['map'](_0x44a68c,function(_0x55d902){if(_0x55d902['type']!==_0xe593('0x40')){var _0x584945={};_0x584945[_0x55d902[_0xe593('0x2b')]]={'$like':'%'+_0x1dacf6[_0xe593('0x34')][_0xe593('0x41')]+'%'};return _0x584945;}})});}_0x4a2eaa=_[_0xe593('0x3f')]({},_0x4a2eaa,_0x1dacf6['options']);var _0x196325={'where':_0x4a2eaa['where']};return db[_0xe593('0x2e')]['count'](_0x196325)['then'](function(_0x590d34){_0x561a01[_0xe593('0x23')]=_0x590d34;if(_0x1dacf6['query'][_0xe593('0x42')]){_0x4a2eaa[_0xe593('0x43')]=[{'all':!![]}];}return db[_0xe593('0x2e')]['findAll'](_0x4a2eaa);})[_0xe593('0x28')](function(_0x3f9784){_0x561a01[_0xe593('0x44')]=_0x3f9784;return _0x561a01;})[_0xe593('0x28')](respondWithFilteredResult(_0xda61a7,_0x4a2eaa))[_0xe593('0x45')](handleError(_0xda61a7,null));};exports[_0xe593('0x46')]=function(_0x1236bb,_0x2e14d3){var _0x4b36e1={'raw':!![],'where':{'id':_0x1236bb[_0xe593('0x47')]['id']}},_0x211065={};_0x211065[_0xe593('0x32')]=_[_0xe593('0x33')](db[_0xe593('0x2e')]['rawAttributes']);_0x211065['query']=_[_0xe593('0x33')](_0x1236bb[_0xe593('0x34')]);_0x211065[_0xe593('0x3e')]=_['intersection'](_0x211065[_0xe593('0x32')],_0x211065[_0xe593('0x34')]);_0x4b36e1['attributes']=_['intersection'](_0x211065[_0xe593('0x32')],qs[_0xe593('0x37')](_0x1236bb[_0xe593('0x34')]['fields']));_0x4b36e1[_0xe593('0x36')]=_0x4b36e1[_0xe593('0x36')][_0xe593('0x38')]?_0x4b36e1[_0xe593('0x36')]:_0x211065['model'];if(_0x1236bb['query']['includeAll']){_0x4b36e1['include']=[{'all':!![]}];}_0x4b36e1=_[_0xe593('0x3f')]({},_0x4b36e1,_0x1236bb['options']);return db[_0xe593('0x2e')][_0xe593('0x48')](_0x4b36e1)[_0xe593('0x28')](handleEntityNotFound(_0x2e14d3,null))[_0xe593('0x28')](respondWithResult(_0x2e14d3,null))[_0xe593('0x45')](handleError(_0x2e14d3,null));};exports[_0xe593('0x49')]=function(_0x7b6f77,_0x297c3e){return db['FreshdeskField'][_0xe593('0x49')](_0x7b6f77[_0xe593('0x4a')],{})[_0xe593('0x28')](respondWithResult(_0x297c3e,0xc9))['catch'](handleError(_0x297c3e,null));};exports[_0xe593('0x26')]=function(_0x5dfdb1,_0x39ec9e){if(_0x5dfdb1[_0xe593('0x4a')]['id']){delete _0x5dfdb1[_0xe593('0x4a')]['id'];}return db['FreshdeskField']['find']({'where':{'id':_0x5dfdb1[_0xe593('0x47')]['id']}})[_0xe593('0x28')](handleEntityNotFound(_0x39ec9e,null))['then'](saveUpdates(_0x5dfdb1['body'],null))['then'](respondWithResult(_0x39ec9e,null))['catch'](handleError(_0x39ec9e,null));};exports['destroy']=function(_0x383645,_0x1e48d8){return db[_0xe593('0x2e')][_0xe593('0x48')]({'where':{'id':_0x383645[_0xe593('0x47')]['id']}})[_0xe593('0x28')](handleEntityNotFound(_0x1e48d8,null))[_0xe593('0x28')](removeEntity(_0x1e48d8,null))[_0xe593('0x45')](handleError(_0x1e48d8,null));};
\ No newline at end of file