Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / attachment / attachment.controller.js
index 34ff181..f3dbbbf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa77d=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','error','map','Attachment','type','key','query','keys','filters','model','attributes','fields','length','order','where','filter','merge','VIRTUAL','name','options','findAll','catch','show','rawAttributes','intersection','includeAll','include','find','clone','params','omit','updatedAt','body','createdAt','create','file','originalname','basename','filename','mimetype','download','findOne','root','html-pdf','eml-format','rimraf','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','crypto','jsforce','querystring','papaparse','../../components/auth/service'];(function(_0x5edcd7,_0x4c5e59){var _0x2f5b45=function(_0x11aa0c){while(--_0x11aa0c){_0x5edcd7['push'](_0x5edcd7['shift']());}};_0x2f5b45(++_0x4c5e59);}(_0xa77d,0x1ca));var _0xda77=function(_0x57cf2b,_0x3f7161){_0x57cf2b=_0x57cf2b-0x0;var _0x594259=_0xa77d[_0x57cf2b];return _0x594259;};'use strict';var pdf=require(_0xda77('0x0'));var emlformat=require(_0xda77('0x1'));var rimraf=require(_0xda77('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xda77('0x3'));var moment=require(_0xda77('0x4'));var BPromise=require(_0xda77('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xda77('0x6'));var sox=require(_0xda77('0x7'));var csv=require(_0xda77('0x8'));var ejs=require(_0xda77('0x9'));var fs=require('fs');var _=require(_0xda77('0xa'));var squel=require('squel');var crypto=require(_0xda77('0xb'));var jsforce=require(_0xda77('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xda77('0x8'));var querystring=require(_0xda77('0xd'));var Papa=require(_0xda77('0xe'));var Redis=require('ioredis');var authService=require(_0xda77('0xf'));var qs=require(_0xda77('0x10'));var as=require(_0xda77('0x11'));var hardwareService=require(_0xda77('0x12'));var logger=require(_0xda77('0x13'))('api');var utils=require(_0xda77('0x14'));var config=require(_0xda77('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xda77('0x16'))['db'];function respondWithStatusCode(_0x250653,_0x1540e5){_0x1540e5=_0x1540e5||0xcc;return function(_0x27acde){if(_0x27acde){return _0x250653[_0xda77('0x17')](_0x1540e5);}return _0x250653[_0xda77('0x18')](_0x1540e5)[_0xda77('0x19')]();};}function respondWithResult(_0x1d3aee,_0x37e11f){_0x37e11f=_0x37e11f||0xc8;return function(_0x2e3044){if(_0x2e3044){return _0x1d3aee[_0xda77('0x18')](_0x37e11f)[_0xda77('0x1a')](_0x2e3044);}};}function respondWithFilteredResult(_0x57822b,_0x1450de){return function(_0x4705b2){if(_0x4705b2){var _0x84d910=_0x4705b2[_0xda77('0x1b')],_0x365777=_0x1450de[_0xda77('0x1c')],_0x706cc0=_0x1450de[_0xda77('0x1c')]+_0x1450de[_0xda77('0x1d')],_0x37851e;if(_0x706cc0>=_0x84d910){_0x706cc0=_0x84d910;_0x37851e=0xc8;}else{_0x37851e=0xce;}_0x57822b['status'](_0x37851e);return _0x57822b[_0xda77('0x1e')](_0xda77('0x1f'),_0x365777+'-'+_0x706cc0+'/'+_0x84d910)[_0xda77('0x1a')](_0x4705b2);}return null;};}function patchUpdates(_0x23b95f){return function(_0x6452d4){try{jsonpatch[_0xda77('0x20')](_0x6452d4,_0x23b95f,!![]);}catch(_0x85626f){return BPromise[_0xda77('0x21')](_0x85626f);}return _0x6452d4['save']();};}function saveUpdates(_0x59a8b5,_0x22002){return function(_0x25dddb){if(_0x25dddb){return _0x25dddb[_0xda77('0x22')](_0x59a8b5)[_0xda77('0x23')](function(_0x10fd09){return _0x10fd09;});}return null;};}function removeEntity(_0x114886,_0xeaf95f){return function(_0x2dcd65){if(_0x2dcd65){return _0x2dcd65[_0xda77('0x24')]()[_0xda77('0x23')](function(){_0x114886[_0xda77('0x18')](0xcc)[_0xda77('0x19')]();});}};}function handleEntityNotFound(_0x349193,_0xb5c2d0){return function(_0x23fca2){if(!_0x23fca2){_0x349193['sendStatus'](0x194);}return _0x23fca2;};}function handleError(_0x2a1371,_0x2e7ba7){_0x2e7ba7=_0x2e7ba7||0x1f4;return function(_0x4bee75){logger[_0xda77('0x25')](_0x4bee75['stack']);if(_0x4bee75['name']){delete _0x4bee75['name'];}_0x2a1371[_0xda77('0x18')](_0x2e7ba7)['send'](_0x4bee75);};}exports['index']=function(_0x53184f,_0x6e2620){var _0x35e6b4={},_0x5149de={},_0x39529b={'count':0x0,'rows':[]};var _0x129291=_[_0xda77('0x26')](db[_0xda77('0x27')]['rawAttributes'],function(_0x52bf35){return{'name':_0x52bf35['fieldName'],'type':_0x52bf35[_0xda77('0x28')][_0xda77('0x29')]};});_0x5149de['model']=_[_0xda77('0x26')](_0x129291,'name');_0x5149de[_0xda77('0x2a')]=_[_0xda77('0x2b')](_0x53184f[_0xda77('0x2a')]);_0x5149de[_0xda77('0x2c')]=_['intersection'](_0x5149de[_0xda77('0x2d')],_0x5149de[_0xda77('0x2a')]);_0x35e6b4[_0xda77('0x2e')]=_['intersection'](_0x5149de[_0xda77('0x2d')],qs[_0xda77('0x2f')](_0x53184f[_0xda77('0x2a')]['fields']));_0x35e6b4[_0xda77('0x2e')]=_0x35e6b4[_0xda77('0x2e')][_0xda77('0x30')]?_0x35e6b4['attributes']:_0x5149de[_0xda77('0x2d')];if(!_0x53184f[_0xda77('0x2a')]['hasOwnProperty']('nolimit')){_0x35e6b4[_0xda77('0x1d')]=qs['limit'](_0x53184f[_0xda77('0x2a')]['limit']);_0x35e6b4[_0xda77('0x1c')]=qs[_0xda77('0x1c')](_0x53184f[_0xda77('0x2a')][_0xda77('0x1c')]);}_0x35e6b4[_0xda77('0x31')]=qs['sort'](_0x53184f[_0xda77('0x2a')]['sort']);_0x35e6b4[_0xda77('0x32')]=qs['filters'](_['pick'](_0x53184f['query'],_0x5149de[_0xda77('0x2c')]),_0x129291);if(_0x53184f[_0xda77('0x2a')][_0xda77('0x33')]){_0x35e6b4['where']=_[_0xda77('0x34')](_0x35e6b4['where'],{'$or':_[_0xda77('0x26')](_0x129291,function(_0x2ef7d8){if(_0x2ef7d8['type']!==_0xda77('0x35')){var _0x617517={};_0x617517[_0x2ef7d8[_0xda77('0x36')]]={'$like':'%'+_0x53184f[_0xda77('0x2a')][_0xda77('0x33')]+'%'};return _0x617517;}})});}_0x35e6b4=_['merge']({},_0x35e6b4,_0x53184f[_0xda77('0x37')]);var _0x75e3fa={'where':_0x35e6b4['where']};return db['Attachment']['count'](_0x75e3fa)[_0xda77('0x23')](function(_0x3224a6){_0x39529b[_0xda77('0x1b')]=_0x3224a6;if(_0x53184f['query']['includeAll']){_0x35e6b4['include']=[{'all':!![]}];}return db['Attachment'][_0xda77('0x38')](_0x35e6b4);})[_0xda77('0x23')](function(_0x46d028){_0x39529b['rows']=_0x46d028;return _0x39529b;})[_0xda77('0x23')](respondWithFilteredResult(_0x6e2620,_0x35e6b4))[_0xda77('0x39')](handleError(_0x6e2620,null));};exports[_0xda77('0x3a')]=function(_0x150736,_0x4affed){var _0x466632={'raw':!![],'where':{'id':_0x150736['params']['id']}},_0x27b144={};_0x27b144['model']=_[_0xda77('0x2b')](db[_0xda77('0x27')][_0xda77('0x3b')]);_0x27b144[_0xda77('0x2a')]=_['keys'](_0x150736[_0xda77('0x2a')]);_0x27b144[_0xda77('0x2c')]=_[_0xda77('0x3c')](_0x27b144[_0xda77('0x2d')],_0x27b144[_0xda77('0x2a')]);_0x466632[_0xda77('0x2e')]=_[_0xda77('0x3c')](_0x27b144[_0xda77('0x2d')],qs[_0xda77('0x2f')](_0x150736[_0xda77('0x2a')][_0xda77('0x2f')]));_0x466632[_0xda77('0x2e')]=_0x466632[_0xda77('0x2e')][_0xda77('0x30')]?_0x466632['attributes']:_0x27b144[_0xda77('0x2d')];if(_0x150736[_0xda77('0x2a')][_0xda77('0x3d')]){_0x466632[_0xda77('0x3e')]=[{'all':!![]}];}_0x466632=_[_0xda77('0x34')]({},_0x466632,_0x150736[_0xda77('0x37')]);return db['Attachment'][_0xda77('0x3f')](_0x466632)['then'](handleEntityNotFound(_0x4affed,null))[_0xda77('0x23')](respondWithResult(_0x4affed,null))['catch'](handleError(_0x4affed,null));};exports[_0xda77('0x40')]=function(_0x561391,_0x24bad9){var _0x44d1b3={'where':{'id':_0x561391[_0xda77('0x41')]['id']}},_0xd761d2={};_0xd761d2['model']=_[_0xda77('0x2b')](db['Attachment']['rawAttributes']);_0x44d1b3['attributes']=_[_0xda77('0x3c')](_0xd761d2[_0xda77('0x2d')],qs['fields'](_0x561391[_0xda77('0x2a')]['fields']));_0x44d1b3[_0xda77('0x2e')]=_0x44d1b3[_0xda77('0x2e')]['length']?_0x44d1b3['attributes']:_0xd761d2['model'];if(_0x561391[_0xda77('0x2a')][_0xda77('0x3d')]){_0x44d1b3['include']=[{'all':!![]}];}_0x44d1b3=_[_0xda77('0x34')]({},_0x44d1b3,_0x561391['options']);return db[_0xda77('0x27')]['find'](_0x44d1b3)['then'](handleEntityNotFound(_0x24bad9,null))[_0xda77('0x23')](function(_0x15c198){if(_0x15c198){var _0x14992a=_0x15c198['get']({'plain':!![]});_0x14992a=qs[_0xda77('0x42')](_0x14992a,['id','createdAt',_0xda77('0x43')]);_0x561391[_0xda77('0x44')]=_['omit'](_0x561391[_0xda77('0x44')],['id',_0xda77('0x45'),_0xda77('0x43')]);return db[_0xda77('0x27')][_0xda77('0x46')](_['merge'](_0x14992a,_0x561391['body']),{'include':_0x561391[_0xda77('0x2a')][_0xda77('0x3d')]?[{'all':!![]}]:undefined});}})[_0xda77('0x23')](respondWithResult(_0x24bad9,0xc9))['catch'](handleError(_0x24bad9,null));};exports[_0xda77('0x22')]=function(_0x5252b4,_0x29b1b2){if(_0x5252b4[_0xda77('0x44')]['id']){delete _0x5252b4[_0xda77('0x44')]['id'];}return db[_0xda77('0x27')][_0xda77('0x3f')]({'where':{'id':_0x5252b4[_0xda77('0x41')]['id']}})[_0xda77('0x23')](handleEntityNotFound(_0x29b1b2,null))[_0xda77('0x23')](saveUpdates(_0x5252b4[_0xda77('0x44')],null))[_0xda77('0x23')](respondWithResult(_0x29b1b2,null))['catch'](handleError(_0x29b1b2,null));};exports[_0xda77('0x24')]=function(_0x1d1f72,_0x324741){return db['Attachment']['find']({'where':{'id':_0x1d1f72[_0xda77('0x41')]['id']}})['then'](handleEntityNotFound(_0x324741,null))[_0xda77('0x23')](removeEntity(_0x324741,null))['catch'](handleError(_0x324741,null));};exports[_0xda77('0x46')]=function(_0x3a4539,_0x40aad1,_0x2cdfcc){_0x3a4539[_0xda77('0x44')][_0xda77('0x36')]=_0x3a4539[_0xda77('0x47')][_0xda77('0x48')];_0x3a4539[_0xda77('0x44')][_0xda77('0x49')]=_0x3a4539[_0xda77('0x47')][_0xda77('0x4a')];_0x3a4539[_0xda77('0x44')][_0xda77('0x28')]=_0x3a4539[_0xda77('0x47')][_0xda77('0x4b')];return db['Attachment']['create'](_0x3a4539[_0xda77('0x44')])['then'](respondWithResult(_0x40aad1,0xc9))['catch'](handleError(_0x40aad1,null));};exports[_0xda77('0x4c')]=function(_0x1ea83f,_0x12f723,_0x5c8b10){return db['Attachment'][_0xda77('0x4d')]({'where':{'id':_0x1ea83f[_0xda77('0x41')]['id']},'raw':!![]})['then'](handleEntityNotFound(_0x12f723,null))['then'](function(_0x55fd1c){if(_0x55fd1c){return _0x12f723[_0xda77('0x4c')](path['join'](config[_0xda77('0x4e')],'server/files/attachments/',_0x55fd1c[_0xda77('0x49')]));}})[_0xda77('0x39')](handleError(_0x12f723,null));};
\ No newline at end of file
+var _0xc872=['order','sort','filter','where','VIRTUAL','merge','includeAll','include','findAll','show','params','options','find','catch','clone','keys','Attachment','omit','updatedAt','body','create','update','file','originalname','filename','mimetype','download','findOne','ChatOfflineMessageId','root','join','basename','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','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','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','reject','save','then','destroy','error','name','rawAttributes','fieldName','type','key','model','map','query','filters','attributes','intersection','fields','length','nolimit'];(function(_0x4c99ee,_0x2d8768){var _0x24bc5f=function(_0x9b00c1){while(--_0x9b00c1){_0x4c99ee['push'](_0x4c99ee['shift']());}};_0x24bc5f(++_0x2d8768);}(_0xc872,0xcc));var _0x2c87=function(_0x5235a6,_0x680b76){_0x5235a6=_0x5235a6-0x0;var _0x1cf37e=_0xc872[_0x5235a6];return _0x1cf37e;};'use strict';var emlformat=require(_0x2c87('0x0'));var rimraf=require(_0x2c87('0x1'));var zipdir=require(_0x2c87('0x2'));var jsonpatch=require(_0x2c87('0x3'));var rp=require(_0x2c87('0x4'));var moment=require('moment');var BPromise=require(_0x2c87('0x5'));var Mustache=require(_0x2c87('0x6'));var util=require(_0x2c87('0x7'));var path=require(_0x2c87('0x8'));var sox=require(_0x2c87('0x9'));var csv=require('to-csv');var ejs=require(_0x2c87('0xa'));var fs=require('fs');var fs_extra=require(_0x2c87('0xb'));var _=require('lodash');var squel=require(_0x2c87('0xc'));var crypto=require(_0x2c87('0xd'));var jsforce=require(_0x2c87('0xe'));var deskjs=require(_0x2c87('0xf'));var toCsv=require('to-csv');var querystring=require(_0x2c87('0x10'));var Papa=require(_0x2c87('0x11'));var Redis=require(_0x2c87('0x12'));var authService=require(_0x2c87('0x13'));var qs=require(_0x2c87('0x14'));var as=require(_0x2c87('0x15'));var hardwareService=require(_0x2c87('0x16'));var logger=require(_0x2c87('0x17'))(_0x2c87('0x18'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x2c87('0x19'))['db'];function respondWithStatusCode(_0x33f50f,_0xdd4f89){_0xdd4f89=_0xdd4f89||0xcc;return function(_0x567bb4){if(_0x567bb4){return _0x33f50f[_0x2c87('0x1a')](_0xdd4f89);}return _0x33f50f[_0x2c87('0x1b')](_0xdd4f89)[_0x2c87('0x1c')]();};}function respondWithResult(_0x2d2745,_0x11efe0){_0x11efe0=_0x11efe0||0xc8;return function(_0x171c86){if(_0x171c86){return _0x2d2745[_0x2c87('0x1b')](_0x11efe0)[_0x2c87('0x1d')](_0x171c86);}};}function respondWithFilteredResult(_0x170f70,_0x164da8){return function(_0x2cee2c){if(_0x2cee2c){var _0x5922b0=typeof _0x164da8[_0x2c87('0x1e')]===_0x2c87('0x1f')&&typeof _0x164da8[_0x2c87('0x20')]===_0x2c87('0x1f');var _0x2ccebf=_0x2cee2c[_0x2c87('0x21')];var _0x204d61=_0x5922b0?0x0:_0x164da8[_0x2c87('0x1e')];var _0x323f17=_0x5922b0?_0x2cee2c[_0x2c87('0x21')]:_0x164da8['offset']+_0x164da8[_0x2c87('0x20')];var _0x211f1e;if(_0x323f17>=_0x2ccebf){_0x323f17=_0x2ccebf;_0x211f1e=0xc8;}else{_0x211f1e=0xce;}_0x170f70[_0x2c87('0x1b')](_0x211f1e);return _0x170f70[_0x2c87('0x22')]('Content-Range',_0x204d61+'-'+_0x323f17+'/'+_0x2ccebf)['json'](_0x2cee2c);}return null;};}function patchUpdates(_0x4225d9){return function(_0x40b2a7){try{jsonpatch['apply'](_0x40b2a7,_0x4225d9,!![]);}catch(_0x5e028b){return BPromise[_0x2c87('0x23')](_0x5e028b);}return _0x40b2a7[_0x2c87('0x24')]();};}function saveUpdates(_0x3086c5,_0x15ea79){return function(_0x28a3b5){if(_0x28a3b5){return _0x28a3b5['update'](_0x3086c5)[_0x2c87('0x25')](function(_0x476e6a){return _0x476e6a;});}return null;};}function removeEntity(_0x3ae760,_0x248555){return function(_0xa9c67c){if(_0xa9c67c){return _0xa9c67c[_0x2c87('0x26')]()[_0x2c87('0x25')](function(){_0x3ae760[_0x2c87('0x1b')](0xcc)[_0x2c87('0x1c')]();});}};}function handleEntityNotFound(_0x4d9236,_0x228ec9){return function(_0x8c2cd3){if(!_0x8c2cd3){_0x4d9236[_0x2c87('0x1a')](0x194);}return _0x8c2cd3;};}function handleError(_0xf9314d,_0x26b892){_0x26b892=_0x26b892||0x1f4;return function(_0x251bf3){logger[_0x2c87('0x27')](_0x251bf3['stack']);if(_0x251bf3['name']){delete _0x251bf3[_0x2c87('0x28')];}_0xf9314d[_0x2c87('0x1b')](_0x26b892)['send'](_0x251bf3);};}exports['index']=function(_0xbd1186,_0x57f118){var _0x1bfd5a={},_0x233ce9={},_0x4ac401={'count':0x0,'rows':[]};var _0x5dc069=_['map'](db['Attachment'][_0x2c87('0x29')],function(_0x34807d){return{'name':_0x34807d[_0x2c87('0x2a')],'type':_0x34807d[_0x2c87('0x2b')][_0x2c87('0x2c')]};});_0x233ce9[_0x2c87('0x2d')]=_[_0x2c87('0x2e')](_0x5dc069,_0x2c87('0x28'));_0x233ce9[_0x2c87('0x2f')]=_['keys'](_0xbd1186[_0x2c87('0x2f')]);_0x233ce9[_0x2c87('0x30')]=_['intersection'](_0x233ce9['model'],_0x233ce9[_0x2c87('0x2f')]);_0x1bfd5a[_0x2c87('0x31')]=_[_0x2c87('0x32')](_0x233ce9[_0x2c87('0x2d')],qs[_0x2c87('0x33')](_0xbd1186[_0x2c87('0x2f')]['fields']));_0x1bfd5a['attributes']=_0x1bfd5a[_0x2c87('0x31')][_0x2c87('0x34')]?_0x1bfd5a[_0x2c87('0x31')]:_0x233ce9[_0x2c87('0x2d')];if(!_0xbd1186[_0x2c87('0x2f')]['hasOwnProperty'](_0x2c87('0x35'))){_0x1bfd5a['limit']=qs[_0x2c87('0x20')](_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x20')]);_0x1bfd5a[_0x2c87('0x1e')]=qs[_0x2c87('0x1e')](_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x1e')]);}_0x1bfd5a[_0x2c87('0x36')]=qs['sort'](_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x37')]);_0x1bfd5a['where']=qs[_0x2c87('0x30')](_['pick'](_0xbd1186[_0x2c87('0x2f')],_0x233ce9[_0x2c87('0x30')]),_0x5dc069);if(_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x38')]){_0x1bfd5a[_0x2c87('0x39')]=_['merge'](_0x1bfd5a[_0x2c87('0x39')],{'$or':_[_0x2c87('0x2e')](_0x5dc069,function(_0x4ddc7d){if(_0x4ddc7d[_0x2c87('0x2b')]!==_0x2c87('0x3a')){var _0x4a6294={};_0x4a6294[_0x4ddc7d[_0x2c87('0x28')]]={'$like':'%'+_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x38')]+'%'};return _0x4a6294;}})});}_0x1bfd5a=_[_0x2c87('0x3b')]({},_0x1bfd5a,_0xbd1186['options']);var _0x4cd7fa={'where':_0x1bfd5a[_0x2c87('0x39')]};return db['Attachment'][_0x2c87('0x21')](_0x4cd7fa)[_0x2c87('0x25')](function(_0x2b8c4c){_0x4ac401[_0x2c87('0x21')]=_0x2b8c4c;if(_0xbd1186[_0x2c87('0x2f')][_0x2c87('0x3c')]){_0x1bfd5a[_0x2c87('0x3d')]=[{'all':!![]}];}return db['Attachment'][_0x2c87('0x3e')](_0x1bfd5a);})['then'](function(_0x395bd6){_0x4ac401['rows']=_0x395bd6;return _0x4ac401;})[_0x2c87('0x25')](respondWithFilteredResult(_0x57f118,_0x1bfd5a))['catch'](handleError(_0x57f118,null));};exports[_0x2c87('0x3f')]=function(_0x3ffa5a,_0x28606f){var _0x4849fd={'raw':!![],'where':{'id':_0x3ffa5a[_0x2c87('0x40')]['id']}},_0x50f5e9={};_0x50f5e9[_0x2c87('0x2d')]=_['keys'](db['Attachment'][_0x2c87('0x29')]);_0x50f5e9[_0x2c87('0x2f')]=_['keys'](_0x3ffa5a[_0x2c87('0x2f')]);_0x50f5e9[_0x2c87('0x30')]=_[_0x2c87('0x32')](_0x50f5e9[_0x2c87('0x2d')],_0x50f5e9[_0x2c87('0x2f')]);_0x4849fd[_0x2c87('0x31')]=_[_0x2c87('0x32')](_0x50f5e9['model'],qs['fields'](_0x3ffa5a[_0x2c87('0x2f')][_0x2c87('0x33')]));_0x4849fd[_0x2c87('0x31')]=_0x4849fd[_0x2c87('0x31')][_0x2c87('0x34')]?_0x4849fd[_0x2c87('0x31')]:_0x50f5e9[_0x2c87('0x2d')];if(_0x3ffa5a[_0x2c87('0x2f')][_0x2c87('0x3c')]){_0x4849fd[_0x2c87('0x3d')]=[{'all':!![]}];}_0x4849fd=_['merge']({},_0x4849fd,_0x3ffa5a[_0x2c87('0x41')]);return db['Attachment'][_0x2c87('0x42')](_0x4849fd)[_0x2c87('0x25')](handleEntityNotFound(_0x28606f,null))['then'](respondWithResult(_0x28606f,null))[_0x2c87('0x43')](handleError(_0x28606f,null));};exports[_0x2c87('0x44')]=function(_0x5eedc4,_0x162ff3){var _0x2a2ec2={'where':{'id':_0x5eedc4[_0x2c87('0x40')]['id']}},_0x5b0546={};_0x5b0546[_0x2c87('0x2d')]=_[_0x2c87('0x45')](db[_0x2c87('0x46')][_0x2c87('0x29')]);_0x2a2ec2[_0x2c87('0x31')]=_['intersection'](_0x5b0546[_0x2c87('0x2d')],qs['fields'](_0x5eedc4[_0x2c87('0x2f')][_0x2c87('0x33')]));_0x2a2ec2[_0x2c87('0x31')]=_0x2a2ec2[_0x2c87('0x31')][_0x2c87('0x34')]?_0x2a2ec2[_0x2c87('0x31')]:_0x5b0546[_0x2c87('0x2d')];if(_0x5eedc4[_0x2c87('0x2f')][_0x2c87('0x3c')]){_0x2a2ec2[_0x2c87('0x3d')]=[{'all':!![]}];}_0x2a2ec2=_[_0x2c87('0x3b')]({},_0x2a2ec2,_0x5eedc4['options']);return db[_0x2c87('0x46')][_0x2c87('0x42')](_0x2a2ec2)['then'](handleEntityNotFound(_0x162ff3,null))[_0x2c87('0x25')](function(_0x569d1d){if(_0x569d1d){var _0x3f4c35=_0x569d1d['get']({'plain':!![]});_0x3f4c35=qs[_0x2c87('0x47')](_0x3f4c35,['id','createdAt',_0x2c87('0x48')]);_0x5eedc4[_0x2c87('0x49')]=_[_0x2c87('0x47')](_0x5eedc4[_0x2c87('0x49')],['id','createdAt',_0x2c87('0x48')]);return db[_0x2c87('0x46')][_0x2c87('0x4a')](_[_0x2c87('0x3b')](_0x3f4c35,_0x5eedc4['body']),{'include':_0x5eedc4['query']['includeAll']?[{'all':!![]}]:undefined});}})[_0x2c87('0x25')](respondWithResult(_0x162ff3,0xc9))['catch'](handleError(_0x162ff3,null));};exports[_0x2c87('0x4b')]=function(_0x2b340c,_0x2ee8b4){if(_0x2b340c[_0x2c87('0x49')]['id']){delete _0x2b340c[_0x2c87('0x49')]['id'];}return db['Attachment'][_0x2c87('0x42')]({'where':{'id':_0x2b340c[_0x2c87('0x40')]['id']}})[_0x2c87('0x25')](handleEntityNotFound(_0x2ee8b4,null))[_0x2c87('0x25')](saveUpdates(_0x2b340c[_0x2c87('0x49')],null))['then'](respondWithResult(_0x2ee8b4,null))[_0x2c87('0x43')](handleError(_0x2ee8b4,null));};exports[_0x2c87('0x26')]=function(_0x45c544,_0x15f890){return db[_0x2c87('0x46')][_0x2c87('0x42')]({'where':{'id':_0x45c544[_0x2c87('0x40')]['id']}})[_0x2c87('0x25')](handleEntityNotFound(_0x15f890,null))[_0x2c87('0x25')](removeEntity(_0x15f890,null))[_0x2c87('0x43')](handleError(_0x15f890,null));};exports[_0x2c87('0x4a')]=function(_0x4a712b,_0x149c7f,_0x1e96d2){_0x4a712b[_0x2c87('0x49')][_0x2c87('0x28')]=_0x4a712b[_0x2c87('0x4c')][_0x2c87('0x4d')];_0x4a712b[_0x2c87('0x49')]['basename']=_0x4a712b[_0x2c87('0x4c')][_0x2c87('0x4e')];_0x4a712b['body']['type']=_0x4a712b[_0x2c87('0x4c')][_0x2c87('0x4f')];return db[_0x2c87('0x46')]['create'](_0x4a712b['body'])[_0x2c87('0x25')](respondWithResult(_0x149c7f,0xc9))[_0x2c87('0x43')](handleError(_0x149c7f,null));};exports[_0x2c87('0x50')]=function(_0x2f110c,_0x159892,_0x1206d7){return db[_0x2c87('0x46')][_0x2c87('0x51')]({'where':{'id':_0x2f110c[_0x2c87('0x40')]['id']},'raw':!![]})[_0x2c87('0x25')](handleEntityNotFound(_0x159892,null))['then'](function(_0x4c6084){if(_0x4c6084){var _0x1950cc=_0x4c6084[_0x2c87('0x52')]!==null;var _0x2cdda0=path['join'](config[_0x2c87('0x53')],'server/files/attachments/');if(_0x1950cc){_0x2cdda0=path[_0x2c87('0x54')](_0x2cdda0,'offline-chat/');}var _0x4576c7=path[_0x2c87('0x54')](_0x2cdda0,_0x4c6084[_0x2c87('0x55')]);return _0x159892['download'](_0x4576c7);}})['catch'](handleError(_0x159892,null));};
\ No newline at end of file