Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index 7629a81..3df24d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6ede=['../../mysqldb','redis','./mailAccount.socket','register','jayson/promise','client','info','request\x20sent','debug','error','message','MailAccount,\x20%s,\x20%s','result','catch','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','update','then','destroy','get','MailAccounts','UserProfileResource','stack','name','yahoo','imap.mail.yahoo.com','hotmail','imap-mail.outlook.com','gmail','smtp.gmail.com','smtp.mail.yahoo.com','smtp-mail.outlook.com','outlook365','Unknown\x20email\x20service\x20provider','user','username','password','pass','modernAuthentication','CloudProviderId','host','port','secure','service','authentication','Imap','Smtp','index','MailServerOut','Pause','mandatoryDispositionPause','MailAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','includeAll','findAll','rows','show','params','MailServerIn','include','options','body','custom','find','describe','MailAccountId','Disposition','create','getDispositions','findOne','nolimit','pick','removeDispositions','ids','addAnswer','map','CannedAnswer','removeAnswers','provider','email','ListId','isNil','active','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','removeImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','omit','getInteractions','MailInteraction','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','MailApplication','bulkCreate','priority','finally','getApplications','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','MailMessage','true','send','CmList','List','CmContact','Contacts','updatedAt','DESC','CloudProvider','Smtp\x20configuration\x20not\x20found','from','attachments','root','basename','getSmtpOptions','SendMail','sendMail','List\x20not\x20found','messageId','out','Interaction','VerifySmtp','verifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','removeAgents','isArray','userMailAccount:remove','getAgents','moment','bluebird','util','path','lodash','juice','api'];(function(_0xc6971f,_0x53138a){var _0x28ca53=function(_0xa0f0b4){while(--_0xa0f0b4){_0xc6971f['push'](_0xc6971f['shift']());}};_0x28ca53(++_0x53138a);}(_0x6ede,0xb6));var _0xe6ed=function(_0x587693,_0x27fe90){_0x587693=_0x587693-0x0;var _0x510a1a=_0x6ede[_0x587693];return _0x510a1a;};'use strict';var moment=require(_0xe6ed('0x0'));var BPromise=require(_0xe6ed('0x1'));var util=require(_0xe6ed('0x2'));var path=require(_0xe6ed('0x3'));var _=require(_0xe6ed('0x4'));var juice=require(_0xe6ed('0x5'));var Redis=require('ioredis');var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0xe6ed('0x6'));var config=require('../../config/environment');var db=require(_0xe6ed('0x7'))['db'];config['redis']=_['defaults'](config[_0xe6ed('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe6ed('0x9'))[_0xe6ed('0xa')](socket);var jayson=require(_0xe6ed('0xb'));var client=jayson[_0xe6ed('0xc')]['http']({'port':0x232b});function respondWithRpcPromise(_0x53d025,_0x58d687,_0x31f4e2,_0x41bf4c){return new BPromise(function(_0x1ba92c,_0x537930){var _0x4eba4e=_0x41bf4c||client;return _0x4eba4e['request'](_0x53d025,_0x31f4e2)['then'](function(_0x157930){logger[_0xe6ed('0xd')]('MailAccount,\x20%s,\x20%s',_0x58d687,_0xe6ed('0xe'));logger[_0xe6ed('0xf')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x58d687,'request\x20sent',JSON['stringify'](_0x157930));if(_0x157930['error']){if(_0x157930[_0xe6ed('0x10')]['code']===0x1f4){logger[_0xe6ed('0x10')]('MailAccount,\x20%s,\x20%s',_0x58d687,_0x157930[_0xe6ed('0x10')][_0xe6ed('0x11')]);return _0x537930(_0x157930['error']['message']);}logger['error']('MailAccount,\x20%s,\x20%s',_0x58d687,_0x157930['error'][_0xe6ed('0x11')]);return _0x1ba92c(_0x157930[_0xe6ed('0x10')][_0xe6ed('0x11')]);}else{logger[_0xe6ed('0xd')](_0xe6ed('0x12'),_0x58d687,'request\x20sent');_0x1ba92c(_0x157930[_0xe6ed('0x13')][_0xe6ed('0x11')]);}})[_0xe6ed('0x14')](function(_0x520069){logger['error'](_0xe6ed('0x12'),_0x58d687,_0x520069);_0x537930(_0x520069);});});}function respondWithStatusCode(_0x4b3cc8,_0x5893db){_0x5893db=_0x5893db||0xcc;return function(_0x2cd004){if(_0x2cd004){return _0x4b3cc8[_0xe6ed('0x15')](_0x5893db);}return _0x4b3cc8[_0xe6ed('0x16')](_0x5893db)[_0xe6ed('0x17')]();};}function respondWithResult(_0xfc1330,_0x3e20eb){_0x3e20eb=_0x3e20eb||0xc8;return function(_0x121534){if(_0x121534){return _0xfc1330[_0xe6ed('0x16')](_0x3e20eb)[_0xe6ed('0x18')](_0x121534);}};}function respondWithFilteredResult(_0x4db1d4,_0x57b529){return function(_0x35fa46){if(_0x35fa46){var _0x394307=typeof _0x57b529['offset']===_0xe6ed('0x19')&&typeof _0x57b529[_0xe6ed('0x1a')]===_0xe6ed('0x19');var _0x362680=_0x35fa46[_0xe6ed('0x1b')];var _0x1e1884=_0x394307?0x0:_0x57b529[_0xe6ed('0x1c')];var _0x2fc69e=_0x394307?_0x35fa46['count']:_0x57b529[_0xe6ed('0x1c')]+_0x57b529[_0xe6ed('0x1a')];var _0x2ca89f;if(_0x2fc69e>=_0x362680){_0x2fc69e=_0x362680;_0x2ca89f=0xc8;}else{_0x2ca89f=0xce;}_0x4db1d4[_0xe6ed('0x16')](_0x2ca89f);return _0x4db1d4['set'](_0xe6ed('0x1d'),_0x1e1884+'-'+_0x2fc69e+'/'+_0x362680)[_0xe6ed('0x18')](_0x35fa46);}return null;};}function saveUpdates(_0x42ef26){return function(_0x15e3e2){if(_0x15e3e2){return _0x15e3e2[_0xe6ed('0x1e')](_0x42ef26)[_0xe6ed('0x1f')](function(_0x53ca50){return _0x53ca50;});}return null;};}function removeEntity(_0x281a5f){return function(_0x592f62){if(_0x592f62){return _0x592f62[_0xe6ed('0x20')]()[_0xe6ed('0x1f')](function(){var _0x1fc7cc=_0x592f62[_0xe6ed('0x21')]({'plain':!![]});var _0x36848e=_0xe6ed('0x22');return db[_0xe6ed('0x23')][_0xe6ed('0x20')]({'where':{'type':_0x36848e,'resourceId':_0x1fc7cc['id']}})[_0xe6ed('0x1f')](function(){return _0x592f62;});})[_0xe6ed('0x1f')](function(){_0x281a5f[_0xe6ed('0x16')](0xcc)[_0xe6ed('0x17')]();});}};}function handleEntityNotFound(_0x17abcc){return function(_0x37a4ac){if(!_0x37a4ac){_0x17abcc[_0xe6ed('0x15')](0x194);}return _0x37a4ac;};}function handleError(_0x57c9fc,_0x11a61a){_0x11a61a=_0x11a61a||0x1f4;return function(_0x5a69b1){logger[_0xe6ed('0x10')](_0x5a69b1[_0xe6ed('0x24')]);if(_0x5a69b1['name']){delete _0x5a69b1[_0xe6ed('0x25')];}_0x57c9fc[_0xe6ed('0x16')](_0x11a61a)['send'](_0x5a69b1);};}function getImapHost(_0x59f3b0){switch(_0x59f3b0){case'gmail':return'imap.gmail.com';case _0xe6ed('0x26'):return _0xe6ed('0x27');case _0xe6ed('0x28'):return _0xe6ed('0x29');case'outlook365':return'outlook.office365.com';}throw new Error('Unknown\x20email\x20service\x20provider',_0x59f3b0);}function getSmtpHost(_0x256776){switch(_0x256776){case _0xe6ed('0x2a'):return _0xe6ed('0x2b');case _0xe6ed('0x26'):return _0xe6ed('0x2c');case _0xe6ed('0x28'):return _0xe6ed('0x2d');case _0xe6ed('0x2e'):return'smtp.office365.com';}throw new Error(_0xe6ed('0x2f'),_0x256776);}function getAuthenticationOptions(_0x1252dd,_0x3ea47f){var _0x4ce8a0={};var _0x2811cb={};if(_0x1252dd){_0x4ce8a0[_0xe6ed('0x30')]=_0x2811cb[_0xe6ed('0x30')]=_0x3ea47f[_0xe6ed('0x31')];_0x4ce8a0[_0xe6ed('0x32')]=_0x2811cb[_0xe6ed('0x33')]=_0x3ea47f['password'];if(_0x3ea47f['modernAuthentication']){_0x4ce8a0[_0xe6ed('0x34')]=_0x2811cb[_0xe6ed('0x34')]=!![];_0x4ce8a0[_0xe6ed('0x35')]=_0x2811cb['CloudProviderId']=_0x3ea47f['CloudProviderId'];_0x4ce8a0[_0xe6ed('0x32')]=_0x2811cb[_0xe6ed('0x33')]=null;}else{_0x4ce8a0[_0xe6ed('0x35')]=_0x2811cb['CloudProviderId']=null;}_0x4ce8a0[_0xe6ed('0x36')]=getImapHost(_0x1252dd);_0x4ce8a0['port']=0x3e1;_0x2811cb[_0xe6ed('0x36')]=getSmtpHost(_0x1252dd);_0x2811cb[_0xe6ed('0x37')]=0x24b;_0x2811cb[_0xe6ed('0x38')]=![];_0x4ce8a0[_0xe6ed('0x39')]=_0x2811cb[_0xe6ed('0x39')]=null;}else{if(_0x3ea47f[_0xe6ed('0x3a')]){_0x4ce8a0[_0xe6ed('0x30')]=_0x2811cb['user']=_0x3ea47f[_0xe6ed('0x31')];_0x4ce8a0[_0xe6ed('0x32')]=_0x2811cb[_0xe6ed('0x33')]=_0x3ea47f[_0xe6ed('0x32')];}else{_0x4ce8a0[_0xe6ed('0x3a')]=_0x2811cb[_0xe6ed('0x3a')]=![];_0x4ce8a0[_0xe6ed('0x30')]=_0x2811cb[_0xe6ed('0x30')]=null;_0x4ce8a0[_0xe6ed('0x32')]=_0x2811cb[_0xe6ed('0x33')]=null;}_0x4ce8a0['host']=_0x3ea47f[_0xe6ed('0x3b')]['host'];_0x4ce8a0[_0xe6ed('0x37')]=_0x3ea47f[_0xe6ed('0x3b')][_0xe6ed('0x37')];_0x2811cb['host']=_0x3ea47f[_0xe6ed('0x3c')][_0xe6ed('0x36')];_0x2811cb[_0xe6ed('0x37')]=_0x3ea47f[_0xe6ed('0x3c')][_0xe6ed('0x37')];}return{'Imap':_0x4ce8a0,'Smtp':_0x2811cb};}exports[_0xe6ed('0x3d')]=function(_0x18e1b0,_0x595d78){var _0x44f148={'include':[{'model':db['MailServerIn'],'as':_0xe6ed('0x3b')},{'model':db[_0xe6ed('0x3e')],'as':_0xe6ed('0x3c')},{'model':db[_0xe6ed('0x3f')],'as':_0xe6ed('0x40')}]},_0x13173d={},_0x562fb6={'count':0x0,'rows':[]};var _0x4a5495=_['map'](db[_0xe6ed('0x41')][_0xe6ed('0x42')],function(_0x5047aa){return{'name':_0x5047aa[_0xe6ed('0x43')],'type':_0x5047aa[_0xe6ed('0x44')][_0xe6ed('0x45')]};});_0x13173d[_0xe6ed('0x46')]=_['map'](_0x4a5495,_0xe6ed('0x25'));_0x13173d[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x18e1b0[_0xe6ed('0x47')]);_0x13173d[_0xe6ed('0x49')]=_['intersection'](_0x13173d['model'],_0x13173d[_0xe6ed('0x47')]);_0x44f148[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x13173d['model'],qs[_0xe6ed('0x4c')](_0x18e1b0[_0xe6ed('0x47')][_0xe6ed('0x4c')]));_0x44f148[_0xe6ed('0x4a')]=_0x44f148['attributes'][_0xe6ed('0x4d')]?_0x44f148[_0xe6ed('0x4a')]:_0x13173d[_0xe6ed('0x46')];if(!_0x18e1b0[_0xe6ed('0x47')][_0xe6ed('0x4e')]('nolimit')){_0x44f148[_0xe6ed('0x1a')]=qs['limit'](_0x18e1b0['query']['limit']);_0x44f148[_0xe6ed('0x1c')]=qs[_0xe6ed('0x1c')](_0x18e1b0[_0xe6ed('0x47')][_0xe6ed('0x1c')]);}_0x44f148[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x18e1b0['query'][_0xe6ed('0x50')]);_0x44f148[_0xe6ed('0x51')]=qs[_0xe6ed('0x49')](_['pick'](_0x18e1b0['query'],_0x13173d[_0xe6ed('0x49')]),_0x4a5495);if(_0x18e1b0['query'][_0xe6ed('0x52')]){_0x44f148[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x44f148[_0xe6ed('0x51')],{'$or':_['map'](_0x4a5495,function(_0x45a435){if(_0x45a435[_0xe6ed('0x44')]!==_0xe6ed('0x54')){var _0x36d657={};_0x36d657[_0x45a435['name']]={'$like':'%'+_0x18e1b0[_0xe6ed('0x47')][_0xe6ed('0x52')]+'%'};return _0x36d657;}})});}_0x44f148=_[_0xe6ed('0x53')]({},_0x44f148,_0x18e1b0['options']);var _0x464da6={'where':_0x44f148['where']};return db[_0xe6ed('0x41')][_0xe6ed('0x1b')](_0x464da6)['then'](function(_0x2e46d5){_0x562fb6[_0xe6ed('0x1b')]=_0x2e46d5;if(_0x18e1b0[_0xe6ed('0x47')][_0xe6ed('0x55')]){_0x44f148['include']=[{'all':!![]}];}return db[_0xe6ed('0x41')][_0xe6ed('0x56')](_0x44f148);})[_0xe6ed('0x1f')](function(_0x419779){_0x562fb6[_0xe6ed('0x57')]=_0x419779;return _0x562fb6;})['then'](respondWithFilteredResult(_0x595d78,_0x44f148))[_0xe6ed('0x14')](handleError(_0x595d78,null));};exports[_0xe6ed('0x58')]=function(_0x4dabc1,_0x44537a){var _0x3270e0={'raw':![],'where':{'id':_0x4dabc1[_0xe6ed('0x59')]['id']},'include':[{'model':db[_0xe6ed('0x5a')],'as':_0xe6ed('0x3b')},{'model':db[_0xe6ed('0x3e')],'as':_0xe6ed('0x3c')},{'model':db[_0xe6ed('0x3f')],'as':_0xe6ed('0x40')}]},_0x169e4b={};_0x169e4b[_0xe6ed('0x46')]=_[_0xe6ed('0x48')](db[_0xe6ed('0x41')]['rawAttributes']);_0x169e4b[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x4dabc1[_0xe6ed('0x47')]);_0x169e4b[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x169e4b[_0xe6ed('0x46')],_0x169e4b[_0xe6ed('0x47')]);_0x3270e0[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x169e4b[_0xe6ed('0x46')],qs[_0xe6ed('0x4c')](_0x4dabc1[_0xe6ed('0x47')][_0xe6ed('0x4c')]));_0x3270e0[_0xe6ed('0x4a')]=_0x3270e0[_0xe6ed('0x4a')][_0xe6ed('0x4d')]?_0x3270e0[_0xe6ed('0x4a')]:_0x169e4b[_0xe6ed('0x46')];if(_0x4dabc1[_0xe6ed('0x47')][_0xe6ed('0x55')]){_0x3270e0[_0xe6ed('0x5b')]=[{'all':!![]}];}_0x3270e0=_[_0xe6ed('0x53')]({},_0x3270e0,_0x4dabc1[_0xe6ed('0x5c')]);return db[_0xe6ed('0x41')]['find'](_0x3270e0)[_0xe6ed('0x1f')](handleEntityNotFound(_0x44537a,null))[_0xe6ed('0x1f')](respondWithResult(_0x44537a,null))[_0xe6ed('0x14')](handleError(_0x44537a,null));};exports[_0xe6ed('0x1e')]=function(_0x49d6b9,_0x45f1a9){if(_0x49d6b9[_0xe6ed('0x5d')]['id']){delete _0x49d6b9[_0xe6ed('0x5d')]['id'];}var _0x26545c=_0x49d6b9[_0xe6ed('0x5d')]['provider']===_0xe6ed('0x5e')?null:_0x49d6b9[_0xe6ed('0x5d')]['provider'];var _0x1e166d=_0x49d6b9['body']['Imap']||{};var _0x531743=_0x49d6b9[_0xe6ed('0x5d')]['Smtp']||{};if(_0x26545c){_0x1e166d[_0xe6ed('0x36')]=getImapHost(_0x26545c);_0x1e166d[_0xe6ed('0x37')]=0x3e1;_0x531743['host']=getSmtpHost(_0x26545c);_0x531743['port']=0x24b;_0x531743[_0xe6ed('0x38')]=![];}if(_0x531743[_0xe6ed('0x34')]){_0x531743[_0xe6ed('0x38')]=![];}else{_0x531743[_0xe6ed('0x35')]=null;}if(!_0x1e166d[_0xe6ed('0x34')])_0x1e166d[_0xe6ed('0x35')]=null;_0x49d6b9['body'][_0xe6ed('0x3b')]=_0x1e166d;_0x49d6b9[_0xe6ed('0x5d')][_0xe6ed('0x3c')]=_0x531743;return db['MailAccount'][_0xe6ed('0x5f')]({'where':{'id':_0x49d6b9[_0xe6ed('0x59')]['id']},'include':[{'model':db[_0xe6ed('0x5a')],'as':_0xe6ed('0x3b')},{'model':db[_0xe6ed('0x3e')],'as':_0xe6ed('0x3c')},{'model':db[_0xe6ed('0x3f')],'as':_0xe6ed('0x40')}]})[_0xe6ed('0x1f')](handleEntityNotFound(_0x45f1a9,null))[_0xe6ed('0x1f')](function(_0x446984){if(!_0x446984)throw new Error('Mail\x20Account\x20not\x20found');if(_0x446984[_0xe6ed('0x39')])delete _0x49d6b9[_0xe6ed('0x5d')][_0xe6ed('0x3b')];return _0x446984;})['then'](saveUpdates(_0x49d6b9[_0xe6ed('0x5d')],null))[_0xe6ed('0x1f')](function(_0x30006d){if(!_0x49d6b9[_0xe6ed('0x5d')][_0xe6ed('0x3b')])return _0x30006d;return db['MailServerIn']['update'](_0x49d6b9['body'][_0xe6ed('0x3b')],{'where':{'MailAccountId':_0x30006d['id']}})[_0xe6ed('0x1f')](function(){return _0x30006d;});})[_0xe6ed('0x1f')](function(_0x4a0bf4){if(!_0x49d6b9[_0xe6ed('0x5d')]['Smtp'])return _0x4a0bf4;return db[_0xe6ed('0x3e')][_0xe6ed('0x1e')](_0x49d6b9['body'][_0xe6ed('0x3c')],{'where':{'MailAccountId':_0x4a0bf4['id']}})['then'](function(){return _0x4a0bf4;});})[_0xe6ed('0x1f')](respondWithResult(_0x45f1a9,null))['catch'](handleError(_0x45f1a9,null));};exports[_0xe6ed('0x60')]=function(_0x375053,_0x2998ee){return db[_0xe6ed('0x41')][_0xe6ed('0x60')]()[_0xe6ed('0x1f')](respondWithResult(_0x2998ee,null))[_0xe6ed('0x14')](handleError(_0x2998ee,null));};exports['addDisposition']=function(_0x45a6bc,_0x473ca8){if(_0x45a6bc[_0xe6ed('0x5d')]['id']){delete _0x45a6bc[_0xe6ed('0x5d')]['id'];}return db['MailAccount'][_0xe6ed('0x5f')]({'where':{'id':_0x45a6bc['params']['id']}})['then'](handleEntityNotFound(_0x473ca8,null))[_0xe6ed('0x1f')](function(_0x5582a8){if(_0x5582a8){_0x45a6bc[_0xe6ed('0x5d')][_0xe6ed('0x61')]=_0x5582a8['id'];return db[_0xe6ed('0x62')][_0xe6ed('0x63')](_0x45a6bc['body']);}})['then'](respondWithResult(_0x473ca8,null))[_0xe6ed('0x14')](handleError(_0x473ca8,null));};exports[_0xe6ed('0x64')]=function(_0x403b83,_0x2c54d5){var _0x43419a={'raw':![],'where':{}};var _0x52b2fd={};var _0x1b535b={'count':0x0,'rows':[]};return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x403b83[_0xe6ed('0x59')]['id']}})['then'](handleEntityNotFound(_0x2c54d5,null))[_0xe6ed('0x1f')](function(_0x27985f){if(_0x27985f){_0x52b2fd[_0xe6ed('0x46')]=_[_0xe6ed('0x48')](db[_0xe6ed('0x62')][_0xe6ed('0x42')]);_0x52b2fd[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x403b83[_0xe6ed('0x47')]);_0x52b2fd[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x52b2fd[_0xe6ed('0x46')],_0x52b2fd['query']);_0x43419a[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x52b2fd[_0xe6ed('0x46')],qs[_0xe6ed('0x4c')](_0x403b83['query'][_0xe6ed('0x4c')]));_0x43419a['attributes']=_0x43419a['attributes'][_0xe6ed('0x4d')]?_0x43419a[_0xe6ed('0x4a')]:_0x52b2fd[_0xe6ed('0x46')];if(!_0x403b83[_0xe6ed('0x47')][_0xe6ed('0x4e')](_0xe6ed('0x66'))){_0x43419a[_0xe6ed('0x1a')]=qs['limit'](_0x403b83[_0xe6ed('0x47')]['limit']);_0x43419a['offset']=qs[_0xe6ed('0x1c')](_0x403b83[_0xe6ed('0x47')][_0xe6ed('0x1c')]);}_0x43419a[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x403b83['query'][_0xe6ed('0x50')]);_0x43419a[_0xe6ed('0x51')]=qs['filters'](_[_0xe6ed('0x67')](_0x403b83['query'],_0x52b2fd[_0xe6ed('0x49')]));_0x43419a[_0xe6ed('0x51')]['MailAccountId']=_0x27985f['id'];if(_0x403b83['query'][_0xe6ed('0x52')]){_0x43419a['where']=_[_0xe6ed('0x53')](_0x43419a[_0xe6ed('0x51')],{'$or':_['map'](_0x43419a[_0xe6ed('0x4a')],function(_0x2bb791){var _0x134134={};_0x134134[_0x2bb791]={'$like':'%'+_0x403b83['query'][_0xe6ed('0x52')]+'%'};return _0x134134;})});}_0x43419a=_[_0xe6ed('0x53')]({},_0x43419a,_0x403b83[_0xe6ed('0x5c')]);return db[_0xe6ed('0x62')][_0xe6ed('0x1b')]({'where':_0x43419a[_0xe6ed('0x51')]})['then'](function(_0x109bd5){_0x1b535b[_0xe6ed('0x1b')]=_0x109bd5;if(_0x403b83[_0xe6ed('0x47')][_0xe6ed('0x55')]){_0x43419a['include']=[{'all':!![]}];}return db[_0xe6ed('0x62')]['findAll'](_0x43419a);})[_0xe6ed('0x1f')](function(_0x4a47b5){_0x1b535b[_0xe6ed('0x57')]=_0x4a47b5;return _0x1b535b;});}})[_0xe6ed('0x1f')](respondWithFilteredResult(_0x2c54d5,_0x43419a))['catch'](handleError(_0x2c54d5,null));};exports[_0xe6ed('0x68')]=function(_0x16b603,_0x3b2d21){return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x16b603[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x3b2d21,null))[_0xe6ed('0x1f')](function(_0x160354){if(_0x160354){return _0x160354[_0xe6ed('0x68')](_0x16b603[_0xe6ed('0x47')][_0xe6ed('0x69')]);}})['then'](respondWithStatusCode(_0x3b2d21,null))[_0xe6ed('0x14')](handleError(_0x3b2d21,null));};exports[_0xe6ed('0x6a')]=function(_0x348398,_0x10ef69){if(_0x348398[_0xe6ed('0x5d')]['id']){delete _0x348398[_0xe6ed('0x5d')]['id'];}return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x348398[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x10ef69,null))[_0xe6ed('0x1f')](function(_0x37ad61){if(_0x37ad61){_0x348398['body'][_0xe6ed('0x61')]=_0x37ad61['id'];return db['CannedAnswer'][_0xe6ed('0x63')](_0x348398['body']);}})[_0xe6ed('0x1f')](respondWithResult(_0x10ef69,null))[_0xe6ed('0x14')](handleError(_0x10ef69,null));};exports['getAnswers']=function(_0x5285b2,_0x533090){var _0x4303fd={'raw':![],'where':{}};var _0x56b36a={};var _0x195a16={'count':0x0,'rows':[]};return db[_0xe6ed('0x41')]['findOne']({'where':{'id':_0x5285b2[_0xe6ed('0x59')]['id']}})['then'](handleEntityNotFound(_0x533090,null))['then'](function(_0x5e6bda){if(_0x5e6bda){_0x56b36a['model']=_[_0xe6ed('0x48')](db['CannedAnswer'][_0xe6ed('0x42')]);_0x56b36a[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x5285b2[_0xe6ed('0x47')]);_0x56b36a[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x56b36a['model'],_0x56b36a[_0xe6ed('0x47')]);_0x4303fd[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x56b36a['model'],qs[_0xe6ed('0x4c')](_0x5285b2['query'][_0xe6ed('0x4c')]));_0x4303fd[_0xe6ed('0x4a')]=_0x4303fd[_0xe6ed('0x4a')][_0xe6ed('0x4d')]?_0x4303fd[_0xe6ed('0x4a')]:_0x56b36a[_0xe6ed('0x46')];if(!_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x4e')](_0xe6ed('0x66'))){_0x4303fd[_0xe6ed('0x1a')]=qs[_0xe6ed('0x1a')](_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x1a')]);_0x4303fd[_0xe6ed('0x1c')]=qs[_0xe6ed('0x1c')](_0x5285b2[_0xe6ed('0x47')]['offset']);}_0x4303fd[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x50')]);_0x4303fd[_0xe6ed('0x51')]=qs[_0xe6ed('0x49')](_[_0xe6ed('0x67')](_0x5285b2[_0xe6ed('0x47')],_0x56b36a[_0xe6ed('0x49')]));_0x4303fd['where']['MailAccountId']=_0x5e6bda['id'];if(_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x52')]){_0x4303fd[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x4303fd['where'],{'$or':_[_0xe6ed('0x6b')](_0x4303fd[_0xe6ed('0x4a')],function(_0x10db18){var _0x2d6614={};_0x2d6614[_0x10db18]={'$like':'%'+_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x52')]+'%'};return _0x2d6614;})});}_0x4303fd=_[_0xe6ed('0x53')]({},_0x4303fd,_0x5285b2['options']);return db[_0xe6ed('0x6c')][_0xe6ed('0x1b')]({'where':_0x4303fd[_0xe6ed('0x51')]})[_0xe6ed('0x1f')](function(_0x3e3b48){_0x195a16[_0xe6ed('0x1b')]=_0x3e3b48;if(_0x5285b2[_0xe6ed('0x47')][_0xe6ed('0x55')]){_0x4303fd[_0xe6ed('0x5b')]=[{'all':!![]}];}return db[_0xe6ed('0x6c')][_0xe6ed('0x56')](_0x4303fd);})[_0xe6ed('0x1f')](function(_0x993809){_0x195a16[_0xe6ed('0x57')]=_0x993809;return _0x195a16;});}})['then'](respondWithFilteredResult(_0x533090,_0x4303fd))[_0xe6ed('0x14')](handleError(_0x533090,null));};exports[_0xe6ed('0x6d')]=function(_0x734dcc,_0x45bd7e){return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x734dcc[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x45bd7e,null))[_0xe6ed('0x1f')](function(_0x3130cd){if(_0x3130cd){return _0x3130cd[_0xe6ed('0x6d')](_0x734dcc['query']['ids']);}})['then'](respondWithStatusCode(_0x45bd7e,null))[_0xe6ed('0x14')](handleError(_0x45bd7e,null));};exports['create']=function(_0x1ebb22,_0x1266db){var _0x13be06={'name':_0x1ebb22[_0xe6ed('0x5d')][_0xe6ed('0x25')],'key':_0x1ebb22['body'][_0xe6ed('0x45')],'provider':_0x1ebb22['body']['provider']===_0xe6ed('0x5e')?null:_0x1ebb22[_0xe6ed('0x5d')][_0xe6ed('0x6e')],'email':_0x1ebb22[_0xe6ed('0x5d')][_0xe6ed('0x6f')],'ListId':_0x1ebb22[_0xe6ed('0x5d')][_0xe6ed('0x70')],'active':!_[_0xe6ed('0x71')](_0x1ebb22['body'][_0xe6ed('0x72')])?_0x1ebb22[_0xe6ed('0x5d')][_0xe6ed('0x72')]:!![],'description':_0x1ebb22[_0xe6ed('0x5d')]['description']||null};var _0x591cab=getAuthenticationOptions(_0x13be06['provider'],_0x1ebb22['body']);_0x13be06['Imap']=_0x591cab[_0xe6ed('0x3b')];_0x13be06[_0xe6ed('0x3c')]=_0x591cab[_0xe6ed('0x3c')];return db['MailAccount'][_0xe6ed('0x63')](_0x13be06,{'include':[{'model':db[_0xe6ed('0x3e')],'as':'Smtp'},{'model':db[_0xe6ed('0x5a')],'as':_0xe6ed('0x3b')}]})[_0xe6ed('0x1f')](function(_0x2460b0){var _0x204be3=_0x1ebb22[_0xe6ed('0x30')][_0xe6ed('0x21')]({'plain':!![]});if(!_0x204be3)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x204be3[_0xe6ed('0x73')]==='user'){var _0x181a3e=_0x2460b0[_0xe6ed('0x21')]({'plain':!![]});return db['UserProfileSection'][_0xe6ed('0x5f')]({'where':{'name':'MailAccounts','userProfileId':_0x204be3[_0xe6ed('0x74')]},'raw':!![]})[_0xe6ed('0x1f')](function(_0x1723c9){if(_0x1723c9&&_0x1723c9[_0xe6ed('0x75')]===0x0){return db[_0xe6ed('0x23')][_0xe6ed('0x63')]({'name':_0x181a3e['name'],'resourceId':_0x181a3e['id'],'type':_0x1723c9[_0xe6ed('0x25')],'sectionId':_0x1723c9['id']},{})[_0xe6ed('0x1f')](function(){return _0x2460b0;});}else{return _0x2460b0;}})[_0xe6ed('0x14')](function(_0x37cbb4){logger[_0xe6ed('0x10')](_0xe6ed('0x76'),_0x37cbb4);throw _0x37cbb4;});}return _0x2460b0;})['then'](respondWithResult(_0x1266db,0xc9))[_0xe6ed('0x14')](handleError(_0x1266db,null));};exports[_0xe6ed('0x77')]=function(_0x373f70,_0x1dbb1d){return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x373f70[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x1dbb1d,null))['then'](function(_0x239383){if(_0x239383){return _0x239383[_0xe6ed('0x77')]();}return null;})[_0xe6ed('0x1f')](respondWithResult(_0x1dbb1d,null))['catch'](handleError(_0x1dbb1d,null));};exports['addImap']=function(_0x51d188,_0xe8d4c){if(_0x51d188[_0xe6ed('0x5d')]['id']){delete _0x51d188[_0xe6ed('0x5d')]['id'];}return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x51d188['params']['id']}})['then'](handleEntityNotFound(_0xe8d4c,null))[_0xe6ed('0x1f')](function(_0x14c61e){if(_0x14c61e){_0x51d188[_0xe6ed('0x5d')][_0xe6ed('0x61')]=_0x14c61e['id'];return db[_0xe6ed('0x5a')][_0xe6ed('0x63')](_0x51d188[_0xe6ed('0x5d')]);}})[_0xe6ed('0x1f')](respondWithResult(_0xe8d4c,null))[_0xe6ed('0x14')](handleError(_0xe8d4c,null));};exports[_0xe6ed('0x78')]=function(_0x12c051,_0x507f70){return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x12c051[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x507f70,null))[_0xe6ed('0x1f')](function(_0x5a2047){if(_0x5a2047){return _0x5a2047['setImap'](null);}return null;})['then'](respondWithStatusCode(_0x507f70,null))[_0xe6ed('0x14')](handleError(_0x507f70,null));};exports[_0xe6ed('0x79')]=function(_0x32085a,_0x40b884){return db[_0xe6ed('0x41')]['findOne']({'where':{'id':_0x32085a[_0xe6ed('0x59')]['id']}})['then'](handleEntityNotFound(_0x40b884,null))[_0xe6ed('0x1f')](function(_0x420260){if(_0x420260){return _0x420260[_0xe6ed('0x79')]();}return null;})[_0xe6ed('0x1f')](respondWithResult(_0x40b884,null))[_0xe6ed('0x14')](handleError(_0x40b884,null));};exports[_0xe6ed('0x7a')]=function(_0x40de6c,_0x5fefdd){if(_0x40de6c[_0xe6ed('0x5d')]['id']){delete _0x40de6c['body']['id'];}return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x40de6c['params']['id']}})['then'](handleEntityNotFound(_0x5fefdd,null))[_0xe6ed('0x1f')](function(_0x1579ab){if(_0x1579ab){_0x40de6c['body'][_0xe6ed('0x61')]=_0x1579ab['id'];return db['MailServerOut']['create'](_0x40de6c[_0xe6ed('0x5d')]);}})[_0xe6ed('0x1f')](respondWithResult(_0x5fefdd,null))[_0xe6ed('0x14')](handleError(_0x5fefdd,null));};exports[_0xe6ed('0x7b')]=function(_0x5ddd7b,_0x5edd1d){return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x5ddd7b[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x5edd1d,null))[_0xe6ed('0x1f')](function(_0x4e91e9){if(_0x4e91e9){return _0x4e91e9[_0xe6ed('0x7c')](null);}return null;})[_0xe6ed('0x1f')](respondWithStatusCode(_0x5edd1d,null))['catch'](handleError(_0x5edd1d,null));};exports['addInteraction']=function(_0x11ef12,_0x2a4352){return db['MailInteraction'][_0xe6ed('0x5f')]({'where':{'id':_0x11ef12[_0xe6ed('0x59')]['id']}})['then'](handleEntityNotFound(_0x2a4352,null))[_0xe6ed('0x1f')](function(_0x2f0955){if(_0x2f0955){return _0x2f0955[_0xe6ed('0x7d')](_0x11ef12['body']['ids'],_[_0xe6ed('0x7e')](_0x11ef12[_0xe6ed('0x5d')],[_0xe6ed('0x69'),'id'])||{});}})['then'](respondWithResult(_0x2a4352,null))[_0xe6ed('0x14')](handleError(_0x2a4352,null));};exports[_0xe6ed('0x7f')]=function(_0x3f23fe,_0x35cef5){var _0x39c04b={'raw':![],'where':{}};var _0x4b5979={};var _0x197bdc={'count':0x0,'rows':[]};return db['MailAccount'][_0xe6ed('0x65')]({'where':{'id':_0x3f23fe['params']['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x35cef5,null))[_0xe6ed('0x1f')](function(_0x326087){if(_0x326087){_0x4b5979[_0xe6ed('0x46')]=_['keys'](db[_0xe6ed('0x80')][_0xe6ed('0x42')]);_0x4b5979[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x3f23fe[_0xe6ed('0x47')]);_0x4b5979['filters']=_[_0xe6ed('0x4b')](_0x4b5979[_0xe6ed('0x46')],_0x4b5979['query']);_0x39c04b['attributes']=_['intersection'](_0x4b5979[_0xe6ed('0x46')],qs['fields'](_0x3f23fe[_0xe6ed('0x47')]['fields']));_0x39c04b[_0xe6ed('0x4a')]=_0x39c04b[_0xe6ed('0x4a')]['length']?_0x39c04b['attributes']:_0x4b5979[_0xe6ed('0x46')];if(!_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x4e')]('nolimit')){_0x39c04b[_0xe6ed('0x1a')]=qs[_0xe6ed('0x1a')](_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x1a')]);_0x39c04b[_0xe6ed('0x1c')]=qs[_0xe6ed('0x1c')](_0x3f23fe[_0xe6ed('0x47')]['offset']);}_0x39c04b[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x3f23fe['query'][_0xe6ed('0x50')]);_0x39c04b['where']=qs[_0xe6ed('0x49')](_[_0xe6ed('0x67')](_0x3f23fe[_0xe6ed('0x47')],_0x4b5979['filters']));_0x39c04b[_0xe6ed('0x51')][_0xe6ed('0x61')]=_0x326087['id'];if(_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x52')]){_0x39c04b['where']=_[_0xe6ed('0x53')](_0x39c04b['where'],{'$or':_['map'](_0x39c04b['attributes'],function(_0x2857a2){var _0x40af02={};_0x40af02[_0x2857a2]={'$like':'%'+_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x52')]+'%'};return _0x40af02;})});}_0x39c04b=_[_0xe6ed('0x53')]({},_0x39c04b,_0x3f23fe['options']);return db[_0xe6ed('0x80')]['count']({'where':_0x39c04b[_0xe6ed('0x51')]})[_0xe6ed('0x1f')](function(_0x579b54){_0x197bdc[_0xe6ed('0x1b')]=_0x579b54;if(_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x55')]){_0x39c04b[_0xe6ed('0x5b')]=[{'model':db['CmContact'],'as':_0xe6ed('0x81'),'required':![]},{'model':db[_0xe6ed('0x82')],'as':_0xe6ed('0x83'),'attributes':[_0xe6ed('0x25'),_0xe6ed('0x84'),_0xe6ed('0x85')],'required':![]},{'model':db[_0xe6ed('0x86')],'as':_0xe6ed('0x87'),'attributes':['id',_0xe6ed('0x25'),_0xe6ed('0x88')],'where':_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x89')]?{'id':_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x89')]}:undefined,'required':_0x3f23fe[_0xe6ed('0x47')][_0xe6ed('0x89')]?!![]:![]}];}return db[_0xe6ed('0x80')][_0xe6ed('0x56')](_0x39c04b);})[_0xe6ed('0x1f')](function(_0x415646){_0x197bdc['rows']=_0x415646;return _0x197bdc;});}})[_0xe6ed('0x1f')](respondWithFilteredResult(_0x35cef5,_0x39c04b))['catch'](handleError(_0x35cef5,null));};exports[_0xe6ed('0x8a')]=function addApplications(_0x3bcfd7,_0x4a7e0f){var _0x121a19=_0x3bcfd7['params']['id'];var _0x381299=_0x3bcfd7[_0xe6ed('0x5d')];var _0x3f4d02=0xc8;var _0x1ab4b4=null;return db[_0xe6ed('0x8b')][_0xe6ed('0x8c')]({'isolationLevel':db[_0xe6ed('0x8b')][_0xe6ed('0x8d')][_0xe6ed('0x8e')][_0xe6ed('0x8f')]},function(_0x35ffdd){return db[_0xe6ed('0x41')]['findOne']({'where':{'id':_0x121a19},'transaction':_0x35ffdd})[_0xe6ed('0x1f')](function(_0xa23e75){if(_0xa23e75){return db[_0xe6ed('0x90')][_0xe6ed('0x20')]({'where':{'MailAccountId':_0x121a19},'transaction':_0x35ffdd})['then'](function(){var _0x5a658f=_[_0xe6ed('0x6b')](_0x381299,function(_0x26c9c4){_0x26c9c4[_0xe6ed('0x61')]=_0x121a19;return _0x26c9c4;});return db[_0xe6ed('0x90')][_0xe6ed('0x91')](_0x5a658f,{'transaction':_0x35ffdd});});}else{_0x3f4d02=0x194;_0x1ab4b4=[];}});})[_0xe6ed('0x1f')](function(){if(_0x3f4d02!==0x194){return db[_0xe6ed('0x90')]['findAndCountAll']({'where':{'MailAccountId':_0x121a19},'order':_0xe6ed('0x92')})[_0xe6ed('0x1f')](function(_0x17fad2){_0x1ab4b4=_0x17fad2;});}})[_0xe6ed('0x14')](function(_0x1b6925){_0x3f4d02=0x1f4;logger[_0xe6ed('0x10')](_0x1b6925[_0xe6ed('0x24')]);if(_0x1b6925['name']){delete _0x1b6925['name'];}_0x1ab4b4=_0x1b6925;})[_0xe6ed('0x93')](function(){if(_0x1ab4b4===null){_0x4a7e0f[_0xe6ed('0x15')](_0x3f4d02);}else{if(_0x3f4d02===0x1f4){_0x4a7e0f['status'](_0x3f4d02)['send'](_0x1ab4b4);}else{_0x4a7e0f[_0xe6ed('0x16')](_0x3f4d02)['json'](_0x1ab4b4);}}});};exports[_0xe6ed('0x94')]=function(_0x280964,_0x505a5e){var _0x5e33bb={};var _0x1ab655={};var _0x281575;var _0x1e974c;return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x280964[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x505a5e,null))[_0xe6ed('0x1f')](function(_0x56f5a7){if(_0x56f5a7){_0x281575=_0x56f5a7;_0x1ab655[_0xe6ed('0x46')]=_[_0xe6ed('0x48')](db[_0xe6ed('0x90')][_0xe6ed('0x42')]);_0x1ab655[_0xe6ed('0x47')]=_['keys'](_0x280964[_0xe6ed('0x47')]);_0x1ab655[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x1ab655[_0xe6ed('0x46')],_0x1ab655['query']);_0x5e33bb[_0xe6ed('0x4a')]=_['intersection'](_0x1ab655['model'],qs['fields'](_0x280964[_0xe6ed('0x47')]['fields']));_0x5e33bb[_0xe6ed('0x4a')]=_0x5e33bb[_0xe6ed('0x4a')]['length']?_0x5e33bb[_0xe6ed('0x4a')]:_0x1ab655['model'];_0x5e33bb[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x280964[_0xe6ed('0x47')][_0xe6ed('0x50')]);_0x5e33bb[_0xe6ed('0x51')]=qs[_0xe6ed('0x49')](_[_0xe6ed('0x67')](_0x280964[_0xe6ed('0x47')],_0x1ab655[_0xe6ed('0x49')]));if(_0x280964[_0xe6ed('0x47')][_0xe6ed('0x52')]){_0x5e33bb[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x5e33bb[_0xe6ed('0x51')],{'$or':_[_0xe6ed('0x6b')](_0x5e33bb[_0xe6ed('0x4a')],function(_0x4bb4c0){var _0x150d8e={};_0x150d8e[_0x4bb4c0]={'$like':'%'+_0x280964['query']['filter']+'%'};return _0x150d8e;})});}_0x5e33bb=_['merge']({},_0x5e33bb,_0x280964[_0xe6ed('0x5c')]);return _0x281575[_0xe6ed('0x94')](_0x5e33bb);}})[_0xe6ed('0x1f')](function(_0x3356ac){if(_0x3356ac){_0x1e974c=_0x3356ac['length'];if(!_0x280964[_0xe6ed('0x47')][_0xe6ed('0x4e')](_0xe6ed('0x66'))){_0x5e33bb[_0xe6ed('0x1a')]=qs[_0xe6ed('0x1a')](_0x280964[_0xe6ed('0x47')][_0xe6ed('0x1a')]);_0x5e33bb[_0xe6ed('0x1c')]=qs['offset'](_0x280964[_0xe6ed('0x47')][_0xe6ed('0x1c')]);}return _0x281575[_0xe6ed('0x94')](_0x5e33bb);}})[_0xe6ed('0x1f')](function(_0x14d7a8){if(_0x14d7a8){return _0x14d7a8?{'count':_0x1e974c,'rows':_0x14d7a8}:null;}})['then'](respondWithResult(_0x505a5e,null))[_0xe6ed('0x14')](handleError(_0x505a5e,null));};exports[_0xe6ed('0x95')]=function(_0x339f26,_0x172f84){var _0x133182={'raw':!![],'where':{}};var _0x22b898={};var _0x337cc2={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x339f26[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x172f84,null))['then'](function(_0x2723ef){if(_0x2723ef){_0x22b898['model']=_['keys'](db['MailMessage']['rawAttributes']);_0x22b898[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x339f26[_0xe6ed('0x47')]);_0x22b898[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x22b898[_0xe6ed('0x46')],_0x22b898['query']);_0x133182[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x22b898[_0xe6ed('0x46')],qs['fields'](_0x339f26['query'][_0xe6ed('0x4c')]));_0x133182['attributes']=_0x133182[_0xe6ed('0x4a')][_0xe6ed('0x4d')]?_0x133182[_0xe6ed('0x4a')]:_0x22b898[_0xe6ed('0x46')];if(!_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x4e')](_0xe6ed('0x66'))){_0x133182['limit']=qs[_0xe6ed('0x1a')](_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x1a')]);_0x133182[_0xe6ed('0x1c')]=qs[_0xe6ed('0x1c')](_0x339f26['query']['offset']);}_0x133182[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x50')]);_0x133182[_0xe6ed('0x51')]=qs['filters'](_[_0xe6ed('0x67')](_0x339f26['query'],_0x22b898['filters']));_0x133182[_0xe6ed('0x51')]['MailAccountId']=_0x2723ef['id'];if(_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x52')]){_0x133182[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x133182[_0xe6ed('0x51')],{'$or':_[_0xe6ed('0x6b')](_0x133182[_0xe6ed('0x4a')],function(_0x449e72){var _0x2aedf9={};_0x2aedf9[_0x449e72]={'$like':'%'+_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x52')]+'%'};return _0x2aedf9;})});}if(_0x339f26[_0xe6ed('0x47')][_0xe6ed('0x96')]){var _0x5c6a18=_0x339f26['query'][_0xe6ed('0x96')][_0xe6ed('0x97')](',');var _0xd12cf={};_0xd12cf[_0x5c6a18[0x0]]={'$gte':moment(_0x5c6a18[0x1])[_0xe6ed('0x98')](_0xe6ed('0x99'))};_0x133182[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x133182[_0xe6ed('0x51')],_0xd12cf);}_0x133182=_[_0xe6ed('0x53')]({},_0x133182,_0x339f26[_0xe6ed('0x5c')]);return db[_0xe6ed('0x9a')][_0xe6ed('0x1b')]({'where':_0x133182[_0xe6ed('0x51')]})[_0xe6ed('0x1f')](function(_0x5d86dc){_0x337cc2[_0xe6ed('0x1b')]=_0x5d86dc;if(_0x339f26['query'][_0xe6ed('0x55')]){_0x133182[_0xe6ed('0x5b')]=[{'all':!![]}];}return db[_0xe6ed('0x9a')][_0xe6ed('0x56')](_0x133182);})[_0xe6ed('0x1f')](function(_0x1f07c6){if(_0x339f26['query']['inlineCss']===_0xe6ed('0x9b')){for(var _0x112206=0x0;_0x112206<_0x1f07c6[_0xe6ed('0x4d')];_0x112206++){_0x1f07c6[_0x112206][_0xe6ed('0x5d')]=juice(_0x1f07c6[_0x112206][_0xe6ed('0x5d')]);}}_0x337cc2['rows']=_0x1f07c6;return _0x337cc2;});}})[_0xe6ed('0x1f')](respondWithFilteredResult(_0x172f84,_0x133182))[_0xe6ed('0x14')](handleError(_0x172f84,null));};exports[_0xe6ed('0x9c')]=function(_0x3e0d1a,_0x30ace4){var _0x2126d6,_0x4eca36={},_0xa2ec1e;if(_0x3e0d1a['body']['to']){_0xa2ec1e=_0x3e0d1a[_0xe6ed('0x5d')]['to'][_0xe6ed('0x97')](',')[0x0];}return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x3e0d1a[_0xe6ed('0x59')]['id']},'include':[{'model':db[_0xe6ed('0x9d')],'as':_0xe6ed('0x9e'),'include':[{'model':db[_0xe6ed('0x9f')],'as':_0xe6ed('0xa0'),'where':{'email':_0xa2ec1e},'limit':0x1,'order':[[_0xe6ed('0xa1'),_0xe6ed('0xa2')]]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![],'include':[{'model':db[_0xe6ed('0xa3')],'as':_0xe6ed('0xa3'),'raw':!![]}]}]})[_0xe6ed('0x1f')](handleEntityNotFound(_0x30ace4,null))[_0xe6ed('0x1f')](function(_0x42f0f1){if(!_0x42f0f1)return;_0x2126d6=_0x42f0f1;if(!_0x42f0f1['Smtp'])throw new Error(_0xe6ed('0xa4'));if(_[_0xe6ed('0x71')](_0x3e0d1a[_0xe6ed('0x5d')][_0xe6ed('0xa5')])){_0x3e0d1a[_0xe6ed('0x5d')]['from']=util[_0xe6ed('0x98')]('%s\x20<%s>',_0x42f0f1[_0xe6ed('0x25')],_0x42f0f1[_0xe6ed('0x6f')]||_0x42f0f1[_0xe6ed('0x3c')][_0xe6ed('0x30')]);}if(_0x3e0d1a[_0xe6ed('0x5d')][_0xe6ed('0xa6')]&&_0x3e0d1a[_0xe6ed('0x5d')][_0xe6ed('0xa6')][_0xe6ed('0x4d')]){for(var _0x17ee2e=0x0;_0x17ee2e<_0x3e0d1a[_0xe6ed('0x5d')]['attachments'][_0xe6ed('0x4d')];_0x17ee2e+=0x1){_0x3e0d1a[_0xe6ed('0x5d')]['attachments'][_0x17ee2e]={'filename':_0x3e0d1a[_0xe6ed('0x5d')]['attachments'][_0x17ee2e][_0xe6ed('0x25')],'path':path['join'](config[_0xe6ed('0xa7')],'server/files/attachments',_0x3e0d1a[_0xe6ed('0x5d')]['attachments'][_0x17ee2e][_0xe6ed('0xa8')])};}}var _0x4759c4=_0x42f0f1[_0xe6ed('0xa9')]();return respondWithRpcPromise(_0xe6ed('0xaa'),_0xe6ed('0xab'),{'account':_0x4759c4,'message':_0x3e0d1a['body']});})[_0xe6ed('0x1f')](function(_0x401449){if(!_0x401449)return;_0x4eca36=_0x401449;if(!_0x2126d6[_0xe6ed('0x9e')])throw new Error(_0xe6ed('0xac'));if(_0x2126d6[_0xe6ed('0x9e')][_0xe6ed('0xa0')][_0xe6ed('0x4d')])return _0x2126d6[_0xe6ed('0x9e')][_0xe6ed('0xa0')][0x0];return db['CmContact'][_0xe6ed('0x63')](_['defaults'](_0x3e0d1a[_0xe6ed('0x5d')],{'firstName':_0x3e0d1a[_0xe6ed('0x5d')]['to'],'email':_0x3e0d1a['body']['to'],'phone':_0x3e0d1a[_0xe6ed('0x5d')]['to'],'ListId':_0x2126d6[_0xe6ed('0x70')]}));})[_0xe6ed('0x1f')](function(_0x41ee0f){if(!_0x41ee0f)return;var _0x4296b3={'UserId':_0x3e0d1a[_0xe6ed('0x30')]['id'],'ContactId':_0x41ee0f['id'],'MailAccountId':_0x2126d6['id'],'inReplyTo':_0x4eca36[_0xe6ed('0xad')],'to':_0x3e0d1a[_0xe6ed('0x5d')][_0xe6ed('0xa5')],'cc':_0x3e0d1a[_0xe6ed('0x5d')]['cc'],'subject':_0x3e0d1a[_0xe6ed('0x5d')]['subject'],'attach':_0x3e0d1a[_0xe6ed('0x5d')]['attach'],'firstMsgDirection':_0xe6ed('0xae'),'lastMsgAt':moment()[_0xe6ed('0x98')](_0xe6ed('0x99')),'lastMsgDirection':'out','Messages':[_[_0xe6ed('0x53')](_0x3e0d1a[_0xe6ed('0x5d')],{'messageId':_0x4eca36[_0xe6ed('0xad')],'sentAt':moment()['format'](_0xe6ed('0x99')),'read':!![],'MailAccountId':_0x2126d6['id'],'UserId':_0x3e0d1a[_0xe6ed('0x30')]['id'],'ContactId':_0x41ee0f['id']})]};if(_0x3e0d1a['body'][_0xe6ed('0xaf')]){_0x4296b3=_[_0xe6ed('0x53')](_0x4296b3,_0x3e0d1a['body'][_0xe6ed('0xaf')]);}return db['MailInteraction']['create'](_0x4296b3,{'include':[{'model':db['MailMessage'],'as':'Messages'}]});})[_0xe6ed('0x1f')](respondWithResult(_0x30ace4,null))[_0xe6ed('0x14')](handleError(_0x30ace4,null));};exports['verifySmtp']=function(_0x255c5a,_0x5e4c68){return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x255c5a[_0xe6ed('0x59')]['id']},'include':[{'model':db[_0xe6ed('0x3e')],'as':_0xe6ed('0x3c'),'raw':!![],'include':[{'model':db[_0xe6ed('0xa3')],'as':_0xe6ed('0xa3'),'raw':!![]}]}]})[_0xe6ed('0x1f')](handleEntityNotFound(_0x5e4c68,null))[_0xe6ed('0x1f')](function(_0x4d3884){if(!_0x4d3884[_0xe6ed('0x3c')])return;var _0x40139f=_0x4d3884[_0xe6ed('0xa9')]();return respondWithRpcPromise(_0xe6ed('0xb0'),_0xe6ed('0xb1'),{'account':_0x40139f});})['then'](respondWithResult(_0x5e4c68,null))[_0xe6ed('0x14')](handleError(_0x5e4c68,null));};exports[_0xe6ed('0x20')]=function(_0x314f28,_0x48f620){return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0x314f28[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x48f620,null))[_0xe6ed('0x1f')](function(_0x5094c3){if(_0x5094c3&&_0x5094c3[_0xe6ed('0x39')]){throw new db[(_0xe6ed('0xb2'))][(_0xe6ed('0xb3'))](_0xe6ed('0xb4'));}return _0x5094c3;})[_0xe6ed('0x1f')](removeEntity(_0x48f620,null))[_0xe6ed('0x14')](handleError(_0x48f620,null));};exports[_0xe6ed('0xb5')]=function(_0xcffbd5,_0x171b86){return db[_0xe6ed('0x41')][_0xe6ed('0x5f')]({'where':{'id':_0xcffbd5[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x171b86,null))[_0xe6ed('0x1f')](function(_0x20d87c){if(_0x20d87c){return _0x20d87c[_0xe6ed('0xb5')](_0xcffbd5['body']['ids'],_[_0xe6ed('0x7e')](_0xcffbd5[_0xe6ed('0x5d')],[_0xe6ed('0x69'),'id'])||{})[_0xe6ed('0xb6')](function(_0x557478){for(var _0x89a7d0=0x0;_0x89a7d0<_0xcffbd5['body']['ids'][_0xe6ed('0x4d')];_0x89a7d0+=0x1){socket[_0xe6ed('0xb7')](_0xe6ed('0xb8'),{'UserId':Number(_0xcffbd5['body']['ids'][_0x89a7d0]),'MailAccountId':Number(_0xcffbd5[_0xe6ed('0x59')]['id'])});}return _0x557478;});}})[_0xe6ed('0x1f')](respondWithResult(_0x171b86,null))['catch'](handleError(_0x171b86,null));};exports[_0xe6ed('0xb9')]=function(_0x2c0a9d,_0x4caae3){return db['MailAccount'][_0xe6ed('0x5f')]({'where':{'id':_0x2c0a9d[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x4caae3,null))['then'](function(_0x5a076f){if(_0x5a076f){return _0x5a076f[_0xe6ed('0xb9')](_0x2c0a9d[_0xe6ed('0x47')]['ids'])[_0xe6ed('0x1f')](function(){if(_[_0xe6ed('0xba')](_0x2c0a9d['query'][_0xe6ed('0x69')])){for(var _0x13a40b=0x0;_0x13a40b<_0x2c0a9d[_0xe6ed('0x47')][_0xe6ed('0x69')][_0xe6ed('0x4d')];_0x13a40b+=0x1){socket[_0xe6ed('0xb7')](_0xe6ed('0xbb'),{'UserId':Number(_0x2c0a9d[_0xe6ed('0x47')]['ids'][_0x13a40b]),'MailAccountId':Number(_0x2c0a9d['params']['id'])});}}else{socket[_0xe6ed('0xb7')](_0xe6ed('0xbb'),{'UserId':Number(_0x2c0a9d['query'][_0xe6ed('0x69')]),'MailAccountId':Number(_0x2c0a9d[_0xe6ed('0x59')]['id'])});}});}})[_0xe6ed('0x1f')](respondWithStatusCode(_0x4caae3,null))['catch'](handleError(_0x4caae3,null));};exports[_0xe6ed('0xbc')]=function(_0x2ed9fe,_0x3a6d6c){var _0x3410dd={};var _0x2de0ee={};var _0xdd8c36;var _0x501dfc;return db[_0xe6ed('0x41')][_0xe6ed('0x65')]({'where':{'id':_0x2ed9fe[_0xe6ed('0x59')]['id']}})[_0xe6ed('0x1f')](handleEntityNotFound(_0x3a6d6c,null))['then'](function(_0x232730){if(_0x232730){_0xdd8c36=_0x232730;_0x2de0ee[_0xe6ed('0x46')]=_['keys'](db['User'][_0xe6ed('0x42')]);_0x2de0ee[_0xe6ed('0x47')]=_[_0xe6ed('0x48')](_0x2ed9fe[_0xe6ed('0x47')]);_0x2de0ee[_0xe6ed('0x49')]=_[_0xe6ed('0x4b')](_0x2de0ee[_0xe6ed('0x46')],_0x2de0ee[_0xe6ed('0x47')]);_0x3410dd[_0xe6ed('0x4a')]=_[_0xe6ed('0x4b')](_0x2de0ee['model'],qs[_0xe6ed('0x4c')](_0x2ed9fe['query'][_0xe6ed('0x4c')]));_0x3410dd[_0xe6ed('0x4a')]=_0x3410dd['attributes']['length']?_0x3410dd[_0xe6ed('0x4a')]:_0x2de0ee[_0xe6ed('0x46')];_0x3410dd[_0xe6ed('0x4f')]=qs[_0xe6ed('0x50')](_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x50')]);_0x3410dd['where']=qs['filters'](_[_0xe6ed('0x67')](_0x2ed9fe[_0xe6ed('0x47')],_0x2de0ee[_0xe6ed('0x49')]));if(_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x52')]){_0x3410dd[_0xe6ed('0x51')]=_[_0xe6ed('0x53')](_0x3410dd[_0xe6ed('0x51')],{'$or':_[_0xe6ed('0x6b')](_0x3410dd[_0xe6ed('0x4a')],function(_0x549d25){var _0x5c0ea1={};_0x5c0ea1[_0x549d25]={'$like':'%'+_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x52')]+'%'};return _0x5c0ea1;})});}_0x3410dd=_[_0xe6ed('0x53')]({},_0x3410dd,_0x2ed9fe['options']);return _0xdd8c36[_0xe6ed('0xbc')](_0x3410dd);}})[_0xe6ed('0x1f')](function(_0x2d05e8){if(_0x2d05e8){_0x501dfc=_0x2d05e8[_0xe6ed('0x4d')];if(!_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x4e')]('nolimit')){_0x3410dd[_0xe6ed('0x1a')]=qs[_0xe6ed('0x1a')](_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x1a')]);_0x3410dd[_0xe6ed('0x1c')]=qs[_0xe6ed('0x1c')](_0x2ed9fe[_0xe6ed('0x47')][_0xe6ed('0x1c')]);}return _0xdd8c36[_0xe6ed('0xbc')](_0x3410dd);}})[_0xe6ed('0x1f')](function(_0x21c48d){if(_0x21c48d){return _0x21c48d?{'count':_0x501dfc,'rows':_0x21c48d}:null;}})[_0xe6ed('0x1f')](respondWithResult(_0x3a6d6c,null))[_0xe6ed('0x14')](handleError(_0x3a6d6c,null));};
\ No newline at end of file
+var _0xd6c8=['userMailAccount:remove','getAgents','moment','util','lodash','juice','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','client','http','request','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','error','message','info','result','catch','sendStatus','status','offset','limit','undefined','count','set','Content-Range','update','get','MailAccounts','UserProfileResource','end','stack','name','send','gmail','imap.gmail.com','yahoo','imap.mail.yahoo.com','hotmail','imap-mail.outlook.com','Unknown\x20email\x20service\x20provider','smtp.gmail.com','smtp.mail.yahoo.com','smtp-mail.outlook.com','user','username','password','modernAuthentication','CloudProviderId','pass','host','port','secure','service','authentication','Imap','Smtp','index','MailServerOut','Pause','mandatoryDispositionPause','map','MailAccount','type','key','model','query','filters','intersection','attributes','fields','nolimit','sort','where','filter','VIRTUAL','merge','options','includeAll','findAll','rows','show','rawAttributes','keys','include','find','body','provider','params','Mail\x20Account\x20not\x20found','MailServerIn','describe','addDisposition','MailAccountId','create','getDispositions','findOne','Disposition','length','hasOwnProperty','order','removeDispositions','addAnswer','CannedAnswer','getAnswers','pick','removeAnswers','custom','email','ListId','isNil','active','description','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','removeImap','setImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','ids','omit','getInteractions','CmContact','User','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','MailApplication','bulkCreate','findAndCountAll','finally','json','getApplications','getMessages','MailMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','inlineCss','CmList','DESC','CloudProvider','Smtp\x20configuration\x20not\x20found','from','%s\x20<%s>','attachments','root','basename','getSmtpOptions','SendMail','List','List\x20not\x20found','Contacts','messageId','attach','out','Interaction','Messages','verifySmtp','VerifySmtp','destroy','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','removeAgents','isArray'];(function(_0x14b24f,_0x23814c){var _0x5530fc=function(_0x1baa50){while(--_0x1baa50){_0x14b24f['push'](_0x14b24f['shift']());}};_0x5530fc(++_0x23814c);}(_0xd6c8,0x192));var _0x8d6c=function(_0x4d934b,_0x52f8e9){_0x4d934b=_0x4d934b-0x0;var _0xc0338b=_0xd6c8[_0x4d934b];return _0xc0338b;};'use strict';var moment=require(_0x8d6c('0x0'));var BPromise=require('bluebird');var util=require(_0x8d6c('0x1'));var path=require('path');var _=require(_0x8d6c('0x2'));var juice=require(_0x8d6c('0x3'));var Redis=require('ioredis');var qs=require(_0x8d6c('0x4'));var logger=require(_0x8d6c('0x5'))(_0x8d6c('0x6'));var config=require(_0x8d6c('0x7'));var db=require(_0x8d6c('0x8'))['db'];config[_0x8d6c('0x9')]=_[_0x8d6c('0xa')](config[_0x8d6c('0x9')],{'host':_0x8d6c('0xb'),'port':0x18eb});var socket=require(_0x8d6c('0xc'))(new Redis(config[_0x8d6c('0x9')]));require(_0x8d6c('0xd'))[_0x8d6c('0xe')](socket);var jayson=require('jayson/promise');var client=jayson[_0x8d6c('0xf')][_0x8d6c('0x10')]({'port':0x232b});function respondWithRpcPromise(_0x47a0a0,_0x2d3aae,_0x44c04a,_0x11ae81){return new BPromise(function(_0x4fdc9e,_0x340eba){var _0x588a90=_0x11ae81||client;return _0x588a90[_0x8d6c('0x11')](_0x47a0a0,_0x44c04a)[_0x8d6c('0x12')](function(_0x841fe2){logger['info'](_0x8d6c('0x13'),_0x2d3aae,_0x8d6c('0x14'));logger[_0x8d6c('0x15')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x2d3aae,_0x8d6c('0x14'),JSON['stringify'](_0x841fe2));if(_0x841fe2[_0x8d6c('0x16')]){if(_0x841fe2[_0x8d6c('0x16')]['code']===0x1f4){logger['error'](_0x8d6c('0x13'),_0x2d3aae,_0x841fe2['error']['message']);return _0x340eba(_0x841fe2[_0x8d6c('0x16')][_0x8d6c('0x17')]);}logger[_0x8d6c('0x16')](_0x8d6c('0x13'),_0x2d3aae,_0x841fe2[_0x8d6c('0x16')]['message']);return _0x4fdc9e(_0x841fe2[_0x8d6c('0x16')][_0x8d6c('0x17')]);}else{logger[_0x8d6c('0x18')](_0x8d6c('0x13'),_0x2d3aae,_0x8d6c('0x14'));_0x4fdc9e(_0x841fe2[_0x8d6c('0x19')][_0x8d6c('0x17')]);}})[_0x8d6c('0x1a')](function(_0x430c94){logger[_0x8d6c('0x16')](_0x8d6c('0x13'),_0x2d3aae,_0x430c94);_0x340eba(_0x430c94);});});}function respondWithStatusCode(_0x49003b,_0x11c810){_0x11c810=_0x11c810||0xcc;return function(_0x511239){if(_0x511239){return _0x49003b[_0x8d6c('0x1b')](_0x11c810);}return _0x49003b[_0x8d6c('0x1c')](_0x11c810)['end']();};}function respondWithResult(_0x29c238,_0x46b5fe){_0x46b5fe=_0x46b5fe||0xc8;return function(_0x2f437d){if(_0x2f437d){return _0x29c238['status'](_0x46b5fe)['json'](_0x2f437d);}};}function respondWithFilteredResult(_0xc3038f,_0x5199eb){return function(_0x10e948){if(_0x10e948){var _0xf33860=typeof _0x5199eb[_0x8d6c('0x1d')]==='undefined'&&typeof _0x5199eb[_0x8d6c('0x1e')]===_0x8d6c('0x1f');var _0x3055de=_0x10e948[_0x8d6c('0x20')];var _0x287231=_0xf33860?0x0:_0x5199eb[_0x8d6c('0x1d')];var _0x5bfa4e=_0xf33860?_0x10e948[_0x8d6c('0x20')]:_0x5199eb[_0x8d6c('0x1d')]+_0x5199eb[_0x8d6c('0x1e')];var _0xd99c09;if(_0x5bfa4e>=_0x3055de){_0x5bfa4e=_0x3055de;_0xd99c09=0xc8;}else{_0xd99c09=0xce;}_0xc3038f[_0x8d6c('0x1c')](_0xd99c09);return _0xc3038f[_0x8d6c('0x21')](_0x8d6c('0x22'),_0x287231+'-'+_0x5bfa4e+'/'+_0x3055de)['json'](_0x10e948);}return null;};}function saveUpdates(_0x28c1c6){return function(_0x175098){if(_0x175098){return _0x175098[_0x8d6c('0x23')](_0x28c1c6)[_0x8d6c('0x12')](function(_0x5b5b90){return _0x5b5b90;});}return null;};}function removeEntity(_0x2a815b){return function(_0x2a243d){if(_0x2a243d){return _0x2a243d['destroy']()['then'](function(){var _0x33331f=_0x2a243d[_0x8d6c('0x24')]({'plain':!![]});var _0x58556a=_0x8d6c('0x25');return db[_0x8d6c('0x26')]['destroy']({'where':{'type':_0x58556a,'resourceId':_0x33331f['id']}})[_0x8d6c('0x12')](function(){return _0x2a243d;});})[_0x8d6c('0x12')](function(){_0x2a815b[_0x8d6c('0x1c')](0xcc)[_0x8d6c('0x27')]();});}};}function handleEntityNotFound(_0x3b2912){return function(_0x3f762b){if(!_0x3f762b){_0x3b2912[_0x8d6c('0x1b')](0x194);}return _0x3f762b;};}function handleError(_0x462635,_0x34177f){_0x34177f=_0x34177f||0x1f4;return function(_0x18eeb7){logger[_0x8d6c('0x16')](_0x18eeb7[_0x8d6c('0x28')]);if(_0x18eeb7[_0x8d6c('0x29')]){delete _0x18eeb7[_0x8d6c('0x29')];}_0x462635['status'](_0x34177f)[_0x8d6c('0x2a')](_0x18eeb7);};}function getImapHost(_0xf36378){switch(_0xf36378){case _0x8d6c('0x2b'):return _0x8d6c('0x2c');case _0x8d6c('0x2d'):return _0x8d6c('0x2e');case _0x8d6c('0x2f'):return _0x8d6c('0x30');case'outlook365':return'outlook.office365.com';}throw new Error(_0x8d6c('0x31'),_0xf36378);}function getSmtpHost(_0x5c3688){switch(_0x5c3688){case'gmail':return _0x8d6c('0x32');case'yahoo':return _0x8d6c('0x33');case _0x8d6c('0x2f'):return _0x8d6c('0x34');case'outlook365':return'smtp.office365.com';}throw new Error(_0x8d6c('0x31'),_0x5c3688);}function getAuthenticationOptions(_0x20739a,_0x20f112){var _0x2b9997={};var _0x265ca5={};if(_0x20739a){_0x2b9997[_0x8d6c('0x35')]=_0x265ca5[_0x8d6c('0x35')]=_0x20f112[_0x8d6c('0x36')];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5['pass']=_0x20f112['password'];if(_0x20f112[_0x8d6c('0x38')]){_0x2b9997['modernAuthentication']=_0x265ca5['modernAuthentication']=!![];_0x2b9997[_0x8d6c('0x39')]=_0x265ca5[_0x8d6c('0x39')]=_0x20f112['CloudProviderId'];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5[_0x8d6c('0x3a')]=null;}else{_0x2b9997[_0x8d6c('0x39')]=_0x265ca5[_0x8d6c('0x39')]=null;}_0x2b9997[_0x8d6c('0x3b')]=getImapHost(_0x20739a);_0x2b9997[_0x8d6c('0x3c')]=0x3e1;_0x265ca5[_0x8d6c('0x3b')]=getSmtpHost(_0x20739a);_0x265ca5['port']=0x24b;_0x265ca5[_0x8d6c('0x3d')]=![];_0x2b9997[_0x8d6c('0x3e')]=_0x265ca5[_0x8d6c('0x3e')]=null;}else{if(_0x20f112[_0x8d6c('0x3f')]){_0x2b9997['user']=_0x265ca5[_0x8d6c('0x35')]=_0x20f112[_0x8d6c('0x36')];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5[_0x8d6c('0x3a')]=_0x20f112[_0x8d6c('0x37')];}else{_0x2b9997[_0x8d6c('0x3f')]=_0x265ca5[_0x8d6c('0x3f')]=![];_0x2b9997[_0x8d6c('0x35')]=_0x265ca5[_0x8d6c('0x35')]=null;_0x2b9997['password']=_0x265ca5['pass']=null;}_0x2b9997['host']=_0x20f112[_0x8d6c('0x40')][_0x8d6c('0x3b')];_0x2b9997[_0x8d6c('0x3c')]=_0x20f112[_0x8d6c('0x40')][_0x8d6c('0x3c')];_0x265ca5[_0x8d6c('0x3b')]=_0x20f112[_0x8d6c('0x41')]['host'];_0x265ca5['port']=_0x20f112[_0x8d6c('0x41')][_0x8d6c('0x3c')];}return{'Imap':_0x2b9997,'Smtp':_0x265ca5};}exports[_0x8d6c('0x42')]=function(_0x1abe81,_0x52a568){var _0x51e7a8={'include':[{'model':db['MailServerIn'],'as':'Imap'},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]},_0x59223d={},_0x153115={'count':0x0,'rows':[]};var _0x249386=_[_0x8d6c('0x46')](db[_0x8d6c('0x47')]['rawAttributes'],function(_0x4503e9){return{'name':_0x4503e9['fieldName'],'type':_0x4503e9[_0x8d6c('0x48')][_0x8d6c('0x49')]};});_0x59223d[_0x8d6c('0x4a')]=_[_0x8d6c('0x46')](_0x249386,_0x8d6c('0x29'));_0x59223d[_0x8d6c('0x4b')]=_['keys'](_0x1abe81[_0x8d6c('0x4b')]);_0x59223d[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x59223d[_0x8d6c('0x4a')],_0x59223d[_0x8d6c('0x4b')]);_0x51e7a8[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x59223d['model'],qs[_0x8d6c('0x4f')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x51e7a8['attributes']=_0x51e7a8['attributes']['length']?_0x51e7a8['attributes']:_0x59223d['model'];if(!_0x1abe81[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x51e7a8[_0x8d6c('0x1e')]=qs['limit'](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x51e7a8[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x51e7a8['order']=qs[_0x8d6c('0x51')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x51e7a8[_0x8d6c('0x52')]=qs['filters'](_['pick'](_0x1abe81[_0x8d6c('0x4b')],_0x59223d[_0x8d6c('0x4c')]),_0x249386);if(_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x51e7a8[_0x8d6c('0x52')]=_['merge'](_0x51e7a8[_0x8d6c('0x52')],{'$or':_['map'](_0x249386,function(_0x419bce){if(_0x419bce[_0x8d6c('0x48')]!==_0x8d6c('0x54')){var _0x2ba688={};_0x2ba688[_0x419bce[_0x8d6c('0x29')]]={'$like':'%'+_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x2ba688;}})});}_0x51e7a8=_[_0x8d6c('0x55')]({},_0x51e7a8,_0x1abe81[_0x8d6c('0x56')]);var _0x1df4fb={'where':_0x51e7a8[_0x8d6c('0x52')]};return db['MailAccount'][_0x8d6c('0x20')](_0x1df4fb)[_0x8d6c('0x12')](function(_0x2f8aab){_0x153115['count']=_0x2f8aab;if(_0x1abe81['query'][_0x8d6c('0x57')]){_0x51e7a8['include']=[{'all':!![]}];}return db['MailAccount'][_0x8d6c('0x58')](_0x51e7a8);})[_0x8d6c('0x12')](function(_0x2ce507){_0x153115[_0x8d6c('0x59')]=_0x2ce507;return _0x153115;})[_0x8d6c('0x12')](respondWithFilteredResult(_0x52a568,_0x51e7a8))[_0x8d6c('0x1a')](handleError(_0x52a568,null));};exports[_0x8d6c('0x5a')]=function(_0x34e59e,_0x43b237){var _0x5862ca={'raw':![],'where':{'id':_0x34e59e['params']['id']},'include':[{'model':db['MailServerIn'],'as':_0x8d6c('0x40')},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]},_0xf02ec5={};_0xf02ec5['model']=_['keys'](db[_0x8d6c('0x47')][_0x8d6c('0x5b')]);_0xf02ec5['query']=_[_0x8d6c('0x5c')](_0x34e59e['query']);_0xf02ec5[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0xf02ec5[_0x8d6c('0x4a')],_0xf02ec5[_0x8d6c('0x4b')]);_0x5862ca[_0x8d6c('0x4e')]=_['intersection'](_0xf02ec5[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x34e59e[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x5862ca[_0x8d6c('0x4e')]=_0x5862ca[_0x8d6c('0x4e')]['length']?_0x5862ca[_0x8d6c('0x4e')]:_0xf02ec5[_0x8d6c('0x4a')];if(_0x34e59e[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x5862ca[_0x8d6c('0x5d')]=[{'all':!![]}];}_0x5862ca=_['merge']({},_0x5862ca,_0x34e59e[_0x8d6c('0x56')]);return db['MailAccount'][_0x8d6c('0x5e')](_0x5862ca)[_0x8d6c('0x12')](handleEntityNotFound(_0x43b237,null))[_0x8d6c('0x12')](respondWithResult(_0x43b237,null))[_0x8d6c('0x1a')](handleError(_0x43b237,null));};exports[_0x8d6c('0x23')]=function(_0x351bb1,_0x2122b6){if(_0x351bb1['body']['id']){delete _0x351bb1[_0x8d6c('0x5f')]['id'];}var _0x3a80d3=_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x60')]==='custom'?null:_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x60')];var _0xfaf6ea=_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')]||{};var _0x3be46a=_0x351bb1[_0x8d6c('0x5f')]['Smtp']||{};if(_0x3a80d3){_0xfaf6ea[_0x8d6c('0x3b')]=getImapHost(_0x3a80d3);_0xfaf6ea[_0x8d6c('0x3c')]=0x3e1;_0x3be46a[_0x8d6c('0x3b')]=getSmtpHost(_0x3a80d3);_0x3be46a[_0x8d6c('0x3c')]=0x24b;_0x3be46a[_0x8d6c('0x3d')]=![];}if(_0x3be46a[_0x8d6c('0x38')]){_0x3be46a[_0x8d6c('0x3d')]=![];}else{_0x3be46a[_0x8d6c('0x39')]=null;}if(!_0xfaf6ea['modernAuthentication'])_0xfaf6ea[_0x8d6c('0x39')]=null;_0x351bb1[_0x8d6c('0x5f')]['Imap']=_0xfaf6ea;_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')]=_0x3be46a;return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x351bb1[_0x8d6c('0x61')]['id']},'include':[{'model':db['MailServerIn'],'as':_0x8d6c('0x40')},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]})[_0x8d6c('0x12')](handleEntityNotFound(_0x2122b6,null))[_0x8d6c('0x12')](function(_0x244c4e){if(!_0x244c4e)throw new Error(_0x8d6c('0x62'));if(_0x244c4e[_0x8d6c('0x3e')])delete _0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')];return _0x244c4e;})['then'](saveUpdates(_0x351bb1['body'],null))['then'](function(_0x4d8f95){if(!_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')])return _0x4d8f95;return db[_0x8d6c('0x63')][_0x8d6c('0x23')](_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')],{'where':{'MailAccountId':_0x4d8f95['id']}})[_0x8d6c('0x12')](function(){return _0x4d8f95;});})['then'](function(_0x2ffb93){if(!_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')])return _0x2ffb93;return db[_0x8d6c('0x43')][_0x8d6c('0x23')](_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')],{'where':{'MailAccountId':_0x2ffb93['id']}})[_0x8d6c('0x12')](function(){return _0x2ffb93;});})['then'](respondWithResult(_0x2122b6,null))[_0x8d6c('0x1a')](handleError(_0x2122b6,null));};exports[_0x8d6c('0x64')]=function(_0x307625,_0x187e5d){return db[_0x8d6c('0x47')][_0x8d6c('0x64')]()[_0x8d6c('0x12')](respondWithResult(_0x187e5d,null))[_0x8d6c('0x1a')](handleError(_0x187e5d,null));};exports[_0x8d6c('0x65')]=function(_0x2e024f,_0x192332){if(_0x2e024f[_0x8d6c('0x5f')]['id']){delete _0x2e024f['body']['id'];}return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0x2e024f[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x192332,null))['then'](function(_0xd0df05){if(_0xd0df05){_0x2e024f[_0x8d6c('0x5f')][_0x8d6c('0x66')]=_0xd0df05['id'];return db['Disposition'][_0x8d6c('0x67')](_0x2e024f[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x192332,null))['catch'](handleError(_0x192332,null));};exports[_0x8d6c('0x68')]=function(_0x1e0049,_0x517ce8){var _0x82b17e={'raw':![],'where':{}};var _0x1a3a1f={};var _0x447cbc={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x1e0049[_0x8d6c('0x61')]['id']}})['then'](handleEntityNotFound(_0x517ce8,null))[_0x8d6c('0x12')](function(_0x6ca3db){if(_0x6ca3db){_0x1a3a1f['model']=_[_0x8d6c('0x5c')](db[_0x8d6c('0x6a')][_0x8d6c('0x5b')]);_0x1a3a1f['query']=_[_0x8d6c('0x5c')](_0x1e0049[_0x8d6c('0x4b')]);_0x1a3a1f[_0x8d6c('0x4c')]=_['intersection'](_0x1a3a1f[_0x8d6c('0x4a')],_0x1a3a1f[_0x8d6c('0x4b')]);_0x82b17e[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x1a3a1f[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x1e0049[_0x8d6c('0x4b')]['fields']));_0x82b17e[_0x8d6c('0x4e')]=_0x82b17e['attributes'][_0x8d6c('0x6b')]?_0x82b17e[_0x8d6c('0x4e')]:_0x1a3a1f[_0x8d6c('0x4a')];if(!_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x6c')](_0x8d6c('0x50'))){_0x82b17e[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x82b17e[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x1e0049[_0x8d6c('0x4b')]['offset']);}_0x82b17e[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x1e0049[_0x8d6c('0x4b')]['sort']);_0x82b17e['where']=qs[_0x8d6c('0x4c')](_['pick'](_0x1e0049['query'],_0x1a3a1f[_0x8d6c('0x4c')]));_0x82b17e[_0x8d6c('0x52')][_0x8d6c('0x66')]=_0x6ca3db['id'];if(_0x1e0049['query'][_0x8d6c('0x53')]){_0x82b17e[_0x8d6c('0x52')]=_['merge'](_0x82b17e[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x82b17e[_0x8d6c('0x4e')],function(_0x500311){var _0x150c0b={};_0x150c0b[_0x500311]={'$like':'%'+_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x150c0b;})});}_0x82b17e=_['merge']({},_0x82b17e,_0x1e0049[_0x8d6c('0x56')]);return db[_0x8d6c('0x6a')][_0x8d6c('0x20')]({'where':_0x82b17e[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x16ea17){_0x447cbc[_0x8d6c('0x20')]=_0x16ea17;if(_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x82b17e['include']=[{'all':!![]}];}return db[_0x8d6c('0x6a')][_0x8d6c('0x58')](_0x82b17e);})[_0x8d6c('0x12')](function(_0x15e4b8){_0x447cbc[_0x8d6c('0x59')]=_0x15e4b8;return _0x447cbc;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x517ce8,_0x82b17e))[_0x8d6c('0x1a')](handleError(_0x517ce8,null));};exports[_0x8d6c('0x6e')]=function(_0x3311a6,_0x4f6bcf){return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x3311a6[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x4f6bcf,null))[_0x8d6c('0x12')](function(_0x55cb5e){if(_0x55cb5e){return _0x55cb5e[_0x8d6c('0x6e')](_0x3311a6[_0x8d6c('0x4b')]['ids']);}})[_0x8d6c('0x12')](respondWithStatusCode(_0x4f6bcf,null))[_0x8d6c('0x1a')](handleError(_0x4f6bcf,null));};exports[_0x8d6c('0x6f')]=function(_0x122ff2,_0x21b972){if(_0x122ff2[_0x8d6c('0x5f')]['id']){delete _0x122ff2[_0x8d6c('0x5f')]['id'];}return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x122ff2[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x21b972,null))[_0x8d6c('0x12')](function(_0x159419){if(_0x159419){_0x122ff2[_0x8d6c('0x5f')][_0x8d6c('0x66')]=_0x159419['id'];return db[_0x8d6c('0x70')]['create'](_0x122ff2[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x21b972,null))[_0x8d6c('0x1a')](handleError(_0x21b972,null));};exports[_0x8d6c('0x71')]=function(_0x63cf42,_0x5c6a4e){var _0x5b9573={'raw':![],'where':{}};var _0x137a34={};var _0x272c36={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x63cf42[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x5c6a4e,null))[_0x8d6c('0x12')](function(_0x107d7a){if(_0x107d7a){_0x137a34[_0x8d6c('0x4a')]=_['keys'](db['CannedAnswer'][_0x8d6c('0x5b')]);_0x137a34[_0x8d6c('0x4b')]=_['keys'](_0x63cf42['query']);_0x137a34[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x137a34[_0x8d6c('0x4a')],_0x137a34[_0x8d6c('0x4b')]);_0x5b9573['attributes']=_[_0x8d6c('0x4d')](_0x137a34[_0x8d6c('0x4a')],qs['fields'](_0x63cf42[_0x8d6c('0x4b')]['fields']));_0x5b9573[_0x8d6c('0x4e')]=_0x5b9573[_0x8d6c('0x4e')]['length']?_0x5b9573[_0x8d6c('0x4e')]:_0x137a34[_0x8d6c('0x4a')];if(!_0x63cf42[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x5b9573['limit']=qs[_0x8d6c('0x1e')](_0x63cf42[_0x8d6c('0x4b')]['limit']);_0x5b9573[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x63cf42['query'][_0x8d6c('0x1d')]);}_0x5b9573[_0x8d6c('0x6d')]=qs['sort'](_0x63cf42['query'][_0x8d6c('0x51')]);_0x5b9573[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x63cf42[_0x8d6c('0x4b')],_0x137a34['filters']));_0x5b9573[_0x8d6c('0x52')][_0x8d6c('0x66')]=_0x107d7a['id'];if(_0x63cf42[_0x8d6c('0x4b')]['filter']){_0x5b9573['where']=_[_0x8d6c('0x55')](_0x5b9573['where'],{'$or':_['map'](_0x5b9573[_0x8d6c('0x4e')],function(_0x40e39c){var _0x1c85fb={};_0x1c85fb[_0x40e39c]={'$like':'%'+_0x63cf42[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x1c85fb;})});}_0x5b9573=_[_0x8d6c('0x55')]({},_0x5b9573,_0x63cf42[_0x8d6c('0x56')]);return db[_0x8d6c('0x70')][_0x8d6c('0x20')]({'where':_0x5b9573[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x2ab35d){_0x272c36[_0x8d6c('0x20')]=_0x2ab35d;if(_0x63cf42[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x5b9573[_0x8d6c('0x5d')]=[{'all':!![]}];}return db[_0x8d6c('0x70')][_0x8d6c('0x58')](_0x5b9573);})[_0x8d6c('0x12')](function(_0x4697ca){_0x272c36[_0x8d6c('0x59')]=_0x4697ca;return _0x272c36;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x5c6a4e,_0x5b9573))[_0x8d6c('0x1a')](handleError(_0x5c6a4e,null));};exports[_0x8d6c('0x73')]=function(_0xa3f1a8,_0x57bdef){return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0xa3f1a8[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x57bdef,null))[_0x8d6c('0x12')](function(_0x56ccd1){if(_0x56ccd1){return _0x56ccd1[_0x8d6c('0x73')](_0xa3f1a8[_0x8d6c('0x4b')]['ids']);}})['then'](respondWithStatusCode(_0x57bdef,null))[_0x8d6c('0x1a')](handleError(_0x57bdef,null));};exports['create']=function(_0x4a083b,_0x171a79){var _0x581e97={'name':_0x4a083b['body'][_0x8d6c('0x29')],'key':_0x4a083b['body'][_0x8d6c('0x49')],'provider':_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x60')]===_0x8d6c('0x74')?null:_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x60')],'email':_0x4a083b['body'][_0x8d6c('0x75')],'ListId':_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x76')],'active':!_[_0x8d6c('0x77')](_0x4a083b['body'][_0x8d6c('0x78')])?_0x4a083b[_0x8d6c('0x5f')]['active']:!![],'description':_0x4a083b['body'][_0x8d6c('0x79')]||null};var _0x25a13c=getAuthenticationOptions(_0x581e97[_0x8d6c('0x60')],_0x4a083b[_0x8d6c('0x5f')]);_0x581e97[_0x8d6c('0x40')]=_0x25a13c[_0x8d6c('0x40')];_0x581e97[_0x8d6c('0x41')]=_0x25a13c[_0x8d6c('0x41')];return db[_0x8d6c('0x47')][_0x8d6c('0x67')](_0x581e97,{'include':[{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db['MailServerIn'],'as':_0x8d6c('0x40')}]})['then'](function(_0x5bd755){var _0x1ffb83=_0x4a083b[_0x8d6c('0x35')]['get']({'plain':!![]});if(!_0x1ffb83)throw new Error(_0x8d6c('0x7a'));if(_0x1ffb83[_0x8d6c('0x7b')]===_0x8d6c('0x35')){var _0x2fbfcf=_0x5bd755[_0x8d6c('0x24')]({'plain':!![]});return db[_0x8d6c('0x7c')][_0x8d6c('0x5e')]({'where':{'name':'MailAccounts','userProfileId':_0x1ffb83[_0x8d6c('0x7d')]},'raw':!![]})['then'](function(_0x3b0c95){if(_0x3b0c95&&_0x3b0c95[_0x8d6c('0x7e')]===0x0){return db[_0x8d6c('0x26')][_0x8d6c('0x67')]({'name':_0x2fbfcf['name'],'resourceId':_0x2fbfcf['id'],'type':_0x3b0c95[_0x8d6c('0x29')],'sectionId':_0x3b0c95['id']},{})[_0x8d6c('0x12')](function(){return _0x5bd755;});}else{return _0x5bd755;}})['catch'](function(_0x6e377){logger[_0x8d6c('0x16')](_0x8d6c('0x7f'),_0x6e377);throw _0x6e377;});}return _0x5bd755;})['then'](respondWithResult(_0x171a79,0xc9))[_0x8d6c('0x1a')](handleError(_0x171a79,null));};exports[_0x8d6c('0x80')]=function(_0x2cd7d8,_0x499c3e){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x2cd7d8[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x499c3e,null))[_0x8d6c('0x12')](function(_0x5174e7){if(_0x5174e7){return _0x5174e7['getImap']();}return null;})['then'](respondWithResult(_0x499c3e,null))['catch'](handleError(_0x499c3e,null));};exports['addImap']=function(_0x17c886,_0x2fbe31){if(_0x17c886[_0x8d6c('0x5f')]['id']){delete _0x17c886[_0x8d6c('0x5f')]['id'];}return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0x17c886['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x2fbe31,null))[_0x8d6c('0x12')](function(_0x1fa9b4){if(_0x1fa9b4){_0x17c886['body'][_0x8d6c('0x66')]=_0x1fa9b4['id'];return db[_0x8d6c('0x63')][_0x8d6c('0x67')](_0x17c886[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x2fbe31,null))[_0x8d6c('0x1a')](handleError(_0x2fbe31,null));};exports[_0x8d6c('0x81')]=function(_0x42337e,_0x19919b){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x42337e[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x19919b,null))[_0x8d6c('0x12')](function(_0x3b8443){if(_0x3b8443){return _0x3b8443[_0x8d6c('0x82')](null);}return null;})[_0x8d6c('0x12')](respondWithStatusCode(_0x19919b,null))['catch'](handleError(_0x19919b,null));};exports[_0x8d6c('0x83')]=function(_0x12c545,_0x27c2d0){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x12c545[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x27c2d0,null))[_0x8d6c('0x12')](function(_0x571e2f){if(_0x571e2f){return _0x571e2f[_0x8d6c('0x83')]();}return null;})[_0x8d6c('0x12')](respondWithResult(_0x27c2d0,null))[_0x8d6c('0x1a')](handleError(_0x27c2d0,null));};exports[_0x8d6c('0x84')]=function(_0x399de3,_0x1b9e20){if(_0x399de3['body']['id']){delete _0x399de3['body']['id'];}return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x399de3[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1b9e20,null))[_0x8d6c('0x12')](function(_0x164c7c){if(_0x164c7c){_0x399de3[_0x8d6c('0x5f')]['MailAccountId']=_0x164c7c['id'];return db[_0x8d6c('0x43')][_0x8d6c('0x67')](_0x399de3[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x1b9e20,null))[_0x8d6c('0x1a')](handleError(_0x1b9e20,null));};exports[_0x8d6c('0x85')]=function(_0x4fbd09,_0x2114ae){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x4fbd09['params']['id']}})['then'](handleEntityNotFound(_0x2114ae,null))[_0x8d6c('0x12')](function(_0x3ba4df){if(_0x3ba4df){return _0x3ba4df[_0x8d6c('0x86')](null);}return null;})[_0x8d6c('0x12')](respondWithStatusCode(_0x2114ae,null))['catch'](handleError(_0x2114ae,null));};exports[_0x8d6c('0x87')]=function(_0xa9b212,_0x3cf156){return db[_0x8d6c('0x88')]['find']({'where':{'id':_0xa9b212[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x3cf156,null))[_0x8d6c('0x12')](function(_0x45c5b1){if(_0x45c5b1){return _0x45c5b1['addInteraction'](_0xa9b212['body'][_0x8d6c('0x89')],_[_0x8d6c('0x8a')](_0xa9b212[_0x8d6c('0x5f')],[_0x8d6c('0x89'),'id'])||{});}})[_0x8d6c('0x12')](respondWithResult(_0x3cf156,null))[_0x8d6c('0x1a')](handleError(_0x3cf156,null));};exports[_0x8d6c('0x8b')]=function(_0x38681a,_0x2fe06b){var _0x11f2d9={'raw':![],'where':{}};var _0xb04ee2={};var _0x3c2667={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x38681a['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x2fe06b,null))[_0x8d6c('0x12')](function(_0x4ec544){if(_0x4ec544){_0xb04ee2[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x88')]['rawAttributes']);_0xb04ee2[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x38681a[_0x8d6c('0x4b')]);_0xb04ee2[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0xb04ee2[_0x8d6c('0x4a')],_0xb04ee2[_0x8d6c('0x4b')]);_0x11f2d9[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0xb04ee2[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x38681a['query'][_0x8d6c('0x4f')]));_0x11f2d9[_0x8d6c('0x4e')]=_0x11f2d9['attributes'][_0x8d6c('0x6b')]?_0x11f2d9[_0x8d6c('0x4e')]:_0xb04ee2[_0x8d6c('0x4a')];if(!_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x6c')](_0x8d6c('0x50'))){_0x11f2d9[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x38681a['query'][_0x8d6c('0x1e')]);_0x11f2d9[_0x8d6c('0x1d')]=qs['offset'](_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x11f2d9['order']=qs[_0x8d6c('0x51')](_0x38681a['query'][_0x8d6c('0x51')]);_0x11f2d9['where']=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x38681a[_0x8d6c('0x4b')],_0xb04ee2[_0x8d6c('0x4c')]));_0x11f2d9['where'][_0x8d6c('0x66')]=_0x4ec544['id'];if(_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x11f2d9[_0x8d6c('0x52')]=_['merge'](_0x11f2d9[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x11f2d9['attributes'],function(_0x27a978){var _0x2b1877={};_0x2b1877[_0x27a978]={'$like':'%'+_0x38681a[_0x8d6c('0x4b')]['filter']+'%'};return _0x2b1877;})});}_0x11f2d9=_[_0x8d6c('0x55')]({},_0x11f2d9,_0x38681a[_0x8d6c('0x56')]);return db[_0x8d6c('0x88')][_0x8d6c('0x20')]({'where':_0x11f2d9[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x492559){_0x3c2667['count']=_0x492559;if(_0x38681a['query'][_0x8d6c('0x57')]){_0x11f2d9[_0x8d6c('0x5d')]=[{'model':db[_0x8d6c('0x8c')],'as':'Contact','required':![]},{'model':db[_0x8d6c('0x8d')],'as':_0x8d6c('0x8e'),'attributes':[_0x8d6c('0x29'),_0x8d6c('0x8f'),_0x8d6c('0x90')],'required':![]},{'model':db[_0x8d6c('0x91')],'as':_0x8d6c('0x92'),'attributes':['id','name',_0x8d6c('0x93')],'where':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]?{'id':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]}:undefined,'required':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]?!![]:![]}];}return db[_0x8d6c('0x88')][_0x8d6c('0x58')](_0x11f2d9);})['then'](function(_0x1bf122){_0x3c2667[_0x8d6c('0x59')]=_0x1bf122;return _0x3c2667;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x2fe06b,_0x11f2d9))[_0x8d6c('0x1a')](handleError(_0x2fe06b,null));};exports[_0x8d6c('0x95')]=function addApplications(_0x4cfe75,_0x24c406){var _0x79bb78=_0x4cfe75[_0x8d6c('0x61')]['id'];var _0x42d75a=_0x4cfe75[_0x8d6c('0x5f')];var _0xbbb41f=0xc8;var _0x265475=null;return db[_0x8d6c('0x96')][_0x8d6c('0x97')]({'isolationLevel':db[_0x8d6c('0x96')][_0x8d6c('0x98')][_0x8d6c('0x99')][_0x8d6c('0x9a')]},function(_0x1e0c17){return db['MailAccount'][_0x8d6c('0x69')]({'where':{'id':_0x79bb78},'transaction':_0x1e0c17})[_0x8d6c('0x12')](function(_0x46f52d){if(_0x46f52d){return db['MailApplication']['destroy']({'where':{'MailAccountId':_0x79bb78},'transaction':_0x1e0c17})[_0x8d6c('0x12')](function(){var _0x150379=_['map'](_0x42d75a,function(_0x203721){_0x203721['MailAccountId']=_0x79bb78;return _0x203721;});return db[_0x8d6c('0x9b')][_0x8d6c('0x9c')](_0x150379,{'transaction':_0x1e0c17});});}else{_0xbbb41f=0x194;_0x265475=[];}});})['then'](function(){if(_0xbbb41f!==0x194){return db['MailApplication'][_0x8d6c('0x9d')]({'where':{'MailAccountId':_0x79bb78},'order':'priority'})[_0x8d6c('0x12')](function(_0x3c584e){_0x265475=_0x3c584e;});}})['catch'](function(_0x56d950){_0xbbb41f=0x1f4;logger['error'](_0x56d950['stack']);if(_0x56d950[_0x8d6c('0x29')]){delete _0x56d950[_0x8d6c('0x29')];}_0x265475=_0x56d950;})[_0x8d6c('0x9e')](function(){if(_0x265475===null){_0x24c406[_0x8d6c('0x1b')](_0xbbb41f);}else{if(_0xbbb41f===0x1f4){_0x24c406['status'](_0xbbb41f)['send'](_0x265475);}else{_0x24c406[_0x8d6c('0x1c')](_0xbbb41f)[_0x8d6c('0x9f')](_0x265475);}}});};exports['getApplications']=function(_0x3d7afd,_0x1d330a){var _0x1dfb2a={};var _0x5bad42={};var _0x5d41f9;var _0x9f30ad;return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x3d7afd['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1d330a,null))[_0x8d6c('0x12')](function(_0xadc7e7){if(_0xadc7e7){_0x5d41f9=_0xadc7e7;_0x5bad42[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x9b')][_0x8d6c('0x5b')]);_0x5bad42[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x3d7afd[_0x8d6c('0x4b')]);_0x5bad42[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x5bad42['model'],_0x5bad42[_0x8d6c('0x4b')]);_0x1dfb2a[_0x8d6c('0x4e')]=_['intersection'](_0x5bad42[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x1dfb2a['attributes']=_0x1dfb2a[_0x8d6c('0x4e')]['length']?_0x1dfb2a[_0x8d6c('0x4e')]:_0x5bad42[_0x8d6c('0x4a')];_0x1dfb2a[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x1dfb2a[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_['pick'](_0x3d7afd['query'],_0x5bad42['filters']));if(_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x1dfb2a[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x1dfb2a[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x1dfb2a[_0x8d6c('0x4e')],function(_0x492b72){var _0x2ea00b={};_0x2ea00b[_0x492b72]={'$like':'%'+_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x2ea00b;})});}_0x1dfb2a=_['merge']({},_0x1dfb2a,_0x3d7afd[_0x8d6c('0x56')]);return _0x5d41f9[_0x8d6c('0xa0')](_0x1dfb2a);}})[_0x8d6c('0x12')](function(_0x268d28){if(_0x268d28){_0x9f30ad=_0x268d28[_0x8d6c('0x6b')];if(!_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x6c')]('nolimit')){_0x1dfb2a[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x1dfb2a[_0x8d6c('0x1d')]=qs['offset'](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}return _0x5d41f9['getApplications'](_0x1dfb2a);}})[_0x8d6c('0x12')](function(_0x48c504){if(_0x48c504){return _0x48c504?{'count':_0x9f30ad,'rows':_0x48c504}:null;}})['then'](respondWithResult(_0x1d330a,null))['catch'](handleError(_0x1d330a,null));};exports[_0x8d6c('0xa1')]=function(_0x5de618,_0x346b93){var _0x3f59a8={'raw':!![],'where':{}};var _0x4397c0={};var _0x2d59fa={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x5de618['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x346b93,null))['then'](function(_0x295b9c){if(_0x295b9c){_0x4397c0[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0xa2')][_0x8d6c('0x5b')]);_0x4397c0[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x5de618[_0x8d6c('0x4b')]);_0x4397c0[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x4397c0[_0x8d6c('0x4a')],_0x4397c0[_0x8d6c('0x4b')]);_0x3f59a8['attributes']=_[_0x8d6c('0x4d')](_0x4397c0[_0x8d6c('0x4a')],qs['fields'](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x3f59a8[_0x8d6c('0x4e')]=_0x3f59a8['attributes'][_0x8d6c('0x6b')]?_0x3f59a8[_0x8d6c('0x4e')]:_0x4397c0[_0x8d6c('0x4a')];if(!_0x5de618[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x3f59a8[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x5de618[_0x8d6c('0x4b')]['limit']);_0x3f59a8['offset']=qs[_0x8d6c('0x1d')](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x3f59a8[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x3f59a8[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x5de618[_0x8d6c('0x4b')],_0x4397c0[_0x8d6c('0x4c')]));_0x3f59a8['where'][_0x8d6c('0x66')]=_0x295b9c['id'];if(_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x3f59a8[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x3f59a8[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x3f59a8[_0x8d6c('0x4e')],function(_0x511279){var _0x446081={};_0x446081[_0x511279]={'$like':'%'+_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x446081;})});}if(_0x5de618[_0x8d6c('0x4b')]['$gte']){var _0x18bc0a=_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0xa3')][_0x8d6c('0xa4')](',');var _0x42aa99={};_0x42aa99[_0x18bc0a[0x0]]={'$gte':moment(_0x18bc0a[0x1])[_0x8d6c('0xa5')](_0x8d6c('0xa6'))};_0x3f59a8[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x3f59a8[_0x8d6c('0x52')],_0x42aa99);}_0x3f59a8=_[_0x8d6c('0x55')]({},_0x3f59a8,_0x5de618[_0x8d6c('0x56')]);return db[_0x8d6c('0xa2')][_0x8d6c('0x20')]({'where':_0x3f59a8[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x4e33f8){_0x2d59fa[_0x8d6c('0x20')]=_0x4e33f8;if(_0x5de618[_0x8d6c('0x4b')]['includeAll']){_0x3f59a8['include']=[{'all':!![]}];}return db[_0x8d6c('0xa2')][_0x8d6c('0x58')](_0x3f59a8);})[_0x8d6c('0x12')](function(_0x25e35b){if(_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0xa7')]==='true'){for(var _0x3b1d5c=0x0;_0x3b1d5c<_0x25e35b[_0x8d6c('0x6b')];_0x3b1d5c++){_0x25e35b[_0x3b1d5c]['body']=juice(_0x25e35b[_0x3b1d5c][_0x8d6c('0x5f')]);}}_0x2d59fa[_0x8d6c('0x59')]=_0x25e35b;return _0x2d59fa;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x346b93,_0x3f59a8))[_0x8d6c('0x1a')](handleError(_0x346b93,null));};exports['send']=function(_0x1ad39d,_0x167fba){var _0x29f328,_0x38ba6b={},_0xe8ce7d;if(_0x1ad39d['body']['to']){_0xe8ce7d=_0x1ad39d[_0x8d6c('0x5f')]['to'][_0x8d6c('0xa4')](',')[0x0];}return db['MailAccount']['find']({'where':{'id':_0x1ad39d[_0x8d6c('0x61')]['id']},'include':[{'model':db[_0x8d6c('0xa8')],'as':'List','include':[{'model':db[_0x8d6c('0x8c')],'as':'Contacts','where':{'email':_0xe8ce7d},'limit':0x1,'order':[['updatedAt',_0x8d6c('0xa9')]]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![],'include':[{'model':db[_0x8d6c('0xaa')],'as':_0x8d6c('0xaa'),'raw':!![]}]}]})['then'](handleEntityNotFound(_0x167fba,null))['then'](function(_0x1f61e3){if(!_0x1f61e3)return;_0x29f328=_0x1f61e3;if(!_0x1f61e3['Smtp'])throw new Error(_0x8d6c('0xab'));if(_[_0x8d6c('0x77')](_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xac')])){_0x1ad39d[_0x8d6c('0x5f')]['from']=util[_0x8d6c('0xa5')](_0x8d6c('0xad'),_0x1f61e3[_0x8d6c('0x29')],_0x1f61e3[_0x8d6c('0x75')]||_0x1f61e3[_0x8d6c('0x41')]['user']);}if(_0x1ad39d['body'][_0x8d6c('0xae')]&&_0x1ad39d['body'][_0x8d6c('0xae')][_0x8d6c('0x6b')]){for(var _0x1a3683=0x0;_0x1a3683<_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')]['length'];_0x1a3683+=0x1){_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683]={'filename':_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683][_0x8d6c('0x29')],'path':path['join'](config[_0x8d6c('0xaf')],'server/files/attachments',_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683][_0x8d6c('0xb0')])};}}var _0x16b84b=_0x1f61e3[_0x8d6c('0xb1')]();return respondWithRpcPromise(_0x8d6c('0xb2'),'sendMail',{'account':_0x16b84b,'message':_0x1ad39d[_0x8d6c('0x5f')]});})[_0x8d6c('0x12')](function(_0x2c3447){if(!_0x2c3447)return;_0x38ba6b=_0x2c3447;if(!_0x29f328[_0x8d6c('0xb3')])throw new Error(_0x8d6c('0xb4'));if(_0x29f328[_0x8d6c('0xb3')]['Contacts']['length'])return _0x29f328[_0x8d6c('0xb3')][_0x8d6c('0xb5')][0x0];return db[_0x8d6c('0x8c')][_0x8d6c('0x67')](_['defaults'](_0x1ad39d['body'],{'firstName':_0x1ad39d[_0x8d6c('0x5f')]['to'],'email':_0x1ad39d[_0x8d6c('0x5f')]['to'],'phone':_0x1ad39d[_0x8d6c('0x5f')]['to'],'ListId':_0x29f328[_0x8d6c('0x76')]}));})['then'](function(_0x840acc){if(!_0x840acc)return;var _0x1cff08={'UserId':_0x1ad39d['user']['id'],'ContactId':_0x840acc['id'],'MailAccountId':_0x29f328['id'],'inReplyTo':_0x38ba6b[_0x8d6c('0xb6')],'to':_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xac')],'cc':_0x1ad39d[_0x8d6c('0x5f')]['cc'],'subject':_0x1ad39d[_0x8d6c('0x5f')]['subject'],'attach':_0x1ad39d['body'][_0x8d6c('0xb7')],'firstMsgDirection':_0x8d6c('0xb8'),'lastMsgAt':moment()['format'](_0x8d6c('0xa6')),'lastMsgDirection':_0x8d6c('0xb8'),'Messages':[_[_0x8d6c('0x55')](_0x1ad39d['body'],{'messageId':_0x38ba6b['messageId'],'sentAt':moment()[_0x8d6c('0xa5')]('YYYY-MM-DD\x20HH:mm:ss'),'read':!![],'MailAccountId':_0x29f328['id'],'UserId':_0x1ad39d[_0x8d6c('0x35')]['id'],'ContactId':_0x840acc['id']})]};if(_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xb9')]){_0x1cff08=_['merge'](_0x1cff08,_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xb9')]);}return db[_0x8d6c('0x88')]['create'](_0x1cff08,{'include':[{'model':db[_0x8d6c('0xa2')],'as':_0x8d6c('0xba')}]});})[_0x8d6c('0x12')](respondWithResult(_0x167fba,null))[_0x8d6c('0x1a')](handleError(_0x167fba,null));};exports[_0x8d6c('0xbb')]=function(_0x333b28,_0x5ae2c4){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x333b28[_0x8d6c('0x61')]['id']},'include':[{'model':db[_0x8d6c('0x43')],'as':'Smtp','raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x8d6c('0xaa'),'raw':!![]}]}]})[_0x8d6c('0x12')](handleEntityNotFound(_0x5ae2c4,null))[_0x8d6c('0x12')](function(_0x40810b){if(!_0x40810b[_0x8d6c('0x41')])return;var _0x5c1323=_0x40810b[_0x8d6c('0xb1')]();return respondWithRpcPromise(_0x8d6c('0xbc'),_0x8d6c('0xbb'),{'account':_0x5c1323});})['then'](respondWithResult(_0x5ae2c4,null))['catch'](handleError(_0x5ae2c4,null));};exports[_0x8d6c('0xbd')]=function(_0x29ed36,_0x3ad506){return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x29ed36[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x3ad506,null))[_0x8d6c('0x12')](function(_0x142ccc){if(_0x142ccc&&_0x142ccc[_0x8d6c('0x3e')]){throw new db['Sequelize'][(_0x8d6c('0xbe'))](_0x8d6c('0xbf'));}return _0x142ccc;})[_0x8d6c('0x12')](removeEntity(_0x3ad506,null))[_0x8d6c('0x1a')](handleError(_0x3ad506,null));};exports[_0x8d6c('0xc0')]=function(_0x280ce2,_0x2216e1){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x280ce2['params']['id']}})['then'](handleEntityNotFound(_0x2216e1,null))['then'](function(_0x545da2){if(_0x545da2){return _0x545da2['addAgents'](_0x280ce2[_0x8d6c('0x5f')]['ids'],_[_0x8d6c('0x8a')](_0x280ce2[_0x8d6c('0x5f')],[_0x8d6c('0x89'),'id'])||{})[_0x8d6c('0xc1')](function(_0x3e1336){for(var _0x3a61e0=0x0;_0x3a61e0<_0x280ce2['body'][_0x8d6c('0x89')][_0x8d6c('0x6b')];_0x3a61e0+=0x1){socket[_0x8d6c('0xc2')](_0x8d6c('0xc3'),{'UserId':Number(_0x280ce2['body'][_0x8d6c('0x89')][_0x3a61e0]),'MailAccountId':Number(_0x280ce2[_0x8d6c('0x61')]['id'])});}return _0x3e1336;});}})[_0x8d6c('0x12')](respondWithResult(_0x2216e1,null))['catch'](handleError(_0x2216e1,null));};exports[_0x8d6c('0xc4')]=function(_0x25e4f7,_0x31d514){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x25e4f7[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x31d514,null))[_0x8d6c('0x12')](function(_0xd3cc53){if(_0xd3cc53){return _0xd3cc53[_0x8d6c('0xc4')](_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')])[_0x8d6c('0x12')](function(){if(_[_0x8d6c('0xc5')](_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')])){for(var _0x2290b0=0x0;_0x2290b0<_0x25e4f7[_0x8d6c('0x4b')]['ids'][_0x8d6c('0x6b')];_0x2290b0+=0x1){socket[_0x8d6c('0xc2')](_0x8d6c('0xc6'),{'UserId':Number(_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')][_0x2290b0]),'MailAccountId':Number(_0x25e4f7[_0x8d6c('0x61')]['id'])});}}else{socket[_0x8d6c('0xc2')](_0x8d6c('0xc6'),{'UserId':Number(_0x25e4f7[_0x8d6c('0x4b')]['ids']),'MailAccountId':Number(_0x25e4f7['params']['id'])});}});}})[_0x8d6c('0x12')](respondWithStatusCode(_0x31d514,null))[_0x8d6c('0x1a')](handleError(_0x31d514,null));};exports[_0x8d6c('0xc7')]=function(_0x341fb5,_0x1160e4){var _0x5688f2={};var _0x428847={};var _0x3c3148;var _0x4b6564;return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x341fb5[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1160e4,null))[_0x8d6c('0x12')](function(_0x5f246){if(_0x5f246){_0x3c3148=_0x5f246;_0x428847[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x8d')][_0x8d6c('0x5b')]);_0x428847[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x341fb5[_0x8d6c('0x4b')]);_0x428847[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x428847['model'],_0x428847[_0x8d6c('0x4b')]);_0x5688f2[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x428847[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x5688f2['attributes']=_0x5688f2['attributes'][_0x8d6c('0x6b')]?_0x5688f2['attributes']:_0x428847[_0x8d6c('0x4a')];_0x5688f2[_0x8d6c('0x6d')]=qs['sort'](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x5688f2[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_['pick'](_0x341fb5[_0x8d6c('0x4b')],_0x428847[_0x8d6c('0x4c')]));if(_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x5688f2[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x5688f2[_0x8d6c('0x52')],{'$or':_['map'](_0x5688f2[_0x8d6c('0x4e')],function(_0x175f89){var _0x3c188e={};_0x3c188e[_0x175f89]={'$like':'%'+_0x341fb5[_0x8d6c('0x4b')]['filter']+'%'};return _0x3c188e;})});}_0x5688f2=_['merge']({},_0x5688f2,_0x341fb5[_0x8d6c('0x56')]);return _0x3c3148[_0x8d6c('0xc7')](_0x5688f2);}})[_0x8d6c('0x12')](function(_0x3ca620){if(_0x3ca620){_0x4b6564=_0x3ca620[_0x8d6c('0x6b')];if(!_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x6c')]('nolimit')){_0x5688f2['limit']=qs['limit'](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x5688f2[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}return _0x3c3148[_0x8d6c('0xc7')](_0x5688f2);}})['then'](function(_0x2b1ee0){if(_0x2b1ee0){return _0x2b1ee0?{'count':_0x4b6564,'rows':_0x2b1ee0}:null;}})[_0x8d6c('0x12')](respondWithResult(_0x1160e4,null))[_0x8d6c('0x1a')](handleError(_0x1160e4,null));};
\ No newline at end of file