Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / attachment / attachment.controller.js
index c0b83d1..003a164 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb48e=['clone','find','get','omit','updatedAt','body','create','file','originalname','basename','filename','mimetype','download','findOne','ChatOfflineMessageId','root','join','offline-chat/','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','filter','merge','VIRTUAL','options','Attachment','includeAll','include','findAll','catch','show','params'];(function(_0x2df729,_0x2681ee){var _0x4b74cc=function(_0x589571){while(--_0x589571){_0x2df729['push'](_0x2df729['shift']());}};_0x4b74cc(++_0x2681ee);}(_0xb48e,0x1c5));var _0xeb48=function(_0x2b08c1,_0x11ff1e){_0x2b08c1=_0x2b08c1-0x0;var _0x135c9e=_0xb48e[_0x2b08c1];return _0x135c9e;};'use strict';var emlformat=require(_0xeb48('0x0'));var rimraf=require(_0xeb48('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xeb48('0x2'));var rp=require(_0xeb48('0x3'));var moment=require(_0xeb48('0x4'));var BPromise=require(_0xeb48('0x5'));var Mustache=require(_0xeb48('0x6'));var util=require(_0xeb48('0x7'));var path=require('path');var sox=require(_0xeb48('0x8'));var csv=require(_0xeb48('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xeb48('0xa'));var crypto=require(_0xeb48('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xeb48('0xc'));var toCsv=require(_0xeb48('0x9'));var querystring=require(_0xeb48('0xd'));var Papa=require(_0xeb48('0xe'));var Redis=require('ioredis');var authService=require(_0xeb48('0xf'));var qs=require(_0xeb48('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeb48('0x11'));var logger=require('../../config/logger')('api');var utils=require(_0xeb48('0x12'));var config=require(_0xeb48('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0xeb48('0x14'))['db'];function respondWithStatusCode(_0x4943bb,_0x1674d3){_0x1674d3=_0x1674d3||0xcc;return function(_0x1d3db4){if(_0x1d3db4){return _0x4943bb[_0xeb48('0x15')](_0x1674d3);}return _0x4943bb['status'](_0x1674d3)[_0xeb48('0x16')]();};}function respondWithResult(_0x167d4d,_0x4c672d){_0x4c672d=_0x4c672d||0xc8;return function(_0x392fb0){if(_0x392fb0){return _0x167d4d[_0xeb48('0x17')](_0x4c672d)[_0xeb48('0x18')](_0x392fb0);}};}function respondWithFilteredResult(_0x3a0023,_0x196a07){return function(_0x3038e0){if(_0x3038e0){var _0x2f82ba=typeof _0x196a07[_0xeb48('0x19')]==='undefined'&&typeof _0x196a07['limit']===_0xeb48('0x1a');var _0x10a5c1=_0x3038e0[_0xeb48('0x1b')];var _0x22872a=_0x2f82ba?0x0:_0x196a07[_0xeb48('0x19')];var _0x2c4caf=_0x2f82ba?_0x3038e0[_0xeb48('0x1b')]:_0x196a07[_0xeb48('0x19')]+_0x196a07[_0xeb48('0x1c')];var _0x30d243;if(_0x2c4caf>=_0x10a5c1){_0x2c4caf=_0x10a5c1;_0x30d243=0xc8;}else{_0x30d243=0xce;}_0x3a0023[_0xeb48('0x17')](_0x30d243);return _0x3a0023[_0xeb48('0x1d')](_0xeb48('0x1e'),_0x22872a+'-'+_0x2c4caf+'/'+_0x10a5c1)[_0xeb48('0x18')](_0x3038e0);}return null;};}function patchUpdates(_0x1290dd){return function(_0x19be36){try{jsonpatch[_0xeb48('0x1f')](_0x19be36,_0x1290dd,!![]);}catch(_0x5f47f1){return BPromise[_0xeb48('0x20')](_0x5f47f1);}return _0x19be36[_0xeb48('0x21')]();};}function saveUpdates(_0x5ecaed,_0x530536){return function(_0x3d582a){if(_0x3d582a){return _0x3d582a[_0xeb48('0x22')](_0x5ecaed)[_0xeb48('0x23')](function(_0x4c9287){return _0x4c9287;});}return null;};}function removeEntity(_0x19fbf8,_0x2836d9){return function(_0x29b5b7){if(_0x29b5b7){return _0x29b5b7[_0xeb48('0x24')]()[_0xeb48('0x23')](function(){_0x19fbf8['status'](0xcc)[_0xeb48('0x16')]();});}};}function handleEntityNotFound(_0x36f77b,_0x4b10c5){return function(_0x1489fe){if(!_0x1489fe){_0x36f77b[_0xeb48('0x15')](0x194);}return _0x1489fe;};}function handleError(_0x474e8c,_0x4ff61b){_0x4ff61b=_0x4ff61b||0x1f4;return function(_0x1ba0b6){logger[_0xeb48('0x25')](_0x1ba0b6[_0xeb48('0x26')]);if(_0x1ba0b6['name']){delete _0x1ba0b6[_0xeb48('0x27')];}_0x474e8c[_0xeb48('0x17')](_0x4ff61b)[_0xeb48('0x28')](_0x1ba0b6);};}exports['index']=function(_0x4c76b4,_0x50a42d){var _0x79679a={},_0x6997cc={},_0x188b89={'count':0x0,'rows':[]};var _0x24a0e3=_[_0xeb48('0x29')](db['Attachment'][_0xeb48('0x2a')],function(_0x1c0536){return{'name':_0x1c0536[_0xeb48('0x2b')],'type':_0x1c0536[_0xeb48('0x2c')][_0xeb48('0x2d')]};});_0x6997cc[_0xeb48('0x2e')]=_[_0xeb48('0x29')](_0x24a0e3,_0xeb48('0x27'));_0x6997cc['query']=_[_0xeb48('0x2f')](_0x4c76b4[_0xeb48('0x30')]);_0x6997cc['filters']=_[_0xeb48('0x31')](_0x6997cc['model'],_0x6997cc[_0xeb48('0x30')]);_0x79679a[_0xeb48('0x32')]=_[_0xeb48('0x31')](_0x6997cc[_0xeb48('0x2e')],qs[_0xeb48('0x33')](_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x33')]));_0x79679a[_0xeb48('0x32')]=_0x79679a['attributes'][_0xeb48('0x34')]?_0x79679a[_0xeb48('0x32')]:_0x6997cc[_0xeb48('0x2e')];if(!_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x35')](_0xeb48('0x36'))){_0x79679a[_0xeb48('0x1c')]=qs[_0xeb48('0x1c')](_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x1c')]);_0x79679a[_0xeb48('0x19')]=qs[_0xeb48('0x19')](_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x19')]);}_0x79679a['order']=qs[_0xeb48('0x37')](_0x4c76b4[_0xeb48('0x30')]['sort']);_0x79679a[_0xeb48('0x38')]=qs[_0xeb48('0x39')](_['pick'](_0x4c76b4[_0xeb48('0x30')],_0x6997cc[_0xeb48('0x39')]),_0x24a0e3);if(_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x3a')]){_0x79679a[_0xeb48('0x38')]=_[_0xeb48('0x3b')](_0x79679a[_0xeb48('0x38')],{'$or':_['map'](_0x24a0e3,function(_0x47c81d){if(_0x47c81d[_0xeb48('0x2c')]!==_0xeb48('0x3c')){var _0x5ed10f={};_0x5ed10f[_0x47c81d[_0xeb48('0x27')]]={'$like':'%'+_0x4c76b4[_0xeb48('0x30')][_0xeb48('0x3a')]+'%'};return _0x5ed10f;}})});}_0x79679a=_[_0xeb48('0x3b')]({},_0x79679a,_0x4c76b4[_0xeb48('0x3d')]);var _0x5d67f6={'where':_0x79679a[_0xeb48('0x38')]};return db[_0xeb48('0x3e')][_0xeb48('0x1b')](_0x5d67f6)['then'](function(_0x1e84c0){_0x188b89[_0xeb48('0x1b')]=_0x1e84c0;if(_0x4c76b4['query'][_0xeb48('0x3f')]){_0x79679a[_0xeb48('0x40')]=[{'all':!![]}];}return db[_0xeb48('0x3e')][_0xeb48('0x41')](_0x79679a);})[_0xeb48('0x23')](function(_0x2362ee){_0x188b89['rows']=_0x2362ee;return _0x188b89;})[_0xeb48('0x23')](respondWithFilteredResult(_0x50a42d,_0x79679a))[_0xeb48('0x42')](handleError(_0x50a42d,null));};exports[_0xeb48('0x43')]=function(_0x34177c,_0x425a8a){var _0x591f79={'raw':!![],'where':{'id':_0x34177c[_0xeb48('0x44')]['id']}},_0x451e36={};_0x451e36['model']=_['keys'](db['Attachment'][_0xeb48('0x2a')]);_0x451e36[_0xeb48('0x30')]=_[_0xeb48('0x2f')](_0x34177c['query']);_0x451e36['filters']=_[_0xeb48('0x31')](_0x451e36['model'],_0x451e36[_0xeb48('0x30')]);_0x591f79[_0xeb48('0x32')]=_[_0xeb48('0x31')](_0x451e36['model'],qs['fields'](_0x34177c[_0xeb48('0x30')][_0xeb48('0x33')]));_0x591f79['attributes']=_0x591f79['attributes']['length']?_0x591f79['attributes']:_0x451e36['model'];if(_0x34177c['query'][_0xeb48('0x3f')]){_0x591f79[_0xeb48('0x40')]=[{'all':!![]}];}_0x591f79=_[_0xeb48('0x3b')]({},_0x591f79,_0x34177c['options']);return db[_0xeb48('0x3e')]['find'](_0x591f79)[_0xeb48('0x23')](handleEntityNotFound(_0x425a8a,null))[_0xeb48('0x23')](respondWithResult(_0x425a8a,null))['catch'](handleError(_0x425a8a,null));};exports[_0xeb48('0x45')]=function(_0x1c85da,_0x317db3){var _0x530a20={'where':{'id':_0x1c85da[_0xeb48('0x44')]['id']}},_0x520538={};_0x520538[_0xeb48('0x2e')]=_[_0xeb48('0x2f')](db['Attachment']['rawAttributes']);_0x530a20[_0xeb48('0x32')]=_[_0xeb48('0x31')](_0x520538['model'],qs[_0xeb48('0x33')](_0x1c85da[_0xeb48('0x30')]['fields']));_0x530a20[_0xeb48('0x32')]=_0x530a20['attributes'][_0xeb48('0x34')]?_0x530a20[_0xeb48('0x32')]:_0x520538[_0xeb48('0x2e')];if(_0x1c85da[_0xeb48('0x30')][_0xeb48('0x3f')]){_0x530a20['include']=[{'all':!![]}];}_0x530a20=_[_0xeb48('0x3b')]({},_0x530a20,_0x1c85da[_0xeb48('0x3d')]);return db[_0xeb48('0x3e')][_0xeb48('0x46')](_0x530a20)[_0xeb48('0x23')](handleEntityNotFound(_0x317db3,null))[_0xeb48('0x23')](function(_0x44ecd5){if(_0x44ecd5){var _0x2092d1=_0x44ecd5[_0xeb48('0x47')]({'plain':!![]});_0x2092d1=qs[_0xeb48('0x48')](_0x2092d1,['id','createdAt',_0xeb48('0x49')]);_0x1c85da[_0xeb48('0x4a')]=_[_0xeb48('0x48')](_0x1c85da[_0xeb48('0x4a')],['id','createdAt',_0xeb48('0x49')]);return db[_0xeb48('0x3e')][_0xeb48('0x4b')](_[_0xeb48('0x3b')](_0x2092d1,_0x1c85da[_0xeb48('0x4a')]),{'include':_0x1c85da['query'][_0xeb48('0x3f')]?[{'all':!![]}]:undefined});}})['then'](respondWithResult(_0x317db3,0xc9))[_0xeb48('0x42')](handleError(_0x317db3,null));};exports[_0xeb48('0x22')]=function(_0x2d6008,_0x4f2661){if(_0x2d6008[_0xeb48('0x4a')]['id']){delete _0x2d6008[_0xeb48('0x4a')]['id'];}return db['Attachment']['find']({'where':{'id':_0x2d6008[_0xeb48('0x44')]['id']}})[_0xeb48('0x23')](handleEntityNotFound(_0x4f2661,null))[_0xeb48('0x23')](saveUpdates(_0x2d6008[_0xeb48('0x4a')],null))[_0xeb48('0x23')](respondWithResult(_0x4f2661,null))[_0xeb48('0x42')](handleError(_0x4f2661,null));};exports[_0xeb48('0x24')]=function(_0x467124,_0x3b5874){return db['Attachment'][_0xeb48('0x46')]({'where':{'id':_0x467124[_0xeb48('0x44')]['id']}})['then'](handleEntityNotFound(_0x3b5874,null))[_0xeb48('0x23')](removeEntity(_0x3b5874,null))[_0xeb48('0x42')](handleError(_0x3b5874,null));};exports[_0xeb48('0x4b')]=function(_0x252d38,_0x1a701b,_0x25064b){_0x252d38['body']['name']=_0x252d38[_0xeb48('0x4c')][_0xeb48('0x4d')];_0x252d38[_0xeb48('0x4a')][_0xeb48('0x4e')]=_0x252d38[_0xeb48('0x4c')][_0xeb48('0x4f')];_0x252d38[_0xeb48('0x4a')][_0xeb48('0x2c')]=_0x252d38['file'][_0xeb48('0x50')];return db[_0xeb48('0x3e')][_0xeb48('0x4b')](_0x252d38['body'])[_0xeb48('0x23')](respondWithResult(_0x1a701b,0xc9))[_0xeb48('0x42')](handleError(_0x1a701b,null));};exports[_0xeb48('0x51')]=function(_0x88a44b,_0x37abc4,_0x341d2c){return db[_0xeb48('0x3e')][_0xeb48('0x52')]({'where':{'id':_0x88a44b['params']['id']},'raw':!![]})['then'](handleEntityNotFound(_0x37abc4,null))[_0xeb48('0x23')](function(_0x4ed4da){if(_0x4ed4da){var _0x517ad8=_0x4ed4da[_0xeb48('0x53')]!==null;var _0x16fd7a=path['join'](config[_0xeb48('0x54')],'server/files/attachments/');if(_0x517ad8){_0x16fd7a=path[_0xeb48('0x55')](_0x16fd7a,_0xeb48('0x56'));}var _0x16e98b=path[_0xeb48('0x55')](_0x16fd7a,_0x4ed4da['basename']);return _0x37abc4[_0xeb48('0x51')](_0x16e98b);}})[_0xeb48('0x42')](handleError(_0x37abc4,null));};
\ No newline at end of file
+var _0xc90a=['Attachment','rawAttributes','fieldName','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','rows','params','include','clone','find','get','omit','updatedAt','createdAt','body','catch','create','file','originalname','filename','mimetype','ChatOfflineMessageId','join','offline-chat/','basename','download','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','apply','reject','save','update','then','destroy','error','name','send','index','map'];(function(_0x3c592f,_0x16cba8){var _0x73463a=function(_0x2e8942){while(--_0x2e8942){_0x3c592f['push'](_0x3c592f['shift']());}};_0x73463a(++_0x16cba8);}(_0xc90a,0x1e9));var _0xac90=function(_0x4f0d5e,_0x33b8b3){_0x4f0d5e=_0x4f0d5e-0x0;var _0x144585=_0xc90a[_0x4f0d5e];return _0x144585;};'use strict';var emlformat=require(_0xac90('0x0'));var rimraf=require(_0xac90('0x1'));var zipdir=require(_0xac90('0x2'));var jsonpatch=require(_0xac90('0x3'));var rp=require(_0xac90('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xac90('0x5'));var util=require('util');var path=require('path');var sox=require(_0xac90('0x6'));var csv=require(_0xac90('0x7'));var ejs=require(_0xac90('0x8'));var fs=require('fs');var fs_extra=require(_0xac90('0x9'));var _=require('lodash');var squel=require(_0xac90('0xa'));var crypto=require(_0xac90('0xb'));var jsforce=require(_0xac90('0xc'));var deskjs=require(_0xac90('0xd'));var toCsv=require(_0xac90('0x7'));var querystring=require(_0xac90('0xe'));var Papa=require(_0xac90('0xf'));var Redis=require(_0xac90('0x10'));var authService=require(_0xac90('0x11'));var qs=require(_0xac90('0x12'));var as=require(_0xac90('0x13'));var hardwareService=require(_0xac90('0x14'));var logger=require(_0xac90('0x15'))(_0xac90('0x16'));var utils=require(_0xac90('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1e40af,_0x18ad0c){_0x18ad0c=_0x18ad0c||0xcc;return function(_0x118ab6){if(_0x118ab6){return _0x1e40af[_0xac90('0x18')](_0x18ad0c);}return _0x1e40af[_0xac90('0x19')](_0x18ad0c)[_0xac90('0x1a')]();};}function respondWithResult(_0x46d648,_0xb1aa54){_0xb1aa54=_0xb1aa54||0xc8;return function(_0xf0d77a){if(_0xf0d77a){return _0x46d648[_0xac90('0x19')](_0xb1aa54)['json'](_0xf0d77a);}};}function respondWithFilteredResult(_0x42807e,_0x3826b4){return function(_0x15e52f){if(_0x15e52f){var _0x4598e1=typeof _0x3826b4['offset']===_0xac90('0x1b')&&typeof _0x3826b4[_0xac90('0x1c')]===_0xac90('0x1b');var _0x505ae1=_0x15e52f[_0xac90('0x1d')];var _0x3c172f=_0x4598e1?0x0:_0x3826b4['offset'];var _0x401562=_0x4598e1?_0x15e52f[_0xac90('0x1d')]:_0x3826b4[_0xac90('0x1e')]+_0x3826b4[_0xac90('0x1c')];var _0x4a856d;if(_0x401562>=_0x505ae1){_0x401562=_0x505ae1;_0x4a856d=0xc8;}else{_0x4a856d=0xce;}_0x42807e[_0xac90('0x19')](_0x4a856d);return _0x42807e[_0xac90('0x1f')](_0xac90('0x20'),_0x3c172f+'-'+_0x401562+'/'+_0x505ae1)[_0xac90('0x21')](_0x15e52f);}return null;};}function patchUpdates(_0x3c57ca){return function(_0x3dc362){try{jsonpatch[_0xac90('0x22')](_0x3dc362,_0x3c57ca,!![]);}catch(_0x23d728){return BPromise[_0xac90('0x23')](_0x23d728);}return _0x3dc362[_0xac90('0x24')]();};}function saveUpdates(_0x1da36b,_0x161c15){return function(_0x3cfd1f){if(_0x3cfd1f){return _0x3cfd1f[_0xac90('0x25')](_0x1da36b)[_0xac90('0x26')](function(_0x4fd97a){return _0x4fd97a;});}return null;};}function removeEntity(_0x4c95a8,_0xc8d5eb){return function(_0x5bd7b6){if(_0x5bd7b6){return _0x5bd7b6[_0xac90('0x27')]()[_0xac90('0x26')](function(){_0x4c95a8[_0xac90('0x19')](0xcc)[_0xac90('0x1a')]();});}};}function handleEntityNotFound(_0x52d2b9,_0x339c89){return function(_0x3e76d7){if(!_0x3e76d7){_0x52d2b9['sendStatus'](0x194);}return _0x3e76d7;};}function handleError(_0x58947b,_0x2d304a){_0x2d304a=_0x2d304a||0x1f4;return function(_0x32c8c2){logger[_0xac90('0x28')](_0x32c8c2['stack']);if(_0x32c8c2[_0xac90('0x29')]){delete _0x32c8c2['name'];}_0x58947b[_0xac90('0x19')](_0x2d304a)[_0xac90('0x2a')](_0x32c8c2);};}exports[_0xac90('0x2b')]=function(_0x4bec72,_0x3b3e78){var _0x4290a3={},_0x59faf9={},_0x4c4577={'count':0x0,'rows':[]};var _0x38aff5=_[_0xac90('0x2c')](db[_0xac90('0x2d')][_0xac90('0x2e')],function(_0x432dfc){return{'name':_0x432dfc[_0xac90('0x2f')],'type':_0x432dfc['type']['key']};});_0x59faf9[_0xac90('0x30')]=_[_0xac90('0x2c')](_0x38aff5,'name');_0x59faf9['query']=_[_0xac90('0x31')](_0x4bec72[_0xac90('0x32')]);_0x59faf9[_0xac90('0x33')]=_[_0xac90('0x34')](_0x59faf9[_0xac90('0x30')],_0x59faf9[_0xac90('0x32')]);_0x4290a3[_0xac90('0x35')]=_['intersection'](_0x59faf9[_0xac90('0x30')],qs[_0xac90('0x36')](_0x4bec72['query']['fields']));_0x4290a3['attributes']=_0x4290a3[_0xac90('0x35')][_0xac90('0x37')]?_0x4290a3[_0xac90('0x35')]:_0x59faf9[_0xac90('0x30')];if(!_0x4bec72[_0xac90('0x32')][_0xac90('0x38')](_0xac90('0x39'))){_0x4290a3['limit']=qs['limit'](_0x4bec72[_0xac90('0x32')][_0xac90('0x1c')]);_0x4290a3[_0xac90('0x1e')]=qs[_0xac90('0x1e')](_0x4bec72[_0xac90('0x32')][_0xac90('0x1e')]);}_0x4290a3[_0xac90('0x3a')]=qs[_0xac90('0x3b')](_0x4bec72[_0xac90('0x32')][_0xac90('0x3b')]);_0x4290a3[_0xac90('0x3c')]=qs[_0xac90('0x33')](_[_0xac90('0x3d')](_0x4bec72[_0xac90('0x32')],_0x59faf9[_0xac90('0x33')]),_0x38aff5);if(_0x4bec72[_0xac90('0x32')][_0xac90('0x3e')]){_0x4290a3[_0xac90('0x3c')]=_[_0xac90('0x3f')](_0x4290a3[_0xac90('0x3c')],{'$or':_[_0xac90('0x2c')](_0x38aff5,function(_0x3c9830){if(_0x3c9830[_0xac90('0x40')]!==_0xac90('0x41')){var _0x1e4a33={};_0x1e4a33[_0x3c9830[_0xac90('0x29')]]={'$like':'%'+_0x4bec72[_0xac90('0x32')]['filter']+'%'};return _0x1e4a33;}})});}_0x4290a3=_[_0xac90('0x3f')]({},_0x4290a3,_0x4bec72[_0xac90('0x42')]);var _0x1cb5c8={'where':_0x4290a3[_0xac90('0x3c')]};return db[_0xac90('0x2d')]['count'](_0x1cb5c8)[_0xac90('0x26')](function(_0xbb24d3){_0x4c4577[_0xac90('0x1d')]=_0xbb24d3;if(_0x4bec72[_0xac90('0x32')][_0xac90('0x43')]){_0x4290a3['include']=[{'all':!![]}];}return db[_0xac90('0x2d')]['findAll'](_0x4290a3);})['then'](function(_0x131dca){_0x4c4577[_0xac90('0x44')]=_0x131dca;return _0x4c4577;})[_0xac90('0x26')](respondWithFilteredResult(_0x3b3e78,_0x4290a3))['catch'](handleError(_0x3b3e78,null));};exports['show']=function(_0x140e0c,_0x1f98c0){var _0x1b8dca={'raw':!![],'where':{'id':_0x140e0c[_0xac90('0x45')]['id']}},_0x1634b0={};_0x1634b0[_0xac90('0x30')]=_[_0xac90('0x31')](db['Attachment']['rawAttributes']);_0x1634b0[_0xac90('0x32')]=_[_0xac90('0x31')](_0x140e0c[_0xac90('0x32')]);_0x1634b0[_0xac90('0x33')]=_[_0xac90('0x34')](_0x1634b0[_0xac90('0x30')],_0x1634b0[_0xac90('0x32')]);_0x1b8dca[_0xac90('0x35')]=_[_0xac90('0x34')](_0x1634b0[_0xac90('0x30')],qs['fields'](_0x140e0c[_0xac90('0x32')][_0xac90('0x36')]));_0x1b8dca[_0xac90('0x35')]=_0x1b8dca[_0xac90('0x35')][_0xac90('0x37')]?_0x1b8dca['attributes']:_0x1634b0['model'];if(_0x140e0c[_0xac90('0x32')][_0xac90('0x43')]){_0x1b8dca[_0xac90('0x46')]=[{'all':!![]}];}_0x1b8dca=_['merge']({},_0x1b8dca,_0x140e0c[_0xac90('0x42')]);return db[_0xac90('0x2d')]['find'](_0x1b8dca)[_0xac90('0x26')](handleEntityNotFound(_0x1f98c0,null))[_0xac90('0x26')](respondWithResult(_0x1f98c0,null))['catch'](handleError(_0x1f98c0,null));};exports[_0xac90('0x47')]=function(_0xac96b6,_0x367b5e){var _0x484f9e={'where':{'id':_0xac96b6[_0xac90('0x45')]['id']}},_0x141a13={};_0x141a13[_0xac90('0x30')]=_[_0xac90('0x31')](db[_0xac90('0x2d')][_0xac90('0x2e')]);_0x484f9e[_0xac90('0x35')]=_[_0xac90('0x34')](_0x141a13[_0xac90('0x30')],qs[_0xac90('0x36')](_0xac96b6['query'][_0xac90('0x36')]));_0x484f9e[_0xac90('0x35')]=_0x484f9e[_0xac90('0x35')][_0xac90('0x37')]?_0x484f9e['attributes']:_0x141a13[_0xac90('0x30')];if(_0xac96b6[_0xac90('0x32')][_0xac90('0x43')]){_0x484f9e[_0xac90('0x46')]=[{'all':!![]}];}_0x484f9e=_[_0xac90('0x3f')]({},_0x484f9e,_0xac96b6[_0xac90('0x42')]);return db['Attachment'][_0xac90('0x48')](_0x484f9e)['then'](handleEntityNotFound(_0x367b5e,null))[_0xac90('0x26')](function(_0x30f6ab){if(_0x30f6ab){var _0x2b61ed=_0x30f6ab[_0xac90('0x49')]({'plain':!![]});_0x2b61ed=qs[_0xac90('0x4a')](_0x2b61ed,['id','createdAt',_0xac90('0x4b')]);_0xac96b6['body']=_[_0xac90('0x4a')](_0xac96b6['body'],['id',_0xac90('0x4c'),_0xac90('0x4b')]);return db[_0xac90('0x2d')]['create'](_['merge'](_0x2b61ed,_0xac96b6[_0xac90('0x4d')]),{'include':_0xac96b6['query'][_0xac90('0x43')]?[{'all':!![]}]:undefined});}})[_0xac90('0x26')](respondWithResult(_0x367b5e,0xc9))[_0xac90('0x4e')](handleError(_0x367b5e,null));};exports[_0xac90('0x25')]=function(_0x23cf83,_0x2e1c16){if(_0x23cf83[_0xac90('0x4d')]['id']){delete _0x23cf83[_0xac90('0x4d')]['id'];}return db[_0xac90('0x2d')][_0xac90('0x48')]({'where':{'id':_0x23cf83[_0xac90('0x45')]['id']}})[_0xac90('0x26')](handleEntityNotFound(_0x2e1c16,null))[_0xac90('0x26')](saveUpdates(_0x23cf83[_0xac90('0x4d')],null))[_0xac90('0x26')](respondWithResult(_0x2e1c16,null))['catch'](handleError(_0x2e1c16,null));};exports[_0xac90('0x27')]=function(_0x4d8554,_0x96f985){return db['Attachment'][_0xac90('0x48')]({'where':{'id':_0x4d8554['params']['id']}})['then'](handleEntityNotFound(_0x96f985,null))['then'](removeEntity(_0x96f985,null))['catch'](handleError(_0x96f985,null));};exports[_0xac90('0x4f')]=function(_0x3a954c,_0x2cd4dc,_0x4c7327){_0x3a954c['body'][_0xac90('0x29')]=_0x3a954c[_0xac90('0x50')][_0xac90('0x51')];_0x3a954c[_0xac90('0x4d')]['basename']=_0x3a954c[_0xac90('0x50')][_0xac90('0x52')];_0x3a954c[_0xac90('0x4d')][_0xac90('0x40')]=_0x3a954c[_0xac90('0x50')][_0xac90('0x53')];return db[_0xac90('0x2d')]['create'](_0x3a954c[_0xac90('0x4d')])[_0xac90('0x26')](respondWithResult(_0x2cd4dc,0xc9))[_0xac90('0x4e')](handleError(_0x2cd4dc,null));};exports['download']=function(_0x2ccb8e,_0x33261c,_0x5cbecf){return db[_0xac90('0x2d')]['findOne']({'where':{'id':_0x2ccb8e[_0xac90('0x45')]['id']},'raw':!![]})[_0xac90('0x26')](handleEntityNotFound(_0x33261c,null))[_0xac90('0x26')](function(_0x1ab720){if(_0x1ab720){var _0x16c36c=_0x1ab720[_0xac90('0x54')]!==null;var _0x27319f=path[_0xac90('0x55')](config['root'],'server/files/attachments/');if(_0x16c36c){_0x27319f=path[_0xac90('0x55')](_0x27319f,_0xac90('0x56'));}var _0x40c10f=path['join'](_0x27319f,_0x1ab720[_0xac90('0x57')]);return _0x33261c[_0xac90('0x58')](_0x40c10f);}})[_0xac90('0x4e')](handleError(_0x33261c,null));};
\ No newline at end of file