Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / attachment / attachment.controller.js
index 4b022c7..bf69dec 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6b8e=['../../config/license/util','status','end','count','offset','limit','set','Content-Range','json','apply','reject','save','update','then','sendStatus','error','stack','name','index','map','Attachment','rawAttributes','type','model','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','include','rows','catch','params','includeAll','options','find','get','omit','updatedAt','body','createdAt','create','destroy','file','originalname','basename','filename','mimetype','download','findOne','join','server/files/attachments/','html-pdf','rimraf','zip-dir','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x320537,_0x58e3f5){var _0x1a213a=function(_0x469509){while(--_0x469509){_0x320537['push'](_0x320537['shift']());}};_0x1a213a(++_0x58e3f5);}(_0x6b8e,0x92));var _0xe6b8=function(_0x372bd9,_0x2d5ef1){_0x372bd9=_0x372bd9-0x0;var _0x914906=_0x6b8e[_0x372bd9];return _0x914906;};'use strict';var pdf=require(_0xe6b8('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xe6b8('0x1'));var zipdir=require(_0xe6b8('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xe6b8('0x3'));var Mustache=require(_0xe6b8('0x4'));var util=require(_0xe6b8('0x5'));var path=require(_0xe6b8('0x6'));var sox=require(_0xe6b8('0x7'));var csv=require(_0xe6b8('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xe6b8('0x9'));var squel=require(_0xe6b8('0xa'));var crypto=require(_0xe6b8('0xb'));var jsforce=require(_0xe6b8('0xc'));var deskjs=require(_0xe6b8('0xd'));var toCsv=require(_0xe6b8('0x8'));var querystring=require(_0xe6b8('0xe'));var Papa=require(_0xe6b8('0xf'));var Redis=require(_0xe6b8('0x10'));var authService=require(_0xe6b8('0x11'));var qs=require(_0xe6b8('0x12'));var as=require(_0xe6b8('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xe6b8('0x14'))(_0xe6b8('0x15'));var utils=require(_0xe6b8('0x16'));var config=require(_0xe6b8('0x17'));var licenseUtil=require(_0xe6b8('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3e6cf6,_0x503993){_0x503993=_0x503993||0xcc;return function(_0x3f1c3a){if(_0x3f1c3a){return _0x3e6cf6['sendStatus'](_0x503993);}return _0x3e6cf6[_0xe6b8('0x19')](_0x503993)[_0xe6b8('0x1a')]();};}function respondWithResult(_0x27ac4a,_0x2024d0){_0x2024d0=_0x2024d0||0xc8;return function(_0x1c2752){if(_0x1c2752){return _0x27ac4a[_0xe6b8('0x19')](_0x2024d0)['json'](_0x1c2752);}};}function respondWithFilteredResult(_0x3fcbe9,_0x16a66d){return function(_0xc7a790){if(_0xc7a790){var _0x13aa38=_0xc7a790[_0xe6b8('0x1b')],_0x1f559d=_0x16a66d[_0xe6b8('0x1c')],_0x525fd8=_0x16a66d[_0xe6b8('0x1c')]+_0x16a66d[_0xe6b8('0x1d')],_0x3e11cc;if(_0x525fd8>=_0x13aa38){_0x525fd8=_0x13aa38;_0x3e11cc=0xc8;}else{_0x3e11cc=0xce;}_0x3fcbe9[_0xe6b8('0x19')](_0x3e11cc);return _0x3fcbe9[_0xe6b8('0x1e')](_0xe6b8('0x1f'),_0x1f559d+'-'+_0x525fd8+'/'+_0x13aa38)[_0xe6b8('0x20')](_0xc7a790);}return null;};}function patchUpdates(_0x27f3ed){return function(_0x3da98c){try{jsonpatch[_0xe6b8('0x21')](_0x3da98c,_0x27f3ed,!![]);}catch(_0x31cc9b){return BPromise[_0xe6b8('0x22')](_0x31cc9b);}return _0x3da98c[_0xe6b8('0x23')]();};}function saveUpdates(_0x103756,_0x4e8801){return function(_0x2df8eb){if(_0x2df8eb){return _0x2df8eb[_0xe6b8('0x24')](_0x103756)[_0xe6b8('0x25')](function(_0x1ffdf6){return _0x1ffdf6;});}return null;};}function removeEntity(_0x11e6c0,_0x18220a){return function(_0xf485ca){if(_0xf485ca){return _0xf485ca['destroy']()[_0xe6b8('0x25')](function(){_0x11e6c0[_0xe6b8('0x19')](0xcc)[_0xe6b8('0x1a')]();});}};}function handleEntityNotFound(_0x125f0e,_0x53eda1){return function(_0x389740){if(!_0x389740){_0x125f0e[_0xe6b8('0x26')](0x194);}return _0x389740;};}function handleError(_0x1b71b4,_0x4a3b9f){_0x4a3b9f=_0x4a3b9f||0x1f4;return function(_0x560dcf){logger[_0xe6b8('0x27')](_0x560dcf[_0xe6b8('0x28')]);if(_0x560dcf['name']){delete _0x560dcf[_0xe6b8('0x29')];}_0x1b71b4[_0xe6b8('0x19')](_0x4a3b9f)['send'](_0x560dcf);};}exports[_0xe6b8('0x2a')]=function(_0x251a36,_0x356582){var _0x514fc2={},_0x8d55da={},_0x488f72={'count':0x0,'rows':[]};var _0x2b458e=_[_0xe6b8('0x2b')](db[_0xe6b8('0x2c')][_0xe6b8('0x2d')],function(_0x233270){return{'name':_0x233270['fieldName'],'type':_0x233270[_0xe6b8('0x2e')]['key']};});_0x8d55da[_0xe6b8('0x2f')]=_['map'](_0x2b458e,_0xe6b8('0x29'));_0x8d55da['query']=_[_0xe6b8('0x30')](_0x251a36[_0xe6b8('0x31')]);_0x8d55da[_0xe6b8('0x32')]=_[_0xe6b8('0x33')](_0x8d55da['model'],_0x8d55da[_0xe6b8('0x31')]);_0x514fc2[_0xe6b8('0x34')]=_[_0xe6b8('0x33')](_0x8d55da[_0xe6b8('0x2f')],qs[_0xe6b8('0x35')](_0x251a36[_0xe6b8('0x31')][_0xe6b8('0x35')]));_0x514fc2[_0xe6b8('0x34')]=_0x514fc2[_0xe6b8('0x34')][_0xe6b8('0x36')]?_0x514fc2[_0xe6b8('0x34')]:_0x8d55da[_0xe6b8('0x2f')];if(!_0x251a36['query']['hasOwnProperty'](_0xe6b8('0x37'))){_0x514fc2['limit']=qs['limit'](_0x251a36[_0xe6b8('0x31')][_0xe6b8('0x1d')]);_0x514fc2[_0xe6b8('0x1c')]=qs[_0xe6b8('0x1c')](_0x251a36[_0xe6b8('0x31')][_0xe6b8('0x1c')]);}_0x514fc2[_0xe6b8('0x38')]=qs[_0xe6b8('0x39')](_0x251a36['query'][_0xe6b8('0x39')]);_0x514fc2[_0xe6b8('0x3a')]=qs['filters'](_[_0xe6b8('0x3b')](_0x251a36['query'],_0x8d55da['filters']),_0x2b458e);if(_0x251a36['query'][_0xe6b8('0x3c')]){_0x514fc2[_0xe6b8('0x3a')]=_['merge'](_0x514fc2[_0xe6b8('0x3a')],{'$or':_[_0xe6b8('0x2b')](_0x2b458e,function(_0x161e84){if(_0x161e84[_0xe6b8('0x2e')]!=='VIRTUAL'){var _0x2912f0={};_0x2912f0[_0x161e84[_0xe6b8('0x29')]]={'$like':'%'+_0x251a36[_0xe6b8('0x31')][_0xe6b8('0x3c')]+'%'};return _0x2912f0;}})});}_0x514fc2=_[_0xe6b8('0x3d')]({},_0x514fc2,_0x251a36['options']);var _0x1c24d1={'where':_0x514fc2[_0xe6b8('0x3a')]};return db[_0xe6b8('0x2c')][_0xe6b8('0x1b')](_0x1c24d1)[_0xe6b8('0x25')](function(_0x457943){_0x488f72[_0xe6b8('0x1b')]=_0x457943;if(_0x251a36[_0xe6b8('0x31')]['includeAll']){_0x514fc2[_0xe6b8('0x3e')]=[{'all':!![]}];}return db[_0xe6b8('0x2c')]['findAll'](_0x514fc2);})[_0xe6b8('0x25')](function(_0x1abdbd){_0x488f72[_0xe6b8('0x3f')]=_0x1abdbd;return _0x488f72;})['then'](respondWithFilteredResult(_0x356582,_0x514fc2))[_0xe6b8('0x40')](handleError(_0x356582,null));};exports['show']=function(_0x3801b7,_0x3084cb){var _0x3be54d={'raw':!![],'where':{'id':_0x3801b7[_0xe6b8('0x41')]['id']}},_0xf989bb={};_0xf989bb[_0xe6b8('0x2f')]=_['keys'](db[_0xe6b8('0x2c')][_0xe6b8('0x2d')]);_0xf989bb[_0xe6b8('0x31')]=_[_0xe6b8('0x30')](_0x3801b7[_0xe6b8('0x31')]);_0xf989bb[_0xe6b8('0x32')]=_[_0xe6b8('0x33')](_0xf989bb[_0xe6b8('0x2f')],_0xf989bb[_0xe6b8('0x31')]);_0x3be54d['attributes']=_[_0xe6b8('0x33')](_0xf989bb[_0xe6b8('0x2f')],qs[_0xe6b8('0x35')](_0x3801b7[_0xe6b8('0x31')][_0xe6b8('0x35')]));_0x3be54d[_0xe6b8('0x34')]=_0x3be54d[_0xe6b8('0x34')][_0xe6b8('0x36')]?_0x3be54d[_0xe6b8('0x34')]:_0xf989bb[_0xe6b8('0x2f')];if(_0x3801b7[_0xe6b8('0x31')][_0xe6b8('0x42')]){_0x3be54d[_0xe6b8('0x3e')]=[{'all':!![]}];}_0x3be54d=_[_0xe6b8('0x3d')]({},_0x3be54d,_0x3801b7['options']);return db[_0xe6b8('0x2c')]['find'](_0x3be54d)['then'](handleEntityNotFound(_0x3084cb,null))[_0xe6b8('0x25')](respondWithResult(_0x3084cb,null))[_0xe6b8('0x40')](handleError(_0x3084cb,null));};exports['clone']=function(_0x413aee,_0x5e58fb){var _0x6c7120={'where':{'id':_0x413aee['params']['id']}},_0x488d16={};_0x488d16['model']=_['keys'](db[_0xe6b8('0x2c')][_0xe6b8('0x2d')]);_0x6c7120[_0xe6b8('0x34')]=_[_0xe6b8('0x33')](_0x488d16[_0xe6b8('0x2f')],qs[_0xe6b8('0x35')](_0x413aee['query'][_0xe6b8('0x35')]));_0x6c7120[_0xe6b8('0x34')]=_0x6c7120[_0xe6b8('0x34')][_0xe6b8('0x36')]?_0x6c7120[_0xe6b8('0x34')]:_0x488d16[_0xe6b8('0x2f')];if(_0x413aee[_0xe6b8('0x31')][_0xe6b8('0x42')]){_0x6c7120[_0xe6b8('0x3e')]=[{'all':!![]}];}_0x6c7120=_['merge']({},_0x6c7120,_0x413aee[_0xe6b8('0x43')]);return db[_0xe6b8('0x2c')][_0xe6b8('0x44')](_0x6c7120)[_0xe6b8('0x25')](handleEntityNotFound(_0x5e58fb,null))[_0xe6b8('0x25')](function(_0x5f1b97){if(_0x5f1b97){var _0x85db1f=_0x5f1b97[_0xe6b8('0x45')]({'plain':!![]});_0x85db1f=qs[_0xe6b8('0x46')](_0x85db1f,['id','createdAt',_0xe6b8('0x47')]);_0x413aee[_0xe6b8('0x48')]=_[_0xe6b8('0x46')](_0x413aee['body'],['id',_0xe6b8('0x49'),_0xe6b8('0x47')]);return db[_0xe6b8('0x2c')][_0xe6b8('0x4a')](_[_0xe6b8('0x3d')](_0x85db1f,_0x413aee['body']),{'include':_0x413aee[_0xe6b8('0x31')][_0xe6b8('0x42')]?[{'all':!![]}]:undefined});}})[_0xe6b8('0x25')](respondWithResult(_0x5e58fb,0xc9))['catch'](handleError(_0x5e58fb,null));};exports[_0xe6b8('0x24')]=function(_0x4c0461,_0x32ed45){if(_0x4c0461['body']['id']){delete _0x4c0461[_0xe6b8('0x48')]['id'];}return db[_0xe6b8('0x2c')][_0xe6b8('0x44')]({'where':{'id':_0x4c0461[_0xe6b8('0x41')]['id']}})[_0xe6b8('0x25')](handleEntityNotFound(_0x32ed45,null))[_0xe6b8('0x25')](saveUpdates(_0x4c0461[_0xe6b8('0x48')],null))[_0xe6b8('0x25')](respondWithResult(_0x32ed45,null))[_0xe6b8('0x40')](handleError(_0x32ed45,null));};exports[_0xe6b8('0x4b')]=function(_0x3f60d1,_0x1ec879){return db[_0xe6b8('0x2c')]['find']({'where':{'id':_0x3f60d1[_0xe6b8('0x41')]['id']}})[_0xe6b8('0x25')](handleEntityNotFound(_0x1ec879,null))[_0xe6b8('0x25')](removeEntity(_0x1ec879,null))[_0xe6b8('0x40')](handleError(_0x1ec879,null));};exports[_0xe6b8('0x4a')]=function(_0x4c084f,_0x298977,_0xd63ef2){_0x4c084f['body'][_0xe6b8('0x29')]=_0x4c084f[_0xe6b8('0x4c')][_0xe6b8('0x4d')];_0x4c084f[_0xe6b8('0x48')][_0xe6b8('0x4e')]=_0x4c084f[_0xe6b8('0x4c')][_0xe6b8('0x4f')];_0x4c084f[_0xe6b8('0x48')]['type']=_0x4c084f['file'][_0xe6b8('0x50')];return db['Attachment'][_0xe6b8('0x4a')](_0x4c084f[_0xe6b8('0x48')])[_0xe6b8('0x25')](respondWithResult(_0x298977,0xc9))['catch'](handleError(_0x298977,null));};exports[_0xe6b8('0x51')]=function(_0x3d93a1,_0x51dfcf,_0x3d4c09){return db[_0xe6b8('0x2c')][_0xe6b8('0x52')]({'where':{'id':_0x3d93a1[_0xe6b8('0x41')]['id']},'raw':!![]})[_0xe6b8('0x25')](handleEntityNotFound(_0x51dfcf,null))[_0xe6b8('0x25')](function(_0x7a75b){if(_0x7a75b){return _0x51dfcf['download'](path[_0xe6b8('0x53')](config['root'],_0xe6b8('0x54'),_0x7a75b[_0xe6b8('0x4e')]));}})[_0xe6b8('0x40')](handleError(_0x51dfcf,null));};
\ No newline at end of file
+var _0x6af8=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','status','end','offset','undefined','count','set','Content-Range','reject','update','then','destroy','error','name','send','index','Attachment','rawAttributes','type','key','model','map','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','limit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','rows','catch','show','params','find','clone','get','omit','createdAt','updatedAt','body','create','file','filename','mimetype','download','ChatOfflineMessageId','join','basename','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x110a30,_0x1ec1e0){var _0x5f0e4f=function(_0x211ea0){while(--_0x211ea0){_0x110a30['push'](_0x110a30['shift']());}};_0x5f0e4f(++_0x1ec1e0);}(_0x6af8,0xe7));var _0x86af=function(_0x981675,_0x59feff){_0x981675=_0x981675-0x0;var _0x566cf4=_0x6af8[_0x981675];return _0x566cf4;};'use strict';var emlformat=require(_0x86af('0x0'));var rimraf=require(_0x86af('0x1'));var zipdir=require(_0x86af('0x2'));var jsonpatch=require(_0x86af('0x3'));var rp=require(_0x86af('0x4'));var moment=require(_0x86af('0x5'));var BPromise=require(_0x86af('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x86af('0x7'));var sox=require('sox');var csv=require(_0x86af('0x8'));var ejs=require(_0x86af('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x86af('0xa'));var crypto=require(_0x86af('0xb'));var jsforce=require(_0x86af('0xc'));var deskjs=require(_0x86af('0xd'));var toCsv=require('to-csv');var querystring=require(_0x86af('0xe'));var Papa=require('papaparse');var Redis=require(_0x86af('0xf'));var authService=require(_0x86af('0x10'));var qs=require(_0x86af('0x11'));var as=require(_0x86af('0x12'));var hardwareService=require(_0x86af('0x13'));var logger=require(_0x86af('0x14'))(_0x86af('0x15'));var utils=require('../../config/utils');var config=require(_0x86af('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3c870b,_0x22ec55){_0x22ec55=_0x22ec55||0xcc;return function(_0x4be0ab){if(_0x4be0ab){return _0x3c870b[_0x86af('0x17')](_0x22ec55);}return _0x3c870b[_0x86af('0x18')](_0x22ec55)[_0x86af('0x19')]();};}function respondWithResult(_0xfd878,_0x2b563d){_0x2b563d=_0x2b563d||0xc8;return function(_0x46aa6b){if(_0x46aa6b){return _0xfd878[_0x86af('0x18')](_0x2b563d)['json'](_0x46aa6b);}};}function respondWithFilteredResult(_0x2a6ba1,_0x2205f9){return function(_0x44a5fa){if(_0x44a5fa){var _0x181da5=typeof _0x2205f9[_0x86af('0x1a')]===_0x86af('0x1b')&&typeof _0x2205f9['limit']===_0x86af('0x1b');var _0x36fb22=_0x44a5fa[_0x86af('0x1c')];var _0x90c30d=_0x181da5?0x0:_0x2205f9[_0x86af('0x1a')];var _0x5e7441=_0x181da5?_0x44a5fa[_0x86af('0x1c')]:_0x2205f9[_0x86af('0x1a')]+_0x2205f9['limit'];var _0x5f1c8c;if(_0x5e7441>=_0x36fb22){_0x5e7441=_0x36fb22;_0x5f1c8c=0xc8;}else{_0x5f1c8c=0xce;}_0x2a6ba1[_0x86af('0x18')](_0x5f1c8c);return _0x2a6ba1[_0x86af('0x1d')](_0x86af('0x1e'),_0x90c30d+'-'+_0x5e7441+'/'+_0x36fb22)['json'](_0x44a5fa);}return null;};}function patchUpdates(_0x2d5e8b){return function(_0x5e8271){try{jsonpatch['apply'](_0x5e8271,_0x2d5e8b,!![]);}catch(_0xe20753){return BPromise[_0x86af('0x1f')](_0xe20753);}return _0x5e8271['save']();};}function saveUpdates(_0x161bf8,_0x516902){return function(_0x17430b){if(_0x17430b){return _0x17430b[_0x86af('0x20')](_0x161bf8)[_0x86af('0x21')](function(_0x251a57){return _0x251a57;});}return null;};}function removeEntity(_0x5e83d7,_0x6aa612){return function(_0x1bb574){if(_0x1bb574){return _0x1bb574[_0x86af('0x22')]()[_0x86af('0x21')](function(){_0x5e83d7[_0x86af('0x18')](0xcc)[_0x86af('0x19')]();});}};}function handleEntityNotFound(_0x5565f6,_0x1ae07c){return function(_0x5961c8){if(!_0x5961c8){_0x5565f6[_0x86af('0x17')](0x194);}return _0x5961c8;};}function handleError(_0xd0eb7b,_0x5dae65){_0x5dae65=_0x5dae65||0x1f4;return function(_0x51b5a2){logger[_0x86af('0x23')](_0x51b5a2['stack']);if(_0x51b5a2[_0x86af('0x24')]){delete _0x51b5a2[_0x86af('0x24')];}_0xd0eb7b[_0x86af('0x18')](_0x5dae65)[_0x86af('0x25')](_0x51b5a2);};}exports[_0x86af('0x26')]=function(_0x44e322,_0x35f296){var _0x639b4d={},_0x13fa03={},_0x52c1a={'count':0x0,'rows':[]};var _0x2e64a8=_['map'](db[_0x86af('0x27')][_0x86af('0x28')],function(_0x4cd511){return{'name':_0x4cd511['fieldName'],'type':_0x4cd511[_0x86af('0x29')][_0x86af('0x2a')]};});_0x13fa03[_0x86af('0x2b')]=_[_0x86af('0x2c')](_0x2e64a8,_0x86af('0x24'));_0x13fa03['query']=_[_0x86af('0x2d')](_0x44e322[_0x86af('0x2e')]);_0x13fa03[_0x86af('0x2f')]=_[_0x86af('0x30')](_0x13fa03[_0x86af('0x2b')],_0x13fa03['query']);_0x639b4d['attributes']=_[_0x86af('0x30')](_0x13fa03[_0x86af('0x2b')],qs[_0x86af('0x31')](_0x44e322[_0x86af('0x2e')][_0x86af('0x31')]));_0x639b4d[_0x86af('0x32')]=_0x639b4d[_0x86af('0x32')][_0x86af('0x33')]?_0x639b4d[_0x86af('0x32')]:_0x13fa03[_0x86af('0x2b')];if(!_0x44e322[_0x86af('0x2e')][_0x86af('0x34')]('nolimit')){_0x639b4d[_0x86af('0x35')]=qs[_0x86af('0x35')](_0x44e322['query'][_0x86af('0x35')]);_0x639b4d[_0x86af('0x1a')]=qs[_0x86af('0x1a')](_0x44e322[_0x86af('0x2e')][_0x86af('0x1a')]);}_0x639b4d[_0x86af('0x36')]=qs[_0x86af('0x37')](_0x44e322[_0x86af('0x2e')][_0x86af('0x37')]);_0x639b4d['where']=qs['filters'](_[_0x86af('0x38')](_0x44e322[_0x86af('0x2e')],_0x13fa03[_0x86af('0x2f')]),_0x2e64a8);if(_0x44e322[_0x86af('0x2e')][_0x86af('0x39')]){_0x639b4d[_0x86af('0x3a')]=_[_0x86af('0x3b')](_0x639b4d['where'],{'$or':_[_0x86af('0x2c')](_0x2e64a8,function(_0x1c4294){if(_0x1c4294[_0x86af('0x29')]!==_0x86af('0x3c')){var _0x4627dc={};_0x4627dc[_0x1c4294[_0x86af('0x24')]]={'$like':'%'+_0x44e322[_0x86af('0x2e')]['filter']+'%'};return _0x4627dc;}})});}_0x639b4d=_[_0x86af('0x3b')]({},_0x639b4d,_0x44e322[_0x86af('0x3d')]);var _0xa78d94={'where':_0x639b4d[_0x86af('0x3a')]};return db[_0x86af('0x27')][_0x86af('0x1c')](_0xa78d94)[_0x86af('0x21')](function(_0x55a404){_0x52c1a[_0x86af('0x1c')]=_0x55a404;if(_0x44e322[_0x86af('0x2e')][_0x86af('0x3e')]){_0x639b4d[_0x86af('0x3f')]=[{'all':!![]}];}return db[_0x86af('0x27')]['findAll'](_0x639b4d);})[_0x86af('0x21')](function(_0x29d913){_0x52c1a[_0x86af('0x40')]=_0x29d913;return _0x52c1a;})['then'](respondWithFilteredResult(_0x35f296,_0x639b4d))[_0x86af('0x41')](handleError(_0x35f296,null));};exports[_0x86af('0x42')]=function(_0x5e6d74,_0x528df8){var _0x4c0e4d={'raw':!![],'where':{'id':_0x5e6d74[_0x86af('0x43')]['id']}},_0x2596f4={};_0x2596f4[_0x86af('0x2b')]=_[_0x86af('0x2d')](db[_0x86af('0x27')][_0x86af('0x28')]);_0x2596f4[_0x86af('0x2e')]=_[_0x86af('0x2d')](_0x5e6d74[_0x86af('0x2e')]);_0x2596f4[_0x86af('0x2f')]=_[_0x86af('0x30')](_0x2596f4[_0x86af('0x2b')],_0x2596f4['query']);_0x4c0e4d[_0x86af('0x32')]=_[_0x86af('0x30')](_0x2596f4[_0x86af('0x2b')],qs[_0x86af('0x31')](_0x5e6d74[_0x86af('0x2e')]['fields']));_0x4c0e4d[_0x86af('0x32')]=_0x4c0e4d['attributes']['length']?_0x4c0e4d[_0x86af('0x32')]:_0x2596f4[_0x86af('0x2b')];if(_0x5e6d74[_0x86af('0x2e')][_0x86af('0x3e')]){_0x4c0e4d[_0x86af('0x3f')]=[{'all':!![]}];}_0x4c0e4d=_[_0x86af('0x3b')]({},_0x4c0e4d,_0x5e6d74['options']);return db[_0x86af('0x27')][_0x86af('0x44')](_0x4c0e4d)[_0x86af('0x21')](handleEntityNotFound(_0x528df8,null))['then'](respondWithResult(_0x528df8,null))[_0x86af('0x41')](handleError(_0x528df8,null));};exports[_0x86af('0x45')]=function(_0x28f1a8,_0xb195a8){var _0x101e11={'where':{'id':_0x28f1a8[_0x86af('0x43')]['id']}},_0x210d7b={};_0x210d7b[_0x86af('0x2b')]=_['keys'](db[_0x86af('0x27')][_0x86af('0x28')]);_0x101e11[_0x86af('0x32')]=_['intersection'](_0x210d7b[_0x86af('0x2b')],qs[_0x86af('0x31')](_0x28f1a8[_0x86af('0x2e')][_0x86af('0x31')]));_0x101e11[_0x86af('0x32')]=_0x101e11['attributes'][_0x86af('0x33')]?_0x101e11['attributes']:_0x210d7b['model'];if(_0x28f1a8[_0x86af('0x2e')][_0x86af('0x3e')]){_0x101e11[_0x86af('0x3f')]=[{'all':!![]}];}_0x101e11=_['merge']({},_0x101e11,_0x28f1a8[_0x86af('0x3d')]);return db[_0x86af('0x27')][_0x86af('0x44')](_0x101e11)[_0x86af('0x21')](handleEntityNotFound(_0xb195a8,null))['then'](function(_0x1558b3){if(_0x1558b3){var _0x1d19a2=_0x1558b3[_0x86af('0x46')]({'plain':!![]});_0x1d19a2=qs[_0x86af('0x47')](_0x1d19a2,['id',_0x86af('0x48'),_0x86af('0x49')]);_0x28f1a8['body']=_[_0x86af('0x47')](_0x28f1a8[_0x86af('0x4a')],['id',_0x86af('0x48'),_0x86af('0x49')]);return db[_0x86af('0x27')][_0x86af('0x4b')](_[_0x86af('0x3b')](_0x1d19a2,_0x28f1a8[_0x86af('0x4a')]),{'include':_0x28f1a8['query'][_0x86af('0x3e')]?[{'all':!![]}]:undefined});}})[_0x86af('0x21')](respondWithResult(_0xb195a8,0xc9))[_0x86af('0x41')](handleError(_0xb195a8,null));};exports[_0x86af('0x20')]=function(_0x31d0f6,_0x573a96){if(_0x31d0f6[_0x86af('0x4a')]['id']){delete _0x31d0f6[_0x86af('0x4a')]['id'];}return db[_0x86af('0x27')][_0x86af('0x44')]({'where':{'id':_0x31d0f6['params']['id']}})[_0x86af('0x21')](handleEntityNotFound(_0x573a96,null))[_0x86af('0x21')](saveUpdates(_0x31d0f6[_0x86af('0x4a')],null))[_0x86af('0x21')](respondWithResult(_0x573a96,null))['catch'](handleError(_0x573a96,null));};exports[_0x86af('0x22')]=function(_0x1936e1,_0x239252){return db[_0x86af('0x27')][_0x86af('0x44')]({'where':{'id':_0x1936e1[_0x86af('0x43')]['id']}})[_0x86af('0x21')](handleEntityNotFound(_0x239252,null))[_0x86af('0x21')](removeEntity(_0x239252,null))[_0x86af('0x41')](handleError(_0x239252,null));};exports[_0x86af('0x4b')]=function(_0x474a23,_0x112355,_0xa4ba52){_0x474a23[_0x86af('0x4a')][_0x86af('0x24')]=_0x474a23[_0x86af('0x4c')]['originalname'];_0x474a23[_0x86af('0x4a')]['basename']=_0x474a23[_0x86af('0x4c')][_0x86af('0x4d')];_0x474a23[_0x86af('0x4a')][_0x86af('0x29')]=_0x474a23[_0x86af('0x4c')][_0x86af('0x4e')];return db['Attachment'][_0x86af('0x4b')](_0x474a23[_0x86af('0x4a')])[_0x86af('0x21')](respondWithResult(_0x112355,0xc9))[_0x86af('0x41')](handleError(_0x112355,null));};exports[_0x86af('0x4f')]=function(_0x21c61a,_0x309762,_0x38031d){return db[_0x86af('0x27')]['findOne']({'where':{'id':_0x21c61a[_0x86af('0x43')]['id']},'raw':!![]})['then'](handleEntityNotFound(_0x309762,null))['then'](function(_0x5be14a){if(_0x5be14a){var _0x3c3533=_0x5be14a[_0x86af('0x50')]!==null;var _0xe10bfd=path[_0x86af('0x51')](config['root'],'server/files/attachments/');if(_0x3c3533){_0xe10bfd=path[_0x86af('0x51')](_0xe10bfd,'offline-chat/');}var _0x1194b7=path[_0x86af('0x51')](_0xe10bfd,_0x5be14a[_0x86af('0x52')]);return _0x309762[_0x86af('0x4f')](_0x1194b7);}})[_0x86af('0x41')](handleError(_0x309762,null));};
\ No newline at end of file