Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / attachment / attachment.controller.js
index 55e2284..003a164 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5de3=['findAll','rows','catch','show','params','clone','get','omit','createdAt','updatedAt','body','find','destroy','create','file','mimetype','download','findOne','join','server/files/attachments/','offline-chat/','basename','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','to-csv','ejs','fs-extra','lodash','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','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','apply','save','update','then','error','stack','name','send','index','map','Attachment','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','options','includeAll','include'];(function(_0x3d46b4,_0x480a15){var _0x46d2d1=function(_0x5acf2c){while(--_0x5acf2c){_0x3d46b4['push'](_0x3d46b4['shift']());}};_0x46d2d1(++_0x480a15);}(_0x5de3,0x18e));var _0x35de=function(_0x596391,_0x4715b1){_0x596391=_0x596391-0x0;var _0x4cb168=_0x5de3[_0x596391];return _0x4cb168;};'use strict';var emlformat=require(_0x35de('0x0'));var rimraf=require(_0x35de('0x1'));var zipdir=require(_0x35de('0x2'));var jsonpatch=require(_0x35de('0x3'));var rp=require(_0x35de('0x4'));var moment=require(_0x35de('0x5'));var BPromise=require(_0x35de('0x6'));var Mustache=require(_0x35de('0x7'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x35de('0x8'));var ejs=require(_0x35de('0x9'));var fs=require('fs');var fs_extra=require(_0x35de('0xa'));var _=require(_0x35de('0xb'));var squel=require(_0x35de('0xc'));var crypto=require(_0x35de('0xd'));var jsforce=require(_0x35de('0xe'));var deskjs=require(_0x35de('0xf'));var toCsv=require(_0x35de('0x8'));var querystring=require(_0x35de('0x10'));var Papa=require(_0x35de('0x11'));var Redis=require(_0x35de('0x12'));var authService=require(_0x35de('0x13'));var qs=require(_0x35de('0x14'));var as=require(_0x35de('0x15'));var hardwareService=require(_0x35de('0x16'));var logger=require(_0x35de('0x17'))(_0x35de('0x18'));var utils=require(_0x35de('0x19'));var config=require(_0x35de('0x1a'));var licenseUtil=require(_0x35de('0x1b'));var db=require(_0x35de('0x1c'))['db'];function respondWithStatusCode(_0x438cb4,_0x1e6c90){_0x1e6c90=_0x1e6c90||0xcc;return function(_0x1e53b4){if(_0x1e53b4){return _0x438cb4[_0x35de('0x1d')](_0x1e6c90);}return _0x438cb4[_0x35de('0x1e')](_0x1e6c90)[_0x35de('0x1f')]();};}function respondWithResult(_0x430a64,_0x1bab0a){_0x1bab0a=_0x1bab0a||0xc8;return function(_0x1a576d){if(_0x1a576d){return _0x430a64[_0x35de('0x1e')](_0x1bab0a)[_0x35de('0x20')](_0x1a576d);}};}function respondWithFilteredResult(_0x2657f9,_0x4c6120){return function(_0x45ce94){if(_0x45ce94){var _0x32d532=typeof _0x4c6120['offset']===_0x35de('0x21')&&typeof _0x4c6120['limit']===_0x35de('0x21');var _0x1c1c00=_0x45ce94[_0x35de('0x22')];var _0x37a642=_0x32d532?0x0:_0x4c6120['offset'];var _0x23ee1f=_0x32d532?_0x45ce94[_0x35de('0x22')]:_0x4c6120[_0x35de('0x23')]+_0x4c6120[_0x35de('0x24')];var _0x28c81;if(_0x23ee1f>=_0x1c1c00){_0x23ee1f=_0x1c1c00;_0x28c81=0xc8;}else{_0x28c81=0xce;}_0x2657f9['status'](_0x28c81);return _0x2657f9[_0x35de('0x25')](_0x35de('0x26'),_0x37a642+'-'+_0x23ee1f+'/'+_0x1c1c00)[_0x35de('0x20')](_0x45ce94);}return null;};}function patchUpdates(_0x252d5c){return function(_0xe3fcc2){try{jsonpatch[_0x35de('0x27')](_0xe3fcc2,_0x252d5c,!![]);}catch(_0x12c598){return BPromise['reject'](_0x12c598);}return _0xe3fcc2[_0x35de('0x28')]();};}function saveUpdates(_0x3331d5,_0x4deea7){return function(_0x41841c){if(_0x41841c){return _0x41841c[_0x35de('0x29')](_0x3331d5)[_0x35de('0x2a')](function(_0x2b30b0){return _0x2b30b0;});}return null;};}function removeEntity(_0x199060,_0x1c7e85){return function(_0x5db96c){if(_0x5db96c){return _0x5db96c['destroy']()[_0x35de('0x2a')](function(){_0x199060[_0x35de('0x1e')](0xcc)[_0x35de('0x1f')]();});}};}function handleEntityNotFound(_0x12f1db,_0x1b4a76){return function(_0x57a8a4){if(!_0x57a8a4){_0x12f1db['sendStatus'](0x194);}return _0x57a8a4;};}function handleError(_0x55dcc8,_0x46ccd5){_0x46ccd5=_0x46ccd5||0x1f4;return function(_0x391d0e){logger[_0x35de('0x2b')](_0x391d0e[_0x35de('0x2c')]);if(_0x391d0e['name']){delete _0x391d0e[_0x35de('0x2d')];}_0x55dcc8[_0x35de('0x1e')](_0x46ccd5)[_0x35de('0x2e')](_0x391d0e);};}exports[_0x35de('0x2f')]=function(_0x840ba8,_0x121d78){var _0x5b6c8f={},_0x24d3e8={},_0x253f00={'count':0x0,'rows':[]};var _0x16ed51=_[_0x35de('0x30')](db[_0x35de('0x31')][_0x35de('0x32')],function(_0x10735b){return{'name':_0x10735b[_0x35de('0x33')],'type':_0x10735b[_0x35de('0x34')][_0x35de('0x35')]};});_0x24d3e8[_0x35de('0x36')]=_[_0x35de('0x30')](_0x16ed51,_0x35de('0x2d'));_0x24d3e8[_0x35de('0x37')]=_[_0x35de('0x38')](_0x840ba8[_0x35de('0x37')]);_0x24d3e8[_0x35de('0x39')]=_[_0x35de('0x3a')](_0x24d3e8[_0x35de('0x36')],_0x24d3e8[_0x35de('0x37')]);_0x5b6c8f[_0x35de('0x3b')]=_[_0x35de('0x3a')](_0x24d3e8[_0x35de('0x36')],qs[_0x35de('0x3c')](_0x840ba8['query']['fields']));_0x5b6c8f[_0x35de('0x3b')]=_0x5b6c8f[_0x35de('0x3b')][_0x35de('0x3d')]?_0x5b6c8f['attributes']:_0x24d3e8[_0x35de('0x36')];if(!_0x840ba8[_0x35de('0x37')][_0x35de('0x3e')](_0x35de('0x3f'))){_0x5b6c8f[_0x35de('0x24')]=qs['limit'](_0x840ba8['query']['limit']);_0x5b6c8f['offset']=qs[_0x35de('0x23')](_0x840ba8[_0x35de('0x37')][_0x35de('0x23')]);}_0x5b6c8f[_0x35de('0x40')]=qs['sort'](_0x840ba8[_0x35de('0x37')][_0x35de('0x41')]);_0x5b6c8f['where']=qs[_0x35de('0x39')](_['pick'](_0x840ba8[_0x35de('0x37')],_0x24d3e8[_0x35de('0x39')]),_0x16ed51);if(_0x840ba8['query'][_0x35de('0x42')]){_0x5b6c8f[_0x35de('0x43')]=_[_0x35de('0x44')](_0x5b6c8f[_0x35de('0x43')],{'$or':_['map'](_0x16ed51,function(_0x3b632c){if(_0x3b632c[_0x35de('0x34')]!=='VIRTUAL'){var _0x58a970={};_0x58a970[_0x3b632c[_0x35de('0x2d')]]={'$like':'%'+_0x840ba8[_0x35de('0x37')][_0x35de('0x42')]+'%'};return _0x58a970;}})});}_0x5b6c8f=_[_0x35de('0x44')]({},_0x5b6c8f,_0x840ba8[_0x35de('0x45')]);var _0x3257bf={'where':_0x5b6c8f['where']};return db[_0x35de('0x31')]['count'](_0x3257bf)['then'](function(_0x31c5e3){_0x253f00[_0x35de('0x22')]=_0x31c5e3;if(_0x840ba8[_0x35de('0x37')][_0x35de('0x46')]){_0x5b6c8f[_0x35de('0x47')]=[{'all':!![]}];}return db['Attachment'][_0x35de('0x48')](_0x5b6c8f);})[_0x35de('0x2a')](function(_0x4ae254){_0x253f00[_0x35de('0x49')]=_0x4ae254;return _0x253f00;})[_0x35de('0x2a')](respondWithFilteredResult(_0x121d78,_0x5b6c8f))[_0x35de('0x4a')](handleError(_0x121d78,null));};exports[_0x35de('0x4b')]=function(_0x3ad42d,_0x549ce6){var _0x1f37df={'raw':!![],'where':{'id':_0x3ad42d[_0x35de('0x4c')]['id']}},_0x517f73={};_0x517f73[_0x35de('0x36')]=_[_0x35de('0x38')](db[_0x35de('0x31')][_0x35de('0x32')]);_0x517f73[_0x35de('0x37')]=_[_0x35de('0x38')](_0x3ad42d[_0x35de('0x37')]);_0x517f73[_0x35de('0x39')]=_[_0x35de('0x3a')](_0x517f73[_0x35de('0x36')],_0x517f73[_0x35de('0x37')]);_0x1f37df[_0x35de('0x3b')]=_[_0x35de('0x3a')](_0x517f73[_0x35de('0x36')],qs[_0x35de('0x3c')](_0x3ad42d['query'][_0x35de('0x3c')]));_0x1f37df[_0x35de('0x3b')]=_0x1f37df['attributes'][_0x35de('0x3d')]?_0x1f37df[_0x35de('0x3b')]:_0x517f73['model'];if(_0x3ad42d[_0x35de('0x37')]['includeAll']){_0x1f37df[_0x35de('0x47')]=[{'all':!![]}];}_0x1f37df=_['merge']({},_0x1f37df,_0x3ad42d[_0x35de('0x45')]);return db[_0x35de('0x31')]['find'](_0x1f37df)[_0x35de('0x2a')](handleEntityNotFound(_0x549ce6,null))[_0x35de('0x2a')](respondWithResult(_0x549ce6,null))[_0x35de('0x4a')](handleError(_0x549ce6,null));};exports[_0x35de('0x4d')]=function(_0x522694,_0xc5fecb){var _0x1ee104={'where':{'id':_0x522694[_0x35de('0x4c')]['id']}},_0x5bbba7={};_0x5bbba7[_0x35de('0x36')]=_['keys'](db[_0x35de('0x31')][_0x35de('0x32')]);_0x1ee104[_0x35de('0x3b')]=_[_0x35de('0x3a')](_0x5bbba7[_0x35de('0x36')],qs[_0x35de('0x3c')](_0x522694[_0x35de('0x37')][_0x35de('0x3c')]));_0x1ee104[_0x35de('0x3b')]=_0x1ee104[_0x35de('0x3b')]['length']?_0x1ee104['attributes']:_0x5bbba7[_0x35de('0x36')];if(_0x522694[_0x35de('0x37')][_0x35de('0x46')]){_0x1ee104[_0x35de('0x47')]=[{'all':!![]}];}_0x1ee104=_[_0x35de('0x44')]({},_0x1ee104,_0x522694[_0x35de('0x45')]);return db[_0x35de('0x31')]['find'](_0x1ee104)[_0x35de('0x2a')](handleEntityNotFound(_0xc5fecb,null))[_0x35de('0x2a')](function(_0x19b277){if(_0x19b277){var _0x5676cb=_0x19b277[_0x35de('0x4e')]({'plain':!![]});_0x5676cb=qs[_0x35de('0x4f')](_0x5676cb,['id',_0x35de('0x50'),_0x35de('0x51')]);_0x522694[_0x35de('0x52')]=_['omit'](_0x522694[_0x35de('0x52')],['id','createdAt',_0x35de('0x51')]);return db[_0x35de('0x31')]['create'](_[_0x35de('0x44')](_0x5676cb,_0x522694[_0x35de('0x52')]),{'include':_0x522694['query']['includeAll']?[{'all':!![]}]:undefined});}})[_0x35de('0x2a')](respondWithResult(_0xc5fecb,0xc9))['catch'](handleError(_0xc5fecb,null));};exports[_0x35de('0x29')]=function(_0x526df6,_0x19bcc9){if(_0x526df6[_0x35de('0x52')]['id']){delete _0x526df6['body']['id'];}return db[_0x35de('0x31')][_0x35de('0x53')]({'where':{'id':_0x526df6['params']['id']}})['then'](handleEntityNotFound(_0x19bcc9,null))[_0x35de('0x2a')](saveUpdates(_0x526df6['body'],null))[_0x35de('0x2a')](respondWithResult(_0x19bcc9,null))[_0x35de('0x4a')](handleError(_0x19bcc9,null));};exports[_0x35de('0x54')]=function(_0x7e0a94,_0x1b91d0){return db[_0x35de('0x31')][_0x35de('0x53')]({'where':{'id':_0x7e0a94['params']['id']}})[_0x35de('0x2a')](handleEntityNotFound(_0x1b91d0,null))[_0x35de('0x2a')](removeEntity(_0x1b91d0,null))[_0x35de('0x4a')](handleError(_0x1b91d0,null));};exports[_0x35de('0x55')]=function(_0x1936ab,_0x428926,_0x5d17b1){_0x1936ab[_0x35de('0x52')][_0x35de('0x2d')]=_0x1936ab[_0x35de('0x56')]['originalname'];_0x1936ab[_0x35de('0x52')]['basename']=_0x1936ab['file']['filename'];_0x1936ab[_0x35de('0x52')][_0x35de('0x34')]=_0x1936ab[_0x35de('0x56')][_0x35de('0x57')];return db[_0x35de('0x31')][_0x35de('0x55')](_0x1936ab[_0x35de('0x52')])['then'](respondWithResult(_0x428926,0xc9))[_0x35de('0x4a')](handleError(_0x428926,null));};exports[_0x35de('0x58')]=function(_0x2366a6,_0x4cd2c5,_0x4f0421){return db[_0x35de('0x31')][_0x35de('0x59')]({'where':{'id':_0x2366a6[_0x35de('0x4c')]['id']},'raw':!![]})[_0x35de('0x2a')](handleEntityNotFound(_0x4cd2c5,null))[_0x35de('0x2a')](function(_0x2f3b6b){if(_0x2f3b6b){var _0x1df110=_0x2f3b6b['ChatOfflineMessageId']!==null;var _0x8fa8d8=path[_0x35de('0x5a')](config['root'],_0x35de('0x5b'));if(_0x1df110){_0x8fa8d8=path['join'](_0x8fa8d8,_0x35de('0x5c'));}var _0x1c9762=path[_0x35de('0x5a')](_0x8fa8d8,_0x2f3b6b[_0x35de('0x5d')]);return _0x4cd2c5[_0x35de('0x58')](_0x1c9762);}})[_0x35de('0x4a')](handleError(_0x4cd2c5,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