Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / attachment / attachment.controller.js
index 23248a2..ae7b6d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcf5b=['filename','mimetype','download','ChatOfflineMessageId','root','join','basename','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','offset','undefined','limit','count','set','Content-Range','reject','update','destroy','then','end','sendStatus','error','stack','send','Attachment','rawAttributes','fieldName','type','model','name','query','keys','filters','intersection','attributes','length','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','show','params','fields','find','get','createdAt','updatedAt','body','omit','create','file','originalname'];(function(_0x2016d8,_0x100b3d){var _0xe519af=function(_0x585b14){while(--_0x585b14){_0x2016d8['push'](_0x2016d8['shift']());}};_0xe519af(++_0x100b3d);}(_0xcf5b,0xb3));var _0xbcf5=function(_0x5cb97e,_0x132a39){_0x5cb97e=_0x5cb97e-0x0;var _0x1714b4=_0xcf5b[_0x5cb97e];return _0x1714b4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbcf5('0x0'));var zipdir=require(_0xbcf5('0x1'));var jsonpatch=require(_0xbcf5('0x2'));var rp=require(_0xbcf5('0x3'));var moment=require(_0xbcf5('0x4'));var BPromise=require(_0xbcf5('0x5'));var Mustache=require(_0xbcf5('0x6'));var util=require(_0xbcf5('0x7'));var path=require(_0xbcf5('0x8'));var sox=require('sox');var csv=require(_0xbcf5('0x9'));var ejs=require(_0xbcf5('0xa'));var fs=require('fs');var fs_extra=require(_0xbcf5('0xb'));var _=require(_0xbcf5('0xc'));var squel=require('squel');var crypto=require(_0xbcf5('0xd'));var jsforce=require(_0xbcf5('0xe'));var deskjs=require(_0xbcf5('0xf'));var toCsv=require(_0xbcf5('0x9'));var querystring=require('querystring');var Papa=require(_0xbcf5('0x10'));var Redis=require('ioredis');var authService=require(_0xbcf5('0x11'));var qs=require(_0xbcf5('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbcf5('0x13'));var logger=require(_0xbcf5('0x14'))(_0xbcf5('0x15'));var utils=require(_0xbcf5('0x16'));var config=require(_0xbcf5('0x17'));var licenseUtil=require(_0xbcf5('0x18'));var db=require(_0xbcf5('0x19'))['db'];function respondWithStatusCode(_0x12c7e5,_0x524511){_0x524511=_0x524511||0xcc;return function(_0x363592){if(_0x363592){return _0x12c7e5['sendStatus'](_0x524511);}return _0x12c7e5[_0xbcf5('0x1a')](_0x524511)['end']();};}function respondWithResult(_0x20faf9,_0x37a832){_0x37a832=_0x37a832||0xc8;return function(_0xfdaa1c){if(_0xfdaa1c){return _0x20faf9[_0xbcf5('0x1a')](_0x37a832)[_0xbcf5('0x1b')](_0xfdaa1c);}};}function respondWithFilteredResult(_0x37bd31,_0x2757f5){return function(_0x3163f3){if(_0x3163f3){var _0x28e047=typeof _0x2757f5[_0xbcf5('0x1c')]===_0xbcf5('0x1d')&&typeof _0x2757f5[_0xbcf5('0x1e')]===_0xbcf5('0x1d');var _0x3562a9=_0x3163f3[_0xbcf5('0x1f')];var _0x19af52=_0x28e047?0x0:_0x2757f5[_0xbcf5('0x1c')];var _0x38b785=_0x28e047?_0x3163f3['count']:_0x2757f5[_0xbcf5('0x1c')]+_0x2757f5['limit'];var _0xaf0501;if(_0x38b785>=_0x3562a9){_0x38b785=_0x3562a9;_0xaf0501=0xc8;}else{_0xaf0501=0xce;}_0x37bd31['status'](_0xaf0501);return _0x37bd31[_0xbcf5('0x20')](_0xbcf5('0x21'),_0x19af52+'-'+_0x38b785+'/'+_0x3562a9)[_0xbcf5('0x1b')](_0x3163f3);}return null;};}function patchUpdates(_0x1e87d7){return function(_0x223f0b){try{jsonpatch['apply'](_0x223f0b,_0x1e87d7,!![]);}catch(_0x851ea4){return BPromise[_0xbcf5('0x22')](_0x851ea4);}return _0x223f0b['save']();};}function saveUpdates(_0x1c6e83,_0x3718d8){return function(_0x42c5cd){if(_0x42c5cd){return _0x42c5cd[_0xbcf5('0x23')](_0x1c6e83)['then'](function(_0x314db3){return _0x314db3;});}return null;};}function removeEntity(_0x33d480,_0x13d934){return function(_0x364407){if(_0x364407){return _0x364407[_0xbcf5('0x24')]()[_0xbcf5('0x25')](function(){_0x33d480[_0xbcf5('0x1a')](0xcc)[_0xbcf5('0x26')]();});}};}function handleEntityNotFound(_0x5565c7,_0x1dad81){return function(_0x51a2a4){if(!_0x51a2a4){_0x5565c7[_0xbcf5('0x27')](0x194);}return _0x51a2a4;};}function handleError(_0x3c3f45,_0x5367d0){_0x5367d0=_0x5367d0||0x1f4;return function(_0x1777d4){logger[_0xbcf5('0x28')](_0x1777d4[_0xbcf5('0x29')]);if(_0x1777d4['name']){delete _0x1777d4['name'];}_0x3c3f45['status'](_0x5367d0)[_0xbcf5('0x2a')](_0x1777d4);};}exports['index']=function(_0x256679,_0x2ee124){var _0x4c2c49={},_0x3b52fe={},_0x5e6beb={'count':0x0,'rows':[]};var _0x42e462=_['map'](db[_0xbcf5('0x2b')][_0xbcf5('0x2c')],function(_0x9f75e8){return{'name':_0x9f75e8[_0xbcf5('0x2d')],'type':_0x9f75e8[_0xbcf5('0x2e')]['key']};});_0x3b52fe[_0xbcf5('0x2f')]=_['map'](_0x42e462,_0xbcf5('0x30'));_0x3b52fe[_0xbcf5('0x31')]=_[_0xbcf5('0x32')](_0x256679[_0xbcf5('0x31')]);_0x3b52fe[_0xbcf5('0x33')]=_[_0xbcf5('0x34')](_0x3b52fe[_0xbcf5('0x2f')],_0x3b52fe[_0xbcf5('0x31')]);_0x4c2c49[_0xbcf5('0x35')]=_[_0xbcf5('0x34')](_0x3b52fe[_0xbcf5('0x2f')],qs['fields'](_0x256679[_0xbcf5('0x31')]['fields']));_0x4c2c49[_0xbcf5('0x35')]=_0x4c2c49[_0xbcf5('0x35')][_0xbcf5('0x36')]?_0x4c2c49[_0xbcf5('0x35')]:_0x3b52fe[_0xbcf5('0x2f')];if(!_0x256679['query']['hasOwnProperty']('nolimit')){_0x4c2c49[_0xbcf5('0x1e')]=qs['limit'](_0x256679[_0xbcf5('0x31')]['limit']);_0x4c2c49[_0xbcf5('0x1c')]=qs[_0xbcf5('0x1c')](_0x256679[_0xbcf5('0x31')][_0xbcf5('0x1c')]);}_0x4c2c49[_0xbcf5('0x37')]=qs['sort'](_0x256679['query'][_0xbcf5('0x38')]);_0x4c2c49[_0xbcf5('0x39')]=qs[_0xbcf5('0x33')](_[_0xbcf5('0x3a')](_0x256679[_0xbcf5('0x31')],_0x3b52fe['filters']),_0x42e462);if(_0x256679[_0xbcf5('0x31')][_0xbcf5('0x3b')]){_0x4c2c49['where']=_['merge'](_0x4c2c49[_0xbcf5('0x39')],{'$or':_['map'](_0x42e462,function(_0x4942eb){if(_0x4942eb[_0xbcf5('0x2e')]!=='VIRTUAL'){var _0x1b548d={};_0x1b548d[_0x4942eb[_0xbcf5('0x30')]]={'$like':'%'+_0x256679[_0xbcf5('0x31')][_0xbcf5('0x3b')]+'%'};return _0x1b548d;}})});}_0x4c2c49=_[_0xbcf5('0x3c')]({},_0x4c2c49,_0x256679[_0xbcf5('0x3d')]);var _0x564faa={'where':_0x4c2c49['where']};return db[_0xbcf5('0x2b')][_0xbcf5('0x1f')](_0x564faa)[_0xbcf5('0x25')](function(_0x25fa91){_0x5e6beb['count']=_0x25fa91;if(_0x256679[_0xbcf5('0x31')][_0xbcf5('0x3e')]){_0x4c2c49[_0xbcf5('0x3f')]=[{'all':!![]}];}return db[_0xbcf5('0x2b')][_0xbcf5('0x40')](_0x4c2c49);})['then'](function(_0xfce913){_0x5e6beb[_0xbcf5('0x41')]=_0xfce913;return _0x5e6beb;})['then'](respondWithFilteredResult(_0x2ee124,_0x4c2c49))[_0xbcf5('0x42')](handleError(_0x2ee124,null));};exports[_0xbcf5('0x43')]=function(_0x490959,_0x5b83b0){var _0x5a94f5={'raw':!![],'where':{'id':_0x490959[_0xbcf5('0x44')]['id']}},_0x4f4ff9={};_0x4f4ff9[_0xbcf5('0x2f')]=_[_0xbcf5('0x32')](db[_0xbcf5('0x2b')]['rawAttributes']);_0x4f4ff9['query']=_[_0xbcf5('0x32')](_0x490959[_0xbcf5('0x31')]);_0x4f4ff9[_0xbcf5('0x33')]=_[_0xbcf5('0x34')](_0x4f4ff9['model'],_0x4f4ff9[_0xbcf5('0x31')]);_0x5a94f5[_0xbcf5('0x35')]=_[_0xbcf5('0x34')](_0x4f4ff9[_0xbcf5('0x2f')],qs[_0xbcf5('0x45')](_0x490959[_0xbcf5('0x31')][_0xbcf5('0x45')]));_0x5a94f5[_0xbcf5('0x35')]=_0x5a94f5['attributes'][_0xbcf5('0x36')]?_0x5a94f5['attributes']:_0x4f4ff9[_0xbcf5('0x2f')];if(_0x490959[_0xbcf5('0x31')][_0xbcf5('0x3e')]){_0x5a94f5['include']=[{'all':!![]}];}_0x5a94f5=_[_0xbcf5('0x3c')]({},_0x5a94f5,_0x490959[_0xbcf5('0x3d')]);return db[_0xbcf5('0x2b')][_0xbcf5('0x46')](_0x5a94f5)[_0xbcf5('0x25')](handleEntityNotFound(_0x5b83b0,null))[_0xbcf5('0x25')](respondWithResult(_0x5b83b0,null))[_0xbcf5('0x42')](handleError(_0x5b83b0,null));};exports['clone']=function(_0x257bf3,_0x12ee26){var _0x338f4b={'where':{'id':_0x257bf3[_0xbcf5('0x44')]['id']}},_0x27106f={};_0x27106f[_0xbcf5('0x2f')]=_[_0xbcf5('0x32')](db[_0xbcf5('0x2b')][_0xbcf5('0x2c')]);_0x338f4b[_0xbcf5('0x35')]=_[_0xbcf5('0x34')](_0x27106f[_0xbcf5('0x2f')],qs[_0xbcf5('0x45')](_0x257bf3[_0xbcf5('0x31')]['fields']));_0x338f4b['attributes']=_0x338f4b['attributes'][_0xbcf5('0x36')]?_0x338f4b[_0xbcf5('0x35')]:_0x27106f['model'];if(_0x257bf3[_0xbcf5('0x31')][_0xbcf5('0x3e')]){_0x338f4b[_0xbcf5('0x3f')]=[{'all':!![]}];}_0x338f4b=_[_0xbcf5('0x3c')]({},_0x338f4b,_0x257bf3['options']);return db[_0xbcf5('0x2b')][_0xbcf5('0x46')](_0x338f4b)[_0xbcf5('0x25')](handleEntityNotFound(_0x12ee26,null))[_0xbcf5('0x25')](function(_0x2450ab){if(_0x2450ab){var _0x13ac85=_0x2450ab[_0xbcf5('0x47')]({'plain':!![]});_0x13ac85=qs['omit'](_0x13ac85,['id',_0xbcf5('0x48'),_0xbcf5('0x49')]);_0x257bf3[_0xbcf5('0x4a')]=_[_0xbcf5('0x4b')](_0x257bf3['body'],['id',_0xbcf5('0x48'),'updatedAt']);return db[_0xbcf5('0x2b')][_0xbcf5('0x4c')](_[_0xbcf5('0x3c')](_0x13ac85,_0x257bf3[_0xbcf5('0x4a')]),{'include':_0x257bf3[_0xbcf5('0x31')]['includeAll']?[{'all':!![]}]:undefined});}})[_0xbcf5('0x25')](respondWithResult(_0x12ee26,0xc9))[_0xbcf5('0x42')](handleError(_0x12ee26,null));};exports[_0xbcf5('0x23')]=function(_0x139fc2,_0x1f355b){if(_0x139fc2['body']['id']){delete _0x139fc2['body']['id'];}return db[_0xbcf5('0x2b')][_0xbcf5('0x46')]({'where':{'id':_0x139fc2['params']['id']}})[_0xbcf5('0x25')](handleEntityNotFound(_0x1f355b,null))[_0xbcf5('0x25')](saveUpdates(_0x139fc2[_0xbcf5('0x4a')],null))['then'](respondWithResult(_0x1f355b,null))['catch'](handleError(_0x1f355b,null));};exports[_0xbcf5('0x24')]=function(_0x28f0b1,_0x3040f5){return db['Attachment'][_0xbcf5('0x46')]({'where':{'id':_0x28f0b1['params']['id']}})[_0xbcf5('0x25')](handleEntityNotFound(_0x3040f5,null))[_0xbcf5('0x25')](removeEntity(_0x3040f5,null))[_0xbcf5('0x42')](handleError(_0x3040f5,null));};exports[_0xbcf5('0x4c')]=function(_0x704b5c,_0x775dba,_0xa2100){_0x704b5c[_0xbcf5('0x4a')]['name']=_0x704b5c[_0xbcf5('0x4d')][_0xbcf5('0x4e')];_0x704b5c[_0xbcf5('0x4a')]['basename']=_0x704b5c[_0xbcf5('0x4d')][_0xbcf5('0x4f')];_0x704b5c[_0xbcf5('0x4a')][_0xbcf5('0x2e')]=_0x704b5c[_0xbcf5('0x4d')][_0xbcf5('0x50')];return db[_0xbcf5('0x2b')]['create'](_0x704b5c[_0xbcf5('0x4a')])[_0xbcf5('0x25')](respondWithResult(_0x775dba,0xc9))[_0xbcf5('0x42')](handleError(_0x775dba,null));};exports[_0xbcf5('0x51')]=function(_0xd0c8e9,_0x452f15,_0x4f8134){return db[_0xbcf5('0x2b')]['findOne']({'where':{'id':_0xd0c8e9['params']['id']},'raw':!![]})[_0xbcf5('0x25')](handleEntityNotFound(_0x452f15,null))[_0xbcf5('0x25')](function(_0x8a4bd7){if(_0x8a4bd7){var _0x2f2d1f=_0x8a4bd7[_0xbcf5('0x52')]!==null;var _0x5efaee=path['join'](config[_0xbcf5('0x53')],'server/files/attachments/');if(_0x2f2d1f){_0x5efaee=path[_0xbcf5('0x54')](_0x5efaee,'offline-chat/');}var _0x1f5320=path[_0xbcf5('0x54')](_0x5efaee,_0x8a4bd7[_0xbcf5('0x55')]);return _0x452f15[_0xbcf5('0x51')](_0x1f5320);}})[_0xbcf5('0x42')](handleError(_0x452f15,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