Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / mailInteraction / mailInteraction.controller.js
index 9545bed..d5a4154 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa679=['missing.recipient@your.company.com','subject','decode','createdAt','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','headers','Bcc','basename','existsSync','readFileSync','writeFileSync','eml-format','zip-dir','moment','bluebird','util','path','lodash','../../components/interaction/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','html-entities','redis','defaults','./mailInteraction.socket','register','sendStatus','status','end','json','undefined','limit','count','offset','update','then','error','stack','name','index','map','MailInteraction','rawAttributes','fieldName','type','key','getOptions','query','user','catch','show','params','model','keys','intersection','attributes','fields','length','include','options','find','create','body','destroy','describe','addMessage','MailMessage','ids','omit','getMessages','findOne','filters','hasOwnProperty','nolimit','sort','where','MailInteractionId','filter','merge','$gte','split','format','includeAll','findAll','true','rows','addTags','setTags','spread','Tag','color','removeTags','download','unix','join','root','server','files','tmp','attachments','push','Attachment','Attachments','Messages','from','bcc','get','each'];(function(_0x73bd6c,_0x3451c){var _0x3914fb=function(_0x26b805){while(--_0x26b805){_0x73bd6c['push'](_0x73bd6c['shift']());}};_0x3914fb(++_0x3451c);}(_0xa679,0x155));var _0x9a67=function(_0x50d0b9,_0x105146){_0x50d0b9=_0x50d0b9-0x0;var _0x313049=_0xa679[_0x50d0b9];return _0x313049;};'use strict';var emlformat=require(_0x9a67('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x9a67('0x1'));var moment=require(_0x9a67('0x2'));var BPromise=require(_0x9a67('0x3'));var util=require(_0x9a67('0x4'));var path=require(_0x9a67('0x5'));var fs=require('fs');var _=require(_0x9a67('0x6'));var juice=require('juice');var Redis=require('ioredis');var interaction=require(_0x9a67('0x7'));var qs=require(_0x9a67('0x8'));var logger=require(_0x9a67('0x9'))(_0x9a67('0xa'));var config=require(_0x9a67('0xb'));var db=require('../../mysqldb')['db'];var htmlEntities=require(_0x9a67('0xc'));config[_0x9a67('0xd')]=_[_0x9a67('0xe')](config[_0x9a67('0xd')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x9a67('0xf'))[_0x9a67('0x10')](socket);function respondWithStatusCode(_0x25b49a,_0x6c4068){_0x6c4068=_0x6c4068||0xcc;return function(_0x397068){if(_0x397068){return _0x25b49a[_0x9a67('0x11')](_0x6c4068);}return _0x25b49a[_0x9a67('0x12')](_0x6c4068)[_0x9a67('0x13')]();};}function respondWithResult(_0x23c5ee,_0x128287){_0x128287=_0x128287||0xc8;return function(_0x58eb41){if(_0x58eb41){return _0x23c5ee[_0x9a67('0x12')](_0x128287)[_0x9a67('0x14')](_0x58eb41);}};}function respondWithFilteredResult(_0x3537a9,_0x56a6cc){return function(_0x30d330){if(_0x30d330){var _0x552432=typeof _0x56a6cc['offset']===_0x9a67('0x15')&&typeof _0x56a6cc[_0x9a67('0x16')]===_0x9a67('0x15');var _0x134b79=_0x30d330[_0x9a67('0x17')];var _0x3b8f2f=_0x552432?0x0:_0x56a6cc[_0x9a67('0x18')];var _0x40ecb8=_0x552432?_0x30d330[_0x9a67('0x17')]:_0x56a6cc[_0x9a67('0x18')]+_0x56a6cc[_0x9a67('0x16')];var _0x21fa75;if(_0x40ecb8>=_0x134b79){_0x40ecb8=_0x134b79;_0x21fa75=0xc8;}else{_0x21fa75=0xce;}_0x3537a9[_0x9a67('0x12')](_0x21fa75);return _0x3537a9['set']('Content-Range',_0x3b8f2f+'-'+_0x40ecb8+'/'+_0x134b79)[_0x9a67('0x14')](_0x30d330);}return null;};}function saveUpdates(_0x388252){return function(_0x56a565){if(_0x56a565){return _0x56a565[_0x9a67('0x19')](_0x388252)['then'](function(_0x269b9b){return _0x269b9b;});}return null;};}function removeEntity(_0x1c7bf1){return function(_0xe70f96){if(_0xe70f96){return _0xe70f96['destroy']()[_0x9a67('0x1a')](function(){_0x1c7bf1[_0x9a67('0x12')](0xcc)[_0x9a67('0x13')]();});}};}function handleEntityNotFound(_0x144a5f){return function(_0x9ed7c7){if(!_0x9ed7c7){_0x144a5f[_0x9a67('0x11')](0x194);}return _0x9ed7c7;};}function handleError(_0x18dc25,_0x3b3afe){_0x3b3afe=_0x3b3afe||0x1f4;return function(_0xb10b1a){logger[_0x9a67('0x1b')](_0xb10b1a[_0x9a67('0x1c')]);if(_0xb10b1a[_0x9a67('0x1d')]){delete _0xb10b1a['name'];}_0x18dc25['status'](_0x3b3afe)['send'](_0xb10b1a);};}exports[_0x9a67('0x1e')]=function(_0x349891,_0x1b7dce){var _0x34be56={};var _0xc2335c=_[_0x9a67('0x1f')](db[_0x9a67('0x20')][_0x9a67('0x21')],function(_0x5c2e25){return{'name':_0x5c2e25[_0x9a67('0x22')],'type':_0x5c2e25[_0x9a67('0x23')][_0x9a67('0x24')]};});_0x34be56=qs[_0x9a67('0x25')](_0xc2335c,_0x349891);return interaction['findAll']('mail',_0x349891[_0x9a67('0x26')],_0x349891[_0x9a67('0x27')],_0x34be56,_0xc2335c)[_0x9a67('0x1a')](respondWithFilteredResult(_0x1b7dce,_0x34be56))[_0x9a67('0x28')](handleError(_0x1b7dce,null));};exports[_0x9a67('0x29')]=function(_0x41d9d6,_0x205c05){var _0x18bdcd={'raw':![],'where':{'id':_0x41d9d6[_0x9a67('0x2a')]['id']}},_0xef5541={};_0xef5541[_0x9a67('0x2b')]=_[_0x9a67('0x2c')](db[_0x9a67('0x20')]['rawAttributes']);_0xef5541[_0x9a67('0x26')]=_[_0x9a67('0x2c')](_0x41d9d6[_0x9a67('0x26')]);_0xef5541['filters']=_[_0x9a67('0x2d')](_0xef5541['model'],_0xef5541[_0x9a67('0x26')]);_0x18bdcd[_0x9a67('0x2e')]=_[_0x9a67('0x2d')](_0xef5541[_0x9a67('0x2b')],qs[_0x9a67('0x2f')](_0x41d9d6[_0x9a67('0x26')][_0x9a67('0x2f')]));_0x18bdcd[_0x9a67('0x2e')]=_0x18bdcd['attributes'][_0x9a67('0x30')]?_0x18bdcd['attributes']:_0xef5541[_0x9a67('0x2b')];if(_0x41d9d6[_0x9a67('0x26')]['includeAll']){_0x18bdcd[_0x9a67('0x31')]=[{'all':!![]}];}_0x18bdcd=_['merge']({},_0x18bdcd,_0x41d9d6[_0x9a67('0x32')]);return db['MailInteraction'][_0x9a67('0x33')](_0x18bdcd)[_0x9a67('0x1a')](handleEntityNotFound(_0x205c05,null))[_0x9a67('0x1a')](respondWithResult(_0x205c05,null))[_0x9a67('0x28')](handleError(_0x205c05,null));};exports[_0x9a67('0x34')]=function(_0x249430,_0x3ede30){return db[_0x9a67('0x20')][_0x9a67('0x34')](_0x249430[_0x9a67('0x35')],{})['then'](respondWithResult(_0x3ede30,0xc9))[_0x9a67('0x28')](handleError(_0x3ede30,null));};exports['update']=function(_0xca4dea,_0x251350){if(_0xca4dea['body']['id']){delete _0xca4dea['body']['id'];}return db[_0x9a67('0x20')]['find']({'where':{'id':_0xca4dea[_0x9a67('0x2a')]['id']}})['then'](handleEntityNotFound(_0x251350,null))[_0x9a67('0x1a')](saveUpdates(_0xca4dea[_0x9a67('0x35')],null))[_0x9a67('0x1a')](respondWithResult(_0x251350,null))['catch'](handleError(_0x251350,null));};exports[_0x9a67('0x36')]=function(_0x12a426,_0x5d699d){return db[_0x9a67('0x20')][_0x9a67('0x33')]({'where':{'id':_0x12a426['params']['id']}})[_0x9a67('0x1a')](handleEntityNotFound(_0x5d699d,null))[_0x9a67('0x1a')](removeEntity(_0x5d699d,null))[_0x9a67('0x28')](handleError(_0x5d699d,null));};exports[_0x9a67('0x37')]=function(_0x4ac7bb,_0x19d82f){return db[_0x9a67('0x20')][_0x9a67('0x37')]()[_0x9a67('0x1a')](respondWithResult(_0x19d82f,null))[_0x9a67('0x28')](handleError(_0x19d82f,null));};exports[_0x9a67('0x38')]=function(_0x38b679,_0x441eb3){return db[_0x9a67('0x39')][_0x9a67('0x33')]({'where':{'id':_0x38b679[_0x9a67('0x2a')]['id']}})[_0x9a67('0x1a')](handleEntityNotFound(_0x441eb3,null))['then'](function(_0x82a713){if(_0x82a713){return _0x82a713[_0x9a67('0x38')](_0x38b679[_0x9a67('0x35')][_0x9a67('0x3a')],_[_0x9a67('0x3b')](_0x38b679[_0x9a67('0x35')],['ids','id'])||{});}})[_0x9a67('0x1a')](respondWithResult(_0x441eb3,null))[_0x9a67('0x28')](handleError(_0x441eb3,null));};exports[_0x9a67('0x3c')]=function(_0x2ca3de,_0x223c60){var _0x6dbb7a={'raw':![],'where':{}};var _0x40e063={};var _0x1133de={'count':0x0,'rows':[]};return db[_0x9a67('0x20')][_0x9a67('0x3d')]({'where':{'id':_0x2ca3de['params']['id']}})[_0x9a67('0x1a')](handleEntityNotFound(_0x223c60,null))['then'](function(_0x49bb55){if(_0x49bb55){_0x40e063[_0x9a67('0x2b')]=_[_0x9a67('0x2c')](db[_0x9a67('0x39')][_0x9a67('0x21')]);_0x40e063['query']=_[_0x9a67('0x2c')](_0x2ca3de[_0x9a67('0x26')]);_0x40e063[_0x9a67('0x3e')]=_['intersection'](_0x40e063[_0x9a67('0x2b')],_0x40e063[_0x9a67('0x26')]);_0x6dbb7a[_0x9a67('0x2e')]=_['intersection'](_0x40e063[_0x9a67('0x2b')],qs['fields'](_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x2f')]));_0x6dbb7a[_0x9a67('0x2e')]=_0x6dbb7a[_0x9a67('0x2e')][_0x9a67('0x30')]?_0x6dbb7a[_0x9a67('0x2e')]:_0x40e063[_0x9a67('0x2b')];if(!_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x3f')](_0x9a67('0x40'))){_0x6dbb7a[_0x9a67('0x16')]=qs[_0x9a67('0x16')](_0x2ca3de[_0x9a67('0x26')]['limit']);_0x6dbb7a[_0x9a67('0x18')]=qs['offset'](_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x18')]);}_0x6dbb7a['order']=qs[_0x9a67('0x41')](_0x2ca3de[_0x9a67('0x26')]['sort']);_0x6dbb7a[_0x9a67('0x42')]=qs['filters'](_['pick'](_0x2ca3de[_0x9a67('0x26')],_0x40e063['filters']));_0x6dbb7a[_0x9a67('0x42')][_0x9a67('0x43')]=_0x49bb55['id'];if(_0x2ca3de['query'][_0x9a67('0x44')]){_0x6dbb7a['where']=_[_0x9a67('0x45')](_0x6dbb7a['where'],{'$or':_[_0x9a67('0x1f')](_0x6dbb7a['attributes'],function(_0x393ff4){var _0x59baa3={};_0x59baa3[_0x393ff4]={'$like':'%'+_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x44')]+'%'};return _0x59baa3;})});}if(_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x46')]){var _0xf49791=_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x46')][_0x9a67('0x47')](',');var _0x34a84a={};_0x34a84a[_0xf49791[0x0]]={'$gte':moment(_0xf49791[0x1])[_0x9a67('0x48')]('YYYY-MM-DD\x20HH:mm:ss')};_0x6dbb7a[_0x9a67('0x42')]=_['merge'](_0x6dbb7a[_0x9a67('0x42')],_0x34a84a);}_0x6dbb7a=_[_0x9a67('0x45')]({},_0x6dbb7a,_0x2ca3de['options']);return db[_0x9a67('0x39')][_0x9a67('0x17')]({'where':_0x6dbb7a[_0x9a67('0x42')]})[_0x9a67('0x1a')](function(_0x34184e){_0x1133de[_0x9a67('0x17')]=_0x34184e;if(_0x2ca3de[_0x9a67('0x26')][_0x9a67('0x49')]){_0x6dbb7a[_0x9a67('0x31')]=[{'all':!![]}];}return db['MailMessage'][_0x9a67('0x4a')](_0x6dbb7a);})[_0x9a67('0x1a')](function(_0x4564fa){if(_0x2ca3de['query']['inlineCss']===_0x9a67('0x4b')){for(var _0x5b57fe=0x0;_0x5b57fe<_0x4564fa[_0x9a67('0x30')];_0x5b57fe++){_0x4564fa[_0x5b57fe]['body']=juice(_0x4564fa[_0x5b57fe]['body']);}}_0x1133de[_0x9a67('0x4c')]=_0x4564fa;return _0x1133de;});}})[_0x9a67('0x1a')](respondWithFilteredResult(_0x223c60,_0x6dbb7a))[_0x9a67('0x28')](handleError(_0x223c60,null));};exports[_0x9a67('0x4d')]=function(_0x4e39d7,_0x8d4f19){return db['MailInteraction'][_0x9a67('0x33')]({'where':{'id':_0x4e39d7['params']['id']}})[_0x9a67('0x1a')](handleEntityNotFound(_0x8d4f19,null))['then'](function(_0x255324){if(_0x255324){return _0x255324[_0x9a67('0x4e')](_0x4e39d7[_0x9a67('0x35')][_0x9a67('0x3a')],_[_0x9a67('0x3b')](_0x4e39d7[_0x9a67('0x35')],[_0x9a67('0x3a'),'id'])||{})[_0x9a67('0x4f')](function(){return db[_0x9a67('0x50')][_0x9a67('0x4a')]({'attributes':['id',_0x9a67('0x1d'),_0x9a67('0x51')],'where':{'id':_0x4e39d7[_0x9a67('0x35')][_0x9a67('0x3a')]}});})[_0x9a67('0x1a')](function(_0x50a8c0){socket['emit']('mailInteractionTags:save',{'id':Number(_0x4e39d7[_0x9a67('0x2a')]['id']),'tags':_0x50a8c0||[]});return{'id':Number(_0x4e39d7[_0x9a67('0x2a')]['id']),'tags':_0x50a8c0||[]};});}})[_0x9a67('0x1a')](respondWithResult(_0x8d4f19,null))[_0x9a67('0x28')](handleError(_0x8d4f19,null));};exports[_0x9a67('0x52')]=function(_0x18e0cb,_0x28ee98){return db[_0x9a67('0x20')][_0x9a67('0x33')]({'where':{'id':_0x18e0cb[_0x9a67('0x2a')]['id']}})['then'](handleEntityNotFound(_0x28ee98,null))['then'](function(_0x2849ba){if(_0x2849ba){return _0x2849ba[_0x9a67('0x52')](_0x18e0cb[_0x9a67('0x26')][_0x9a67('0x3a')]);}})[_0x9a67('0x1a')](respondWithStatusCode(_0x28ee98,null))['catch'](handleError(_0x28ee98,null));};exports[_0x9a67('0x53')]=function(_0x13e5b4,_0x50e7a4){var _0x528bb0=moment()[_0x9a67('0x54')]()['toString']();var _0x14d64c=path[_0x9a67('0x55')](config[_0x9a67('0x56')],_0x9a67('0x57'),_0x9a67('0x58'),_0x9a67('0x59'));var _0x4c30a8=path[_0x9a67('0x55')](config['root'],_0x9a67('0x57'),_0x9a67('0x58'),_0x9a67('0x5a'));var _0x8e002b=path[_0x9a67('0x55')](_0x14d64c,_0x528bb0);var _0x56513f=util[_0x9a67('0x48')]('transcript-%d-%s.zip',_0x13e5b4[_0x9a67('0x2a')]['id'],_0x528bb0);var _0x168286=path[_0x9a67('0x55')](_0x14d64c,_0x56513f);var _0x12d899=[];if(_0x13e5b4[_0x9a67('0x26')][_0x9a67('0x5a')]){_0x12d899[_0x9a67('0x5b')]({'model':db[_0x9a67('0x5c')],'as':_0x9a67('0x5d'),'raw':!![]});}var _0x38bfa7=[{'model':db[_0x9a67('0x39')],'as':_0x9a67('0x5e'),'attributes':['id','body',_0x9a67('0x5f'),'to','cc',_0x9a67('0x60'),'subject','createdAt'],'where':{'secret':![]},'order':qs[_0x9a67('0x41')]('id'),'include':_0x12d899}];return db[_0x9a67('0x20')]['find']({'where':{'id':_0x13e5b4[_0x9a67('0x2a')]['id']},'include':_0x38bfa7})[_0x9a67('0x1a')](handleEntityNotFound(_0x50e7a4,null))[_0x9a67('0x1a')](function(_0x592bb8){if(_0x592bb8&&_0x592bb8[_0x9a67('0x5e')]){var _0x22b9ac=_0x592bb8[_0x9a67('0x61')]({'plain':!![]});fs['mkdirSync'](_0x8e002b);return BPromise[_0x9a67('0x62')](_0x22b9ac[_0x9a67('0x5e')],function(_0xb129b5,_0x20eb27){var _0x18af99={'from':_0xb129b5[_0x9a67('0x5f')],'to':_0xb129b5['to']||_0x9a67('0x63'),'subject':_0xb129b5[_0x9a67('0x64')],'html':htmlEntities[_0x9a67('0x65')](_0xb129b5[_0x9a67('0x35')]),'headers':{'Date':moment(_0xb129b5[_0x9a67('0x66')])['format'](_0x9a67('0x67'))},'attachments':[]};if(_0xb129b5['cc']){_0x18af99[_0x9a67('0x68')]['Cc']=_0xb129b5['cc'];}if(_0xb129b5[_0x9a67('0x60')]){_0x18af99[_0x9a67('0x68')][_0x9a67('0x69')]=_0xb129b5[_0x9a67('0x60')];}return new BPromise(function(_0x1b00cb,_0x219a9a){if(_0xb129b5[_0x9a67('0x5d')]){for(var _0x2361b9=0x0;_0x2361b9<_0xb129b5[_0x9a67('0x5d')][_0x9a67('0x30')];_0x2361b9++){var _0x1f507c=_0xb129b5[_0x9a67('0x5d')][_0x2361b9];var _0x10b1e4=path[_0x9a67('0x55')](_0x4c30a8,_0x1f507c[_0x9a67('0x6a')]);if(fs[_0x9a67('0x6b')](_0x10b1e4)){_0x18af99[_0x9a67('0x5a')][_0x9a67('0x5b')]({'name':_0x1f507c[_0x9a67('0x1d')],'contentType':_0x1f507c[_0x9a67('0x23')],'data':fs[_0x9a67('0x6c')](_0x10b1e4)});}}}emlformat['build'](_0x18af99,function(_0x58847,_0x910a8a){if(_0x58847)return _0x219a9a(_0x58847);fs[_0x9a67('0x6d')](path[_0x9a67('0x55')](_0x8e002b,util[_0x9a67('0x48')]('message%d.eml',_0x20eb27)),_0x910a8a);return _0x1b00cb(_0x910a8a);});});})[_0x9a67('0x1a')](function(){return new BPromise(function(_0x4d9ca3,_0x53622a){zipdir(_0x8e002b,{'saveTo':_0x168286},function(_0x479972,_0x4b619f){if(_0x479972)return _0x53622a(_0x479972);return _0x4d9ca3(_0x4b619f);});})[_0x9a67('0x1a')](function(){return new BPromise(function(_0x548336,_0x394205){rimraf(_0x8e002b,function(_0x53343a){if(_0x53343a)_0x394205(_0x53343a);return _0x548336();});});})[_0x9a67('0x1a')](function(){return _0x50e7a4[_0x9a67('0x53')](_0x168286,_0x56513f,function(_0x2eb7d0){if(!_0x2eb7d0)fs['unlinkSync'](_0x168286);});});});}else{return _0x50e7a4[_0x9a67('0x11')](0xc8);}})[_0x9a67('0x28')](handleError(_0x50e7a4,null));};
\ No newline at end of file
+var _0x3007=['map','MailInteraction','fieldName','type','key','getOptions','findAll','mail','query','user','show','params','model','keys','filters','intersection','attributes','fields','includeAll','include','merge','options','find','catch','create','body','describe','addMessage','MailMessage','ids','getMessages','rawAttributes','length','nolimit','order','sort','where','pick','MailInteractionId','filter','$gte','split','format','inlineCss','rows','addTags','setTags','omit','spread','Tag','color','emit','mailInteractionTags:save','removeTags','download','unix','toString','join','server','files','root','attachments','transcript-%d-%s.zip','Attachments','Messages','from','bcc','subject','createdAt','each','missing.recipient@your.company.com','decode','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','headers','basename','existsSync','push','readFileSync','writeFileSync','message%d.eml','eml-format','zip-dir','bluebird','util','path','lodash','juice','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','html-entities','redis','defaults','localhost','end','json','offset','undefined','count','limit','status','Content-Range','then','destroy','sendStatus','error','stack','name','index'];(function(_0x49bba8,_0x3a9f40){var _0x5dca5d=function(_0x526539){while(--_0x526539){_0x49bba8['push'](_0x49bba8['shift']());}};_0x5dca5d(++_0x3a9f40);}(_0x3007,0xc0));var _0x7300=function(_0x4898f0,_0x49fb26){_0x4898f0=_0x4898f0-0x0;var _0x58b576=_0x3007[_0x4898f0];return _0x58b576;};'use strict';var emlformat=require(_0x7300('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x7300('0x1'));var moment=require('moment');var BPromise=require(_0x7300('0x2'));var util=require(_0x7300('0x3'));var path=require(_0x7300('0x4'));var fs=require('fs');var _=require(_0x7300('0x5'));var juice=require(_0x7300('0x6'));var Redis=require(_0x7300('0x7'));var interaction=require('../../components/interaction/service');var qs=require(_0x7300('0x8'));var logger=require(_0x7300('0x9'))(_0x7300('0xa'));var config=require(_0x7300('0xb'));var db=require(_0x7300('0xc'))['db'];var htmlEntities=require(_0x7300('0xd'));config[_0x7300('0xe')]=_[_0x7300('0xf')](config[_0x7300('0xe')],{'host':_0x7300('0x10'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7300('0xe')]));require('./mailInteraction.socket')['register'](socket);function respondWithStatusCode(_0x245430,_0x1092c9){_0x1092c9=_0x1092c9||0xcc;return function(_0x23bdc5){if(_0x23bdc5){return _0x245430['sendStatus'](_0x1092c9);}return _0x245430['status'](_0x1092c9)[_0x7300('0x11')]();};}function respondWithResult(_0x42afd3,_0x29d8c3){_0x29d8c3=_0x29d8c3||0xc8;return function(_0x51570f){if(_0x51570f){return _0x42afd3['status'](_0x29d8c3)[_0x7300('0x12')](_0x51570f);}};}function respondWithFilteredResult(_0x5e3bbe,_0x3c0c0b){return function(_0x146055){if(_0x146055){var _0x3457f8=typeof _0x3c0c0b[_0x7300('0x13')]===_0x7300('0x14')&&typeof _0x3c0c0b['limit']===_0x7300('0x14');var _0x4c7c4f=_0x146055[_0x7300('0x15')];var _0x2993d5=_0x3457f8?0x0:_0x3c0c0b['offset'];var _0x951503=_0x3457f8?_0x146055[_0x7300('0x15')]:_0x3c0c0b[_0x7300('0x13')]+_0x3c0c0b[_0x7300('0x16')];var _0x43c6b7;if(_0x951503>=_0x4c7c4f){_0x951503=_0x4c7c4f;_0x43c6b7=0xc8;}else{_0x43c6b7=0xce;}_0x5e3bbe[_0x7300('0x17')](_0x43c6b7);return _0x5e3bbe['set'](_0x7300('0x18'),_0x2993d5+'-'+_0x951503+'/'+_0x4c7c4f)[_0x7300('0x12')](_0x146055);}return null;};}function saveUpdates(_0x31719a){return function(_0xff3be0){if(_0xff3be0){return _0xff3be0['update'](_0x31719a)[_0x7300('0x19')](function(_0x47a767){return _0x47a767;});}return null;};}function removeEntity(_0x460283){return function(_0x2a8b41){if(_0x2a8b41){return _0x2a8b41[_0x7300('0x1a')]()['then'](function(){_0x460283[_0x7300('0x17')](0xcc)[_0x7300('0x11')]();});}};}function handleEntityNotFound(_0x5565f4){return function(_0x510d79){if(!_0x510d79){_0x5565f4[_0x7300('0x1b')](0x194);}return _0x510d79;};}function handleError(_0x3a0f8c,_0x3dbafd){_0x3dbafd=_0x3dbafd||0x1f4;return function(_0x165ecb){logger[_0x7300('0x1c')](_0x165ecb[_0x7300('0x1d')]);if(_0x165ecb[_0x7300('0x1e')]){delete _0x165ecb['name'];}_0x3a0f8c[_0x7300('0x17')](_0x3dbafd)['send'](_0x165ecb);};}exports[_0x7300('0x1f')]=function(_0x131842,_0x1716c2){var _0x202dde={};var _0x527369=_[_0x7300('0x20')](db[_0x7300('0x21')]['rawAttributes'],function(_0x356f2a){return{'name':_0x356f2a[_0x7300('0x22')],'type':_0x356f2a[_0x7300('0x23')][_0x7300('0x24')]};});_0x202dde=qs[_0x7300('0x25')](_0x527369,_0x131842);return interaction[_0x7300('0x26')](_0x7300('0x27'),_0x131842[_0x7300('0x28')],_0x131842[_0x7300('0x29')],_0x202dde,_0x527369)[_0x7300('0x19')](respondWithFilteredResult(_0x1716c2,_0x202dde))['catch'](handleError(_0x1716c2,null));};exports[_0x7300('0x2a')]=function(_0x2ae0c1,_0x379a00){var _0x50f520={'raw':![],'where':{'id':_0x2ae0c1[_0x7300('0x2b')]['id']}},_0x4eec17={};_0x4eec17[_0x7300('0x2c')]=_[_0x7300('0x2d')](db[_0x7300('0x21')]['rawAttributes']);_0x4eec17['query']=_[_0x7300('0x2d')](_0x2ae0c1[_0x7300('0x28')]);_0x4eec17[_0x7300('0x2e')]=_[_0x7300('0x2f')](_0x4eec17[_0x7300('0x2c')],_0x4eec17[_0x7300('0x28')]);_0x50f520[_0x7300('0x30')]=_[_0x7300('0x2f')](_0x4eec17[_0x7300('0x2c')],qs['fields'](_0x2ae0c1['query'][_0x7300('0x31')]));_0x50f520[_0x7300('0x30')]=_0x50f520['attributes']['length']?_0x50f520[_0x7300('0x30')]:_0x4eec17[_0x7300('0x2c')];if(_0x2ae0c1['query'][_0x7300('0x32')]){_0x50f520[_0x7300('0x33')]=[{'all':!![]}];}_0x50f520=_[_0x7300('0x34')]({},_0x50f520,_0x2ae0c1[_0x7300('0x35')]);return db[_0x7300('0x21')][_0x7300('0x36')](_0x50f520)[_0x7300('0x19')](handleEntityNotFound(_0x379a00,null))[_0x7300('0x19')](respondWithResult(_0x379a00,null))[_0x7300('0x37')](handleError(_0x379a00,null));};exports[_0x7300('0x38')]=function(_0xad3793,_0x4ead96){return db['MailInteraction'][_0x7300('0x38')](_0xad3793[_0x7300('0x39')],{})[_0x7300('0x19')](respondWithResult(_0x4ead96,0xc9))['catch'](handleError(_0x4ead96,null));};exports['update']=function(_0x378352,_0x287fef){if(_0x378352[_0x7300('0x39')]['id']){delete _0x378352[_0x7300('0x39')]['id'];}return db[_0x7300('0x21')][_0x7300('0x36')]({'where':{'id':_0x378352[_0x7300('0x2b')]['id']}})[_0x7300('0x19')](handleEntityNotFound(_0x287fef,null))[_0x7300('0x19')](saveUpdates(_0x378352[_0x7300('0x39')],null))[_0x7300('0x19')](respondWithResult(_0x287fef,null))[_0x7300('0x37')](handleError(_0x287fef,null));};exports[_0x7300('0x1a')]=function(_0x235606,_0x5814c7){return db['MailInteraction']['find']({'where':{'id':_0x235606[_0x7300('0x2b')]['id']}})['then'](handleEntityNotFound(_0x5814c7,null))[_0x7300('0x19')](removeEntity(_0x5814c7,null))['catch'](handleError(_0x5814c7,null));};exports[_0x7300('0x3a')]=function(_0x239733,_0x41cab6){return db['MailInteraction'][_0x7300('0x3a')]()[_0x7300('0x19')](respondWithResult(_0x41cab6,null))[_0x7300('0x37')](handleError(_0x41cab6,null));};exports[_0x7300('0x3b')]=function(_0x40a978,_0x4dca77){return db[_0x7300('0x3c')]['find']({'where':{'id':_0x40a978['params']['id']}})[_0x7300('0x19')](handleEntityNotFound(_0x4dca77,null))[_0x7300('0x19')](function(_0x49d29c){if(_0x49d29c){return _0x49d29c['addMessage'](_0x40a978[_0x7300('0x39')][_0x7300('0x3d')],_['omit'](_0x40a978[_0x7300('0x39')],['ids','id'])||{});}})[_0x7300('0x19')](respondWithResult(_0x4dca77,null))[_0x7300('0x37')](handleError(_0x4dca77,null));};exports[_0x7300('0x3e')]=function(_0x13978a,_0x2cdce8){var _0x9c86ae={'raw':![],'where':{}};var _0x3caa05={};var _0x2ee94a={'count':0x0,'rows':[]};return db['MailInteraction']['findOne']({'where':{'id':_0x13978a[_0x7300('0x2b')]['id']}})[_0x7300('0x19')](handleEntityNotFound(_0x2cdce8,null))[_0x7300('0x19')](function(_0x1838ac){if(_0x1838ac){_0x3caa05[_0x7300('0x2c')]=_[_0x7300('0x2d')](db[_0x7300('0x3c')][_0x7300('0x3f')]);_0x3caa05[_0x7300('0x28')]=_[_0x7300('0x2d')](_0x13978a[_0x7300('0x28')]);_0x3caa05['filters']=_[_0x7300('0x2f')](_0x3caa05[_0x7300('0x2c')],_0x3caa05[_0x7300('0x28')]);_0x9c86ae['attributes']=_[_0x7300('0x2f')](_0x3caa05[_0x7300('0x2c')],qs[_0x7300('0x31')](_0x13978a[_0x7300('0x28')][_0x7300('0x31')]));_0x9c86ae[_0x7300('0x30')]=_0x9c86ae[_0x7300('0x30')][_0x7300('0x40')]?_0x9c86ae[_0x7300('0x30')]:_0x3caa05[_0x7300('0x2c')];if(!_0x13978a[_0x7300('0x28')]['hasOwnProperty'](_0x7300('0x41'))){_0x9c86ae[_0x7300('0x16')]=qs['limit'](_0x13978a[_0x7300('0x28')][_0x7300('0x16')]);_0x9c86ae[_0x7300('0x13')]=qs[_0x7300('0x13')](_0x13978a[_0x7300('0x28')][_0x7300('0x13')]);}_0x9c86ae[_0x7300('0x42')]=qs['sort'](_0x13978a[_0x7300('0x28')][_0x7300('0x43')]);_0x9c86ae[_0x7300('0x44')]=qs[_0x7300('0x2e')](_[_0x7300('0x45')](_0x13978a[_0x7300('0x28')],_0x3caa05[_0x7300('0x2e')]));_0x9c86ae[_0x7300('0x44')][_0x7300('0x46')]=_0x1838ac['id'];if(_0x13978a[_0x7300('0x28')][_0x7300('0x47')]){_0x9c86ae[_0x7300('0x44')]=_[_0x7300('0x34')](_0x9c86ae[_0x7300('0x44')],{'$or':_[_0x7300('0x20')](_0x9c86ae[_0x7300('0x30')],function(_0x53dad7){var _0x4ea656={};_0x4ea656[_0x53dad7]={'$like':'%'+_0x13978a['query'][_0x7300('0x47')]+'%'};return _0x4ea656;})});}if(_0x13978a[_0x7300('0x28')][_0x7300('0x48')]){var _0x3fdac6=_0x13978a[_0x7300('0x28')][_0x7300('0x48')][_0x7300('0x49')](',');var _0x2c1043={};_0x2c1043[_0x3fdac6[0x0]]={'$gte':moment(_0x3fdac6[0x1])[_0x7300('0x4a')]('YYYY-MM-DD\x20HH:mm:ss')};_0x9c86ae['where']=_[_0x7300('0x34')](_0x9c86ae[_0x7300('0x44')],_0x2c1043);}_0x9c86ae=_['merge']({},_0x9c86ae,_0x13978a[_0x7300('0x35')]);return db[_0x7300('0x3c')][_0x7300('0x15')]({'where':_0x9c86ae[_0x7300('0x44')]})[_0x7300('0x19')](function(_0x49e8d2){_0x2ee94a[_0x7300('0x15')]=_0x49e8d2;if(_0x13978a[_0x7300('0x28')][_0x7300('0x32')]){_0x9c86ae[_0x7300('0x33')]=[{'all':!![]}];}return db[_0x7300('0x3c')][_0x7300('0x26')](_0x9c86ae);})[_0x7300('0x19')](function(_0x2314fc){if(_0x13978a['query'][_0x7300('0x4b')]==='true'){for(var _0x46234c=0x0;_0x46234c<_0x2314fc[_0x7300('0x40')];_0x46234c++){_0x2314fc[_0x46234c][_0x7300('0x39')]=juice(_0x2314fc[_0x46234c][_0x7300('0x39')]);}}_0x2ee94a[_0x7300('0x4c')]=_0x2314fc;return _0x2ee94a;});}})[_0x7300('0x19')](respondWithFilteredResult(_0x2cdce8,_0x9c86ae))[_0x7300('0x37')](handleError(_0x2cdce8,null));};exports[_0x7300('0x4d')]=function(_0x52a9f6,_0x32914a){return db[_0x7300('0x21')][_0x7300('0x36')]({'where':{'id':_0x52a9f6[_0x7300('0x2b')]['id']}})[_0x7300('0x19')](handleEntityNotFound(_0x32914a,null))[_0x7300('0x19')](function(_0x2faad5){if(_0x2faad5){return _0x2faad5[_0x7300('0x4e')](_0x52a9f6[_0x7300('0x39')]['ids'],_[_0x7300('0x4f')](_0x52a9f6[_0x7300('0x39')],[_0x7300('0x3d'),'id'])||{})[_0x7300('0x50')](function(){return db[_0x7300('0x51')]['findAll']({'attributes':['id',_0x7300('0x1e'),_0x7300('0x52')],'where':{'id':_0x52a9f6[_0x7300('0x39')][_0x7300('0x3d')]}});})[_0x7300('0x19')](function(_0x1f31e6){socket[_0x7300('0x53')](_0x7300('0x54'),{'id':Number(_0x52a9f6['params']['id']),'tags':_0x1f31e6||[]});return{'id':Number(_0x52a9f6[_0x7300('0x2b')]['id']),'tags':_0x1f31e6||[]};});}})[_0x7300('0x19')](respondWithResult(_0x32914a,null))[_0x7300('0x37')](handleError(_0x32914a,null));};exports[_0x7300('0x55')]=function(_0x28475a,_0x5729c9){return db[_0x7300('0x21')][_0x7300('0x36')]({'where':{'id':_0x28475a[_0x7300('0x2b')]['id']}})[_0x7300('0x19')](handleEntityNotFound(_0x5729c9,null))[_0x7300('0x19')](function(_0x18d6f1){if(_0x18d6f1){return _0x18d6f1['removeTags'](_0x28475a[_0x7300('0x28')][_0x7300('0x3d')]);}})[_0x7300('0x19')](respondWithStatusCode(_0x5729c9,null))[_0x7300('0x37')](handleError(_0x5729c9,null));};exports[_0x7300('0x56')]=function(_0x447422,_0xb4bb32){var _0x5609b8=moment()[_0x7300('0x57')]()[_0x7300('0x58')]();var _0x2a8be9=path[_0x7300('0x59')](config['root'],_0x7300('0x5a'),_0x7300('0x5b'),'tmp');var _0x204196=path[_0x7300('0x59')](config[_0x7300('0x5c')],_0x7300('0x5a'),_0x7300('0x5b'),_0x7300('0x5d'));var _0x4caac4=path[_0x7300('0x59')](_0x2a8be9,_0x5609b8);var _0x57f708=util[_0x7300('0x4a')](_0x7300('0x5e'),_0x447422['params']['id'],_0x5609b8);var _0x2c9689=path[_0x7300('0x59')](_0x2a8be9,_0x57f708);var _0x358aee=[];if(_0x447422[_0x7300('0x28')][_0x7300('0x5d')]){_0x358aee['push']({'model':db['Attachment'],'as':_0x7300('0x5f'),'raw':!![]});}var _0x2ab44d=[{'model':db['MailMessage'],'as':_0x7300('0x60'),'attributes':['id','body',_0x7300('0x61'),'to','cc',_0x7300('0x62'),_0x7300('0x63'),_0x7300('0x64')],'where':{'secret':![]},'order':qs[_0x7300('0x43')]('id'),'include':_0x358aee}];return db[_0x7300('0x21')]['find']({'where':{'id':_0x447422[_0x7300('0x2b')]['id']},'include':_0x2ab44d})[_0x7300('0x19')](handleEntityNotFound(_0xb4bb32,null))[_0x7300('0x19')](function(_0x3c9d37){if(_0x3c9d37&&_0x3c9d37['Messages']){var _0xf74aec=_0x3c9d37['get']({'plain':!![]});fs['mkdirSync'](_0x4caac4);return BPromise[_0x7300('0x65')](_0xf74aec[_0x7300('0x60')],function(_0x24e6b4,_0x572b93){var _0x586fe2={'from':_0x24e6b4['from'],'to':_0x24e6b4['to']||_0x7300('0x66'),'subject':_0x24e6b4[_0x7300('0x63')],'html':htmlEntities[_0x7300('0x67')](_0x24e6b4['body']),'headers':{'Date':moment(_0x24e6b4[_0x7300('0x64')])[_0x7300('0x4a')](_0x7300('0x68'))},'attachments':[]};if(_0x24e6b4['cc']){_0x586fe2[_0x7300('0x69')]['Cc']=_0x24e6b4['cc'];}if(_0x24e6b4[_0x7300('0x62')]){_0x586fe2[_0x7300('0x69')]['Bcc']=_0x24e6b4[_0x7300('0x62')];}return new BPromise(function(_0x9feedf,_0x1701e5){if(_0x24e6b4[_0x7300('0x5f')]){for(var _0x29e5c1=0x0;_0x29e5c1<_0x24e6b4['Attachments']['length'];_0x29e5c1++){var _0x3043fd=_0x24e6b4[_0x7300('0x5f')][_0x29e5c1];var _0x1dadce=path[_0x7300('0x59')](_0x204196,_0x3043fd[_0x7300('0x6a')]);if(fs[_0x7300('0x6b')](_0x1dadce)){_0x586fe2['attachments'][_0x7300('0x6c')]({'name':_0x3043fd[_0x7300('0x1e')],'contentType':_0x3043fd['type'],'data':fs[_0x7300('0x6d')](_0x1dadce)});}}}emlformat['build'](_0x586fe2,function(_0x18712b,_0x3384ad){if(_0x18712b)return _0x1701e5(_0x18712b);fs[_0x7300('0x6e')](path[_0x7300('0x59')](_0x4caac4,util[_0x7300('0x4a')](_0x7300('0x6f'),_0x572b93)),_0x3384ad);return _0x9feedf(_0x3384ad);});});})[_0x7300('0x19')](function(){return new BPromise(function(_0x4d4bef,_0x5a7037){zipdir(_0x4caac4,{'saveTo':_0x2c9689},function(_0x39e988,_0x2a9fcb){if(_0x39e988)return _0x5a7037(_0x39e988);return _0x4d4bef(_0x2a9fcb);});})['then'](function(){return new BPromise(function(_0x51d74c,_0x3c2f86){rimraf(_0x4caac4,function(_0x54d1de){if(_0x54d1de)_0x3c2f86(_0x54d1de);return _0x51d74c();});});})[_0x7300('0x19')](function(){return _0xb4bb32[_0x7300('0x56')](_0x2c9689,_0x57f708,function(_0x1edfbc){if(!_0x1edfbc)fs['unlinkSync'](_0x2c9689);});});});}else{return _0xb4bb32['sendStatus'](0xc8);}})['catch'](handleError(_0xb4bb32,null));};
\ No newline at end of file