Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / attachment / attachment.controller.js
index 5bc346a..ae7b6d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0307=['body','omit','update','create','file','originalname','basename','filename','mimetype','download','findOne','join','server/files/attachments/','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','Content-Range','apply','reject','save','then','destroy','error','name','index','map','rawAttributes','fieldName','type','model','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','filters','filter','where','merge','options','count','includeAll','include','Attachment','rows','catch','params','keys','clone','find','createdAt','updatedAt'];(function(_0x5d284b,_0x105a76){var _0xf8f20e=function(_0x5d002a){while(--_0x5d002a){_0x5d284b['push'](_0x5d284b['shift']());}};_0xf8f20e(++_0x105a76);}(_0x0307,0x1b1));var _0x7030=function(_0x1147ab,_0x10e72b){_0x1147ab=_0x1147ab-0x0;var _0x55cb5a=_0x0307[_0x1147ab];return _0x55cb5a;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x7030('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x7030('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7030('0x2'));var moment=require(_0x7030('0x3'));var BPromise=require(_0x7030('0x4'));var Mustache=require(_0x7030('0x5'));var util=require(_0x7030('0x6'));var path=require(_0x7030('0x7'));var sox=require(_0x7030('0x8'));var csv=require(_0x7030('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x7030('0xa'));var squel=require(_0x7030('0xb'));var crypto=require('crypto');var jsforce=require(_0x7030('0xc'));var deskjs=require(_0x7030('0xd'));var toCsv=require(_0x7030('0x9'));var querystring=require(_0x7030('0xe'));var Papa=require(_0x7030('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x7030('0x10'));var as=require(_0x7030('0x11'));var hardwareService=require(_0x7030('0x12'));var logger=require(_0x7030('0x13'))(_0x7030('0x14'));var utils=require(_0x7030('0x15'));var config=require(_0x7030('0x16'));var licenseUtil=require(_0x7030('0x17'));var db=require(_0x7030('0x18'))['db'];function respondWithStatusCode(_0x2b904f,_0x2a6280){_0x2a6280=_0x2a6280||0xcc;return function(_0x3b3a18){if(_0x3b3a18){return _0x2b904f[_0x7030('0x19')](_0x2a6280);}return _0x2b904f[_0x7030('0x1a')](_0x2a6280)[_0x7030('0x1b')]();};}function respondWithResult(_0x5682dc,_0x4deb2e){_0x4deb2e=_0x4deb2e||0xc8;return function(_0x128179){if(_0x128179){return _0x5682dc[_0x7030('0x1a')](_0x4deb2e)[_0x7030('0x1c')](_0x128179);}};}function respondWithFilteredResult(_0x10d3de,_0x1e5a8a){return function(_0x267b67){if(_0x267b67){var _0x113914=_0x267b67['count'],_0x120c20=_0x1e5a8a['offset'],_0x5ea38f=_0x1e5a8a[_0x7030('0x1d')]+_0x1e5a8a[_0x7030('0x1e')],_0x21b41f;if(_0x5ea38f>=_0x113914){_0x5ea38f=_0x113914;_0x21b41f=0xc8;}else{_0x21b41f=0xce;}_0x10d3de[_0x7030('0x1a')](_0x21b41f);return _0x10d3de['set'](_0x7030('0x1f'),_0x120c20+'-'+_0x5ea38f+'/'+_0x113914)[_0x7030('0x1c')](_0x267b67);}return null;};}function patchUpdates(_0x22dd33){return function(_0x19a57c){try{jsonpatch[_0x7030('0x20')](_0x19a57c,_0x22dd33,!![]);}catch(_0x23bb9c){return BPromise[_0x7030('0x21')](_0x23bb9c);}return _0x19a57c[_0x7030('0x22')]();};}function saveUpdates(_0x5fc88c,_0x1a6049){return function(_0x54f3c1){if(_0x54f3c1){return _0x54f3c1['update'](_0x5fc88c)[_0x7030('0x23')](function(_0x166c89){return _0x166c89;});}return null;};}function removeEntity(_0x30a431,_0x221720){return function(_0x1b7a97){if(_0x1b7a97){return _0x1b7a97[_0x7030('0x24')]()['then'](function(){_0x30a431[_0x7030('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x7b6150,_0x4a8227){return function(_0x45c2e7){if(!_0x45c2e7){_0x7b6150[_0x7030('0x19')](0x194);}return _0x45c2e7;};}function handleError(_0x266898,_0xeaf255){_0xeaf255=_0xeaf255||0x1f4;return function(_0x51d9ac){logger[_0x7030('0x25')](_0x51d9ac['stack']);if(_0x51d9ac[_0x7030('0x26')]){delete _0x51d9ac[_0x7030('0x26')];}_0x266898[_0x7030('0x1a')](_0xeaf255)['send'](_0x51d9ac);};}exports[_0x7030('0x27')]=function(_0x2e086e,_0x44ed2f){var _0x56b4ce={},_0x10dedd={},_0x40640b={'count':0x0,'rows':[]};var _0x2369ef=_[_0x7030('0x28')](db['Attachment'][_0x7030('0x29')],function(_0x127787){return{'name':_0x127787[_0x7030('0x2a')],'type':_0x127787[_0x7030('0x2b')]['key']};});_0x10dedd[_0x7030('0x2c')]=_[_0x7030('0x28')](_0x2369ef,_0x7030('0x26'));_0x10dedd[_0x7030('0x2d')]=_['keys'](_0x2e086e['query']);_0x10dedd['filters']=_['intersection'](_0x10dedd[_0x7030('0x2c')],_0x10dedd[_0x7030('0x2d')]);_0x56b4ce[_0x7030('0x2e')]=_[_0x7030('0x2f')](_0x10dedd[_0x7030('0x2c')],qs[_0x7030('0x30')](_0x2e086e[_0x7030('0x2d')][_0x7030('0x30')]));_0x56b4ce[_0x7030('0x2e')]=_0x56b4ce[_0x7030('0x2e')][_0x7030('0x31')]?_0x56b4ce[_0x7030('0x2e')]:_0x10dedd[_0x7030('0x2c')];if(!_0x2e086e[_0x7030('0x2d')][_0x7030('0x32')](_0x7030('0x33'))){_0x56b4ce[_0x7030('0x1e')]=qs[_0x7030('0x1e')](_0x2e086e['query'][_0x7030('0x1e')]);_0x56b4ce['offset']=qs[_0x7030('0x1d')](_0x2e086e[_0x7030('0x2d')]['offset']);}_0x56b4ce[_0x7030('0x34')]=qs[_0x7030('0x35')](_0x2e086e[_0x7030('0x2d')][_0x7030('0x35')]);_0x56b4ce['where']=qs[_0x7030('0x36')](_['pick'](_0x2e086e[_0x7030('0x2d')],_0x10dedd[_0x7030('0x36')]),_0x2369ef);if(_0x2e086e[_0x7030('0x2d')][_0x7030('0x37')]){_0x56b4ce[_0x7030('0x38')]=_['merge'](_0x56b4ce['where'],{'$or':_[_0x7030('0x28')](_0x2369ef,function(_0x481974){if(_0x481974['type']!=='VIRTUAL'){var _0x1e23bc={};_0x1e23bc[_0x481974[_0x7030('0x26')]]={'$like':'%'+_0x2e086e[_0x7030('0x2d')][_0x7030('0x37')]+'%'};return _0x1e23bc;}})});}_0x56b4ce=_[_0x7030('0x39')]({},_0x56b4ce,_0x2e086e[_0x7030('0x3a')]);var _0x351bf6={'where':_0x56b4ce[_0x7030('0x38')]};return db['Attachment'][_0x7030('0x3b')](_0x351bf6)[_0x7030('0x23')](function(_0x2e9244){_0x40640b[_0x7030('0x3b')]=_0x2e9244;if(_0x2e086e[_0x7030('0x2d')][_0x7030('0x3c')]){_0x56b4ce[_0x7030('0x3d')]=[{'all':!![]}];}return db[_0x7030('0x3e')]['findAll'](_0x56b4ce);})[_0x7030('0x23')](function(_0x366db3){_0x40640b[_0x7030('0x3f')]=_0x366db3;return _0x40640b;})['then'](respondWithFilteredResult(_0x44ed2f,_0x56b4ce))[_0x7030('0x40')](handleError(_0x44ed2f,null));};exports['show']=function(_0x1d5eee,_0x14fd67){var _0x3dd2f3={'raw':!![],'where':{'id':_0x1d5eee[_0x7030('0x41')]['id']}},_0x1d2e65={};_0x1d2e65[_0x7030('0x2c')]=_[_0x7030('0x42')](db[_0x7030('0x3e')][_0x7030('0x29')]);_0x1d2e65[_0x7030('0x2d')]=_[_0x7030('0x42')](_0x1d5eee[_0x7030('0x2d')]);_0x1d2e65['filters']=_[_0x7030('0x2f')](_0x1d2e65[_0x7030('0x2c')],_0x1d2e65[_0x7030('0x2d')]);_0x3dd2f3[_0x7030('0x2e')]=_[_0x7030('0x2f')](_0x1d2e65[_0x7030('0x2c')],qs[_0x7030('0x30')](_0x1d5eee['query'][_0x7030('0x30')]));_0x3dd2f3[_0x7030('0x2e')]=_0x3dd2f3['attributes']['length']?_0x3dd2f3[_0x7030('0x2e')]:_0x1d2e65[_0x7030('0x2c')];if(_0x1d5eee[_0x7030('0x2d')][_0x7030('0x3c')]){_0x3dd2f3[_0x7030('0x3d')]=[{'all':!![]}];}_0x3dd2f3=_[_0x7030('0x39')]({},_0x3dd2f3,_0x1d5eee[_0x7030('0x3a')]);return db[_0x7030('0x3e')]['find'](_0x3dd2f3)[_0x7030('0x23')](handleEntityNotFound(_0x14fd67,null))[_0x7030('0x23')](respondWithResult(_0x14fd67,null))['catch'](handleError(_0x14fd67,null));};exports[_0x7030('0x43')]=function(_0x5e1bd8,_0x28f829){var _0x2b4209={'where':{'id':_0x5e1bd8[_0x7030('0x41')]['id']}},_0x2379f1={};_0x2379f1[_0x7030('0x2c')]=_[_0x7030('0x42')](db[_0x7030('0x3e')][_0x7030('0x29')]);_0x2b4209[_0x7030('0x2e')]=_[_0x7030('0x2f')](_0x2379f1[_0x7030('0x2c')],qs[_0x7030('0x30')](_0x5e1bd8['query']['fields']));_0x2b4209[_0x7030('0x2e')]=_0x2b4209[_0x7030('0x2e')][_0x7030('0x31')]?_0x2b4209[_0x7030('0x2e')]:_0x2379f1['model'];if(_0x5e1bd8[_0x7030('0x2d')][_0x7030('0x3c')]){_0x2b4209[_0x7030('0x3d')]=[{'all':!![]}];}_0x2b4209=_[_0x7030('0x39')]({},_0x2b4209,_0x5e1bd8[_0x7030('0x3a')]);return db[_0x7030('0x3e')][_0x7030('0x44')](_0x2b4209)[_0x7030('0x23')](handleEntityNotFound(_0x28f829,null))['then'](function(_0x4ed57d){if(_0x4ed57d){var _0x49703c=_0x4ed57d['get']({'plain':!![]});_0x49703c=qs['omit'](_0x49703c,['id',_0x7030('0x45'),_0x7030('0x46')]);_0x5e1bd8[_0x7030('0x47')]=_[_0x7030('0x48')](_0x5e1bd8['body'],['id','createdAt',_0x7030('0x46')]);return db[_0x7030('0x3e')]['create'](_[_0x7030('0x39')](_0x49703c,_0x5e1bd8[_0x7030('0x47')]),{'include':_0x5e1bd8['query'][_0x7030('0x3c')]?[{'all':!![]}]:undefined});}})[_0x7030('0x23')](respondWithResult(_0x28f829,0xc9))[_0x7030('0x40')](handleError(_0x28f829,null));};exports[_0x7030('0x49')]=function(_0x13210d,_0x42d3ca){if(_0x13210d['body']['id']){delete _0x13210d[_0x7030('0x47')]['id'];}return db[_0x7030('0x3e')][_0x7030('0x44')]({'where':{'id':_0x13210d[_0x7030('0x41')]['id']}})[_0x7030('0x23')](handleEntityNotFound(_0x42d3ca,null))['then'](saveUpdates(_0x13210d[_0x7030('0x47')],null))[_0x7030('0x23')](respondWithResult(_0x42d3ca,null))[_0x7030('0x40')](handleError(_0x42d3ca,null));};exports['destroy']=function(_0x15553e,_0x220d38){return db[_0x7030('0x3e')][_0x7030('0x44')]({'where':{'id':_0x15553e[_0x7030('0x41')]['id']}})[_0x7030('0x23')](handleEntityNotFound(_0x220d38,null))[_0x7030('0x23')](removeEntity(_0x220d38,null))['catch'](handleError(_0x220d38,null));};exports[_0x7030('0x4a')]=function(_0x53b95b,_0x41eb93,_0x39bab3){_0x53b95b[_0x7030('0x47')]['name']=_0x53b95b[_0x7030('0x4b')][_0x7030('0x4c')];_0x53b95b[_0x7030('0x47')][_0x7030('0x4d')]=_0x53b95b[_0x7030('0x4b')][_0x7030('0x4e')];_0x53b95b[_0x7030('0x47')]['type']=_0x53b95b[_0x7030('0x4b')][_0x7030('0x4f')];return db[_0x7030('0x3e')][_0x7030('0x4a')](_0x53b95b['body'])[_0x7030('0x23')](respondWithResult(_0x41eb93,0xc9))[_0x7030('0x40')](handleError(_0x41eb93,null));};exports[_0x7030('0x50')]=function(_0xe2de05,_0x71a351,_0x3bf410){return db[_0x7030('0x3e')][_0x7030('0x51')]({'where':{'id':_0xe2de05['params']['id']},'raw':!![]})[_0x7030('0x23')](handleEntityNotFound(_0x71a351,null))[_0x7030('0x23')](function(_0x360aa5){if(_0x360aa5){return _0x71a351['download'](path[_0x7030('0x52')](config['root'],_0x7030('0x53'),_0x360aa5[_0x7030('0x4d')]));}})[_0x7030('0x40')](handleError(_0x71a351,null));};
\ No newline at end of file
+var _0xc6d4=['query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','Attachment','includeAll','include','findAll','rows','catch','show','params','fields','find','clone','options','get','omit','createdAt','updatedAt','body','create','update','file','originalname','basename','filename','mimetype','ChatOfflineMessageId','join','root','download','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','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','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','save','destroy','then','sendStatus','error','name','rawAttributes','type','model','map'];(function(_0x589248,_0x31dea3){var _0x486750=function(_0x3e7c21){while(--_0x3e7c21){_0x589248['push'](_0x589248['shift']());}};_0x486750(++_0x31dea3);}(_0xc6d4,0x192));var _0x4c6d=function(_0x2d7f0e,_0x3e6fbd){_0x2d7f0e=_0x2d7f0e-0x0;var _0x110b07=_0xc6d4[_0x2d7f0e];return _0x110b07;};'use strict';var emlformat=require(_0x4c6d('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x4c6d('0x1'));var rp=require(_0x4c6d('0x2'));var moment=require(_0x4c6d('0x3'));var BPromise=require(_0x4c6d('0x4'));var Mustache=require(_0x4c6d('0x5'));var util=require(_0x4c6d('0x6'));var path=require('path');var sox=require(_0x4c6d('0x7'));var csv=require(_0x4c6d('0x8'));var ejs=require(_0x4c6d('0x9'));var fs=require('fs');var fs_extra=require(_0x4c6d('0xa'));var _=require(_0x4c6d('0xb'));var squel=require(_0x4c6d('0xc'));var crypto=require(_0x4c6d('0xd'));var jsforce=require(_0x4c6d('0xe'));var deskjs=require(_0x4c6d('0xf'));var toCsv=require('to-csv');var querystring=require(_0x4c6d('0x10'));var Papa=require(_0x4c6d('0x11'));var Redis=require(_0x4c6d('0x12'));var authService=require(_0x4c6d('0x13'));var qs=require(_0x4c6d('0x14'));var as=require(_0x4c6d('0x15'));var hardwareService=require(_0x4c6d('0x16'));var logger=require(_0x4c6d('0x17'))(_0x4c6d('0x18'));var utils=require(_0x4c6d('0x19'));var config=require(_0x4c6d('0x1a'));var licenseUtil=require(_0x4c6d('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x349b59,_0x2edd1f){_0x2edd1f=_0x2edd1f||0xcc;return function(_0x439990){if(_0x439990){return _0x349b59['sendStatus'](_0x2edd1f);}return _0x349b59[_0x4c6d('0x1c')](_0x2edd1f)[_0x4c6d('0x1d')]();};}function respondWithResult(_0x3f08bf,_0x1c3823){_0x1c3823=_0x1c3823||0xc8;return function(_0x5c71cd){if(_0x5c71cd){return _0x3f08bf[_0x4c6d('0x1c')](_0x1c3823)['json'](_0x5c71cd);}};}function respondWithFilteredResult(_0x7a9de8,_0x5f3e57){return function(_0xa3bab6){if(_0xa3bab6){var _0x1d22c1=typeof _0x5f3e57[_0x4c6d('0x1e')]===_0x4c6d('0x1f')&&typeof _0x5f3e57[_0x4c6d('0x20')]===_0x4c6d('0x1f');var _0x524fdd=_0xa3bab6[_0x4c6d('0x21')];var _0x1f583e=_0x1d22c1?0x0:_0x5f3e57[_0x4c6d('0x1e')];var _0x53b8e0=_0x1d22c1?_0xa3bab6[_0x4c6d('0x21')]:_0x5f3e57[_0x4c6d('0x1e')]+_0x5f3e57[_0x4c6d('0x20')];var _0x3a8473;if(_0x53b8e0>=_0x524fdd){_0x53b8e0=_0x524fdd;_0x3a8473=0xc8;}else{_0x3a8473=0xce;}_0x7a9de8['status'](_0x3a8473);return _0x7a9de8[_0x4c6d('0x22')](_0x4c6d('0x23'),_0x1f583e+'-'+_0x53b8e0+'/'+_0x524fdd)['json'](_0xa3bab6);}return null;};}function patchUpdates(_0xd21491){return function(_0x4a8a16){try{jsonpatch[_0x4c6d('0x24')](_0x4a8a16,_0xd21491,!![]);}catch(_0x6c6f54){return BPromise[_0x4c6d('0x25')](_0x6c6f54);}return _0x4a8a16[_0x4c6d('0x26')]();};}function saveUpdates(_0x4be924,_0x325c76){return function(_0x23f01e){if(_0x23f01e){return _0x23f01e['update'](_0x4be924)['then'](function(_0x20d25a){return _0x20d25a;});}return null;};}function removeEntity(_0x33f0ba,_0x2c63f3){return function(_0x3f4d5a){if(_0x3f4d5a){return _0x3f4d5a[_0x4c6d('0x27')]()[_0x4c6d('0x28')](function(){_0x33f0ba[_0x4c6d('0x1c')](0xcc)[_0x4c6d('0x1d')]();});}};}function handleEntityNotFound(_0x224993,_0x1fedb8){return function(_0x576a8c){if(!_0x576a8c){_0x224993[_0x4c6d('0x29')](0x194);}return _0x576a8c;};}function handleError(_0x1b3308,_0x520a1d){_0x520a1d=_0x520a1d||0x1f4;return function(_0x572e7a){logger[_0x4c6d('0x2a')](_0x572e7a['stack']);if(_0x572e7a['name']){delete _0x572e7a[_0x4c6d('0x2b')];}_0x1b3308['status'](_0x520a1d)['send'](_0x572e7a);};}exports['index']=function(_0x2adb5d,_0x5609b9){var _0x4ccd70={},_0x5e480a={},_0x255e57={'count':0x0,'rows':[]};var _0x43cd6a=_['map'](db['Attachment'][_0x4c6d('0x2c')],function(_0x2e6c5c){return{'name':_0x2e6c5c['fieldName'],'type':_0x2e6c5c[_0x4c6d('0x2d')]['key']};});_0x5e480a[_0x4c6d('0x2e')]=_[_0x4c6d('0x2f')](_0x43cd6a,'name');_0x5e480a[_0x4c6d('0x30')]=_[_0x4c6d('0x31')](_0x2adb5d['query']);_0x5e480a[_0x4c6d('0x32')]=_[_0x4c6d('0x33')](_0x5e480a[_0x4c6d('0x2e')],_0x5e480a[_0x4c6d('0x30')]);_0x4ccd70[_0x4c6d('0x34')]=_['intersection'](_0x5e480a['model'],qs['fields'](_0x2adb5d['query']['fields']));_0x4ccd70[_0x4c6d('0x34')]=_0x4ccd70['attributes'][_0x4c6d('0x35')]?_0x4ccd70[_0x4c6d('0x34')]:_0x5e480a[_0x4c6d('0x2e')];if(!_0x2adb5d[_0x4c6d('0x30')][_0x4c6d('0x36')](_0x4c6d('0x37'))){_0x4ccd70[_0x4c6d('0x20')]=qs[_0x4c6d('0x20')](_0x2adb5d[_0x4c6d('0x30')][_0x4c6d('0x20')]);_0x4ccd70[_0x4c6d('0x1e')]=qs['offset'](_0x2adb5d[_0x4c6d('0x30')][_0x4c6d('0x1e')]);}_0x4ccd70[_0x4c6d('0x38')]=qs[_0x4c6d('0x39')](_0x2adb5d[_0x4c6d('0x30')][_0x4c6d('0x39')]);_0x4ccd70[_0x4c6d('0x3a')]=qs[_0x4c6d('0x32')](_[_0x4c6d('0x3b')](_0x2adb5d[_0x4c6d('0x30')],_0x5e480a[_0x4c6d('0x32')]),_0x43cd6a);if(_0x2adb5d[_0x4c6d('0x30')]['filter']){_0x4ccd70[_0x4c6d('0x3a')]=_[_0x4c6d('0x3c')](_0x4ccd70[_0x4c6d('0x3a')],{'$or':_[_0x4c6d('0x2f')](_0x43cd6a,function(_0x18cf5b){if(_0x18cf5b[_0x4c6d('0x2d')]!=='VIRTUAL'){var _0x490e5e={};_0x490e5e[_0x18cf5b['name']]={'$like':'%'+_0x2adb5d['query'][_0x4c6d('0x3d')]+'%'};return _0x490e5e;}})});}_0x4ccd70=_['merge']({},_0x4ccd70,_0x2adb5d['options']);var _0x3b109c={'where':_0x4ccd70['where']};return db[_0x4c6d('0x3e')][_0x4c6d('0x21')](_0x3b109c)['then'](function(_0xcc18c8){_0x255e57[_0x4c6d('0x21')]=_0xcc18c8;if(_0x2adb5d[_0x4c6d('0x30')][_0x4c6d('0x3f')]){_0x4ccd70[_0x4c6d('0x40')]=[{'all':!![]}];}return db[_0x4c6d('0x3e')][_0x4c6d('0x41')](_0x4ccd70);})[_0x4c6d('0x28')](function(_0x51a881){_0x255e57[_0x4c6d('0x42')]=_0x51a881;return _0x255e57;})[_0x4c6d('0x28')](respondWithFilteredResult(_0x5609b9,_0x4ccd70))[_0x4c6d('0x43')](handleError(_0x5609b9,null));};exports[_0x4c6d('0x44')]=function(_0x49d85e,_0x4088fe){var _0x29be3b={'raw':!![],'where':{'id':_0x49d85e[_0x4c6d('0x45')]['id']}},_0x377598={};_0x377598['model']=_[_0x4c6d('0x31')](db[_0x4c6d('0x3e')][_0x4c6d('0x2c')]);_0x377598[_0x4c6d('0x30')]=_['keys'](_0x49d85e[_0x4c6d('0x30')]);_0x377598[_0x4c6d('0x32')]=_[_0x4c6d('0x33')](_0x377598['model'],_0x377598[_0x4c6d('0x30')]);_0x29be3b[_0x4c6d('0x34')]=_[_0x4c6d('0x33')](_0x377598['model'],qs[_0x4c6d('0x46')](_0x49d85e['query'][_0x4c6d('0x46')]));_0x29be3b[_0x4c6d('0x34')]=_0x29be3b['attributes'][_0x4c6d('0x35')]?_0x29be3b[_0x4c6d('0x34')]:_0x377598[_0x4c6d('0x2e')];if(_0x49d85e[_0x4c6d('0x30')][_0x4c6d('0x3f')]){_0x29be3b[_0x4c6d('0x40')]=[{'all':!![]}];}_0x29be3b=_['merge']({},_0x29be3b,_0x49d85e['options']);return db[_0x4c6d('0x3e')][_0x4c6d('0x47')](_0x29be3b)[_0x4c6d('0x28')](handleEntityNotFound(_0x4088fe,null))[_0x4c6d('0x28')](respondWithResult(_0x4088fe,null))['catch'](handleError(_0x4088fe,null));};exports[_0x4c6d('0x48')]=function(_0xa343ae,_0x2822e3){var _0x52dac9={'where':{'id':_0xa343ae[_0x4c6d('0x45')]['id']}},_0x9fc11f={};_0x9fc11f[_0x4c6d('0x2e')]=_[_0x4c6d('0x31')](db[_0x4c6d('0x3e')]['rawAttributes']);_0x52dac9[_0x4c6d('0x34')]=_[_0x4c6d('0x33')](_0x9fc11f[_0x4c6d('0x2e')],qs[_0x4c6d('0x46')](_0xa343ae['query'][_0x4c6d('0x46')]));_0x52dac9[_0x4c6d('0x34')]=_0x52dac9[_0x4c6d('0x34')][_0x4c6d('0x35')]?_0x52dac9[_0x4c6d('0x34')]:_0x9fc11f[_0x4c6d('0x2e')];if(_0xa343ae['query'][_0x4c6d('0x3f')]){_0x52dac9[_0x4c6d('0x40')]=[{'all':!![]}];}_0x52dac9=_['merge']({},_0x52dac9,_0xa343ae[_0x4c6d('0x49')]);return db[_0x4c6d('0x3e')][_0x4c6d('0x47')](_0x52dac9)[_0x4c6d('0x28')](handleEntityNotFound(_0x2822e3,null))[_0x4c6d('0x28')](function(_0x556120){if(_0x556120){var _0x25789e=_0x556120[_0x4c6d('0x4a')]({'plain':!![]});_0x25789e=qs[_0x4c6d('0x4b')](_0x25789e,['id',_0x4c6d('0x4c'),_0x4c6d('0x4d')]);_0xa343ae['body']=_[_0x4c6d('0x4b')](_0xa343ae[_0x4c6d('0x4e')],['id',_0x4c6d('0x4c'),_0x4c6d('0x4d')]);return db[_0x4c6d('0x3e')][_0x4c6d('0x4f')](_[_0x4c6d('0x3c')](_0x25789e,_0xa343ae[_0x4c6d('0x4e')]),{'include':_0xa343ae['query']['includeAll']?[{'all':!![]}]:undefined});}})['then'](respondWithResult(_0x2822e3,0xc9))[_0x4c6d('0x43')](handleError(_0x2822e3,null));};exports[_0x4c6d('0x50')]=function(_0x3e6f75,_0xbea47a){if(_0x3e6f75['body']['id']){delete _0x3e6f75[_0x4c6d('0x4e')]['id'];}return db['Attachment'][_0x4c6d('0x47')]({'where':{'id':_0x3e6f75['params']['id']}})[_0x4c6d('0x28')](handleEntityNotFound(_0xbea47a,null))[_0x4c6d('0x28')](saveUpdates(_0x3e6f75[_0x4c6d('0x4e')],null))[_0x4c6d('0x28')](respondWithResult(_0xbea47a,null))[_0x4c6d('0x43')](handleError(_0xbea47a,null));};exports[_0x4c6d('0x27')]=function(_0x22f5a5,_0x5c5803){return db[_0x4c6d('0x3e')][_0x4c6d('0x47')]({'where':{'id':_0x22f5a5[_0x4c6d('0x45')]['id']}})[_0x4c6d('0x28')](handleEntityNotFound(_0x5c5803,null))[_0x4c6d('0x28')](removeEntity(_0x5c5803,null))[_0x4c6d('0x43')](handleError(_0x5c5803,null));};exports[_0x4c6d('0x4f')]=function(_0x4b7596,_0x8cdcf8,_0x518d72){_0x4b7596[_0x4c6d('0x4e')][_0x4c6d('0x2b')]=_0x4b7596[_0x4c6d('0x51')][_0x4c6d('0x52')];_0x4b7596[_0x4c6d('0x4e')][_0x4c6d('0x53')]=_0x4b7596[_0x4c6d('0x51')][_0x4c6d('0x54')];_0x4b7596[_0x4c6d('0x4e')]['type']=_0x4b7596[_0x4c6d('0x51')][_0x4c6d('0x55')];return db[_0x4c6d('0x3e')][_0x4c6d('0x4f')](_0x4b7596[_0x4c6d('0x4e')])[_0x4c6d('0x28')](respondWithResult(_0x8cdcf8,0xc9))[_0x4c6d('0x43')](handleError(_0x8cdcf8,null));};exports['download']=function(_0x39eb2a,_0x2ef94a,_0x568e54){return db[_0x4c6d('0x3e')]['findOne']({'where':{'id':_0x39eb2a[_0x4c6d('0x45')]['id']},'raw':!![]})[_0x4c6d('0x28')](handleEntityNotFound(_0x2ef94a,null))['then'](function(_0x1deacc){if(_0x1deacc){var _0x4b1999=_0x1deacc[_0x4c6d('0x56')]!==null;var _0x183879=path[_0x4c6d('0x57')](config[_0x4c6d('0x58')],'server/files/attachments/');if(_0x4b1999){_0x183879=path['join'](_0x183879,'offline-chat/');}var _0x223486=path[_0x4c6d('0x57')](_0x183879,_0x1deacc[_0x4c6d('0x53')]);return _0x2ef94a[_0x4c6d('0x59')](_0x223486);}})[_0x4c6d('0x43')](handleError(_0x2ef94a,null));};
\ No newline at end of file