Built motion from commit f16df95f.|2.5.40
[motion2.git] / server / api / attachment / attachment.controller.js
index 73eae2b..2f03614 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0b2=['zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','lodash','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','update','then','destroy','error','stack','name','send','index','map','Attachment','fieldName','type','key','model','keys','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','includeAll','include','findAll','catch','show','params','rawAttributes','merge','find','clone','options','get','omit','body','create','file','originalname','basename','filename','mimetype','download','findOne','join','root','server/files/attachments/','offline-chat/','eml-format','rimraf'];(function(_0x4a8c03,_0x3fe458){var _0x243608=function(_0x513803){while(--_0x513803){_0x4a8c03['push'](_0x4a8c03['shift']());}};_0x243608(++_0x3fe458);}(_0xb0b2,0xb4));var _0x2b0b=function(_0x5b39e6,_0x3f3d77){_0x5b39e6=_0x5b39e6-0x0;var _0x26709a=_0xb0b2[_0x5b39e6];return _0x26709a;};'use strict';var emlformat=require(_0x2b0b('0x0'));var rimraf=require(_0x2b0b('0x1'));var zipdir=require(_0x2b0b('0x2'));var jsonpatch=require(_0x2b0b('0x3'));var rp=require('request-promise');var moment=require(_0x2b0b('0x4'));var BPromise=require(_0x2b0b('0x5'));var Mustache=require(_0x2b0b('0x6'));var util=require(_0x2b0b('0x7'));var path=require(_0x2b0b('0x8'));var sox=require(_0x2b0b('0x9'));var csv=require(_0x2b0b('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x2b0b('0xb'));var squel=require('squel');var crypto=require(_0x2b0b('0xc'));var jsforce=require(_0x2b0b('0xd'));var deskjs=require(_0x2b0b('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x2b0b('0xf'));var Redis=require('ioredis');var authService=require(_0x2b0b('0x10'));var qs=require(_0x2b0b('0x11'));var as=require(_0x2b0b('0x12'));var hardwareService=require(_0x2b0b('0x13'));var logger=require(_0x2b0b('0x14'))(_0x2b0b('0x15'));var utils=require(_0x2b0b('0x16'));var config=require(_0x2b0b('0x17'));var licenseUtil=require(_0x2b0b('0x18'));var db=require(_0x2b0b('0x19'))['db'];function respondWithStatusCode(_0x31af67,_0x481fbc){_0x481fbc=_0x481fbc||0xcc;return function(_0x369cfb){if(_0x369cfb){return _0x31af67[_0x2b0b('0x1a')](_0x481fbc);}return _0x31af67['status'](_0x481fbc)[_0x2b0b('0x1b')]();};}function respondWithResult(_0x27f37c,_0x28be1c){_0x28be1c=_0x28be1c||0xc8;return function(_0x35ded5){if(_0x35ded5){return _0x27f37c[_0x2b0b('0x1c')](_0x28be1c)[_0x2b0b('0x1d')](_0x35ded5);}};}function respondWithFilteredResult(_0x134a26,_0x232247){return function(_0x639dd7){if(_0x639dd7){var _0x5b0a8b=typeof _0x232247[_0x2b0b('0x1e')]===_0x2b0b('0x1f')&&typeof _0x232247[_0x2b0b('0x20')]===_0x2b0b('0x1f');var _0x57443a=_0x639dd7[_0x2b0b('0x21')];var _0x2d7208=_0x5b0a8b?0x0:_0x232247[_0x2b0b('0x1e')];var _0x4933ce=_0x5b0a8b?_0x639dd7[_0x2b0b('0x21')]:_0x232247[_0x2b0b('0x1e')]+_0x232247[_0x2b0b('0x20')];var _0x1cdc9f;if(_0x4933ce>=_0x57443a){_0x4933ce=_0x57443a;_0x1cdc9f=0xc8;}else{_0x1cdc9f=0xce;}_0x134a26[_0x2b0b('0x1c')](_0x1cdc9f);return _0x134a26[_0x2b0b('0x22')](_0x2b0b('0x23'),_0x2d7208+'-'+_0x4933ce+'/'+_0x57443a)['json'](_0x639dd7);}return null;};}function patchUpdates(_0x337f1e){return function(_0x5e1e84){try{jsonpatch[_0x2b0b('0x24')](_0x5e1e84,_0x337f1e,!![]);}catch(_0x493183){return BPromise['reject'](_0x493183);}return _0x5e1e84['save']();};}function saveUpdates(_0x2c230c,_0x2dbde5){return function(_0x5b57e1){if(_0x5b57e1){return _0x5b57e1[_0x2b0b('0x25')](_0x2c230c)[_0x2b0b('0x26')](function(_0x615e8b){return _0x615e8b;});}return null;};}function removeEntity(_0x34a6f6,_0x5c1d0d){return function(_0x546392){if(_0x546392){return _0x546392[_0x2b0b('0x27')]()[_0x2b0b('0x26')](function(){_0x34a6f6[_0x2b0b('0x1c')](0xcc)[_0x2b0b('0x1b')]();});}};}function handleEntityNotFound(_0x35cd59,_0x51f58b){return function(_0x291194){if(!_0x291194){_0x35cd59[_0x2b0b('0x1a')](0x194);}return _0x291194;};}function handleError(_0x5af92f,_0x2e140f){_0x2e140f=_0x2e140f||0x1f4;return function(_0x2434a4){logger[_0x2b0b('0x28')](_0x2434a4[_0x2b0b('0x29')]);if(_0x2434a4['name']){delete _0x2434a4[_0x2b0b('0x2a')];}_0x5af92f['status'](_0x2e140f)[_0x2b0b('0x2b')](_0x2434a4);};}exports[_0x2b0b('0x2c')]=function(_0x118bbf,_0x453a53){var _0x302f0f={},_0x558774={},_0x3fdb4f={'count':0x0,'rows':[]};var _0x277153=_[_0x2b0b('0x2d')](db[_0x2b0b('0x2e')]['rawAttributes'],function(_0x2df8dc){return{'name':_0x2df8dc[_0x2b0b('0x2f')],'type':_0x2df8dc[_0x2b0b('0x30')][_0x2b0b('0x31')]};});_0x558774[_0x2b0b('0x32')]=_[_0x2b0b('0x2d')](_0x277153,_0x2b0b('0x2a'));_0x558774['query']=_[_0x2b0b('0x33')](_0x118bbf[_0x2b0b('0x34')]);_0x558774['filters']=_['intersection'](_0x558774[_0x2b0b('0x32')],_0x558774[_0x2b0b('0x34')]);_0x302f0f[_0x2b0b('0x35')]=_[_0x2b0b('0x36')](_0x558774[_0x2b0b('0x32')],qs[_0x2b0b('0x37')](_0x118bbf[_0x2b0b('0x34')][_0x2b0b('0x37')]));_0x302f0f[_0x2b0b('0x35')]=_0x302f0f['attributes'][_0x2b0b('0x38')]?_0x302f0f[_0x2b0b('0x35')]:_0x558774[_0x2b0b('0x32')];if(!_0x118bbf[_0x2b0b('0x34')][_0x2b0b('0x39')](_0x2b0b('0x3a'))){_0x302f0f[_0x2b0b('0x20')]=qs[_0x2b0b('0x20')](_0x118bbf[_0x2b0b('0x34')]['limit']);_0x302f0f[_0x2b0b('0x1e')]=qs[_0x2b0b('0x1e')](_0x118bbf[_0x2b0b('0x34')][_0x2b0b('0x1e')]);}_0x302f0f[_0x2b0b('0x3b')]=qs[_0x2b0b('0x3c')](_0x118bbf[_0x2b0b('0x34')][_0x2b0b('0x3c')]);_0x302f0f[_0x2b0b('0x3d')]=qs[_0x2b0b('0x3e')](_[_0x2b0b('0x3f')](_0x118bbf[_0x2b0b('0x34')],_0x558774[_0x2b0b('0x3e')]),_0x277153);if(_0x118bbf[_0x2b0b('0x34')][_0x2b0b('0x40')]){_0x302f0f[_0x2b0b('0x3d')]=_['merge'](_0x302f0f[_0x2b0b('0x3d')],{'$or':_[_0x2b0b('0x2d')](_0x277153,function(_0xc966f1){if(_0xc966f1[_0x2b0b('0x30')]!=='VIRTUAL'){var _0x30abe9={};_0x30abe9[_0xc966f1[_0x2b0b('0x2a')]]={'$like':'%'+_0x118bbf[_0x2b0b('0x34')]['filter']+'%'};return _0x30abe9;}})});}_0x302f0f=_['merge']({},_0x302f0f,_0x118bbf['options']);var _0xcd942c={'where':_0x302f0f[_0x2b0b('0x3d')]};return db[_0x2b0b('0x2e')]['count'](_0xcd942c)[_0x2b0b('0x26')](function(_0x6dd43e){_0x3fdb4f[_0x2b0b('0x21')]=_0x6dd43e;if(_0x118bbf['query'][_0x2b0b('0x41')]){_0x302f0f[_0x2b0b('0x42')]=[{'all':!![]}];}return db[_0x2b0b('0x2e')][_0x2b0b('0x43')](_0x302f0f);})[_0x2b0b('0x26')](function(_0x3d0b9f){_0x3fdb4f['rows']=_0x3d0b9f;return _0x3fdb4f;})[_0x2b0b('0x26')](respondWithFilteredResult(_0x453a53,_0x302f0f))[_0x2b0b('0x44')](handleError(_0x453a53,null));};exports[_0x2b0b('0x45')]=function(_0x3f0256,_0x375624){var _0x8ab93c={'raw':!![],'where':{'id':_0x3f0256[_0x2b0b('0x46')]['id']}},_0x19b5e8={};_0x19b5e8[_0x2b0b('0x32')]=_[_0x2b0b('0x33')](db['Attachment'][_0x2b0b('0x47')]);_0x19b5e8['query']=_[_0x2b0b('0x33')](_0x3f0256['query']);_0x19b5e8[_0x2b0b('0x3e')]=_[_0x2b0b('0x36')](_0x19b5e8['model'],_0x19b5e8[_0x2b0b('0x34')]);_0x8ab93c[_0x2b0b('0x35')]=_[_0x2b0b('0x36')](_0x19b5e8[_0x2b0b('0x32')],qs['fields'](_0x3f0256[_0x2b0b('0x34')][_0x2b0b('0x37')]));_0x8ab93c[_0x2b0b('0x35')]=_0x8ab93c[_0x2b0b('0x35')][_0x2b0b('0x38')]?_0x8ab93c[_0x2b0b('0x35')]:_0x19b5e8[_0x2b0b('0x32')];if(_0x3f0256['query']['includeAll']){_0x8ab93c[_0x2b0b('0x42')]=[{'all':!![]}];}_0x8ab93c=_[_0x2b0b('0x48')]({},_0x8ab93c,_0x3f0256['options']);return db[_0x2b0b('0x2e')][_0x2b0b('0x49')](_0x8ab93c)[_0x2b0b('0x26')](handleEntityNotFound(_0x375624,null))['then'](respondWithResult(_0x375624,null))[_0x2b0b('0x44')](handleError(_0x375624,null));};exports[_0x2b0b('0x4a')]=function(_0xc9a1d6,_0x26eae5){var _0x580982={'where':{'id':_0xc9a1d6[_0x2b0b('0x46')]['id']}},_0x6ae8d3={};_0x6ae8d3['model']=_[_0x2b0b('0x33')](db[_0x2b0b('0x2e')]['rawAttributes']);_0x580982['attributes']=_[_0x2b0b('0x36')](_0x6ae8d3[_0x2b0b('0x32')],qs['fields'](_0xc9a1d6[_0x2b0b('0x34')][_0x2b0b('0x37')]));_0x580982['attributes']=_0x580982['attributes'][_0x2b0b('0x38')]?_0x580982['attributes']:_0x6ae8d3[_0x2b0b('0x32')];if(_0xc9a1d6['query'][_0x2b0b('0x41')]){_0x580982[_0x2b0b('0x42')]=[{'all':!![]}];}_0x580982=_['merge']({},_0x580982,_0xc9a1d6[_0x2b0b('0x4b')]);return db['Attachment'][_0x2b0b('0x49')](_0x580982)['then'](handleEntityNotFound(_0x26eae5,null))[_0x2b0b('0x26')](function(_0x214bbd){if(_0x214bbd){var _0x213a7d=_0x214bbd[_0x2b0b('0x4c')]({'plain':!![]});_0x213a7d=qs[_0x2b0b('0x4d')](_0x213a7d,['id','createdAt','updatedAt']);_0xc9a1d6[_0x2b0b('0x4e')]=_['omit'](_0xc9a1d6[_0x2b0b('0x4e')],['id','createdAt','updatedAt']);return db['Attachment'][_0x2b0b('0x4f')](_[_0x2b0b('0x48')](_0x213a7d,_0xc9a1d6[_0x2b0b('0x4e')]),{'include':_0xc9a1d6[_0x2b0b('0x34')]['includeAll']?[{'all':!![]}]:undefined});}})['then'](respondWithResult(_0x26eae5,0xc9))['catch'](handleError(_0x26eae5,null));};exports[_0x2b0b('0x25')]=function(_0x4ca0b4,_0x2864a9){if(_0x4ca0b4['body']['id']){delete _0x4ca0b4[_0x2b0b('0x4e')]['id'];}return db['Attachment']['find']({'where':{'id':_0x4ca0b4[_0x2b0b('0x46')]['id']}})['then'](handleEntityNotFound(_0x2864a9,null))[_0x2b0b('0x26')](saveUpdates(_0x4ca0b4[_0x2b0b('0x4e')],null))['then'](respondWithResult(_0x2864a9,null))['catch'](handleError(_0x2864a9,null));};exports[_0x2b0b('0x27')]=function(_0x41d150,_0x4bdbcd){return db[_0x2b0b('0x2e')][_0x2b0b('0x49')]({'where':{'id':_0x41d150[_0x2b0b('0x46')]['id']}})[_0x2b0b('0x26')](handleEntityNotFound(_0x4bdbcd,null))[_0x2b0b('0x26')](removeEntity(_0x4bdbcd,null))[_0x2b0b('0x44')](handleError(_0x4bdbcd,null));};exports[_0x2b0b('0x4f')]=function(_0xa11432,_0x58e11f,_0x2d6418){_0xa11432[_0x2b0b('0x4e')][_0x2b0b('0x2a')]=_0xa11432[_0x2b0b('0x50')][_0x2b0b('0x51')];_0xa11432[_0x2b0b('0x4e')][_0x2b0b('0x52')]=_0xa11432[_0x2b0b('0x50')][_0x2b0b('0x53')];_0xa11432[_0x2b0b('0x4e')][_0x2b0b('0x30')]=_0xa11432['file'][_0x2b0b('0x54')];return db['Attachment'][_0x2b0b('0x4f')](_0xa11432['body'])[_0x2b0b('0x26')](respondWithResult(_0x58e11f,0xc9))['catch'](handleError(_0x58e11f,null));};exports[_0x2b0b('0x55')]=function(_0x1ff537,_0x82758a,_0x4cb996){return db[_0x2b0b('0x2e')][_0x2b0b('0x56')]({'where':{'id':_0x1ff537[_0x2b0b('0x46')]['id']},'raw':!![]})[_0x2b0b('0x26')](handleEntityNotFound(_0x82758a,null))['then'](function(_0x24a216){if(_0x24a216){var _0x224ccc=_0x24a216['ChatOfflineMessageId']!==null;var _0x24616d=path[_0x2b0b('0x57')](config[_0x2b0b('0x58')],_0x2b0b('0x59'));if(_0x224ccc){_0x24616d=path['join'](_0x24616d,_0x2b0b('0x5a'));}var _0x40bf3e=path[_0x2b0b('0x57')](_0x24616d,_0x24a216['basename']);return _0x82758a[_0x2b0b('0x55')](_0x40bf3e);}})['catch'](handleError(_0x82758a,null));};
\ No newline at end of file
+var _0xf064=['json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','sendStatus','error','name','send','index','map','Attachment','fieldName','type','model','filters','query','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','show','params','keys','rawAttributes','find','catch','clone','includeAll','omit','body','updatedAt','create','destroy','basename','file','filename','download','join','root','server/files/attachments/','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','fs-extra','lodash','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','end','status'];(function(_0x453327,_0x3ebe4a){var _0x1d5a70=function(_0x1ff3d3){while(--_0x1ff3d3){_0x453327['push'](_0x453327['shift']());}};_0x1d5a70(++_0x3ebe4a);}(_0xf064,0xe3));var _0x4f06=function(_0x4f9b18,_0x2cb5ca){_0x4f9b18=_0x4f9b18-0x0;var _0x29f20c=_0xf064[_0x4f9b18];return _0x29f20c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x4f06('0x0'));var zipdir=require(_0x4f06('0x1'));var jsonpatch=require(_0x4f06('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x4f06('0x3'));var Mustache=require(_0x4f06('0x4'));var util=require(_0x4f06('0x5'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4f06('0x6'));var _=require(_0x4f06('0x7'));var squel=require('squel');var crypto=require(_0x4f06('0x8'));var jsforce=require(_0x4f06('0x9'));var deskjs=require('desk.js');var toCsv=require(_0x4f06('0xa'));var querystring=require(_0x4f06('0xb'));var Papa=require(_0x4f06('0xc'));var Redis=require(_0x4f06('0xd'));var authService=require(_0x4f06('0xe'));var qs=require(_0x4f06('0xf'));var as=require(_0x4f06('0x10'));var hardwareService=require(_0x4f06('0x11'));var logger=require(_0x4f06('0x12'))(_0x4f06('0x13'));var utils=require('../../config/utils');var config=require(_0x4f06('0x14'));var licenseUtil=require(_0x4f06('0x15'));var db=require(_0x4f06('0x16'))['db'];function respondWithStatusCode(_0x4c277b,_0x9d5a99){_0x9d5a99=_0x9d5a99||0xcc;return function(_0x1aabbc){if(_0x1aabbc){return _0x4c277b['sendStatus'](_0x9d5a99);}return _0x4c277b['status'](_0x9d5a99)[_0x4f06('0x17')]();};}function respondWithResult(_0x216966,_0x18af74){_0x18af74=_0x18af74||0xc8;return function(_0x53a6b4){if(_0x53a6b4){return _0x216966[_0x4f06('0x18')](_0x18af74)[_0x4f06('0x19')](_0x53a6b4);}};}function respondWithFilteredResult(_0x31253a,_0x4e68a5){return function(_0x503d0a){if(_0x503d0a){var _0x7585d=typeof _0x4e68a5[_0x4f06('0x1a')]===_0x4f06('0x1b')&&typeof _0x4e68a5['limit']===_0x4f06('0x1b');var _0x32ac25=_0x503d0a[_0x4f06('0x1c')];var _0x2a3a4e=_0x7585d?0x0:_0x4e68a5['offset'];var _0x59bfab=_0x7585d?_0x503d0a['count']:_0x4e68a5['offset']+_0x4e68a5[_0x4f06('0x1d')];var _0x213cd4;if(_0x59bfab>=_0x32ac25){_0x59bfab=_0x32ac25;_0x213cd4=0xc8;}else{_0x213cd4=0xce;}_0x31253a[_0x4f06('0x18')](_0x213cd4);return _0x31253a[_0x4f06('0x1e')](_0x4f06('0x1f'),_0x2a3a4e+'-'+_0x59bfab+'/'+_0x32ac25)[_0x4f06('0x19')](_0x503d0a);}return null;};}function patchUpdates(_0x7ee837){return function(_0x52cc14){try{jsonpatch[_0x4f06('0x20')](_0x52cc14,_0x7ee837,!![]);}catch(_0x3b06ee){return BPromise[_0x4f06('0x21')](_0x3b06ee);}return _0x52cc14[_0x4f06('0x22')]();};}function saveUpdates(_0x23aa82,_0x36448a){return function(_0xc58205){if(_0xc58205){return _0xc58205[_0x4f06('0x23')](_0x23aa82)[_0x4f06('0x24')](function(_0x376dfa){return _0x376dfa;});}return null;};}function removeEntity(_0x51824e,_0x4ff237){return function(_0x23a339){if(_0x23a339){return _0x23a339['destroy']()['then'](function(){_0x51824e[_0x4f06('0x18')](0xcc)[_0x4f06('0x17')]();});}};}function handleEntityNotFound(_0x4a584e,_0x424c57){return function(_0x16d610){if(!_0x16d610){_0x4a584e[_0x4f06('0x25')](0x194);}return _0x16d610;};}function handleError(_0x4a36ef,_0x3fddf8){_0x3fddf8=_0x3fddf8||0x1f4;return function(_0x378e21){logger[_0x4f06('0x26')](_0x378e21['stack']);if(_0x378e21[_0x4f06('0x27')]){delete _0x378e21['name'];}_0x4a36ef['status'](_0x3fddf8)[_0x4f06('0x28')](_0x378e21);};}exports[_0x4f06('0x29')]=function(_0x50a8c9,_0x4007dc){var _0x16a7e5={},_0x1b3338={},_0x474bb4={'count':0x0,'rows':[]};var _0x3e4018=_[_0x4f06('0x2a')](db[_0x4f06('0x2b')]['rawAttributes'],function(_0x5f2307){return{'name':_0x5f2307[_0x4f06('0x2c')],'type':_0x5f2307[_0x4f06('0x2d')]['key']};});_0x1b3338[_0x4f06('0x2e')]=_[_0x4f06('0x2a')](_0x3e4018,_0x4f06('0x27'));_0x1b3338['query']=_['keys'](_0x50a8c9['query']);_0x1b3338[_0x4f06('0x2f')]=_['intersection'](_0x1b3338[_0x4f06('0x2e')],_0x1b3338[_0x4f06('0x30')]);_0x16a7e5[_0x4f06('0x31')]=_[_0x4f06('0x32')](_0x1b3338[_0x4f06('0x2e')],qs[_0x4f06('0x33')](_0x50a8c9[_0x4f06('0x30')][_0x4f06('0x33')]));_0x16a7e5['attributes']=_0x16a7e5[_0x4f06('0x31')][_0x4f06('0x34')]?_0x16a7e5[_0x4f06('0x31')]:_0x1b3338[_0x4f06('0x2e')];if(!_0x50a8c9[_0x4f06('0x30')]['hasOwnProperty'](_0x4f06('0x35'))){_0x16a7e5[_0x4f06('0x1d')]=qs[_0x4f06('0x1d')](_0x50a8c9[_0x4f06('0x30')][_0x4f06('0x1d')]);_0x16a7e5[_0x4f06('0x1a')]=qs[_0x4f06('0x1a')](_0x50a8c9['query']['offset']);}_0x16a7e5[_0x4f06('0x36')]=qs[_0x4f06('0x37')](_0x50a8c9['query'][_0x4f06('0x37')]);_0x16a7e5[_0x4f06('0x38')]=qs[_0x4f06('0x2f')](_[_0x4f06('0x39')](_0x50a8c9[_0x4f06('0x30')],_0x1b3338[_0x4f06('0x2f')]),_0x3e4018);if(_0x50a8c9[_0x4f06('0x30')][_0x4f06('0x3a')]){_0x16a7e5['where']=_[_0x4f06('0x3b')](_0x16a7e5[_0x4f06('0x38')],{'$or':_[_0x4f06('0x2a')](_0x3e4018,function(_0xecbaf1){if(_0xecbaf1[_0x4f06('0x2d')]!==_0x4f06('0x3c')){var _0x92775e={};_0x92775e[_0xecbaf1[_0x4f06('0x27')]]={'$like':'%'+_0x50a8c9['query']['filter']+'%'};return _0x92775e;}})});}_0x16a7e5=_[_0x4f06('0x3b')]({},_0x16a7e5,_0x50a8c9[_0x4f06('0x3d')]);var _0x3a95e7={'where':_0x16a7e5[_0x4f06('0x38')]};return db[_0x4f06('0x2b')][_0x4f06('0x1c')](_0x3a95e7)[_0x4f06('0x24')](function(_0x14c7ca){_0x474bb4['count']=_0x14c7ca;if(_0x50a8c9[_0x4f06('0x30')]['includeAll']){_0x16a7e5[_0x4f06('0x3e')]=[{'all':!![]}];}return db[_0x4f06('0x2b')][_0x4f06('0x3f')](_0x16a7e5);})[_0x4f06('0x24')](function(_0x3c088d){_0x474bb4['rows']=_0x3c088d;return _0x474bb4;})[_0x4f06('0x24')](respondWithFilteredResult(_0x4007dc,_0x16a7e5))['catch'](handleError(_0x4007dc,null));};exports[_0x4f06('0x40')]=function(_0x1bd764,_0x3120cd){var _0xe64a5c={'raw':!![],'where':{'id':_0x1bd764[_0x4f06('0x41')]['id']}},_0x6d01e={};_0x6d01e[_0x4f06('0x2e')]=_[_0x4f06('0x42')](db[_0x4f06('0x2b')][_0x4f06('0x43')]);_0x6d01e['query']=_['keys'](_0x1bd764[_0x4f06('0x30')]);_0x6d01e['filters']=_[_0x4f06('0x32')](_0x6d01e[_0x4f06('0x2e')],_0x6d01e['query']);_0xe64a5c[_0x4f06('0x31')]=_['intersection'](_0x6d01e[_0x4f06('0x2e')],qs['fields'](_0x1bd764[_0x4f06('0x30')][_0x4f06('0x33')]));_0xe64a5c['attributes']=_0xe64a5c[_0x4f06('0x31')]['length']?_0xe64a5c[_0x4f06('0x31')]:_0x6d01e[_0x4f06('0x2e')];if(_0x1bd764['query']['includeAll']){_0xe64a5c['include']=[{'all':!![]}];}_0xe64a5c=_[_0x4f06('0x3b')]({},_0xe64a5c,_0x1bd764[_0x4f06('0x3d')]);return db[_0x4f06('0x2b')][_0x4f06('0x44')](_0xe64a5c)['then'](handleEntityNotFound(_0x3120cd,null))[_0x4f06('0x24')](respondWithResult(_0x3120cd,null))[_0x4f06('0x45')](handleError(_0x3120cd,null));};exports[_0x4f06('0x46')]=function(_0xb2ca82,_0x434826){var _0x32f6bf={'where':{'id':_0xb2ca82['params']['id']}},_0x530baa={};_0x530baa[_0x4f06('0x2e')]=_['keys'](db['Attachment']['rawAttributes']);_0x32f6bf[_0x4f06('0x31')]=_[_0x4f06('0x32')](_0x530baa[_0x4f06('0x2e')],qs[_0x4f06('0x33')](_0xb2ca82[_0x4f06('0x30')][_0x4f06('0x33')]));_0x32f6bf[_0x4f06('0x31')]=_0x32f6bf[_0x4f06('0x31')][_0x4f06('0x34')]?_0x32f6bf[_0x4f06('0x31')]:_0x530baa['model'];if(_0xb2ca82[_0x4f06('0x30')][_0x4f06('0x47')]){_0x32f6bf[_0x4f06('0x3e')]=[{'all':!![]}];}_0x32f6bf=_[_0x4f06('0x3b')]({},_0x32f6bf,_0xb2ca82[_0x4f06('0x3d')]);return db[_0x4f06('0x2b')][_0x4f06('0x44')](_0x32f6bf)[_0x4f06('0x24')](handleEntityNotFound(_0x434826,null))['then'](function(_0x302158){if(_0x302158){var _0x256aa0=_0x302158['get']({'plain':!![]});_0x256aa0=qs[_0x4f06('0x48')](_0x256aa0,['id','createdAt','updatedAt']);_0xb2ca82[_0x4f06('0x49')]=_[_0x4f06('0x48')](_0xb2ca82[_0x4f06('0x49')],['id','createdAt',_0x4f06('0x4a')]);return db[_0x4f06('0x2b')][_0x4f06('0x4b')](_['merge'](_0x256aa0,_0xb2ca82[_0x4f06('0x49')]),{'include':_0xb2ca82[_0x4f06('0x30')][_0x4f06('0x47')]?[{'all':!![]}]:undefined});}})['then'](respondWithResult(_0x434826,0xc9))[_0x4f06('0x45')](handleError(_0x434826,null));};exports[_0x4f06('0x23')]=function(_0xe5044,_0x402ad2){if(_0xe5044['body']['id']){delete _0xe5044[_0x4f06('0x49')]['id'];}return db['Attachment']['find']({'where':{'id':_0xe5044[_0x4f06('0x41')]['id']}})[_0x4f06('0x24')](handleEntityNotFound(_0x402ad2,null))[_0x4f06('0x24')](saveUpdates(_0xe5044['body'],null))[_0x4f06('0x24')](respondWithResult(_0x402ad2,null))['catch'](handleError(_0x402ad2,null));};exports[_0x4f06('0x4c')]=function(_0x418d3d,_0x2d4ca0){return db[_0x4f06('0x2b')]['find']({'where':{'id':_0x418d3d[_0x4f06('0x41')]['id']}})['then'](handleEntityNotFound(_0x2d4ca0,null))['then'](removeEntity(_0x2d4ca0,null))[_0x4f06('0x45')](handleError(_0x2d4ca0,null));};exports['create']=function(_0x3b546b,_0xbb6901,_0x4f8988){_0x3b546b[_0x4f06('0x49')][_0x4f06('0x27')]=_0x3b546b['file']['originalname'];_0x3b546b[_0x4f06('0x49')][_0x4f06('0x4d')]=_0x3b546b[_0x4f06('0x4e')][_0x4f06('0x4f')];_0x3b546b['body'][_0x4f06('0x2d')]=_0x3b546b[_0x4f06('0x4e')]['mimetype'];return db['Attachment'][_0x4f06('0x4b')](_0x3b546b[_0x4f06('0x49')])[_0x4f06('0x24')](respondWithResult(_0xbb6901,0xc9))[_0x4f06('0x45')](handleError(_0xbb6901,null));};exports[_0x4f06('0x50')]=function(_0xbdc4ec,_0x405a6c,_0x9961f3){return db['Attachment']['findOne']({'where':{'id':_0xbdc4ec[_0x4f06('0x41')]['id']},'raw':!![]})[_0x4f06('0x24')](handleEntityNotFound(_0x405a6c,null))[_0x4f06('0x24')](function(_0x326db8){if(_0x326db8){var _0x5e16be=_0x326db8['ChatOfflineMessageId']!==null;var _0x94f082=path[_0x4f06('0x51')](config[_0x4f06('0x52')],_0x4f06('0x53'));if(_0x5e16be){_0x94f082=path[_0x4f06('0x51')](_0x94f082,'offline-chat/');}var _0x1d8a92=path[_0x4f06('0x51')](_0x94f082,_0x326db8[_0x4f06('0x4d')]);return _0x405a6c[_0x4f06('0x50')](_0x1d8a92);}})[_0x4f06('0x45')](handleError(_0x405a6c,null));};
\ No newline at end of file